Commit 194b5258 authored by Andrei Tosa's avatar Andrei Tosa
Browse files

Generator works with no seed

parent a460a8b8
.PHONY: help
help::
$(ECHO) "Makefile Usage:"
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> VER=<host_cpp/host_c>"
$(ECHO) " Command to pick the specific files and generates the design for specified Target and Device."
$(ECHO) ""
$(ECHO) " make clean "
$(ECHO) " Command to remove the generated non-hardware files."
$(ECHO) ""
$(ECHO) " make cleanall"
$(ECHO) " Command to remove all the generated files."
$(ECHO) ""
$(ECHO) " make check TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform>"
$(ECHO) " Command to run application in emulation."
$(ECHO) ""
TARGETS := hw
TARGET := $(TARGETS)
DEVICE := $(DEVICES)
XCLBIN := ./xclbin
KERNEL_NAME := rndgen
VER ?= host_cpp
DSA := $(call device2sandsa, $(DEVICE))
BUILD_DIR := ./_x.$(TARGET)
BUILD_DIR_rndgen = $(BUILD_DIR)/$(KERNEL_NAME)
# The C++ Compiler to use: g++
CXX := g++
# The kernel Compiler to use : V++
VPP := $(XILINX_VITIS)/bin/v++
# The below are compile flags are passed to the C++ Compiler
opencl_CXXFLAGS += -g -I./ -I$(XILINX_XRT)/include -I$(XILINX_VIVADO)/include -Wall -O0 -g -std=c++11
# The below are linking flags for C++ Comnpiler
opencl_LDFLAGS += -L$(XILINX_XRT)/lib -lOpenCL -lpthread
CXXFLAGS += $(opencl_CXXFLAGS)
LDFLAGS += $(opencl_LDFLAGS)
# Host CPP FILE
HOST_C_SRCS += src/host.c
# Host Header FILE
HOST_C_HDRS += src/host.h
#Host CPP FILE
HOST_CPP_SRCS += src/host.cpp
# Host Header FILE
HOST_CPP_HDRS += src/host.hpp
# Enable Profiling
REPORT := no
PROFILE:= yes
#timeline_trace is always enabled
# Host compiler global settings
CXXFLAGS += -fmessage-length=0
LDFLAGS += -lrt -lstdc++
# Kernel compiler global settings
CLFLAGS += -t $(TARGET) --config design.cfg --save-temps
EXECUTABLE = host
EMCONFIG_DIR = $(XCLBIN)
BINARY_CONTAINERS += $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin
BINARY_CONTAINER_rndgen_OBJS += $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xo
CP = cp -rf
host_change: $(VER)
.PHONY: all clean cleanall docs emconfig
all: check-devices $(host_change) $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig Makefile
.PHONY: exe
exe: $(EXECUTABLE)
# Building kernel
$(XCLBIN)/$(KERNEL_NAME).$(TARGET).xo: src/rndgen.cpp
mkdir -p $(XCLBIN)
$(VPP) $(CLFLAGS) --temp_dir $(BUILD_DIR_rndgen) -c -k $(KERNEL_NAME) -I'$(<D)' -o'$@' '$<'
$(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin: $(BINARY_CONTAINER_rndgen_OBJS)
mkdir -p $(XCLBIN)
$(VPP) $(CLFLAGS) --temp_dir $(BUILD_DIR_rndgen) -l $(LDCLFLAGS) -o'$@' $(+)
ifeq ($(VER),host_cpp)
# Building Host
$(EXECUTABLE): $(HOST_CPP_SRCS) $(HOST_CPP_HDRS)
mkdir -p $(XCLBIN)
$(CXX) $(CXXFLAGS) $(HOST_CPP_SRCS) $(HOST_CPP_HDRS) -o '$@' $(LDFLAGS)
else
$(EXECUTABLE): $(HOST_C_SRCS) $(HOST_C_HDRS)
mkdir -p $(XCLBIN)
$(CXX) $(CXXFLAGS) $(HOST_C_SRCS) $(HOST_C_HDRS) -o '$@' $(LDFLAGS)
endif
emconfig:$(EMCONFIG_DIR)/emconfig.json
$(EMCONFIG_DIR)/emconfig.json:
emconfigutil --platform $(DEVICE) --od $(EMCONFIG_DIR)
check: all
ifeq ($(VER),host_cpp)
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
$(CP) $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin
#$(DEVICE)
else
./$(EXECUTABLE) $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin
#$(DEVICE)
endif
else
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
$(CP) $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin $(DEVICE)
else
./$(EXECUTABLE) $(XCLBIN)/$(KERNEL_NAME).$(TARGET).xclbin $(DEVICE)
endif
endif
# Cleaning stuff
RMDIR = rm -rf
clean:
-$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*}
-$(RMDIR) TempConfig system_estimate.xtxt *.rpt
-$(RMDIR) *.protoinst _v++_* .Xil emconfig.json dltmp* xmltmp* *.log *.jou
cleanall: clean
-$(RMDIR) $(XCLBIN)
-$(RMDIR) _x.*
check-devices:
ifndef DEVICE
$(error DEVICE not set. Please set the DEVICE properly and rerun. Run "make help" for more details.)
endif
check_xrt:
ifndef XILINX_XRT
$(error XILINX_XRT variable is not set, please set correctly and rerun)
endif
ECHO := @echo
#'estimate' for estimate report generation
#'system' for system report generation
ifneq ($(REPORT), no)
CLFLAGS += --report estimate
CLLDFLAGS += --report system
endif
#Generates profile summary report
ifeq ($(PROFILE), yes)
LDCLFLAGS += --profile_kernel data:all:all:all:all
LDCFLAGS += --profile_kernel stall:all:all:all:all
LDCFALGS += --profile_kernel exec:all:all:all:all
endif
File deleted
......@@ -38,12 +38,12 @@ int main(int argc, char** argv)
OCL_CHECK(err, cl::Program program(context, devices, bins, NULL, &err));
OCL_CHECK(err, cl::Kernel krnl_rnd_gen(program,"rndgen", &err));
OCL_CHECK(err, cl::Buffer buffer_output(context,CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY,
vector_size_bytes, source_hw_results.data(), &err));
short seed = 12345;
OCL_CHECK(err, err = krnl_rnd_gen.setArg(0, seed));
OCL_CHECK(err, err = krnl_rnd_gen.setArg(1, buffer_output));
// OCL_CHECK(err, cl::Buffer buffer_seed(context,CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY, sizeof(short), &seed, &err));
OCL_CHECK(err, cl::Buffer buffer_output(context,CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY, vector_size_bytes, source_hw_results.data(), &err));
// OCL_CHECK(err, err = krnl_rnd_gen.setArg(0, buffer_seed));
OCL_CHECK(err, err = krnl_rnd_gen.setArg(0, buffer_output));
std::cout << "* * * START SIMULATION\n";
//OCL_CHECK(err, err = q.enqueueMigrateMemObjects({seed}, 0));
......@@ -52,7 +52,7 @@ int main(int argc, char** argv)
OCL_CHECK(err, err = q.enqueueMigrateMemObjects({buffer_output},CL_MIGRATE_MEM_OBJECT_HOST));
std::cout << "* * * MEMORY OFFLOAD\n";
// q.finish();
q.finish();
std::cout << "* * * SIMULATION DONE\n";
// OPENCL HOST CODE AREA END
......@@ -61,8 +61,9 @@ int main(int argc, char** argv)
std::ofstream fout("data.out");
bool match = true;
for (int i = 0 ; i < DATA_SIZE ; i++){
std::cout << i << ' ';
fout << source_hw_results[i] << ' ';
if (i % 5 == 0)
fout << '\n';
}
fout.close();
......
......@@ -8,40 +8,31 @@
extern "C" {
void rndgen(
const ap_int<REG_SIZE> seed,
//const ap_int<REG_SIZE> seed,
unsigned int *out
)
{
//#pragma HLS INTERFACE m_axi port=seed offset=slave bundle=gmem
#pragma HLS INTERFACE m_axi port=out offset=slave bundle=gmem
//#pragma HLS INTERFACE s_axilite port=seed bundle=control
#pragma HLS INTERFACE s_axilite port=out bundle=control
#pragma HLS INTERFACE s_axilite port=return bundle=control
ap_int<REG_SIZE> X, Y;
ap_int<REG_SIZE> buf[SET_SIZE];
initseed: for (int i = 0; i < REG_SIZE; i++)
X[i] = seed[i]; //seed & ((ap_int<REG_SIZE>) 1 << i);
ap_uint<REG_SIZE> X, Y;
X = 12345;
generator: for (int i = 0; i < SET_SIZE; i++) {
for (int j = 1; j < REG_SIZE - 1; j++)
Y[j] = F2(X[j - 1], X[j], X[j+1]);
Y[0] = F1(X[REG_SIZE], X[0], X[1]);
Y[REG_SIZE] = F1(X[REG_SIZE - 1], X[REG_SIZE], X[0]);
Y[0] = F1(X[REG_SIZE - 1], X[0], X[1]);
Y[REG_SIZE - 1] = F1(X[REG_SIZE - 2], X[REG_SIZE - 1], X[0]);
buf[i] = Y;
result: for (int j = 0; j < REG_SIZE; j++) {
//buf[i](j) = Y[j];
X[j] = Y[j];
}
write: for(int j = 0; j < REG_SIZE; j++) {
out[i] = buf[j].to_int();
}
out[i] = Y.to_int();
X = Y;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment