1 | # |
---|
2 | # $Id: Makefile 123 2009-06-08 20:43:30Z rosiere $ |
---|
3 | # |
---|
4 | # [ Description ] |
---|
5 | # |
---|
6 | # Makefile |
---|
7 | # |
---|
8 | |
---|
9 | include Makefile.defs |
---|
10 | |
---|
11 | #-----[ Specint variable ]-------------------------------------------------------- |
---|
12 | |
---|
13 | # BENCHS = 164.gzip \ |
---|
14 | # 175.vpr \ |
---|
15 | # 176.gcc \ |
---|
16 | # 181.mcf \ |
---|
17 | # 255.vortex \ |
---|
18 | # 256.bzip2 \ |
---|
19 | # 300.twolf |
---|
20 | |
---|
21 | BENCHS = 164.gzip |
---|
22 | |
---|
23 | |
---|
24 | SPECINT2000_PATH = /users/cao/kane/Project/SPEC_CPU2000/benchspec/CINT2000 |
---|
25 | SPECINT2000_PATHS = $(addprefix $(SPECINT2000_PATH)/, $(BENCHS)) |
---|
26 | |
---|
27 | SPECINT2000_PATH_INC = $(addprefix -I, $(addsuffix /src, $(SPECINT2000_PATHS))) |
---|
28 | SPECINT2000_PATH_SRC = $(wildcard $(addsuffix /src , $(SPECINT2000_PATHS))) |
---|
29 | SPECINT2000_OBJECTS = $(foreach bench,$(BENCHS),$(addprefix $(DIR_OBJ)/$(bench)_, $(addsuffix .o, $(basename $(notdir $(wildcard $(SPECINT2000_PATH)/$(bench)/src/*.c)))))) |
---|
30 | |
---|
31 | #-----[ Directory ]--------------------------------------------------------------- |
---|
32 | |
---|
33 | DIR_SOFT = .. |
---|
34 | |
---|
35 | DIR_SRC = ./src |
---|
36 | DIR_C = $(DIR_SRC)/c |
---|
37 | DIR_ASM = $(DIR_SRC)/asm |
---|
38 | DIR_SYS = $(DIR_SRC)/sys |
---|
39 | DIR_INC = $(DIR_SRC)/include |
---|
40 | DIR_LDSCRIPT = $(NEWLIB)/lib/ |
---|
41 | |
---|
42 | INCDIR = $(NEWLIB_INCDIR) -I$(DIR_INC) $(SPECINT2000_PATH_INC) |
---|
43 | LIBDIR = $(NEWLIB_LIBDIR) |
---|
44 | LIBNAME = $(NEWLIB_LIBNAME) |
---|
45 | |
---|
46 | FILE_BENCH = $(DIR_INC)/workload.h |
---|
47 | FILE_BENCH_SED = $(DIR_INC)/workload.h.sed |
---|
48 | |
---|
49 | #-----[ Flags ]------------------------------------------------------------------- |
---|
50 | |
---|
51 | FLAGS = -DSPECINT2000_PATH=\"$(SPECINT2000_PATH)\" -DNB_THREAD_MAX=$(NB_THREAD_MAX) |
---|
52 | FLAGS_164.gzip = |
---|
53 | FLAGS_175.vpr = -DSPEC_CPU2000 |
---|
54 | FLAGS_176.gcc = |
---|
55 | FLAGS_181.mcf = -DWANT_STDC_PROTO |
---|
56 | FLAGS_186.crafty = |
---|
57 | FLAGS_197.parser = |
---|
58 | FLAGS_252.eon = |
---|
59 | FLAGS_253.perlbmk = |
---|
60 | FLAGS_254.gap = |
---|
61 | FLAGS_255.vortex = |
---|
62 | FLAGS_256.bzip2 = -DWANT_STDC_PROTO |
---|
63 | FLAGS_300.twolf = -DSPEC_CPU2000 |
---|
64 | |
---|
65 | #-----[ Files ]------------------------------------------------------------------- |
---|
66 | OBJECTS = $(NEWLIB)/lib/*.o \ |
---|
67 | $(patsubst $(DIR_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_ASM)/*.s)) \ |
---|
68 | $(patsubst $(DIR_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SYS)/*.s)) \ |
---|
69 | $(patsubst $(DIR_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_C)/*.c)) \ |
---|
70 | $(SPECINT2000_OBJECTS) |
---|
71 | |
---|
72 | vpath %.h $(SPECINT2000_PATH_INC) |
---|
73 | # vpath %.c $(SPECINT2000_PATH_SRC) |
---|
74 | |
---|
75 | include $(DIR_SOFT)/Makefile.Software |
---|
76 | |
---|
77 | $(DIR_OBJ)/164.gzip_%.o : $(SPECINT2000_PATH)/164.gzip/src/%.c |
---|
78 | @\ |
---|
79 | $(ECHO) "Compilation : $*.c"; \ |
---|
80 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_164.gzip) -o $@ -c $^ ; |
---|
81 | |
---|
82 | $(DIR_OBJ)/175.vpr_%.o : $(SPECINT2000_PATH)/175.vpr/src/%.c |
---|
83 | @\ |
---|
84 | $(ECHO) "Compilation : $*.c"; \ |
---|
85 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_175.vpr) -o $@ -c $^ ; |
---|
86 | |
---|
87 | $(DIR_OBJ)/176.gcc_%.o : $(SPECINT2000_PATH)/176.gcc/src/%.c |
---|
88 | @\ |
---|
89 | $(ECHO) "Compilation : $*.c"; \ |
---|
90 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_176.gcc) -o $@ -c $^ ; |
---|
91 | |
---|
92 | $(DIR_OBJ)/181.mcf_%.o : $(SPECINT2000_PATH)/181.mcf/src/%.c |
---|
93 | @\ |
---|
94 | $(ECHO) "Compilation : $*.c"; \ |
---|
95 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_181.mcf) -o $@ -c $^ ; |
---|
96 | |
---|
97 | $(DIR_OBJ)/186.crafty_%.o : $(SPECINT2000_PATH)/186.crafty/src/%.c |
---|
98 | @\ |
---|
99 | $(ECHO) "Compilation : $*.c"; \ |
---|
100 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_186.crafty) -o $@ -c $^ ; |
---|
101 | |
---|
102 | $(DIR_OBJ)/255.vortex_%.o : $(SPECINT2000_PATH)/255.vortex/src/%.c |
---|
103 | @\ |
---|
104 | $(ECHO) "Compilation : $*.c"; \ |
---|
105 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_255.vortex) -o $@ -c $^ ; |
---|
106 | |
---|
107 | $(DIR_OBJ)/197.parser_%.o : $(SPECINT2000_PATH)/197.parser/src/%.c |
---|
108 | @\ |
---|
109 | $(ECHO) "Compilation : $*.c"; \ |
---|
110 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_197.parser) -o $@ -c $^ ; |
---|
111 | |
---|
112 | $(DIR_OBJ)/252.eon_%.o : $(SPECINT2000_PATH)/252.eon/src/%.c |
---|
113 | @\ |
---|
114 | $(ECHO) "Compilation : $*.c"; \ |
---|
115 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_252.eon) -o $@ -c $^ ; |
---|
116 | |
---|
117 | $(DIR_OBJ)/253.perlbmk_%.o : $(SPECINT2000_PATH)/253.perlbmk/src/%.c |
---|
118 | @\ |
---|
119 | $(ECHO) "Compilation : $*.c"; \ |
---|
120 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_253.perlbmk) -o $@ -c $^ ; |
---|
121 | |
---|
122 | $(DIR_OBJ)/254.gap_%.o : $(SPECINT2000_PATH)/254.gap/src/%.c |
---|
123 | @\ |
---|
124 | $(ECHO) "Compilation : $*.c"; \ |
---|
125 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_254.gap) -o $@ -c $^ ; |
---|
126 | |
---|
127 | $(DIR_OBJ)/256.bzip2_%.o : $(SPECINT2000_PATH)/256.bzip2/src/%.c |
---|
128 | @\ |
---|
129 | $(ECHO) "Compilation : $*.c"; \ |
---|
130 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_256.bzip2) -o $@ -c $^ ; |
---|
131 | |
---|
132 | $(DIR_OBJ)/300.twolf_%.o : $(SPECINT2000_PATH)/300.twolf/src/%.c |
---|
133 | @\ |
---|
134 | $(ECHO) "Compilation : $*.c"; \ |
---|
135 | $(OR32_CC) $(OR32_CC_OPT) $(FLAGS_300.twolf) -o $@ -c $^ ; |
---|
136 | |
---|
137 | list : |
---|
138 | @\ |
---|
139 | for bench in $(BENCHS); do \ |
---|
140 | $(ECHO) $${bench}; \ |
---|
141 | done; |
---|
142 | |
---|
143 | print : |
---|
144 | @$(CAT) $(FILE_BENCH); |
---|
145 | |
---|
146 | define : |
---|
147 | @ \ |
---|
148 | $(ECHO) "Give a Number of thread (1 by default, Max : $(NB_THREAD_MAX)) : "; \ |
---|
149 | declare -i NB_THREAD=0; \ |
---|
150 | $(READ) NB_THREAD; \ |
---|
151 | \ |
---|
152 | if $(TEST) "$$NB_THREAD" -ge "$(NB_THREAD_MAX)"; \ |
---|
153 | then \ |
---|
154 | NB_THREAD=$(NB_THREAD_MAX); \ |
---|
155 | else \ |
---|
156 | if $(TEST) "$$NB_THREAD" -eq 0; \ |
---|
157 | then \ |
---|
158 | NB_THREAD=1; \ |
---|
159 | fi; \ |
---|
160 | fi; \ |
---|
161 | \ |
---|
162 | $(ECHO) "You want $$NB_THREAD thread(s)"; \ |
---|
163 | $(ECHO) ""; \ |
---|
164 | declare -i NUM_THREAD=0; \ |
---|
165 | declare WORKLOAD=""; \ |
---|
166 | declare -i PREVIOUS=1; \ |
---|
167 | declare -i CPT=2; \ |
---|
168 | declare -a BENCHS; \ |
---|
169 | \ |
---|
170 | BENCHS[0]="previous choose"; \ |
---|
171 | BENCHS[1]="none"; \ |
---|
172 | for benchs in $(BENCHS); do \ |
---|
173 | BENCHS[$$CPT]=$${benchs/"."/"_"}; \ |
---|
174 | CPT=$$(($$CPT+1)); \ |
---|
175 | done; \ |
---|
176 | \ |
---|
177 | $(ECHO) "For each Thread, you must select a number of benchmark (0 by default)";\ |
---|
178 | $(ECHO) ""; \ |
---|
179 | \ |
---|
180 | while [ $$NUM_THREAD -lt $$NB_THREAD ]; \ |
---|
181 | do \ |
---|
182 | if $(TEST) $$NUM_THREAD -ne 0; \ |
---|
183 | then \ |
---|
184 | WORKLOAD=$$WORKLOAD",\n"; \ |
---|
185 | fi; \ |
---|
186 | \ |
---|
187 | $(ECHO) "For Thread[$$NUM_THREAD] ....."; \ |
---|
188 | declare -i NUM_BENCH; \ |
---|
189 | \ |
---|
190 | $(ECHO) "0) previous choose : $${BENCHS[$$PREVIOUS]}"; \ |
---|
191 | CPT=1; \ |
---|
192 | while [ $$CPT -lt $${#BENCHS[*]} ]; \ |
---|
193 | do \ |
---|
194 | $(ECHO) "$$CPT) $${BENCHS[$$CPT]}"; \ |
---|
195 | CPT=$$(($$CPT+1)); \ |
---|
196 | done; \ |
---|
197 | $(READ) NUM_BENCH; \ |
---|
198 | \ |
---|
199 | if $(TEST) "$$NUM_BENCH" -ge "$$CPT"; \ |
---|
200 | then \ |
---|
201 | NUM_BENCH=0; \ |
---|
202 | fi; \ |
---|
203 | \ |
---|
204 | if $(TEST) "$$NUM_BENCH" -eq "0"; \ |
---|
205 | then \ |
---|
206 | NUM_BENCH=$$PREVIOUS; \ |
---|
207 | else \ |
---|
208 | PREVIOUS=$$NUM_BENCH; \ |
---|
209 | fi; \ |
---|
210 | \ |
---|
211 | $(ECHO) "Benchmark selected : $${BENCHS[$$NUM_BENCH]}"; \ |
---|
212 | $(ECHO) ""; \ |
---|
213 | \ |
---|
214 | WORKLOAD=$$WORKLOAD"\t(void *) run_$${BENCHS[$$NUM_BENCH]}"; \ |
---|
215 | NUM_THREAD=$$(($$NUM_THREAD+1)); \ |
---|
216 | done; \ |
---|
217 | $(ECHO) ""; \ |
---|
218 | $(ECHO) "Generate the file : $(FILE_BENCH)"; \ |
---|
219 | $(CAT) $(FILE_BENCH_SED) |$(SED) "s/@WORKLOAD/$$WORKLOAD/" > $(FILE_BENCH); \ |
---|
220 | $(RM) $$$$; \ |
---|
221 | $(ECHO) ""; |
---|
222 | |
---|
223 | |
---|
224 | workload : |
---|
225 | @ \ |
---|
226 | $(ECHO) "Give a Number of thread (1 by default, Max : $(NB_THREAD_MAX)) : "; \ |
---|
227 | declare -i NB_THREAD=0; \ |
---|
228 | $(READ) NB_THREAD; \ |
---|
229 | \ |
---|
230 | if $(TEST) "$$NB_THREAD" -ge "$(NB_THREAD_MAX)"; \ |
---|
231 | then \ |
---|
232 | NB_THREAD=$(NB_THREAD_MAX); \ |
---|
233 | else \ |
---|
234 | if $(TEST) "$$NB_THREAD" -eq 0; \ |
---|
235 | then \ |
---|
236 | NB_THREAD=1; \ |
---|
237 | fi; \ |
---|
238 | fi; \ |
---|
239 | \ |
---|
240 | $(ECHO) " * You want $$NB_THREAD thread(s)"; \ |
---|
241 | $(ECHO) ""; \ |
---|
242 | $(ECHO) "List of all Benchmark"; \ |
---|
243 | declare -i CPT=1; \ |
---|
244 | declare -a BENCHS; \ |
---|
245 | \ |
---|
246 | for benchs in $(BENCHS); do \ |
---|
247 | $(ECHO) " $$CPT) $$benchs"; \ |
---|
248 | BENCHS[$$CPT]=$${benchs/"."/"_"}; \ |
---|
249 | CPT=$$(($$CPT+1)); \ |
---|
250 | done; \ |
---|
251 | $(ECHO) ""; \ |
---|
252 | $(ECHO) "Enter the list benchmark (0 to stop)"; \ |
---|
253 | declare -i NUM_BENCH; \ |
---|
254 | CPT=1; \ |
---|
255 | declare -a -i WORKLOAD; \ |
---|
256 | \ |
---|
257 | while $(TEST) 1; do \ |
---|
258 | $(READ) NUM_BENCH; \ |
---|
259 | \ |
---|
260 | if $(TEST) $$NUM_BENCH -eq 0; then \ |
---|
261 | break; \ |
---|
262 | fi; \ |
---|
263 | \ |
---|
264 | if $(TEST) $$NUM_BENCH -gt $${#BENCHS[*]}; then \ |
---|
265 | $(ECHO) " * Out of limit, retry ..."; \ |
---|
266 | else \ |
---|
267 | echo " * $${BENCHS[$$NUM_BENCH]}"; \ |
---|
268 | WORKLOAD[$$CPT]=$$NUM_BENCH; \ |
---|
269 | CPT=$$(($$CPT+1)); \ |
---|
270 | fi; \ |
---|
271 | done; \ |
---|
272 | \ |
---|
273 | if $(TEST) $$NB_THREAD -gt $${#WORKLOAD[*]}; then \ |
---|
274 | $(ECHO) "Error : The number of bench in the workload ($${#WORKLOAD[*]}) is < at the number of thread ($$NB_THREAD)"; \ |
---|
275 | exit; \ |
---|
276 | fi; \ |
---|
277 | $(ECHO) ""; \ |
---|
278 | $(ECHO) "Generate the workload"; \ |
---|
279 | \ |
---|
280 | declare -i NB_ITERATION=1; \ |
---|
281 | CPT=$$(($$NB_THREAD+1)); \ |
---|
282 | while $(TEST) $$CPT -le $${#WORKLOAD[*]}; do \ |
---|
283 | NB_ITERATION=$$(($$NB_ITERATION*$$CPT)); \ |
---|
284 | CPT=$$(($$CPT+1)); \ |
---|
285 | done; \ |
---|
286 | CPT=$$(($${#WORKLOAD[*]}-$$NB_THREAD)); \ |
---|
287 | while $(TEST) $$CPT -gt 0; do \ |
---|
288 | NB_ITERATION=$$(($$NB_ITERATION/$$CPT)); \ |
---|
289 | CPT=$$(($$CPT-1)); \ |
---|
290 | done; \ |
---|
291 | $(ECHO) " * $$NB_ITERATION Workloads (n!/(p!*(n-p)!))"; \ |
---|
292 | \ |
---|
293 | declare -a -i PTR; \ |
---|
294 | CPT=1; \ |
---|
295 | while $(TEST) $$CPT -le $$NB_THREAD; do \ |
---|
296 | PTR[$$CPT]=$$(($$NB_THREAD-$$CPT+1)); \ |
---|
297 | CPT=$$(($$CPT+1)); \ |
---|
298 | done; \ |
---|
299 | \ |
---|
300 | CPT=0; \ |
---|
301 | declare -i IT; \ |
---|
302 | declare -a -i OVF; \ |
---|
303 | declare -a -i NB_OVF; \ |
---|
304 | \ |
---|
305 | while $(TEST) $$CPT -lt $$NB_ITERATION; do \ |
---|
306 | declare COMMAND="$$NB_THREAD\n"; \ |
---|
307 | echo -ne " - [$$CPT]\t"; \ |
---|
308 | \ |
---|
309 | OVF[0]=0; \ |
---|
310 | NB_OVF=0; \ |
---|
311 | if $(TEST) $${PTR[1]} -ge $${#WORKLOAD[*]}; then \ |
---|
312 | OVF[0]=1; \ |
---|
313 | fi; \ |
---|
314 | \ |
---|
315 | IT=1; \ |
---|
316 | while $(TEST) $$IT -le $$NB_THREAD; do \ |
---|
317 | echo -ne " $${BENCHS[$${WORKLOAD[$${PTR[$$IT]}]}]}\t"; \ |
---|
318 | \ |
---|
319 | COMMAND="$${COMMAND}$$(($${WORKLOAD[$${PTR[$$IT]}]}+1))\n"; \ |
---|
320 | OVF[$$(($$IT))]=0; \ |
---|
321 | if $(TEST) $${OVF[$$(($$IT-1))]} -eq 1 ; then \ |
---|
322 | if $(TEST) $$(($${PTR[$$IT]}+$$NB_OVF)) -ge $${#WORKLOAD[*]}; then \ |
---|
323 | OVF[$$IT]=1; \ |
---|
324 | NB_OVF=$$(($$NB_OVF+1)); \ |
---|
325 | fi; \ |
---|
326 | fi; \ |
---|
327 | \ |
---|
328 | IT=$$(($$IT+1)); \ |
---|
329 | done; \ |
---|
330 | echo ""; \ |
---|
331 | \ |
---|
332 | $(ECHO) -e $${COMMAND} | $(MAKE) define; \ |
---|
333 | $(MAKE) $(DIR_BIN)/$(EXE)_$${CPT}.x; \ |
---|
334 | \ |
---|
335 | PTR[1]=$$(($${PTR[1]}+1)); \ |
---|
336 | IT=$$NB_THREAD; \ |
---|
337 | while $(TEST) $$IT -ge 1; do \ |
---|
338 | if $(TEST) $${OVF[$$IT]} -eq 1 ; then \ |
---|
339 | PTR[$$(($$IT))]=$${PTR[$$(($$IT+1))]}; \ |
---|
340 | fi; \ |
---|
341 | \ |
---|
342 | if $(TEST) $${OVF[$$(($$IT-1))]} -eq 1 ; then \ |
---|
343 | PTR[$$(($$IT))]=$$(($${PTR[$$IT]}+1)); \ |
---|
344 | fi; \ |
---|
345 | IT=$$(($$IT-1)); \ |
---|
346 | done; \ |
---|
347 | \ |
---|
348 | CPT=$$(($$CPT+1)); \ |
---|
349 | done; \ |
---|