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