Log In | Get Help   
Home My Page Projects Code Snippets Project Openings UPC Operations Microbenchmarking Suite
Summary Activity Tracker Lists Docs News SCM Files
[uoms] Annotation of /trunk/uoms/src/init.upc
[uoms] / trunk / uoms / src / init.upc Repository:
ViewVC logotype

Annotation of /trunk/uoms/src/init.upc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (view) (download)

1 : dalvarez 14 /******************************************************************************/
2 :     /* */
3 :     /* Copyright (c) 2008, 2009, 2010 */
4 :     /* Computer Architecture Group (CAG) */
5 :     /* University of A Coruña, Spain */
6 :     /* (http://gac.des.udc.es) */
7 :     /* Galicia Supercomputing Center (CESGA) */
8 :     /* (http://www.cesga.es) */
9 :     /* Hewlett-Packard Spain (HP) */
10 :     /* (http://www.hp.es) */
11 :     /* */
12 :     /* This file is part of UPC Operations Microbenchmarking Suite (UOMS). */
13 :     /* */
14 :     /* UOMS is free software: you can redistribute it and/or modify */
15 :     /* it under the terms of the GNU Lesser General Public License as published */
16 :     /* by the Free Software Foundation, either version 3 of the License, or */
17 :     /* (at your option) any later version. */
18 :     /* */
19 :     /* UOMS is distributed in the hope that it will be useful, */
20 :     /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
21 :     /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
22 :     /* GNU Lesser General Public License for more details. */
23 :     /* */
24 :     /* You should have received a copy of the GNU Lesser General Public License */
25 :     /* along with UOMS. If not, see <http://www.gnu.org/licenses/>. */
26 :     /* */
27 :     /******************************************************************************/
28 : dalvarez 1
29 : dalvarez 14 /******************************************************************************/
30 :     /* */
31 :     /* FUNDING: This development has been funded by Hewlett-Packard Spain */
32 :     /* */
33 :     /* Project Name: */
34 :     /* UPCHACO (2008-2011) */
35 :     /* Subproject: */
36 :     /* Improving UPC Usability and Performance in Constellation Systems: */
37 :     /* Implementation/Extensions of UPC Libraries. */
38 :     /* (UPCPUProject -> UPC Performance and Usability Project) */
39 :     /* */
40 :     /******************************************************************************/
41 : dalvarez 1
42 : dalvarez 14 /******************************************************************************
43 : dalvarez 1
44 :     For further documentation, see
45 :    
46 :     [1] Files under doc/
47 :    
48 : dalvarez 14 *******************************************************************************/
49 : dalvarez 1
50 :     #include <stdio.h>
51 :     #include <stdlib.h>
52 :     #include <math.h>
53 :     #include <errno.h>
54 :     #include <string.h>
55 :     #include <upc_collective.h>
56 :     #include "defines.h"
57 :     #include "headers.h"
58 :    
59 :     #define roundtoint(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
60 :    
61 :     extern char * valid_bms[NUM_BMS];
62 :     extern upc_op_t reduce_op;
63 :    
64 :     long maxsize, minsize;
65 :    
66 :     /*
67 :     Set benchmarks names
68 :     */
69 :     void set_bms_names(){
70 : dalvarez 14 valid_bms[FORALL_R] = "upc_forall read";
71 :     valid_bms[FORALL_W] = "upc_forall write";
72 :     valid_bms[FORALL_RW] = "upc_forall read+write";
73 :     valid_bms[FOR_R] = "for read";
74 :     valid_bms[FOR_W] = "for write";
75 :     valid_bms[FOR_RW] = "for read+write";
76 : dalvarez 1 valid_bms[BARRIER] = "upc_barrier";
77 :     valid_bms[BROADCAST] = "upc_all_broadcast";
78 :     valid_bms[SCATTER] = "upc_all_scatter";
79 :     valid_bms[GATHER] = "upc_all_gather";
80 :     valid_bms[GATHERALL] = "upc_all_gather_all";
81 :     valid_bms[EXCHANGE] = "upc_all_exchange";
82 :     valid_bms[PERMUTE] = "upc_all_permute";
83 :     valid_bms[MEMGET] = "upc_memget";
84 :     valid_bms[MEMPUT] = "upc_memput";
85 :     valid_bms[MEMCPY] = "upc_memcpy";
86 :     valid_bms[LMEMGET] = "local_upc_memget";
87 :     valid_bms[LMEMPUT] = "local_upc_memput";
88 :     valid_bms[LMEMCPY] = "local_upc_memcpy";
89 :     valid_bms[SMEMCPY] = "memcpy";
90 :     valid_bms[MEMMOVE] = "memmove";
91 :     valid_bms[ALLALLOC] = "upc_all_alloc";
92 :     valid_bms[FREE] = "upc_free";
93 :     valid_bms[REDUCE_C] = "upc_all_reduceC";
94 :     valid_bms[PREFIX_REDUCE_C] = "upc_all_prefix_reduceC";
95 :     valid_bms[REDUCE_UC] = "upc_all_reduceUC";
96 :     valid_bms[PREFIX_REDUCE_UC] = "upc_all_prefix_reduceUC";
97 :     valid_bms[REDUCE_S] = "upc_all_reduceS";
98 :     valid_bms[PREFIX_REDUCE_S] = "upc_all_prefix_reduceS";
99 :     valid_bms[REDUCE_US] = "upc_all_reduceUS";
100 :     valid_bms[PREFIX_REDUCE_US] = "upc_all_prefix_reduceUS";
101 :     valid_bms[REDUCE_I] = "upc_all_reduceI";
102 :     valid_bms[PREFIX_REDUCE_I] = "upc_all_prefix_reduceI";
103 :     valid_bms[REDUCE_UI] = "upc_all_reduceUI";
104 :     valid_bms[PREFIX_REDUCE_UI] = "upc_all_prefix_reduceUI";
105 :     valid_bms[REDUCE_L] = "upc_all_reduceL";
106 :     valid_bms[PREFIX_REDUCE_L] = "upc_all_prefix_reduceL";
107 :     valid_bms[REDUCE_UL] = "upc_all_reduceUL";
108 :     valid_bms[PREFIX_REDUCE_UL] = "upc_all_prefix_reduceUL";
109 :     valid_bms[REDUCE_F] = "upc_all_reduceF";
110 :     valid_bms[PREFIX_REDUCE_F] = "upc_all_prefix_reduceF";
111 :     valid_bms[REDUCE_D] = "upc_all_reduceD";
112 :     valid_bms[PREFIX_REDUCE_D] = "upc_all_prefix_reduceD";
113 :     valid_bms[REDUCE_LD] = "upc_all_reduceLD";
114 :     valid_bms[PREFIX_REDUCE_LD] = "upc_all_prefix_reduceLD";
115 :     #ifdef ASYNC_MEM_TEST
116 : dalvarez 7 valid_bms[AMEMGET] = "upc_memget_async";
117 :     valid_bms[AMEMPUT] = "upc_memput_async";
118 :     valid_bms[AMEMCPY] = "upc_memcpy_async";
119 :     valid_bms[ALMEMGET] = "local_upc_memget_async";
120 :     valid_bms[ALMEMPUT] = "local_upc_memput_async";
121 :     valid_bms[ALMEMCPY] = "local_upc_memcpy_async";
122 : dalvarez 1 #endif
123 : dalvarez 7 #ifdef ASYNCI_MEM_TEST
124 :     valid_bms[AIMEMGET] = "upc_memget_asynci";
125 :     valid_bms[AIMEMPUT] = "upc_memput_asynci";
126 :     valid_bms[AIMEMCPY] = "upc_memcpy_asynci";
127 :     valid_bms[AILMEMGET] = "local_upc_memget_asynci";
128 :     valid_bms[AILMEMPUT] = "local_upc_memput_asynci";
129 :     valid_bms[AILMEMCPY] = "local_upc_memcpy_asynci";
130 :     #endif
131 : dalvarez 1 }
132 :    
133 :     /*
134 :     Set min size
135 :     */
136 :     int set_min_size(char *size){
137 :     if(size[0] >= '0' && size[0] <= '9'){
138 :     errno = 0;
139 :     minsize = strtol(size,NULL,10);
140 :     if(errno != 0){
141 :     if(MYTHREAD == 0){
142 :     fprintf(stderr,"*** minsize (%s) not valid: ",size);
143 :     perror(NULL);
144 :     }
145 :     return -1;
146 :     }
147 :     }
148 :     else{
149 :     if(MYTHREAD == 0){
150 :     fprintf(stderr,"*** minsize (%s) not valid",size);
151 :     }
152 :     return -1;
153 :     }
154 :     return 0;
155 :     }
156 :    
157 :     /*
158 :     Set max size
159 :     */
160 :     int set_max_size(char *size){
161 :     if(size[0] >= '0' && size[0] <= '9'){
162 :     errno = 0;
163 :     maxsize = strtol(size,NULL,10);
164 :     if(errno != 0){
165 :     if(MYTHREAD == 0){
166 :     fprintf(stderr,"*** maxsize (%s) not valid: ",size);
167 :     perror(NULL);
168 :     }
169 :     return -1;
170 :     }
171 :     }
172 :     else{
173 :     if(MYTHREAD == 0){
174 :     fprintf(stderr,"*** maxsize (%s) not valid",size);
175 :     }
176 :     return -1;
177 :     }
178 :     return 0;
179 :     }
180 :    
181 :     /*
182 :     Set reduce operation
183 :     */
184 :     int set_reduce_op(char *operation){
185 :     extern char *char_reduce_op;
186 :    
187 :     if(strcmp(operation,"UPC_ADD") == 0){
188 :     reduce_op = UPC_ADD;
189 :     char_reduce_op = operation;
190 :     }
191 :     else if(strcmp(operation,"UPC_MULT") == 0){
192 :     reduce_op = UPC_MULT;
193 :     char_reduce_op = operation;
194 :     }
195 :     else if(strcmp(operation,"UPC_AND") == 0){
196 :     reduce_op = UPC_AND;
197 :     char_reduce_op = operation;
198 :     }
199 :     else if(strcmp(operation,"UPC_OR") == 0){
200 :     reduce_op = UPC_OR;
201 :     char_reduce_op = operation;
202 :     }
203 :     else if(strcmp(operation,"UPC_XOR") == 0){
204 :     reduce_op = UPC_XOR;
205 :     char_reduce_op = operation;
206 :     }
207 :     else if(strcmp(operation,"UPC_LOGAND") == 0){
208 :     reduce_op = UPC_LOGAND;
209 :     char_reduce_op = operation;
210 :     }
211 :     else if(strcmp(operation,"UPC_LOGOR") == 0){
212 :     reduce_op = UPC_LOGOR;
213 :     char_reduce_op = operation;
214 :     }
215 :     else if(strcmp(operation,"UPC_MIN") == 0){
216 :     reduce_op = UPC_MIN;
217 :     char_reduce_op = operation;
218 :     }
219 :     else if(strcmp(operation,"UPC_MAX") == 0){
220 :     reduce_op = UPC_MAX;
221 :     char_reduce_op = operation;
222 :     }
223 :     else{
224 :     return -1;
225 :     }
226 :     return 0;
227 :     }
228 :    
229 :     /*
230 :     Set synchronization mode
231 :     */
232 :     int set_sync_mode(char *mode){
233 :     extern upc_flag_t sync_mode;
234 :     extern char * char_sync_mode;
235 :    
236 :     if(strcmp(mode,"UPC_IN_ALLSYNC|UPC_OUT_ALLSYNC") == 0){
237 :     sync_mode = UPC_IN_ALLSYNC|UPC_OUT_ALLSYNC;
238 :     char_sync_mode = mode;
239 :     }
240 :     else if(strcmp(mode,"UPC_IN_ALLSYNC|UPC_OUT_MYSYNC") == 0){
241 :     sync_mode = UPC_IN_ALLSYNC|UPC_OUT_MYSYNC;
242 :     char_sync_mode = mode;
243 :     }
244 :     else if(strcmp(mode,"UPC_IN_ALLSYNC|UPC_OUT_NOSYNC") == 0){
245 :     sync_mode = UPC_IN_ALLSYNC|UPC_OUT_NOSYNC;
246 :     char_sync_mode = mode;
247 :     }
248 :     else if(strcmp(mode,"UPC_IN_MYSYNC|UPC_OUT_ALLSYNC") == 0){
249 :     sync_mode = UPC_IN_MYSYNC|UPC_OUT_ALLSYNC;
250 :     char_sync_mode = mode;
251 :     }
252 :     else if(strcmp(mode,"UPC_IN_MYSYNC|UPC_OUT_MYSYNC") == 0){
253 :     sync_mode = UPC_IN_MYSYNC|UPC_OUT_MYSYNC;
254 :     char_sync_mode = mode;
255 :     }
256 :     else if(strcmp(mode,"UPC_IN_MYSYNC|UPC_OUT_NOSYNC") == 0){
257 :     sync_mode = UPC_IN_MYSYNC|UPC_OUT_NOSYNC;
258 :     char_sync_mode = mode;
259 :     }
260 :     else if(strcmp(mode,"UPC_IN_NOSYNC|UPC_OUT_ALLSYNC") == 0){
261 :     sync_mode = UPC_IN_NOSYNC|UPC_OUT_ALLSYNC;
262 :     char_sync_mode = mode;
263 :     }
264 :     else if(strcmp(mode,"UPC_IN_NOSYNC|UPC_OUT_MYSYNC") == 0){
265 :     sync_mode = UPC_IN_NOSYNC|UPC_OUT_MYSYNC;
266 :     char_sync_mode = mode;
267 :     }
268 :     else if(strcmp(mode,"UPC_IN_NOSYNC|UPC_OUT_NOSYNC") == 0){
269 :     sync_mode = UPC_IN_NOSYNC|UPC_OUT_NOSYNC;
270 :     char_sync_mode = mode;
271 :     }
272 :     else{
273 :     return -1;
274 :     }
275 :     return 0;
276 :     }
277 :    
278 :     /*
279 :     Set benchmark list
280 :     */
281 :     void set_bms(int alternative_bm_list, char *bm_file){
282 :     extern int *bm_list;
283 :     extern int num_bms;
284 :     FILE *fd;
285 :    
286 :     /*
287 :     Default procedure
288 :     */
289 :     if(alternative_bm_list == 0){
290 :     num_bms = NUM_BMS;
291 :     errno = 0;
292 :     bm_list = malloc(num_bms*sizeof(int));
293 :     if(errno != 0){
294 :     if(MYTHREAD == 0){
295 : dalvarez 14 /*
296 :     Just in case you want to run the benchmark in a toaster or someone/something steal all your memory ;-)
297 :     */
298 : dalvarez 1 fprintf(stderr,"*** Unable to allocate %ld bytes for benchmark list storing: ",num_bms*sizeof(int));
299 :     perror(NULL);
300 :     }
301 :     upc_barrier;
302 :     exit(-1);
303 :     }
304 :    
305 :     int j = 0;
306 :     for(int i = 0; i < num_bms; i++){
307 :     if(reduce_op == UPC_AND || reduce_op == UPC_OR || reduce_op == UPC_XOR){
308 :     if(i == REDUCE_F || i == PREFIX_REDUCE_F || i == REDUCE_D || i == PREFIX_REDUCE_D || i == REDUCE_LD || i == PREFIX_REDUCE_LD){
309 :     continue;
310 :     }
311 :     }
312 :     bm_list[j] = i;
313 :     j++;
314 :     }
315 :    
316 :     }
317 :    
318 :     /*
319 :     User defined
320 :     */
321 :     else{
322 :     if(bm_file == NULL){
323 :     if(MYTHREAD == 0){
324 :     fprintf(stderr,"Unexpected error when parsing the benchmarks list file\n");
325 :     }
326 :     upc_barrier;
327 :     exit(-1);
328 :     }
329 :    
330 :     errno = 0;
331 :     fd = fopen(bm_file,"r");
332 :     if(errno != 0){
333 :     if(MYTHREAD == 0){
334 :     fprintf(stderr,"*** Error opening file %s: ",bm_file);
335 :     perror(NULL);
336 :     }
337 :     upc_barrier;
338 :     exit(-1);
339 :     }
340 :    
341 :     char curbm[30];
342 :    
343 :     /*
344 :     Two phases: one for get the number of benchmarks and the other to actually store them
345 :     */
346 :     while (!feof(fd) && fgets(curbm, 30, fd)) {
347 :     for(int i = 0; i < 30; i++){
348 :     if(curbm[i] == '\n' || curbm[i] == ' '){
349 :     curbm[i] = '\0';
350 :     }
351 :     }
352 :     for(int i = 0; i < NUM_BMS; i++){
353 :     if(strcmp(curbm,valid_bms[i]) == 0){
354 :     num_bms++;
355 :     }
356 :     }
357 :     }
358 :     errno = 0;
359 :     rewind(fd);
360 :     if(errno != 0){
361 :     if(MYTHREAD == 0){
362 :     fprintf(stderr,"*** Error reading file %s: ",bm_file);
363 :     perror(NULL);
364 :     }
365 :     upc_barrier;
366 :     exit(-1);
367 :     }
368 :     errno = 0;
369 :     bm_list = malloc(num_bms*sizeof(int));
370 :     if(errno != 0){
371 :     if(MYTHREAD == 0){
372 : dalvarez 14 /*
373 :     Just in case you want to run the benchmark in a toaster or someone/something steal all your memory ;-)
374 :     */
375 : dalvarez 1 fprintf(stderr,"*** Unable to allocate %ld bytes for benchmark list storing: ",num_bms*sizeof(int));
376 :     perror(NULL);
377 :     }
378 :     upc_barrier;
379 :     exit(-1);
380 :     }
381 :     int i = 0;
382 :     while (!feof(fd) && fgets(curbm, 30, fd)) {
383 : dalvarez 7 for(int j = 0; j < 30; j++){
384 :     if(curbm[j] == '\n' || curbm[j] == ' '){
385 :     curbm[j] = '\0';
386 : dalvarez 1 }
387 :     }
388 :     for(int j = 0; j < NUM_BMS; j++){
389 :     errno = 0;
390 :     if(strcmp(curbm,valid_bms[j]) == 0){
391 :     if(errno != 0){
392 :     if(MYTHREAD == 0){
393 :     fprintf(stderr,"*** Error parsing %s in file %s: ",curbm,bm_file);
394 :     perror(NULL);
395 :     }
396 :     upc_barrier;
397 :     exit(-1);
398 :     }
399 :     bm_list[i] = j;
400 :     i++;
401 :     }
402 :     }
403 :     }
404 :    
405 :     fclose(fd);
406 :    
407 :     }
408 :    
409 :     if(num_bms < 1){
410 :     if(MYTHREAD == 0)
411 :     fprintf(stderr,"*** No valid benchmarks specified\n");
412 :     exit(-1);
413 :     }
414 :    
415 :     }
416 :    
417 :     /*
418 :     Set problem sizes
419 :     */
420 :     void set_sizes(int alternative_sizes, char *sizes_file){
421 :     extern long *sizes;
422 :     extern int num_sizes;
423 :     FILE *fd;
424 :    
425 :     /*
426 :     Default procedure
427 :     */
428 :     if(alternative_sizes == 0){
429 :     num_sizes = roundtoint(log2((double)maxsize)) - roundtoint(log2((double)minsize)) + 1;
430 :     errno = 0;
431 :     sizes = malloc(num_sizes*sizeof(long));
432 :     if(errno != 0){
433 :     if(MYTHREAD == 0){
434 :     fprintf(stderr,"*** Unable to allocate %ld bytes for message sizes storing: ",num_sizes*sizeof(int));
435 :     perror(NULL);
436 :     }
437 :     upc_barrier;
438 :     exit(-1);
439 :     }
440 :    
441 :     sizes[0] = minsize;
442 :    
443 :     for(int i = 1; i < num_sizes; i++){
444 :     sizes[i] = sizes[i-1]*2;
445 :     }
446 :    
447 :     if(sizes[num_sizes-1] > maxsize){
448 : dalvarez 14 num_sizes--; // We waste sizeof(long) bytes, but probably we can afford it
449 : dalvarez 1 }
450 :    
451 :     }
452 :    
453 :     /*
454 :     User defined
455 :     */
456 :     else{
457 :     if(sizes_file == NULL){
458 :     if(MYTHREAD == 0){
459 :     fprintf(stderr,"Unexpected error when parsing the problem sizes file\n");
460 :     }
461 :     upc_barrier;
462 :     exit(-1);
463 :     }
464 :    
465 :     errno = 0;
466 :     fd = fopen(sizes_file,"r");
467 :     if(errno != 0){
468 :     if(MYTHREAD == 0){
469 :     fprintf(stderr,"*** Error opening file %s: ",sizes_file);
470 :     perror(NULL);
471 :     }
472 :     upc_barrier;
473 :     exit(-1);
474 :     }
475 :    
476 :     char cursize[20];
477 :    
478 :     /*
479 :     Two phases: one for get the number of sizes and the other to actually store them
480 :     */
481 :     while (!feof(fd) && fgets(cursize, 20, fd)) {
482 :     if(cursize[0] >= '0' && cursize[0] <= '9'){
483 :     errno = 0;
484 : dalvarez 7 strtol(cursize,NULL,10);
485 : dalvarez 1 if(errno != 0){
486 :     if(MYTHREAD == 0){
487 :     fprintf(stderr,"*** Error parsing %s in file %s: ",cursize,sizes_file);
488 :     perror(NULL);
489 :     }
490 :     upc_barrier;
491 :     exit(-1);
492 :     }
493 :     num_sizes++;
494 :     }
495 :     else{ /* Silently ignores other lines */
496 :     continue;
497 :     }
498 :     }
499 :     errno = 0;
500 :     rewind(fd);
501 :     if(errno != 0){
502 :     if(MYTHREAD == 0){
503 :     fprintf(stderr,"*** Error reading file %s: ",sizes_file);
504 :     perror(NULL);
505 :     }
506 :     upc_barrier;
507 :     exit(-1);
508 :     }
509 :     errno = 0;
510 :     sizes = malloc(num_sizes*sizeof(long));
511 :     if(errno != 0){
512 :     if(MYTHREAD == 0){
513 :     fprintf(stderr,"*** Unable to allocate %ld bytes for message sizes storing: ",num_sizes*sizeof(int));
514 :     perror(NULL);
515 :     }
516 :     upc_barrier;
517 :     exit(-1);
518 :     }
519 :     int i = 0;
520 :     while (!feof(fd) && fgets(cursize, 20, fd)) {
521 :     if(cursize[0] >= '0' && cursize[0] <= '9'){
522 :     errno = 0;
523 :     sizes[i] = strtol(cursize,NULL,10);
524 :     if(errno != 0){
525 :     if(MYTHREAD == 0){
526 :     fprintf(stderr,"*** Error parsing %s in file %s: ",cursize,sizes_file);
527 :     perror(NULL);
528 :     }
529 :     upc_barrier;
530 :     exit(-1);
531 :     }
532 :     i++;
533 :     }
534 :     else{ /* Silently ignores other lines */
535 :     continue;
536 :     }
537 :     }
538 :    
539 :     fclose(fd);
540 :    
541 :     }
542 :    
543 :     if(num_sizes < 1){
544 :     if(MYTHREAD == 0)
545 :     fprintf(stderr,"*** No block sizes specified\n");
546 :     exit(-1);
547 :     }
548 :    
549 :     }
550 :    
551 :     // Init functions. E.g., initialize permutation array
552 :     void UOMS_init(){
553 :    
554 :     int i;
555 :     extern shared int perm[THREADS]; //for permutation
556 :    
557 :     //set the permutation array
558 :     if ( MYTHREAD == 0 )
559 :     {
560 :     for (i=0; i<THREADS; ++i)
561 :     perm[i] = i;
562 :     for (i=THREADS-1; i>0; --i)
563 :     {
564 :     int j = ((int)rand() >> 3) % i;
565 :     int tmp = perm[i];
566 :     perm[i] = perm[j];
567 :     perm[j] = tmp;
568 :     }
569 :     }
570 :     }
571 :    
572 :     void init(int argc, char **argv){
573 :     extern FILE *unit;
574 :     extern int cache_invalidation;
575 :     extern int warmup;
576 :     char *sizes_file = NULL;
577 :     char *output_file = NULL;
578 :     char *bm_file = NULL;
579 :     int alternative_output_file = 0;
580 :     int alternative_sizes = 0;
581 :     int alternative_bm_list = 0;
582 :     minsize = MINSIZE;
583 :     maxsize = MAXSIZE;
584 :    
585 :     warmup = 0; // Defaults to off
586 :    
587 :     set_bms_names();
588 :    
589 :     /*
590 :     Command line arguments parsing
591 :     */
592 :     for(int i = 1; i < argc; i++){
593 :     if(strcmp(argv[i],"-off_cache") == 0){
594 :     cache_invalidation = 1;
595 :     }
596 :     else if(strcmp(argv[i],"-msglen") == 0){
597 :     i++;
598 :     if(i == argc){
599 :     if(MYTHREAD == 0)
600 :     print_usage(argv[0]);
601 :     exit(-1);
602 :     }
603 :     else{
604 :     alternative_sizes = 1;
605 :     sizes_file = argv[i];
606 :     }
607 :     }
608 :     else if(strcmp(argv[i],"-input") == 0){
609 :     i++;
610 :     if(i == argc){
611 :     if(MYTHREAD == 0)
612 :     print_usage(argv[0]);
613 :     upc_barrier;
614 :     exit(-1);
615 :     }
616 :     else{
617 :     alternative_bm_list = 1;
618 :     bm_file = argv[i];
619 :     }
620 :     }
621 :     else if(strcmp(argv[i],"-reduce_op") == 0){
622 :     i++;
623 :     if(i == argc){
624 :     if(MYTHREAD == 0)
625 :     print_usage(argv[0]);
626 :     exit(-1);
627 :     }
628 :     else{
629 :     if(set_reduce_op(argv[i]) != 0){
630 :     if(MYTHREAD == 0)
631 :     print_usage(argv[0]);
632 :     exit(-1);
633 :     }
634 :     }
635 :     }
636 :     else if(strcmp(argv[i],"-sync_mode") == 0){
637 :     i++;
638 :     if(i == argc){
639 :     if(MYTHREAD == 0)
640 :     print_usage(argv[0]);
641 :     exit(-1);
642 :     }
643 :     else{
644 :     if(set_sync_mode(argv[i]) != 0){
645 :     if(MYTHREAD == 0)
646 :     print_usage(argv[0]);
647 :     exit(-1);
648 :     }
649 :     }
650 :     }
651 :     else if(strcmp(argv[i],"-minsize") == 0){
652 :     i++;
653 :     if(i == argc){
654 :     if(MYTHREAD == 0)
655 :     print_usage(argv[0]);
656 :     exit(-1);
657 :     }
658 :     else{
659 :     if(set_min_size(argv[i]) != 0){
660 :     if(MYTHREAD == 0)
661 :     print_usage(argv[0]);
662 :     exit(-1);
663 :     }
664 :     }
665 :     }
666 :     else if(strcmp(argv[i],"-maxsize") == 0){
667 :     i++;
668 :     if(i == argc){
669 :     if(MYTHREAD == 0)
670 :     print_usage(argv[0]);
671 :     exit(-1);
672 :     }
673 :     else{
674 :     if(set_max_size(argv[i]) != 0){
675 :     if(MYTHREAD == 0)
676 :     print_usage(argv[0]);
677 :     exit(-1);
678 :     }
679 :     }
680 :     }
681 :     else if(strcmp(argv[i],"-warmup") == 0){
682 :     warmup = 1;
683 :     }
684 :     else if(strcmp(argv[i],"-help") == 0){
685 :     if(MYTHREAD == 0)
686 :     print_usage(argv[0]);
687 :     upc_barrier;
688 :     exit(-1);
689 :     }
690 :     else if(strcmp(argv[i],"-version") == 0){
691 :     if(MYTHREAD == 0)
692 :     print_version();
693 :     upc_barrier;
694 :     exit(-1);
695 :     }
696 :     else{
697 :     if(i == argc-1 && argv[i][0] != '-' ){
698 :     alternative_output_file = 1;
699 :     output_file = argv[i];
700 :     }
701 :     else{
702 :     if(MYTHREAD == 0){
703 :     printf("Unrecognized option ignored: %s\n",argv[i]);
704 :     }
705 :     }
706 :     }
707 :     }
708 :    
709 :     /*
710 :     Optional files checking and parsing
711 :     */
712 :     set_sizes(alternative_sizes,sizes_file);
713 :     set_bms(alternative_bm_list,bm_file);
714 :    
715 :     /*
716 :     Optional output file
717 :     */
718 :     if(alternative_output_file){
719 :     errno = 0;
720 :     unit = fopen(output_file,"w");
721 :     if(errno != 0){
722 :     if(MYTHREAD == 0){
723 :     fprintf(stderr,"*** Error creating or truncating file %s: ",output_file);
724 :     perror(NULL);
725 :     }
726 :     upc_barrier;
727 :     exit(-1);
728 :     }
729 :     }
730 :     else{
731 :     unit = stdout;
732 :     }
733 :     UOMS_init();
734 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge