SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
partest.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** Copyright (c) 2019 **
8 ** DataDirect Networks **
9 ** **
10 ** See the file COPYRIGHT in the package base directory for details **
11 ****************************************************************************/
12 
13 #define _XOPEN_SOURCE 700
14 
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <ctype.h>
19 #include <mpi.h>
20 #include <time.h>
21 #include <math.h>
22 
23 #include "sion_debug.h"
24 #include "sion_printts.h"
25 #include "sion.h"
26 #include "partest.h"
27 #include "partest_util.h"
28 #include "partest_split_comm.h"
29 
30 
41 int main(int argc, char **argv)
42 {
43  int rank, size, rc = 0;
44  char *localbuffer ;
45  time_t t;
46  sion_int64 commwork_size64 = 1;
47 
48  /* communicators */
49  _test_communicators communicators;
50 
51  /* options */
52  _test_options options;
53 
54  MPI_Init(&argc, &argv);
55  MPI_Comm_size(MPI_COMM_WORLD, &size);
56  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
57  /* */ DPRINTFTS(rank, "after MPI_Init");
58 
59  /* srand ( time(NULL)*rank ); */
60 
61  /* printf("starting partest %02d of %02d\n", rank,size); */
62 
63  init_options(&options);
64 
65 
66 
67  if (rank == 0) {
68 #ifdef _SION_AIX
69  parse_options_std(argc, argv, &options);
70  if(rc==0) {
71  usage(argv[0]);
72  }
73 #else
74  rc=parse_options_long(argc, argv, &options);
75  if(rc==0) {
76  usage_long(argv[0]);
77  }
78 #endif
79  }
80  MPI_Bcast(&rc, 1, MPI_INT, 0, MPI_COMM_WORLD);
81  if(rc==0) {
82  MPI_Abort(MPI_COMM_WORLD, 1);
83  }
84 
85  distribute_options_mpi(&options);
86 
87  /* adjust communicators */
88  communicators.all = MPI_COMM_WORLD;
89  MPI_Comm_size(MPI_COMM_WORLD, &communicators.all_size);
90  MPI_Comm_rank(MPI_COMM_WORLD, &communicators.all_rank);
91  split_communicator(&communicators, options.bluegene, options.bluegene_np, options.bluegene_sort, options.numfiles, options.read_task_offset, options.verbose);
92 
93  /* determine global and local size of data to be written and read */
94  commwork_size64 = (sion_int64) communicators.work_size;
95  if (options.globalsize > 0) {
96  options.totalsize = (sion_int64) options.globalsize / commwork_size64;
97  }
98  else {
99  /* commwork_size64 = 1; */
100  options.globalsize = options.totalsize * commwork_size64;
101  }
102 
103  if((options.totalsize>options.bufsize) || (options.read_task_offset>0) || (options.do_write==0) ) {
104  options.suppress_checksum=1;
105  }
106 
107  if(options.fsblksize<0) options.fsblksize=-1;
108 
109  /* chunksize set to localsize if -1 */
110  if(options.chunksize<0) options.chunksize=options.totalsize;
111 
112  if ( (communicators.work_size>0) && (communicators.work_rank==0) ) {
113  time(&t);
114  fprintf(stderr, "------------------------------------------------------------------------------------------\n");
115  fprintf(stderr, "SION parallel file I/O benchmark 'partest': start at %s", ctime(&t));
116  fprintf(stderr, "partest Number of tasks that will use the file tasks: running on %d tasks\n", size);
117  fprintf(stderr, "------------------------------------------------------------------------------------------\n");
118 #ifndef CHECKSUM
119  fprintf(stderr, "partest parameter: CHECKSUM DISABLED!\n\n");
120 #else
121  if(options.suppress_checksum) {
122  fprintf(stderr, "partest parameter: CHECKSUM not possible, DISABLED!\n\n");
123  }
124 #endif
125  fprintf(stderr, "partest parameter: (-f) datafile = %s\n", options.filename);
126  fprintf(stderr, "partest parameter: (-n) number of files = %d\n", options.numfiles);
127  fprintf(stderr, "partest parameter: (-F) random factor = %13.4f\n", options.factor);
128  fprintf(stderr, "partest parameter: (-X) remove files after test = %d\n", options.unlink_files);
129  fprintf(stderr, "partest parameter: (-b/-B) local buffer size / task = %15lld bytes %10.3f MB\n", options.bufsize, options.bufsize / (1.0 MB));
130  fprintf(stderr, "partest parameter: (-g/-G) global total data size = %15lld bytes %10.3f GB\n", options.globalsize, options.globalsize / (1024.0 MB));
131  fprintf(stderr, "partest parameter: (-s/-S) total data size / task = %15lld bytes %10.3f MB\n", options.totalsize, options.totalsize / (1.0 MB));
132  fprintf(stderr, "partest parameter: (-r/-R) sion chunk size = %15lld bytes %10.3f MB\n", options.chunksize, options.chunksize / (1.0 MB));
133  fprintf(stderr, "partest parameter: (-Q) fs block size = %15d bytes %10.3f MB\n", options.fsblksize, options.fsblksize / (1.0 MB));
134  if (options.type == 0)
135  fprintf(stderr, "partest parameter: (-T) test type = %d (sion, collective read)\n", options.type);
136  if (options.type == 1)
137  fprintf(stderr, "partest parameter: (-T) test type = %d (sion, independant read)\n", options.type);
138  if (options.type == 2)
139  fprintf(stderr, "partest parameter: (-T) test type = %d (mpi-io)\n", options.type);
140  if (options.type == 3)
141  fprintf(stderr, "partest parameter: (-T) test type = %d (single files)\n", options.type);
142  fprintf(stderr, "partest parameter: (-j) serialize_blocknum = %d\n", options.serialize_blocknum);
143  fprintf(stderr, "partest parameter: (-Z) read task offset = %d\n", options.read_task_offset);
144  fprintf(stderr, "partest parameter: (-o) start offset bytes = %d\n", options.startoffset);
145  fprintf(stderr, "partest parameter: (-v) verbose = %d\n", options.verbose);
146  fprintf(stderr, "partest parameter: (-d) debug = %d\n", options.debug);
147  fprintf(stderr, "partest parameter: (-D) Debug = %d\n", options.Debug);
148  fprintf(stderr, "partest parameter: (-M) collective write = %d\n", options.collectivewrite);
149  fprintf(stderr, "partest parameter: (-m) collective read = %d\n", options.collectiveread);
150  fprintf(stderr, "partest parameter: (-c) MSA-aware collective I/O = %d\n", options.collmsa);
151 
152 
153  fprintf(stderr, "partest parameter: (-w) MPI-IO, IBM, Large Block IO = %d\n", options.mpiio_lb);
154  fprintf(stderr, "partest parameter: (-W) MPI-IO, IBM, IO bufsize = %d KB\n", options.mpiio_bs);
155  fprintf(stderr, "partest parameter: (-x) MPI-IO, IBM, sparse access = %d\n", options.mpiio_sa);
156  fprintf(stderr, "partest parameter: (-C) suppress_checksum = %d\n", options.suppress_checksum);
157  fprintf(stderr, "partest parameter: (-O) do_write = %d\n", options.do_write);
158  fprintf(stderr, "partest parameter: (-I) do_read = %d\n", options.do_read);
159  fprintf(stderr, "partest parameter: (-L) use_posix = %d\n", options.use_posix);
160 #if defined(_SION_SIONFWD)
161  fprintf(stderr, "partest parameter: (-l) use_sionfwd = %d\n", options.use_sionfwd);
162 #endif
163 #ifdef _SION_IME_NATIVE
164  fprintf(stderr, "partest parameter: (-i) use_ime_native = %d\n", options.use_ime_native);
165 #endif
166 
167  fprintf(stderr, "partest parameter: (-P) Blue Gene, I/O nodes = %d\n", options.bluegene);
168  fprintf(stderr, "partest parameter: (-p) Blue Gene: task/IO-nodes = %d\n", options.bluegene_np);
169  fprintf(stderr, "partest parameter: (-Y) Blue Gene: task sort = %d\n", options.bluegene_sort);
170 
171  fprintf(stderr, "partest parameter: ( ) commwork_size64 = %lld\n", commwork_size64);
172 
173  fprintf(stderr, "partest versioninfo: SION_MAIN_VERSION = %d\n", SION_MAIN_VERSION);
174  fprintf(stderr, "partest versioninfo: SION_SUB_VERSION = %d\n", SION_SUB_VERSION);
175  fprintf(stderr, "partest versioninfo: SION_VERSION_PATCHLEVEL = %d\n", SION_VERSION_PATCHLEVEL);
176  fprintf(stderr, "partest versioninfo: SION_FILEFORMAT_VERSION = %d\n", SION_FILEFORMAT_VERSION);
177  fprintf(stderr, "partest versioninfo: SION_GIT_REVISION = %s\n", GIT_REV);
178 
179 
180  }
181 
182  barrier_after_start(MPI_COMM_WORLD);
183 
184  if ( (communicators.work_size>0) && (communicators.work_rank==0) ) {
185  fprintf(stderr, "partest parameter: ( ) comm(all) = %d of %d\n", communicators.all_rank, communicators.all_size);
186  fprintf(stderr, "partest parameter: ( ) comm(work) = %d of %d\n", communicators.work_rank, communicators.work_size);
187  fprintf(stderr, "partest parameter: ( ) comm(local) = %d of %d\n", communicators.local_rank, communicators.local_size);
188  fprintf(stderr, "------------------------------------------------------------------------------------------\n");
189  }
190 
191  barrier_after_start(MPI_COMM_WORLD);
192  /* */ DPRINTFTS(rank, "after pstart");
193  /* Init the local buffer that will be written to the file */
194  localbuffer = (char *) malloc(options.bufsize);
195 
196  srand(time(NULL)*communicators.work_rank);
197  /* for (i = 0; i < (options.bufsize / sizeof(int)); i++) */
198  /* localbuffer[i] = (char) rand() % 256; */
199 
200 /* memset (localbuffer, 'a'+rank%26, bufsize); */
201  memset (localbuffer, 'a'+rank%26, options.bufsize);
202  barrier_after_malloc(MPI_COMM_WORLD);
203  /* */ DPRINTFTS(rank, "after malloc");
204 
205  /* random factor handling */
206  if(options.factor>0.0) {
207  if((options.collectivewrite) || (options.collectiveread)) {
208  if(options.bufsize<options.totalsize*(1+options.factor)) {
209  fprintf(stderr, "partest: ERROR deadlock possible if collective read/write and random factor used, and buffer is too small aborting\n");
210  MPI_Abort(MPI_COMM_WORLD,0);
211  exit(0);
212  }
213  }
214 
215  options.totalsize += ((sion_int64) (options.factor * (sion_int64) options.totalsize * (sion_int64) rand() / (sion_int64) RAND_MAX));
216  options.chunksize += ((sion_int64) (options.factor * (sion_int64) options.totalsize * (sion_int64) rand() / (sion_int64) RAND_MAX));
217  fprintf(stderr, "partest parameter: ( ) new totalsize[%4d] = %lld\n", communicators.work_rank, options.totalsize);
218  }
219 
220 
221 
222  /* */ DPRINTFTS(rank, "before scall2");
223  if ( (communicators.work_size>0) && (communicators.work_rank==0) ) {
224  fprintf(stderr, "partest parameter: ( ) new totalsize = %lld\n", options.totalsize);
225  }
226  barrier_after_malloc(MPI_COMM_WORLD);
227  if (options.type == 0) {
228  options.collectiveopenforread = 1;
229  test_paropen_multi_mpi(options.filename, localbuffer, &communicators, &options);
230 
231  }
232  else if (options.type == 1) {
233  options.collectiveopenforread = 0;
234  test_paropen_multi_mpi(options.filename, localbuffer, &communicators, &options);
235  }
236  else if (options.type == 2) {
237  options.collectiveopenforread = 1;
238  test_mpiio_multi_mpi(options.filename, localbuffer, &communicators, &options);
239  }
240  else if (options.type == 3) {
241  options.collectiveopenforread = 1;
242  test_single_mpi(options.filename, localbuffer, &communicators, &options);
243  }
244 
245  /* */ DPRINTFTS(rank, "before MPI_Finalize");
246  barrier_after_malloc(MPI_COMM_WORLD);
247 
248  if ( (communicators.work_size>0) && (communicators.work_rank==0) ) {
249  time(&t);
250  fprintf(stderr, "SION parallel file I/O benchmark 'partest': end at %s\n", ctime(&t));
251  }
252 
253  MPI_Finalize();
254  return (0);
255 }
256 
Sion Time Stamp Header.