SIONlib  1.7.5
Scalable I/O library for parallel access to task-local files
partest_opts.c
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
10 #define _XOPEN_SOURCE 700
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include <unistd.h>
17 #include <mpi.h>
18 #include <time.h>
19 #include <math.h>
20 #ifdef _SION_AIX
21 #include "getopt_long.h"
22 #else
23 #include <getopt.h>
24 #endif
25 #include "sion.h"
26 #include "partest_opts.h"
27 #include "partest.h"
28 
29 int init_options ( _test_options *options) {
30  int rc=0;
31 
32  options->type = 0;
33  options->bluegene = 0;
34  options->bluegene_np = 0;
35  options->bluegene_sort = 0;
36  options->bufsize = 10 MB;
37  options->totalsize = 20 MB;
38  options->chunksize = options->totalsize;
39  options->fsblksize = 2.0 MB;
40  options->verbose = 0;
41  options->debug = 0;
42  options->Debug = 0;
43  options->numfiles = 1;
44  options->startoffset = 0;
45  options->read_task_offset = 0;
46  options->collectiveopenforread = 1;
47  options->collectivewrite = 0;
48  options->collectiveread = 0;
49  options->collmsa = 0;
50  options->unlink_files = 0;
51  options->suppress_checksum = 0;
52  options->serialize_blocknum = -1;
53  options->mpiio_lb = -1;
54  options->mpiio_bs = -1;
55  options->mpiio_sa = -1;
56  options->factor = 0.0;
57 
58  options->do_write = 1;
59  options->do_read = 1;
60  options->use_posix = 0;
61 
62  options->globalsize = -1;
63 
64  strcpy(options->filename, "partest_parfile.sion");
65 
66  return(rc);
67 }
68 
69 int parse_options_std ( int argc, char **argv, _test_options *options) {
70  int rc=0;
71  int i;
72 
73  /* parse command line */
74  i = 1;
75  while (i < argc) {
76  if (argv[i][0] == '-') {
77  switch (argv[i][1]) {
78  case 'f':
79  strcpy(options->filename, argv[++i]);
80  break;
81  case 'F':
82  options->factor = atof(argv[++i]);
83  break;
84  case 'n':
85  options->numfiles = atoi(argv[++i]);
86  break;
87  case 'b':
88  options->bufsize = (sion_int64) atoi(argv[++i]);
89  break;
90  case 'B':
91  options->bufsize = (sion_int64) atoi(argv[++i]) MB;
92  break;
93  case 'g':
94  options->globalsize = (sion_int64) atoi(argv[++i]);
95  break;
96  case 'G':
97  options->globalsize = (sion_int64) atoi(argv[++i]) * 1024 MB;
98  break;
99  case 'I':
100  options->do_write = 0;
101  break;
102  case 'O':
103  options->do_read = 0;
104  break;
105  case 'L':
106  options->use_posix = 1;
107  break;
108  case 's':
109  options->totalsize = (sion_int64) atoi(argv[++i]);
110  break;
111  case 'S':
112  options->totalsize = (sion_int64) atoi(argv[++i]) MB;
113  break;
114  case 'r':
115  options->chunksize = (sion_int64) atoi(argv[++i]);
116  break;
117  case 'R':
118  options->chunksize = (sion_int64) atoi(argv[++i]) MB;
119  break;
120  case 'q':
121  options->fsblksize = atoi(argv[++i]);
122  break;
123  case 'Q':
124  options->fsblksize = atof(argv[++i]) MB;
125  break;
126  case 'o':
127  options->startoffset = (sion_int64) atoi(argv[++i]);
128  break;
129  case 'P':
130  options->bluegene = 1;
131  break;
132  case 'p':
133  options->bluegene_np = atoi(argv[++i]);
134  break;
135  case 'T':
136  options->type = atoi(argv[++i]);
137  break;
138  case 'w':
139  options->mpiio_lb = atoi(argv[++i]);
140  break;
141  case 'W':
142  options->mpiio_bs = atoi(argv[++i]);
143  break;
144  case 'x':
145  options->mpiio_sa = atoi(argv[++i]);
146  break;
147  case 'Z':
148  options->read_task_offset = atoi(argv[++i]);
149  break;
150  case 'X':
151  options->unlink_files = atoi(argv[++i]);
152  break;
153  case 'j':
154  options->serialize_blocknum = atoi(argv[++i]);
155  break;
156  case 'C':
157  options->suppress_checksum = 1;
158  break;
159  case 'M':
160  options->collectivewrite++;
161  break;
162  case 'm':
163  options->collectiveread++;
164  break;
165  case 'c':
166  options->collmsa = 1;
167  break;
168  case 'd':
169  options->debug++;
170  break;
171  case 'D':
172  options->Debug++;
173  break;
174  case 'v':
175  options->verbose++;
176  break;
177  default:
178  printf("Arg default: %s\n", argv[i]);
179  usage(argv[0]);
180  }
181  }
182  else {
183  printf("Arg error: %s\n", argv[i]);
184  usage(argv[0]);
185  }
186  i++;
187  }
188 
189  return(rc);
190 }
191 
192 
193 int parse_options_long ( int argc, char **argv, _test_options *options) {
194  int rc=1;
195  int c;
196  int option_index = 0;
197  static struct option long_options[] = {
198  {"filename", required_argument, 0, 'f'},
199  {"numfiles", required_argument, 0, 'n'},
200  {"chunksize", required_argument, 0, 'r'},
201  {"fsblksize", required_argument, 0, 'q'},
202  {"testtype", required_argument, 0, 'T'},
203  {"bufsize", required_argument, 0, 'b'},
204  {"totalsize", required_argument, 0, 'g'},
205  {"localsize", required_argument, 0, 's'},
206  {"factor", required_argument, 0, 'F'},
207  {"write", required_argument, 0, 'W'},
208  {"read", required_argument, 0, 'R'},
209 
210  {"verbose", required_argument, 0, 'v'},
211  {"nochecksum",required_argument, 0, 'C'},
212  {"debugtask", required_argument, 0, 'd'},
213  {"Debugtask", required_argument, 0, 'D'},
214 
215  {"posix", required_argument, 0, 'L'},
216  {"collwrite", required_argument, 0, 'M'},
217  {"collread", required_argument, 0, 'm'},
218  {"collmsa", required_argument, 0, 'c'},
219 
220  {"taskoffset",required_argument, 0, 'Z'},
221  {"byteoffset",required_argument, 0, 'O'},
222  {"serialized",required_argument, 0, 'j'},
223  {"unlinkfiles",required_argument, 0, 'X'},
224  {"bgionode", required_argument, 0, 'P'},
225  {"bgtaskperionode", required_argument, 0, 'p'},
226  {"bgtasksort", required_argument, 0, 'Y'},
227  {"hintlargeblock", required_argument, 0, 'w'},
228  {"hintiobufsize", required_argument, 0, 'Q'},
229  {"hintsparseacess", required_argument, 0, 'x'},
230 
231 
232  {0, 0, 0, 0}
233  };
234 
235  while(1) {
236  c = getopt_long(argc, argv, "f:n:r:q:T:b:g:s:F:W:R:vCdDLMmcZ:X:O:j:wQ:x",
237  long_options, &option_index);
238  if (c == -1)
239  break;
240 
241  switch (c) {
242  case 0:
243  printf("option %s", long_options[option_index].name);
244  if (optarg)
245  printf(" with arg %s", optarg);
246  printf("\n");
247  break;
248  case 'f':
249  strcpy(options->filename, optarg);
250  break;
251  case 'n':
252  options->numfiles = atoi(optarg);
253  break;
254  case 'r':
255  options->chunksize = to_bytes(optarg);
256  break;
257  case 'q':
258  options->fsblksize = to_bytes(optarg);
259  break;
260 
261  case 'T':
262  options->type = atoi(optarg);
263  break;
264  case 'b':
265  options->bufsize = to_bytes(optarg);
266  break;
267  case 'g':
268  options->globalsize = to_bytes(optarg);
269  break;
270  case 's':
271  options->totalsize = to_bytes(optarg);
272  break;
273  case 'F':
274  options->factor = atoi(optarg);
275  break;
276  case 'W':
277  options->do_write = atoi(optarg);
278  break;
279  case 'R':
280  options->do_read = atoi(optarg);
281  break;
282 
283  case 'v':
284  if(optarg) {
285  options->verbose = atoi(optarg);
286  } else options->verbose = 1;
287 
288  break;
289 
290  case 'C':
291  if(optarg) {
292  options->suppress_checksum = atoi(optarg);
293  } else options->suppress_checksum = 1;
294  break;
295 
296  case 'd':
297  if(optarg) {
298  options->debug = atoi(optarg);
299  } else options->debug = 1;
300  break;
301 
302  case 'D':
303  if(optarg) {
304  options->Debug = atoi(optarg);
305  } else options->Debug = 1;
306  break;
307 
308  case 'L':
309  if(optarg) {
310  options->use_posix = atoi(optarg);
311  } else options->use_posix = 1;
312  break;
313 
314  case 'M':
315  if(optarg) {
316  options->collectivewrite = atoi(optarg);
317  } else options->collectivewrite = 1;
318  break;
319 
320  case 'm':
321  if(optarg) {
322  options->collectiveread = atoi(optarg);
323  } else options->collectiveread = 1;
324  break;
325 
326  case 'c':
327  options->collmsa = 1;
328  break;
329 
330  case 'Z':
331  options->read_task_offset = atoi(optarg);
332  break;
333 
334  case 'O':
335  options->startoffset = atoi(optarg);
336  break;
337 
338  case 'j':
339  options->serialize_blocknum = atoi(optarg);
340  break;
341 
342  case 'X':
343  if(optarg) {
344  options->unlink_files = atoi(optarg);
345  } else options->unlink_files = 1;
346  break;
347 
348  case 'P':
349  if(optarg) {
350  options->bluegene = atoi(optarg);
351  } else options->bluegene = 1;
352  break;
353 
354  case 'p':
355  options->bluegene_np = atoi(optarg);
356  break;
357 
358  case 'Y':
359  options->bluegene_sort = atoi(optarg);
360  break;
361 
362  case 'w':
363  if(optarg) {
364  options->mpiio_lb = atoi(optarg);
365  } else options->mpiio_lb = 1;
366  break;
367 
368  case 'Q':
369  options->mpiio_bs = atoi(optarg);
370  break;
371 
372  case 'x':
373  if(optarg) {
374  options->mpiio_sa = atoi(optarg);
375  } else options->mpiio_sa = 1;
376  break;
377 
378  default:
379  printf("?? getopt_long returned character code 0%o ??\n", c);
380  rc=0;
381  return(rc);
382  }
383  }
384 
385  return(rc);
386 }
387 
388 int distribute_options_mpi ( _test_options *options) {
389  int rc=0;
390 
391  MPI_Bcast(options->filename, FNAMELEN, MPI_CHAR, 0, MPI_COMM_WORLD);
392  MPI_Bcast(&options->factor, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
393 
394  MPI_Bcast(&options->bufsize, 1, SION_MPI_INT64, 0, MPI_COMM_WORLD);
395  MPI_Bcast(&options->totalsize, 1, SION_MPI_INT64, 0, MPI_COMM_WORLD);
396  MPI_Bcast(&options->globalsize, 1, SION_MPI_INT64, 0, MPI_COMM_WORLD);
397  MPI_Bcast(&options->chunksize, 1, SION_MPI_INT64, 0, MPI_COMM_WORLD);
398  MPI_Bcast(&options->fsblksize, 1, SION_MPI_INT32, 0, MPI_COMM_WORLD);
399 
400  MPI_Bcast(&options->type, 1, MPI_INT, 0, MPI_COMM_WORLD);
401  MPI_Bcast(&options->verbose, 1, MPI_INT, 0, MPI_COMM_WORLD);
402  MPI_Bcast(&options->bluegene, 1, MPI_INT, 0, MPI_COMM_WORLD);
403  MPI_Bcast(&options->bluegene_np, 1, MPI_INT, 0, MPI_COMM_WORLD);
404  MPI_Bcast(&options->unlink_files, 1, MPI_INT, 0, MPI_COMM_WORLD);
405  MPI_Bcast(&options->serialize_blocknum, 1, MPI_INT, 0, MPI_COMM_WORLD);
406 
407  MPI_Bcast(&options->collectivewrite, 1, MPI_INT, 0, MPI_COMM_WORLD);
408  MPI_Bcast(&options->collectiveread, 1, MPI_INT, 0, MPI_COMM_WORLD);
409  MPI_Bcast(&options->collmsa, 1, MPI_INT, 0, MPI_COMM_WORLD);
410 
411  MPI_Bcast(&options->numfiles, 1, MPI_INT, 0, MPI_COMM_WORLD);
412  MPI_Bcast(&options->debug, 1, MPI_INT, 0, MPI_COMM_WORLD);
413  MPI_Bcast(&options->Debug, 1, MPI_INT, 0, MPI_COMM_WORLD);
414  MPI_Bcast(&options->read_task_offset, 1, MPI_INT, 0, MPI_COMM_WORLD);
415 
416  MPI_Bcast(&options->suppress_checksum, 1, MPI_INT, 0, MPI_COMM_WORLD);
417  MPI_Bcast(&options->do_read, 1, MPI_INT, 0, MPI_COMM_WORLD);
418  MPI_Bcast(&options->do_write, 1, MPI_INT, 0, MPI_COMM_WORLD);
419  MPI_Bcast(&options->use_posix, 1, MPI_INT, 0, MPI_COMM_WORLD);
420 
421  return(rc);
422 }
423 
424 
425 void usage_long(char *name) {
426 
427  fprintf(stderr, "Usage: %s options\n\n", name);
428  fprintf(stderr, "Options:\n");
429 
430  fprintf(stderr, " Sion File Settings:\n");
431  fprintf(stderr, " [-f filename] (--filename[=]) filename of direct access file\n");
432  fprintf(stderr, " [-n <number of files>] (--numfiles[=]) number of files (def: 1)\n");
433  fprintf(stderr, " [-r <chunksize>] (--chunksize[=]) sion chunk size (see size format)\n");
434  fprintf(stderr, " [-q <fsblksize>] (--fsblksize[=]) size of filesystem blocks (see\n");
435  fprintf(stderr, " size format)\n");
436 
437  fprintf(stderr, " Test Configuration:\n");
438  fprintf(stderr, " [-T <type>] (--testtype[=]) type of test\n");
439  fprintf(stderr, " (0:SION, standard),\n");
440  fprintf(stderr, " (1: SION:, independant read),\n");
441  fprintf(stderr, " (2:MPI IO), (3: Task-Local-File)\n");
442  fprintf(stderr, " [-b <bufsize>] (--bufsize[=]) size of blocks written in ONE\n");
443  fprintf(stderr, " fwrite (see size format)\n");
444  fprintf(stderr, " [-g <totalsize>] (--totalsize[=]) global total size of data written\n");
445  fprintf(stderr, " (see size format)\n");
446  fprintf(stderr, " [-s <localsize>] (--localsize[=]) local size of data written by each\n");
447  fprintf(stderr, " processor (see size format)\n");
448  fprintf(stderr, " [-F <factor>] (--factor[=]) factor for random size\n");
449  fprintf(stderr, " (0.0 to 1.0, def: 0.0)\n");
450  fprintf(stderr, " [-R (0|1)] (--read[=]) switch read off/on\n");
451  fprintf(stderr, " [-W (0|1|2)] (--write[=]) switch write off, on, or double\n");
452  fprintf(stderr, " write\n");
453 
454  fprintf(stderr, " Special Test Options:\n");
455  fprintf(stderr, " [-v] (--verbose[=](0|1)) verbose print info for each\n");
456  fprintf(stderr, " task\n");
457  fprintf(stderr, " [-C] (--nochecksum[=](0|1)) suppress checksum\n");
458  fprintf(stderr, " [-d] (--debugtask[=](0|1)) debug task 0\n");
459  fprintf(stderr, " [-D] (--Debugtask[=](0|1)) debug task n\n");
460  fprintf(stderr, " [-L] (--posix[=](0|1)) use POSIX calls instead of\n");
461  fprintf(stderr, " ANSI calls\n");
462  fprintf(stderr, " [-M] (--collwrite[=](0|1)) use collective write if\n");
463  fprintf(stderr, " possible\n");
464  fprintf(stderr, " [-m] (--collread[=](0|1)) use collective read if\n");
465  fprintf(stderr, " possible\n");
466  fprintf(stderr, " [-c] (--collmsa) optimize collective I/O for\n");
467  fprintf(stderr, " modular supercomputers\n");
468  fprintf(stderr, " [-Z <offset>] (--taskoffset[=]) shift tasks numbering for\n");
469  fprintf(stderr, " reading by offset to prevent\n");
470  fprintf(stderr, " data caching of file-system\n");
471  fprintf(stderr, " (default: 0)\n");
472  fprintf(stderr, " [-O <bytes>] (--byteoffset[=]) start offset, write <bytes>\n");
473  fprintf(stderr, " first before using blksize\n");
474  fprintf(stderr, " (default: 0)\n");
475  fprintf(stderr, " [-j <#tasks>] (--serialized[=]) serialize I/O, only I/O of\n");
476  fprintf(stderr, " #tasks are running in parallel\n");
477  fprintf(stderr, " (-1 -> all tasks in parallel,\n");
478  fprintf(stderr, " -2 -> use transactions,\n");
479  fprintf(stderr, " -def: -1)\n");
480  fprintf(stderr, " [-X] (--unlinkfiles[=](0|1)) remove files after test\n");
481 
482  fprintf(stderr, " Blue Gene/L, Blue Gene/P , Blue Gene/Q:\n");
483  fprintf(stderr, " [-P <mode>] (--bgionode[=](0|1|2)) order tasks by BG I/O-node\n");
484  fprintf(stderr, " (0 none, 1 ION, 2 IOB)\n");
485  fprintf(stderr, " [-Y <sort>] (--bgtaskperionode[=]) number of tasks per BG\n");
486  fprintf(stderr, " I/O-node\n");
487  fprintf(stderr, " [-p <numtasks>] (--bgtasksort[=](0|1)) sort task inside local\n");
488  fprintf(stderr, " communicator (0 distance to\n");
489  fprintf(stderr, " ION, 1 global rank)\n");
490 
491  fprintf(stderr, " MPI-IO, GPFS options:\n");
492  fprintf(stderr, " [-w] (--hintlargeblock[=](0|1)) Hint MPI-IO, IBM, Large\n");
493  fprintf(stderr, " Block IO\n");
494  fprintf(stderr, " [-Q <size>] (--hintiobufsize[=]) Hint MPI-IO, IBM, IO\n");
495  fprintf(stderr, " bufsize in KB\n");
496  fprintf(stderr, " [-x] (--hintsparseacess[=](0|1)) Hint MPI-IO, IBM, sparse\n");
497  fprintf(stderr, " access\n");
498 
499  fprintf(stderr, " Size Formats: <d>[k, K, kib, kiB, Kib, KiB] for kibi bytes\n");
500  fprintf(stderr, " <d>[kb, kB, Kb, KB] for kilo bytes\n");
501  fprintf(stderr, " similarly for [M, G, T]\n");
502 
503 }
504 
505 void usage(char *name) {
506 
507  fprintf(stderr, "Usage: %s options\n\n", name);
508  fprintf(stderr, "Options:\n\n");
509 
510  fprintf(stderr, " Sion File Settings:\n");
511  fprintf(stderr, " [-f filename] filename of direct access file\n");
512  fprintf(stderr, " [-n <number of files>] number of files\n");
513  fprintf(stderr, " [-r <chunksize>] sion chunk size in bytes\n");
514  fprintf(stderr, " [-R <chunksize>] sion chunk size in MBytes\n");
515  fprintf(stderr, " [-q <fsblksize>] size of filesystem blocks in bytes\n");
516  fprintf(stderr, " [-Q <fsblksize>] size of filesystem blocks in MBytes\n");
517 
518  fprintf(stderr, " Test Configuration:\n");
519  fprintf(stderr, " [-F <factor>] factor for random size (0.0 to 1.0, def: 0.0)\n");
520  fprintf(stderr, " [-b <bufsize>] size of blocks written in ONE fwrite in bytes\n");
521  fprintf(stderr, " [-B <bufsize>] size of blocks written in ONE fwrite in MBytes\n");
522  fprintf(stderr, " [-g <globaltotalsize>] global total size of data written in bytes\n");
523  fprintf(stderr, " [-G <globaltotalsize>] global total size of data written in GBytes\n");
524  fprintf(stderr, " [-s <totalsize>] total size of data written by each processor in bytes\n");
525  fprintf(stderr, " [-S <totalsize>] total size of data written by each processor in MBytes\n");
526  fprintf(stderr, " [-T <type>] type of test (0): w/o collective read; (2): MPI IO\n");
527  fprintf(stderr, " [-v] verbose print info for each task\n");
528  fprintf(stderr, " [-C] suppress checksum\n");
529  fprintf(stderr, " [-I] only read data\n");
530  fprintf(stderr, " [-O] only write data\n");
531  fprintf(stderr, " [-d] debug task 0\n");
532  fprintf(stderr, " [-D] debug task n\n");
533  fprintf(stderr, " [-L] use POSIX calls instead of ANSI call\n");
534  fprintf(stderr, " [-M] use collective write if possible\n");
535  fprintf(stderr, " [-m] use collective read if possible\n");
536  fprintf(stderr, " [-c] optimize collective I/O for modular supercomputers\n");
537  fprintf(stderr, " [-Z <offset>] shift tasks numbering for reading by offset to ommit\n");
538  fprintf(stderr, " data caching of file-system (default: 0)\n");
539  fprintf(stderr, " [-o <bytes>] start offset, write <bytes> first before using blksize\n");
540  fprintf(stderr, " (default: 0)\n");
541  fprintf(stderr, " [-j <#tasks>] serialize I/O, only I/O of #tasks are running in\n");
542  fprintf(stderr, " parallel (-1 -> all tasks in parallel, -2 -> use\n");
543  fprintf(stderr, " transactions, def: -1)\n");
544 
545  fprintf(stderr, " Blue Gene/L, Blue Gene/P , Blue Gene/Q:\n");
546  fprintf(stderr, " [-P <mode>] order tasks by BG I/O-node (0 none, 1 ION, 2 IOB)\n");
547  fprintf(stderr, " [-Y <sort>] number of tasks per BG I/O-node\n");
548  fprintf(stderr, " [-p <numtasks>] number of tasks per BG I/O-node\n");
549 
550  fprintf(stderr, " MPI-IO, GPFS options:\n");
551  fprintf(stderr, " [-w <1|0>] Hint MPI-IO, IBM, Large Block IO\n");
552  fprintf(stderr, " [-W <size>] Hint MPI-IO, IBM, IO bufsize in KB\n");
553  fprintf(stderr, " [-x <1|0>] Hint MPI-IO, IBM, sparse access\n");
554 
555  exit(1);
556 
557 }
558 
559 
560 /* convert following formats to bytes:
561  t,T,Ti,Tib,TiB -> 1024*1024*1024*1024 bytes
562  g,G,Gi,Gib,GiB -> 1024*1024*1024 bytes
563  m,M,Mi,Mib,MiB -> 1024*1024 bytes
564  k,K,Ki,Kib,KiB -> 1024 bytes
565 
566  Tb,TB -> 1000*1000*1000*1000 bytes
567  Gb,GB -> 1000*1000*1000 bytes
568  Mb,MB -> 1000*1000 bytes
569  Kb,KB -> 1000 bytes
570 */
571 sion_int64 to_bytes ( char *option) {
572  int rc;
573  sion_int64 size = -1;
574  sion_int64 factor = 1024;
575  char char1='\0',char2='\0',char3='\0';
576  rc = sscanf(option, "%lld%c%c%c", &size, &char1,&char2,&char3);
577  if (rc == 3 && ( (char2=='b') || (char2=='B') )) {
578  factor = 1000;
579  }
580 
581  if ( (char1=='T') || (char1=='t') ) size*=factor*factor*factor*factor;
582  if ( (char1=='G') || (char1=='g') ) size*=factor*factor*factor;
583  if ( (char1=='M') || (char1=='m') ) size*=factor*factor;
584  if ( (char1=='K') || (char1=='k') ) size*=factor;
585 
586  return size;
587 }
sion.h
_test_options_struct
Definition: partest_opts.h:14