-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile.common
More file actions
executable file
·184 lines (138 loc) · 5.97 KB
/
Makefile.common
File metadata and controls
executable file
·184 lines (138 loc) · 5.97 KB
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
####################################################
# Makefile ------- Thomas Chau 2013 #
# Tested for MaxCompiler 2013.2.2 #
####################################################
# 1) For SLiC interface only
# If you are using MaxCompilerRT,
# use maxfilecompile instead of sliccompile
# and change LFLAGS -lslic to -lmaxcompilerrt
# 2) This makefile depends on project-specific
# settings defined in project's Makefile
# 3) Usage: use project's makefile (navigate
# to project's directory and use makefile there)
#
# ---- Paths ----
ifndef $(MAXCOMPILER_BUILD_DIR)
MAXCOMPILER_BUILD_DIR=.
endif
SIMMAXDIR=$(MAXCOMPILER_BUILD_DIR)/$(PRJ)_$(DFEModel)_DFE_SIM/results
DFEMAXDIR=$(MAXCOMPILER_BUILD_DIR)/$(PRJ)_$(DFEModel)_DFE/results
MAXELEROSDIR_SIM:=$(MAXCOMPILERDIR)/lib/maxeleros-sim
# ---- Source files ----
ENGINEFILES=$(wildcard ../src/*.maxj)
# ---- Command alias ----
# Note that if you want to change CC to gcc, you may also have to
# change some of the compiler optimization flags
CC=icc
MAXFILECOMPILE=maxfilecompile
SLICCOMPILE=sliccompile
MAXGUESSBUILDDIR=maxGuessBuildDir
MAXFILESTITCH=maxfilestitch
MAXJAVARUN=maxJavaRun
MAXJC=maxjc
MAXDEBUG=maxdebug
MAXRENDERGRAPHS=maxRenderGraphs
MAXCOMPILERSIM=maxcompilersim
MAXOS_HW=/opt/maxeler/maxeleros/lib/libmaxeleros.so
MAXOS_SIM=$(MAXELEROSDIR_SIM)/lib/libmaxeleros.so
# ---- Compiler settings ----
JFLAGS=-cp $(MAXCOMPILERDIR)/lib/MaxCompiler.jar -1.6 -d .
OPT_FLAGS=-xHost -O3
CFLAGS=-std=c99 -openmp $(OPT_FLAGS) -Wall -I${MAXCOMPILERDIR}/include -I${MAXCOMPILERDIR}/include/slic -I${MAXELEROSDIR}/include -D_XOPEN_SOURCE=600
LFLAGS=-L${MAXCOMPILERDIR}/lib -L${MAXELEROSDIR}/lib -lmaxeleros -lslic -lm -lpthread -openmp
# Add this on the command line to pass to make when compiling
# Useful for debug/optimization flags
EXTRA_CFLAGS?=
# This is set in the gdbsim/gdbdfe targets
DEBUG_FLAGS?=
ALL_FLAGS = $(CFLAGS) $(EXTRA_CFLAGS) $(DEBUG_FLAGS)
# ---- Run-time arguments ----
ARGS?=
# ---- Default DFE ----
DFEID=/dev/maxeler0
# # Files to remove on clean
TRASH=*~ ../src/*~ *.o
DIST_TRASH_SIM=Maxfiles.h *.class *sim.o *simc.o debug* *.dot *.png
DIST_TRASH_DFE=Maxfiles.h *.class *dfe.o *dfec.o debug* *.dot *.png
help:
@ echo "Current configuration:"
@ echo " Compiler $(CC)"
@ echo " Optimizations $(OPT_FLAGS)"
@ echo " MAXCOMPILERDIR $(MAXCOMPILERDIR)"
@ echo ""
@ echo "Available targets: "
@ echo " runsim -- build and run design in simulation (requires MaxCompiler license)"
@ echo " stopsim -- stop the currently running simulated device"
@ echo " build -- build the design in hardware (requires MaxCompiler license)"
@ echo " run -- run design in hardware (requires local access to a DFE)"
@ echo " debug -- debug a simulation design using MaxDebug"
@ echo " debughw -- debug a hardware design using MaxDebug (requires local access to DFE)"
@ echo " gdbsim, gdbdfe -- build CPU code with debug symbols"
@ echo " cleansim, cleandfe, clean -- clean executables for simulation, hardware or both"
@ echo " distcleansim, distcleanhw, distclean -- delete the entire sim, hw or both directories"
@ echo " help -- print this help message"
all: runsim build
.PHONY: stopsim run cleansim cleandfe debug debughw
# ---- Simulation ----
$(SIMMAXDIR)/$(PRJ).max: $(ENGINEFILES)
$(MAXJC) $(JFLAGS) $(ENGINEFILES)
MAXAPPJCP=. MAXSOURCEDIRS='../src' $(MAXJAVARUN) -v -m 8192 $(MANAGER) DFEModel=$(DFEModel) maxFileName=$(PRJ) target='DFE_SIM' enableMPCX=$(MPCX)
cp $(SIMMAXDIR)/$(PRJ).h $(SIMMAXDIR)/Maxfiles.h
$(PRJ)_sim.o: $(SIMMAXDIR)/$(PRJ).max
$(SLICCOMPILE) $< $@
$(PRJ)_dSFMT_sim.o: ../../common/dSFMT-src-2.2.1/dSFMT.c
$(CC) $< $(ALL_FLAGS) -I$(SIMMAXDIR) -D__SIM__ -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_func_sim.o: ../src/Func.c
$(CC) $< $(ALL_FLAGS) -I$(SIMMAXDIR) -D__SIM__ -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_simc.o: ../src/Smc.c
$(CC) $< $(ALL_FLAGS) -I$(SIMMAXDIR) -D__SIM__ -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_sim: $(PRJ)_sim.o $(PRJ)_simc.o $(PRJ)_func_sim.o $(PRJ)_dSFMT_sim.o
$(CC) $(ALL_FLAGS) -o $@ $^ $(LFLAGS)
runsim: $(PRJ)_sim
$(MAXCOMPILERSIM) -n $(USER)a -c$(DEVICENUM) restart
SLIC_CONF+="use_simulation=$(USER)a" LD_PRELOAD=$(MAXOS_SIM) ./$(PRJ)_sim $(ARGS) $(USER)a0:$(USER)a
make stopsim
stopsim:
$(MAXCOMPILERSIM) -n $(USER)a -c$(DEVICENUM) stop
gdbsim:
DEBUG_FLAGS="-O0 -g" make $(PRJ)_sim
LD_PRELOAD=$(MAXOS_SIM) gdb $(PRJ)_sim
# ---- DFE ----
$(DFEMAXDIR)/$(PRJ).max: $(ENGINEFILES)
$(MAXJC) $(JFLAGS) $(ENGINEFILES)
MAXAPPJCP=. MAXSOURCEDIRS='../src' $(MAXJAVARUN) -v -m 8192 $(MANAGER) DFEModel=$(DFEModel) maxFileName=$(PRJ) target='DFE' enableMPCX=$(MPCX)
cp $(DFEMAXDIR)/$(PRJ).h $(DFEMAXDIR)/Maxfiles.h
$(PRJ)_dfe.o: $(DFEMAXDIR)/$(PRJ).max
$(SLICCOMPILE) $< $@
$(PRJ)_dSFMT_dfe.o: ../../common/dSFMT-src-2.2.1/dSFMT.c
$(CC) $< $(ALL_FLAGS) -I$(DFEMAXDIR) -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_func_dfe.o: ../src/Func.c
$(CC) $< $(ALL_FLAGS) -I$(DFEMAXDIR) -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_dfec.o: ../src/Smc.c
$(CC) $< $(ALL_FLAGS) -I$(DFEMAXDIR) -DDESIGN_NAME=$(PRJ) -c -o $@
$(PRJ)_dfe: $(PRJ)_dfe.o $(PRJ)_dfec.o $(PRJ)_func_dfe.o $(PRJ)_dSFMT_dfe.o
$(CC) $(ALL_FLAGS) -o $@ $^ $(LFLAGS)
build: $(PRJ)_dfe
run:
SLIC_CONF=$(SLIC_CONF) LD_PRELOAD=$(MAXOS_HW) ./${PRJ}_dfe $(ARGS)
gdbdfe:
DEBUG_FLAGS="-O0 -g" make build
LD_PRELOAD=$(MAXOS_HW) gdb $(PRJ)_dfe
# ---- Clean ----
cleansim:
rm -f $(PRJ)_sim $(TRASH)
cleandfe:
rm -f $(PRJ)_dfe $(TRASH)
clean: cleansim cleandfe
distcleansim: cleansim
rm -rf $(DIST_TRASH_SIM) $(PRJ)_$(DFEModel)_DFE_SIM
distcleandfe: cleandfe
rm -rf $(DIST_TRASH_DFE) $(PRJ)_$(DFEModel)_DFE
distclean: distcleansim distcleandfe
# ---- Debug ----
# make debug -- debug the main kernel
# make debug KERNEL=kernel name -- debug a specific kernel
debug:
maxdebug -v -g $(PRJ)Graph -s $(PRJ)Graph -c -k $(KERNEL) -d $(USER)a0:$(USER)a $(SIMMAXDIR)/$(PRJ).max
debughw:
maxdebug -v -g $(PRJ)Graph -s $(PRJ)Graph -c -k $(KERNEL) -d $(DFEID) $(DFEMAXDIR)/$(PRJ).max