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