1 | // $Id: benchmark.c 118 2009-05-20 22:01:32Z rosiere $ |
---|
2 | |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | #include <stdio.h> |
---|
6 | |
---|
7 | #ifndef MIBENCH_DATA_PATH |
---|
8 | # error "MIBENCH_DATA_PATH must be defined" |
---|
9 | #endif |
---|
10 | |
---|
11 | #define MiBench_small |
---|
12 | //#define MiBench_large |
---|
13 | |
---|
14 | //-----[ automative ]----------------------------- |
---|
15 | int main_basicmath_small (void); |
---|
16 | int main_basicmath_large (void); |
---|
17 | int main_bitcount (int argc, char *argv[]); |
---|
18 | int main_qsort_small (int argc, char *argv[]); |
---|
19 | int main_qsort_large (int argc, char *argv[]); |
---|
20 | int main_susan (int argc, char *argv[]); |
---|
21 | //-----[ office ]--------------------------------- |
---|
22 | int main_stringsearch_small (void); |
---|
23 | int main_stringsearch_large (void); |
---|
24 | //-----[ network ]-------------------------------- |
---|
25 | int main_dijkstra (int argc, char *argv[]); |
---|
26 | //-----[ security ]------------------------------- |
---|
27 | int main_sha (int argc, char *argv[]); |
---|
28 | |
---|
29 | //======================================================================================= |
---|
30 | // [ run_none ] |
---|
31 | //======================================================================================= |
---|
32 | void run_none (void) |
---|
33 | { |
---|
34 | printf("***** none *****\n"); |
---|
35 | return; |
---|
36 | } |
---|
37 | |
---|
38 | //======================================================================================= |
---|
39 | // [ run_automative_basicmath ] |
---|
40 | //======================================================================================= |
---|
41 | void run_automative_basicmath (void) |
---|
42 | { |
---|
43 | printf("***** automative.basicmath - Begin *****\n"); |
---|
44 | |
---|
45 | #ifdef MiBench_small |
---|
46 | main_basicmath_small (); |
---|
47 | #endif |
---|
48 | #ifdef MiBench_large |
---|
49 | main_basicmath_large (); |
---|
50 | #endif |
---|
51 | |
---|
52 | printf("***** automative.basicmath - End *****\n"); |
---|
53 | } |
---|
54 | |
---|
55 | //======================================================================================= |
---|
56 | // [ run_automative_bitcount ] |
---|
57 | //======================================================================================= |
---|
58 | #ifdef MiBench_small |
---|
59 | void main_bitcount_small (void) |
---|
60 | { |
---|
61 | int argc = 2; |
---|
62 | char ** argv; |
---|
63 | |
---|
64 | char * execname = "./bitcount"; |
---|
65 | char * iteration = "75000"; |
---|
66 | |
---|
67 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
68 | |
---|
69 | argv[0] = (char *) malloc (strlen(execname )); |
---|
70 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
71 | |
---|
72 | argv[1] = (char *) malloc (strlen(iteration)); |
---|
73 | argv[1] = memcpy(argv[1],iteration,strlen(iteration)); |
---|
74 | |
---|
75 | main_bitcount(argc, argv); |
---|
76 | |
---|
77 | for (int i=0; i<argc; ++i) |
---|
78 | free(argv[i]); |
---|
79 | free(argv); |
---|
80 | } |
---|
81 | #endif |
---|
82 | |
---|
83 | #ifdef MiBench_large |
---|
84 | void main_bitcount_large (void) |
---|
85 | { |
---|
86 | int argc = 2; |
---|
87 | char ** argv; |
---|
88 | |
---|
89 | char * execname = "./bitcount"; |
---|
90 | char * iteration = "1125000"; |
---|
91 | |
---|
92 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
93 | |
---|
94 | argv[0] = (char *) malloc (strlen(execname )); |
---|
95 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
96 | |
---|
97 | argv[1] = (char *) malloc (strlen(iteration)); |
---|
98 | argv[1] = memcpy(argv[1],iteration,strlen(iteration)); |
---|
99 | |
---|
100 | main_bitcount(argc, argv); |
---|
101 | |
---|
102 | for (int i=0; i<argc; ++i) |
---|
103 | free(argv[i]); |
---|
104 | free(argv); |
---|
105 | } |
---|
106 | #endif |
---|
107 | |
---|
108 | void run_automative_bitcount (void) |
---|
109 | { |
---|
110 | printf("***** automative.bitcount - Begin *****\n"); |
---|
111 | |
---|
112 | #ifdef MiBench_small |
---|
113 | main_bitcount_small (); |
---|
114 | #endif |
---|
115 | #ifdef MiBench_large |
---|
116 | main_bitcount_large (); |
---|
117 | #endif |
---|
118 | |
---|
119 | printf("***** automative.bitcount - End *****\n"); |
---|
120 | } |
---|
121 | |
---|
122 | //======================================================================================= |
---|
123 | // [ run_automative_qsort ] |
---|
124 | //======================================================================================= |
---|
125 | #ifdef MiBench_small |
---|
126 | void _main_qsort_small (void) |
---|
127 | { |
---|
128 | int argc = 2; |
---|
129 | char ** argv; |
---|
130 | |
---|
131 | char * execname = "./qsort"; |
---|
132 | char *_filename = "/qsort-input_small.dat"; |
---|
133 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
134 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
135 | |
---|
136 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
137 | |
---|
138 | argv[0] = (char *) malloc (strlen(execname )); |
---|
139 | argv[0] = memcpy(argv[0],execname ,strlen(execname)); |
---|
140 | |
---|
141 | argv[1] = (char *) malloc (strlen(filename )); |
---|
142 | argv[1] = memcpy(argv[1],filename ,strlen(filename)); |
---|
143 | |
---|
144 | main_qsort_small(argc, argv); |
---|
145 | |
---|
146 | for (int i=0; i<argc; ++i) |
---|
147 | free(argv[i]); |
---|
148 | free(argv); |
---|
149 | } |
---|
150 | #endif |
---|
151 | |
---|
152 | #ifdef MiBench_large |
---|
153 | void _main_qsort_large (void) |
---|
154 | { |
---|
155 | int argc = 2; |
---|
156 | char ** argv; |
---|
157 | |
---|
158 | char * execname = "./qsort"; |
---|
159 | char *_filename = "/qsort-input_large.dat"; |
---|
160 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
161 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
162 | |
---|
163 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
164 | |
---|
165 | argv[0] = (char *) malloc (strlen(execname )); |
---|
166 | argv[0] = memcpy(argv[0],execname ,strlen(execname)); |
---|
167 | |
---|
168 | argv[1] = (char *) malloc (strlen(filename )); |
---|
169 | argv[1] = memcpy(argv[1],filename ,strlen(filename)); |
---|
170 | |
---|
171 | main_qsort_large(argc, argv); |
---|
172 | |
---|
173 | for (int i=0; i<argc; ++i) |
---|
174 | free(argv[i]); |
---|
175 | free(argv); |
---|
176 | } |
---|
177 | #endif |
---|
178 | |
---|
179 | void run_automative_qsort (void) |
---|
180 | { |
---|
181 | printf("***** automative.qsort - Begin *****\n"); |
---|
182 | |
---|
183 | #ifdef MiBench_small |
---|
184 | _main_qsort_small (); |
---|
185 | #endif |
---|
186 | #ifdef MiBench_large |
---|
187 | _main_qsort_large (); |
---|
188 | #endif |
---|
189 | |
---|
190 | printf("***** automative.qsort - End *****\n"); |
---|
191 | } |
---|
192 | |
---|
193 | //======================================================================================= |
---|
194 | // [ run_automative_susan ] |
---|
195 | //======================================================================================= |
---|
196 | #ifdef MiBench_small |
---|
197 | void main_susan_small (void) |
---|
198 | { |
---|
199 | int argc = 4; |
---|
200 | char ** argv; |
---|
201 | |
---|
202 | char * execname = "./susan"; |
---|
203 | char *_filename_input = "/susan-input_small.pgm"; |
---|
204 | char * filename_input = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename_input)); |
---|
205 | strcpy(filename_input,MIBENCH_DATA_PATH); strcat(filename_input,_filename_input); |
---|
206 | |
---|
207 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
208 | |
---|
209 | argv[0] = (char *) malloc (strlen(execname )); |
---|
210 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
211 | |
---|
212 | argv[1] = (char *) malloc (strlen(filename_input )); |
---|
213 | argv[1] = memcpy(argv[1],filename_input ,strlen(filename_input )); |
---|
214 | |
---|
215 | char * filename_output = "output_small.smoothing.pgm"; |
---|
216 | char * option = "-s"; |
---|
217 | |
---|
218 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
219 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
220 | |
---|
221 | argv[3] = (char *) malloc (strlen(option )); |
---|
222 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
223 | |
---|
224 | main_susan(argc, argv); |
---|
225 | |
---|
226 | for (int i=2; i<argc; ++i) |
---|
227 | free(argv[i]); |
---|
228 | |
---|
229 | filename_output = "output_small.edges.pgm"; |
---|
230 | option = "-e"; |
---|
231 | |
---|
232 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
233 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
234 | |
---|
235 | argv[3] = (char *) malloc (strlen(option )); |
---|
236 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
237 | |
---|
238 | main_susan(argc, argv); |
---|
239 | |
---|
240 | for (int i=2; i<argc; ++i) |
---|
241 | free(argv[i]); |
---|
242 | |
---|
243 | for (int i=2; i<argc; ++i) |
---|
244 | free(argv[i]); |
---|
245 | |
---|
246 | filename_output = "output_small.cornes.pgm"; |
---|
247 | option = "-c"; |
---|
248 | |
---|
249 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
250 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
251 | |
---|
252 | argv[3] = (char *) malloc (strlen(option )); |
---|
253 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
254 | |
---|
255 | main_susan(argc, argv); |
---|
256 | |
---|
257 | for (int i=0; i<argc; ++i) |
---|
258 | free(argv[i]); |
---|
259 | free(argv); |
---|
260 | } |
---|
261 | #endif |
---|
262 | |
---|
263 | #ifdef MiBench_large |
---|
264 | void main_susan_large (void) |
---|
265 | { |
---|
266 | int argc = 4; |
---|
267 | char ** argv; |
---|
268 | |
---|
269 | char * execname = "./susan"; |
---|
270 | char *_filename_input = "/susan-input_large.pgm"; |
---|
271 | char * filename_input = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename_input)); |
---|
272 | strcpy(filename_input,MIBENCH_DATA_PATH); strcat(filename_input,_filename_input); |
---|
273 | |
---|
274 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
275 | |
---|
276 | argv[0] = (char *) malloc (strlen(execname )); |
---|
277 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
278 | |
---|
279 | argv[1] = (char *) malloc (strlen(filename_input )); |
---|
280 | argv[1] = memcpy(argv[1],filename_input ,strlen(filename_input )); |
---|
281 | |
---|
282 | char * filename_output = "output_large.smoothing.pgm"; |
---|
283 | char * option = "-s"; |
---|
284 | |
---|
285 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
286 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
287 | |
---|
288 | argv[3] = (char *) malloc (strlen(option )); |
---|
289 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
290 | |
---|
291 | main_susan(argc, argv); |
---|
292 | |
---|
293 | for (int i=2; i<argc; ++i) |
---|
294 | free(argv[i]); |
---|
295 | |
---|
296 | filename_output = "output_large.edges.pgm"; |
---|
297 | option = "-e"; |
---|
298 | |
---|
299 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
300 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
301 | |
---|
302 | argv[3] = (char *) malloc (strlen(option )); |
---|
303 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
304 | |
---|
305 | main_susan(argc, argv); |
---|
306 | |
---|
307 | for (int i=2; i<argc; ++i) |
---|
308 | free(argv[i]); |
---|
309 | |
---|
310 | for (int i=2; i<argc; ++i) |
---|
311 | free(argv[i]); |
---|
312 | |
---|
313 | filename_output = "output_large.cornes.pgm"; |
---|
314 | option = "-c"; |
---|
315 | |
---|
316 | argv[2] = (char *) malloc (strlen(filename_output)); |
---|
317 | argv[2] = memcpy(argv[2],filename_output,strlen(filename_output)); |
---|
318 | |
---|
319 | argv[3] = (char *) malloc (strlen(option )); |
---|
320 | argv[3] = memcpy(argv[3],option ,strlen(option )); |
---|
321 | |
---|
322 | main_susan(argc, argv); |
---|
323 | |
---|
324 | for (int i=0; i<argc; ++i) |
---|
325 | free(argv[i]); |
---|
326 | free(argv); |
---|
327 | } |
---|
328 | #endif |
---|
329 | |
---|
330 | void run_automative_susan (void) |
---|
331 | { |
---|
332 | printf("***** automative.susan - Begin *****\n"); |
---|
333 | |
---|
334 | #ifdef MiBench_small |
---|
335 | main_susan_small (); |
---|
336 | #endif |
---|
337 | #ifdef MiBench_large |
---|
338 | main_susan_large (); |
---|
339 | #endif |
---|
340 | |
---|
341 | printf("***** automative.susan - End *****\n"); |
---|
342 | } |
---|
343 | |
---|
344 | //======================================================================================= |
---|
345 | // [ run_network_dijkstra ] |
---|
346 | //======================================================================================= |
---|
347 | |
---|
348 | #ifdef MiBench_small |
---|
349 | void main_dijkstra_small (void) |
---|
350 | { |
---|
351 | int argc = 3; |
---|
352 | |
---|
353 | char ** argv; |
---|
354 | |
---|
355 | char * execname = "./dijkstra"; |
---|
356 | char *_filename = "/dijkstra-input.dat"; |
---|
357 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
358 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
359 | char * nb_path = "20"; |
---|
360 | |
---|
361 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
362 | |
---|
363 | argv[0] = (char *) malloc (strlen(execname )); |
---|
364 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
365 | |
---|
366 | argv[1] = (char *) malloc (strlen(filename )); |
---|
367 | argv[1] = memcpy(argv[1],filename ,strlen(filename )); |
---|
368 | |
---|
369 | argv[2] = (char *) malloc (strlen(nb_path )); |
---|
370 | argv[2] = memcpy(argv[2],nb_path ,strlen(nb_path )); |
---|
371 | |
---|
372 | main_dijkstra(argc, argv); |
---|
373 | |
---|
374 | for (int i=0; i<argc; ++i) |
---|
375 | free(argv[i]); |
---|
376 | free(argv); |
---|
377 | } |
---|
378 | #endif |
---|
379 | |
---|
380 | |
---|
381 | #ifdef MiBench_large |
---|
382 | void main_dijkstra_large (void) |
---|
383 | { |
---|
384 | int argc = 3; |
---|
385 | |
---|
386 | char ** argv; |
---|
387 | |
---|
388 | char * execname = "./dijkstra"; |
---|
389 | char *_filename = "/dijkstra-input.dat"; |
---|
390 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
391 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
392 | char * nb_path = "100"; |
---|
393 | |
---|
394 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
395 | |
---|
396 | argv[0] = (char *) malloc (strlen(execname )); |
---|
397 | argv[0] = memcpy(argv[0],execname ,strlen(execname )); |
---|
398 | |
---|
399 | argv[1] = (char *) malloc (strlen(filename )); |
---|
400 | argv[1] = memcpy(argv[1],filename ,strlen(filename )); |
---|
401 | |
---|
402 | argv[2] = (char *) malloc (strlen(nb_path )); |
---|
403 | argv[2] = memcpy(argv[2],nb_path ,strlen(nb_path )); |
---|
404 | |
---|
405 | main_dijkstra(argc, argv); |
---|
406 | |
---|
407 | for (int i=0; i<argc; ++i) |
---|
408 | free(argv[i]); |
---|
409 | free(argv); |
---|
410 | } |
---|
411 | #endif |
---|
412 | |
---|
413 | void run_network_dijkstra (void) |
---|
414 | { |
---|
415 | printf("***** network.dijkstra - Begin *****\n"); |
---|
416 | |
---|
417 | #ifdef MiBench_small |
---|
418 | main_dijkstra_small (); |
---|
419 | #endif |
---|
420 | #ifdef MiBench_large |
---|
421 | main_dijkstra_large (); |
---|
422 | #endif |
---|
423 | |
---|
424 | printf("***** network.dijkstra - End *****\n"); |
---|
425 | } |
---|
426 | |
---|
427 | //======================================================================================= |
---|
428 | // [ run_office_stringsearch ] |
---|
429 | //======================================================================================= |
---|
430 | void run_office_stringsearch (void) |
---|
431 | { |
---|
432 | printf("***** office.stringsearch - Begin *****\n"); |
---|
433 | |
---|
434 | #ifdef MiBench_small |
---|
435 | main_stringsearch_small (); |
---|
436 | #endif |
---|
437 | #ifdef MiBench_large |
---|
438 | main_stringsearch_large (); |
---|
439 | #endif |
---|
440 | |
---|
441 | printf("***** office.stringsearch - End *****\n"); |
---|
442 | } |
---|
443 | |
---|
444 | //======================================================================================= |
---|
445 | // [ run_security_sha ] |
---|
446 | //======================================================================================= |
---|
447 | #ifdef MiBench_small |
---|
448 | void main_sha_small (void) |
---|
449 | { |
---|
450 | int argc = 2; |
---|
451 | char ** argv; |
---|
452 | |
---|
453 | char * execname = "./sha"; |
---|
454 | char *_filename = "/sha-input_small.asc"; |
---|
455 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
456 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
457 | |
---|
458 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
459 | |
---|
460 | argv[0] = (char *) malloc (strlen(execname )); |
---|
461 | argv[0] = memcpy(argv[0],execname ,strlen(execname)); |
---|
462 | |
---|
463 | argv[1] = (char *) malloc (strlen(filename )); |
---|
464 | argv[1] = memcpy(argv[1],filename ,strlen(filename)); |
---|
465 | |
---|
466 | main_sha(argc, argv); |
---|
467 | |
---|
468 | for (int i=0; i<argc; ++i) |
---|
469 | free(argv[i]); |
---|
470 | free(argv); |
---|
471 | } |
---|
472 | #endif |
---|
473 | |
---|
474 | #ifdef MiBench_large |
---|
475 | void main_sha_large (void) |
---|
476 | { |
---|
477 | int argc = 2; |
---|
478 | char ** argv; |
---|
479 | |
---|
480 | char * execname = "./sha"; |
---|
481 | char *_filename = "/sha-input_large.asc"; |
---|
482 | char * filename = (char *) malloc(strlen(MIBENCH_DATA_PATH)+strlen(_filename)); |
---|
483 | strcpy(filename,MIBENCH_DATA_PATH); strcat(filename,_filename); |
---|
484 | |
---|
485 | argv = (char **)malloc ((argc) * sizeof(char *)); |
---|
486 | |
---|
487 | argv[0] = (char *) malloc (strlen(execname )); |
---|
488 | argv[0] = memcpy(argv[0],execname ,strlen(execname)); |
---|
489 | |
---|
490 | argv[1] = (char *) malloc (strlen(filename )); |
---|
491 | argv[1] = memcpy(argv[1],filename ,strlen(filename)); |
---|
492 | |
---|
493 | main_sha(argc, argv); |
---|
494 | |
---|
495 | for (int i=0; i<argc; ++i) |
---|
496 | free(argv[i]); |
---|
497 | free(argv); |
---|
498 | } |
---|
499 | #endif |
---|
500 | |
---|
501 | void run_security_sha (void) |
---|
502 | { |
---|
503 | printf("***** security.sha - Begin *****\n"); |
---|
504 | |
---|
505 | #ifdef MiBench_small |
---|
506 | main_sha_small (); |
---|
507 | #endif |
---|
508 | #ifdef MiBench_large |
---|
509 | main_sha_large (); |
---|
510 | #endif |
---|
511 | |
---|
512 | printf("***** security.sha - End *****\n"); |
---|
513 | } |
---|