forked from IBM/mini-era
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.sim
222 lines (179 loc) · 8.41 KB
/
Makefile.sim
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# This Makefile compiles the HPVM-CAVA pilot project.
# It builds HPVM-related dependencies, then the native camera pipeline ISP code.
#
# Paths to some dependencies (e.g., HPVM, LLVM) must exist in Makefile.config,
# which can be copied from Makefile.config.example for a start.
CONFIG_FILE := Makefile.config
ifeq ($(wildcard $(CONFIG_FILE)),)
$(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example)
endif
include $(CONFIG_FILE)
# Compiler Flags
DLEVEL ?= 0
LFLAGS += -lm -lrt
# Build dirs
ifeq ($(VERSION),)
VERSION = Default
endif
SRC_DIR = src/
CAM_PIPE_SRC_DIR = $(SRC_DIR)
BUILD_DIR = build/$(TARGET)_$(VERSION)
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
INCLUDES += -I$(SRC_DIR)
ifneq ($(CONFUSE_ROOT),)
INCLUDES += -I$(CONFUSE_ROOT)/include
LFLAGS += -L$(CONFUSE_ROOT)/lib
endif
EXE = miniera-visc-sim-$(VERSION)-$(TARGET)
CAM_CFLAGS += -mf16c -flax-vector-conversions
LFLAGS += -pthread
#$(DEBUG): $(NATIVE_FULL_PATH_SRCS) $(GEM5_FULL_PATH_SRCS)
# @echo Building benchmark for native machine with debug support.
# #@mkdir -p $(BUILD_DIR)
# @$(CC) $(CAM_CFLAGS) -ggdb3 $(INCLUDES) -DGEM5 -DDMA_MODE -DDMA_INTERFACE_V3 -o $(DEBUG) $^ $(LFLAGS)
#
#clean-native:
# rm -f $(NATIVE) $(DEBUG)
## BEGIN HPVM MAKEFILE
LANGUAGE=visc
SRCDIR_OBJS=sim_environs.ll
OBJS_SRC=$(wildcard $(SRC_DIR)/*.c)
VISC_OBJS=main.visc.ll
APP = $(EXE)
APP_CUDALDFLAGS=-lm -lstdc++
APP_CFLAGS= $(INCLUDES) -DDMA_MODE -DDMA_INTERFACE_V3 -DUSE_SIM_ENVIRON
APP_CXXFLAGS=-ffast-math -O0 -I/opt/opencv/include
APP_LDFLAGS=$(LFLAGS)
OPT_FLAGS = -tti -targetlibinfo -tbaa -scoped-noalias -assumption-cache-tracker -profile-summary-info -forceattrs -inferattrs -ipsccp -globalopt -domtree -mem2reg -deadargelim -domtree -basicaa -aa -simplifycfg -pgo-icall-prom -basiccg -globals-aa -prune-eh -always-inline -functionattrs -domtree -sroa -early-cse -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -domtree -basicaa -aa -libcalls-shrinkwrap -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa-verification -lcssa -basicaa -aa -scalar-evolution -loop-rotate -licm -loop-unswitch -simplifycfg -domtree -basicaa -aa -loops -loop-simplify -lcssa-verification -lcssa -scalar-evolution -indvars -loop-idiom -loop-deletion -memdep -memcpyopt -sccp -domtree -demanded-bits -bdce -basicaa -aa -lazy-value-info -jump-threading -correlated-propagation -domtree -basicaa -aa -memdep -dse -loops -loop-simplify -lcssa-verification -lcssa -aa -scalar-evolution -licm -postdomtree -adce -simplifycfg -domtree -basicaa -aa -barrier -basiccg -rpo-functionattrs -globals-aa -float2int -domtree -loops -loop-simplify -lcssa-verification -lcssa -basicaa -aa -scalar-evolution -loop-rotate -loop-accesses -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -loop-distribute -loop-simplify -lcssa-verification -lcssa -branch-prob -block-freq -scalar-evolution -basicaa -aa -loop-accesses -demanded-bits -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -loop-vectorize -loop-simplify -scalar-evolution -aa -loop-accesses -loop-load-elim -basicaa -aa -simplifycfg -domtree -basicaa -aa -loops -scalar-evolution -alignment-from-assumptions -strip-dead-prototypes -domtree -loops -branch-prob -block-freq -loop-simplify -lcssa-verification -lcssa -basicaa -aa -scalar-evolution -branch-prob -block-freq -loop-sink -instsimplify
CFLAGS = -O1 $(APP_CFLAGS) $(PLATFORM_CFLAGS)
OBJS_CFLAGS = -O1 $(APP_CFLAGS) $(PLATFORM_CFLAGS)
CXXFLAGS = $(APP_CXXFLAGS) $(PLATFORM_CXXFLAGS)
LDFLAGS= $(APP_LDFLAGS) $(PLATFORM_LDFLAGS)
LIBCLC_LIB_PATH = $(LLVM_SRC_ROOT)/../libclc/built_libs
VISC_RT_PATH = $(LLVM_SRC_ROOT)/projects/visc-rt
VISC_RT_LIB = $(VISC_RT_PATH)/visc-rt.ll
#LIBCLC_NVPTX_LIB = $(LIBCLC_LIB_PATH)/nvptx--nvidiacl.bc
LIBCLC_NVPTX_LIB = $(LIBCLC_LIB_PATH)/nvptx64--nvidiacl.bc
#LIBCLC_NVPTX_LIB = nvptx64--nvidiacl.bc
LLVM_34_AS = $(LLVM_34_ROOT)/build/bin/llvm-as
TESTGEN_OPTFLAGS = -load LLVMGenVISC.so -genvisc -globaldce
KERNEL_GEN_FLAGS = -O3 -target nvptx64-nvidia-nvcl
ifeq ($(TARGET),x86)
DEVICE = SPIR_TARGET
VISC_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_SPIR.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -localmem -dfg2llvm-spir -dfg2llvm-x86 -clearDFG
CFLAGS += -DOPENCL_CPU
VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-spir
else ifeq ($(TARGET),seq)
DEVICE = CPU_TARGET
VISC_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG
VISC_OPTFLAGS += -visc-timers-x86
else ifeq ($(TARGET),fpga)
DEVICE = FPGA_TARGET
VISC_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_FPGA.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -localmem -dfg2llvm-fpga -dfg2llvm-x86 -clearDFG
CFLAGS += -DOPENCL_CPU
VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-fpga
else
DEVICE = GPU_TARGET
VISC_OPTFLAGS = -load LLVMBuildDFG.so -load LLVMLocalMem.so -load LLVMDFG2LLVM_NVPTX.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -localmem -dfg2llvm-nvptx -dfg2llvm-x86 -clearDFG
VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-ptx
endif
TESTGEN_OPTFLAGS += -visc-timers-gen
CFLAGS += -DDEVICE=$(DEVICE)
CXXFLAGS += -DDEVICE=$(DEVICE)
#ifeq ($(TIMER),x86)
# VISC_OPTFLAGS += -visc-timers-x86
#else ifeq ($(TIMER),ptx)
# VISC_OPTFLAGS += -visc-timers-ptx
#else ifeq ($(TIMER),gen)
# TESTGEN_OPTFLAGS += -visc-timers-gen
#else ifeq ($(TIMER),spir)
# TESTGEN_OPTFLAGS += -visc-timers-spir
#else ifeq ($(TIMER),fpga)
# TESTGEN_OPTFLAGS += -visc-timers-fpga
#else ifeq ($(TIMER),no)
#else
# ifeq ($(TARGET),x86)
# VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-spir
# else ifeq ($(TARGET),seq)
# VISC_OPTFLAGS += -visc-timers-x86
# else ifeq ($(TARGET),fpga)
# VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-fpga
# else ifeq ($(TARGET),seqx86)
# VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-spir
# else ifeq ($(TARGET),seqgpu)
# VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-ptx
# else
# VISC_OPTFLAGS += -visc-timers-x86 -visc-timers-ptx
# endif
# TESTGEN_OPTFLAGS += -visc-timers-gen
#endif
# Add BUILDDIR as a prefix to each element of $1
INBUILDDIR=$(addprefix $(BUILD_DIR)/,$(1))
# Add SRCDIR as a prefix to each element of $1
#INSRCDIR=$(addprefix $(SRCDIR)/,$(1))
PYTHON_LLVM_40_34 = ../llvm-40-34.py
.PRECIOUS: $(BUILD_DIR)/%.ll
OBJS = $(call INBUILDDIR,$(SRCDIR_OBJS))
TEST_OBJS = $(call INBUILDDIR,$(VISC_OBJS))
KERNEL = $(TEST_OBJS).kernels.ll
ifeq ($(TARGET),x86)
SPIR_ASSEMBLY = $(TEST_OBJS).kernels.bc
else ifeq ($(TARGET),seq)
else ifeq ($(TARGET),fpga)
AOC_CL = $(TEST_OBJS).kernels.cl
AOCL_ASSEMBLY = $(TEST_OBJS).kernels.aocx
BOARD = a10gx
ifeq ($(EMULATION),1)
EXE = cava-visc-emu
AOC_EMU = -march=emulator
BUILD_DIR = build/$(TARGET)-emu
endif
else
KERNEL_LINKED = $(BUILD_DIR)/$(APP).kernels.linked.ll
#KERNEL = $(TEST_OBJS).kernels.ll
PTX_ASSEMBLY = $(TEST_OBJS).nvptx.s
endif
HOST_LINKED = $(BUILD_DIR)/$(APP).linked.ll
HOST = $(BUILD_DIR)/$(APP).host.ll
ifeq ($(OPENCL_PATH),)
FAILSAFE=no_opencl
else
FAILSAFE=
endif
# Targets
default: $(FAILSAFE) $(BUILD_DIR) $(EXE)
#default: $(FAILSAFE) $(BUILD_DIR) $(PTX_ASSEMBLY) $(SPIR_ASSEMBLY) $(AOC_CL) $(AOCL_ASSEMBLY) $(EXE)
$(PTX_ASSEMBLY) : $(KERNEL_LINKED)
$(CC) $(KERNEL_GEN_FLAGS) -S $< -o $@
$(KERNEL_LINKED) : $(KERNEL)
$(LLVM_LINK) $(LIBCLC_NVPTX_LIB) -S $< -o $@
$(SPIR_ASSEMBLY) : $(KERNEL)
python $(PYTHON_LLVM_40_34) $< $(BUILD_DIR)/kernel_34.ll
$(LLVM_34_AS) $(BUILD_DIR)/kernel_34.ll -o $@
$(AOCL_ASSEMBLY) : $(AOC_CL)
aoc --report $(AOC_EMU) $(AOC_CL) -o $(AOCL_ASSEMBLY) -board=$(BOARD)
$(AOC_CL) : $(KERNEL)
llvm-cbe --debug $(KERNEL)
$(EXE) : $(HOST_LINKED)
$(CXX) -O3 $(LDFLAGS) $< -o $@
$(HOST_LINKED) : $(HOST) $(OBJS) $(VISC_RT_LIB)
$(LLVM_LINK) $^ -S -o $@
$(VISC_RT_LIB) : $(VISC_RT_PATH)/visc-rt.cpp
make -C $(LLVM_LIB_PATH)
$(HOST) $(KERNEL): $(BUILD_DIR)/$(VISC_OBJS)
$(OPT) -debug $(VISC_OPTFLAGS) -S $< -o $(HOST)
# mv *.ll $(BUILD_DIR)
# $(OPT) -debug-only=DFG2LLVM_SPIR,DFG2LLVM_X86,DFG2LLVM_FPGA,GENVISC $(VISC_OPTFLAGS) -S $< -o $(HOST)
#$(OBJS): $(OBJS_SRC)
# $(CC) $(OBJS_CFLAGS) -emit-llvm -S -o $@ $<
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.ll : $(SRC_DIR)/%.c
$(CC) $(OBJS_CFLAGS) -emit-llvm -S -o $@ $<
$(BUILD_DIR)/main.ll : $(SRC_DIR)/main.c
$(CC) $(CFLAGS) -emit-llvm -S -o $@ $<
#$(BUILD_DIR)/main.opt.ll : $(BUILD_DIR)/main.ll
# $(OPT) $(OPT_FLAGS) $< -S -o $@
$(BUILD_DIR)/main.visc.ll : $(BUILD_DIR)/main.ll
$(OPT) -debug-only=genvisc $(TESTGEN_OPTFLAGS) $< -S -o $@
## END HPVM MAKEFILE