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