-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
79 lines (65 loc) · 2.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.RECIPEPREFIX +=
#######################################################################################
.PHONY: help
help:
@echo "Makefile Usage:"
@echo " make build TARGET=<sw_emu/hw_emu/hw>"
@echo " Command to generate the design for specified Target and Device."
@echo ""
@echo " make host "
@echo " Command to generate host."
@echo ""
@echo " make device "
@echo " Command to generate hardware platform files(xo,xclbin)."
@echo ""
@echo " make clean "
@echo " Command to remove the generated files."
@echo ""
#######################################################################################
TARGET := sw_emu
PLATFORM := xilinx_u280_xdma_201920_3
HOST_EXE := host
XO := pw_advection_kernel.$(TARGET).xo
XCLBIN := pw_advection_kernel.$(TARGET).xclbin
KERNEL_NAME := pw_advection_kernel
DEVICE_SRCDIR:=kernel
TEMP_DIR := ./_x.$(TARGET)
SOURCES := $(wildcard $(DEVICE_SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(DEVICE_SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(DEVICE_SRCDIR)/%.cpp=%.xo)
# Host building global settings
CXXFLAGS := -I$(XILINX_XRT)/include/ -I$(XILINX_VIVADO)/include/ -Wall -O3 -std=c++11 -L$(XILINX_XRT)/lib/ -lpthread -lrt -lstdc++
CXXFLAGS2 := -lOpenCL
# Kernel compiler & linker global settings
KRNL_COMPILE_OPTS := -t $(TARGET) --config ../design.cfg --save-temps -j 26
KRNL_LINK_OPTS := -t $(TARGET) --config ../link.cfg -j 26
build: $(XO) $(XCLBIN) $(HOST_EXE) emconfig
.PHONY: device
.ONESHELL:
device: mkrefdir $(OBJECTS) $(XCLBIN)
cp reference_files_$(TARGET)/$(XCLBIN) bin/.
mkrefdir:
rm -Rf reference_files_$(TARGET)
mkdir -p reference_files_$(TARGET)
mkdir -p bin
# Building kernel
.PHONY: $(OBJECTS)
$(OBJECTS): %.xo : $(DEVICE_SRCDIR)/%.cpp
cd reference_files_$(TARGET) ; v++ $(KRNL_COMPILE_OPTS) -c -k pw_advection -I'../include' -I'../$(<D)' -o'$@' ../$<
.PHONY: $(XCLBIN)
$(XCLBIN): $(OBJECTS)
cd reference_files_$(TARGET) ; v++ $(KRNL_LINK_OPTS) -l -o'$@' $(+)
.PHONY: $(HOST_EXE)
# Building Host
$(HOST_EXE): host/host.cpp
g++ $(CXXFLAGS) -o bin/host '$<' $(CXXFLAGS2)
.PHONY: cpu
cpu: cpu/cpu_code.c
g++ $(CXXFLAGS) -o bin/cpu_code '$<' $(CXXFLAGS2) -fopenmp
.PHONY: emconfig
emconfig:
emconfigutil --platform $(PLATFORM)
# Cleaning stuff
.PHONY: clean
clean:
rm -f $(HOST_EXE) *mmult.$(TARGET).$(PLATFORM).* *.log *.json *.xo