-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaos.patch
More file actions
5347 lines (5344 loc) · 138 KB
/
daos.patch
File metadata and controls
5347 lines (5344 loc) · 138 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --exclude testmpio_daos --exclude testmpio -Nur Testmpio/Makefile Testmpio-patched/Makefile
--- Testmpio/Makefile 2003-09-08 17:49:12.000000000 -0400
+++ Testmpio-patched/Makefile 2019-09-04 16:17:02.396867273 -0400
@@ -5,14 +5,17 @@
MPIEXEC = $(MPIHOME)/bin/mpiexec
LIBS =
CFLAGS = -g
-all-redirect: testmpio
+all-redirect: testmpio testmpio_daos
testmpio: testmpio.c
$(MPICC) $(CFLAGS) -o testmpio testmpio.c $(LIBS)
+testmpio_daos: testmpio_daos.c
+ $(MPICC) $(CFLAGS) -o testmpio_daos testmpio_daos.c $(LIBS)
+
testing: testmpio
MPIO_USER_PATH=`pwd`/t1 ; export MPIO_USER_PATH ; \
$(MPIEXEC) -n 4 ./testmpio 1
clean:
- -rm -f *.o testmpio t1/*
+ -rm -f *.o testmpio testmpio_daos t1/*
diff --exclude testmpio_daos --exclude testmpio -Nur Testmpio/testmpio_daos.c Testmpio-patched/testmpio_daos.c
--- Testmpio/testmpio_daos.c 1969-12-31 19:00:00.000000000 -0500
+++ Testmpio-patched/testmpio_daos.c 2019-09-04 16:16:59.489785684 -0400
@@ -0,0 +1,5320 @@
+/*===========================================================================
+ *
+ * Name: testmpio.c
+ *
+ * Functions:
+ * dotests
+ * main
+ * test_collective
+ * test_datareps
+ * test_errhandlers
+ * test_filecontrol
+ * test_localpointer
+ * test_manycomms
+ * test_manyopens
+ * test_openclose
+ * test_openmodes
+ * test_nb_collective
+ * test_nb_localpointer
+ * test_nb_rdwr
+ * test_nb_readwrite
+ * test_nb_sharedpointer
+ * test_rdwr
+ * test_readwrite
+ * test_sharedpointer
+ *
+ * some_handler
+ * user_handler
+ * user_native_extent_fn
+ * user16_extent_fn
+ * user16_read_fn
+ * user16_write_fn
+ * write_then_read
+ *
+ * Description:
+ * Tests MPI-IO interface functions. Includes functions
+ * for testing collective open and close of files, independent
+ * read and write with using file and buffer types, file open
+ * modes, multiple opens of the same file, and access by
+ * multiple communicators, file control, error handling,
+ * and datarep and data conversion facilities.
+ *
+ * Traceability:
+ * Version Date Description
+ * ------- ---- -----------
+ * 3.0 01/09/98 initial HPSS version
+ * 3.1 04/29/98 added test_datareps; mods for
+ * public release versions
+ * 3.2 06/10/98 completed error checking
+ * 3.3 06/22/98 fixed Testany/Waitany bug
+ * 3.4P 06/30/98 error handling mods
+ * 3.5P 08/18/98 added barriers in test_filecontrol
+ *
+ * Notes:
+ *
+ * See the accompanying file LEGAL-NOTICE for disclaimers and
+ * information on commercial use.
+ *
+ *-------------------------------------------------------------------------*/
+
+#include "mpi.h"
+
+/* Temporary for MPICH2 testing */
+#ifdef EARLY_MPICH2
+#define MPI_Wait MPIO_Wait
+#define MPI_Request MPIO_Request
+#define MPI_Waitall MPIO_Waitall
+#define MPI_Waitsome MPIO_Waitsome
+#define MPI_Waitany MPIO_Waitany
+#define MPI_Test MPIO_Test
+#define MPI_Testall MPIO_Testall
+#define MPI_Testsome MPIO_Testsome
+#define MPI_Testany MPIO_Testany
+#endif
+/* End of temporary MPICH2 */
+
+/* testmpio requries this definition to use the varargs form
+ of the user-defined error handlers */
+#define USE_STDARG
+
+/* define this if the MPI implementation sets the status value
+ when an error occurs. This is not required by the MPI
+ standard, and user programs should not use status after an
+ error return.
+*/
+/* #define STATUS_VALID_AFTER_ERROR */
+
+/* Define the following to suppress non-local error tests */
+#define NO_NON_LOCAL_ERRTESTS
+
+/* Define VERBOSE to get more information */
+/* #define VERBOSE */
+
+/* Define DETAIL to be
+ DETAIL_NONE (error messages only)
+ DETAIL_BASE (messages about tests from process zero only)
+ DETAIL_ALL (all messages)
+*/
+#define DETAIL_NONE 0
+#define DETAIL_BASE 1
+#define DETAIL_ALL 2
+/* You can define DETAIL when compiling to change the level of detail */
+/* TODO: This should be runtime, rather than compile time, as the overhead
+ is modest */
+#ifndef DETAIL
+/*#define DETAIL DETAIL_BASE*/
+#define DETAIL DETAIL_NONE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h> /* For getpid */
+#include <string.h> /* For memset */
+#include <time.h>
+
+#define BUFLEN 80
+
+#ifndef MAX_PATH_LEN
+#define MAX_PATH_LEN 1024
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif /* TRUE */
+
+#ifndef FALSE
+# define FALSE 0
+#endif /* FALSE */
+
+/* Detail levels: 0=none, 1=BASIC, 2=ALL */
+static int detailLevel = 1;
+/* the "do...while" makes these look like a regular statement, avoiding
+ bugs if these are used with sloppy coding */
+#define ENTERING(fun) do {\
+ if (detailLevel > 0) {\
+ if (detailLevel > 1 || wrank == 0) {\
+ fprintf(stderr, "(%d)FLOWTRACE: Entering %s\n", myid, fun);}}} while(0)
+#define LEAVING(fun) do {\
+ if (detailLevel > 0) {\
+ if (detailLevel > 1 || wrank == 0) {\
+ fprintf(stderr, "(%d)FLOWTRACE: Leaving %s\n", myid, fun);}}} while(0)
+#define DEBUG_TRACE(str) do {\
+ if (detailLevel > 0) {\
+ if (detailLevel > 1 || wrank == 0) {\
+ fprintf(stderr, "(%d)%s\n", myid, str);}}} while(0)
+
+/* We could use snprintf, but this is a workable solution for these*/
+#define MAKEFILENAME(name, namelen, prefix, path, id) \
+ do { if (strlen(prefix) + strlen(path) + 11 > namelen) { \
+ fprintf( stderr, "name (length %d) too short for file name at line %d\n",\
+ namelen, __LINE__ );\
+ MPI_Abort( MPI_COMM_WORLD, 1 );\
+ } else { sprintf(name, "%s/%s%d", path, prefix, id); } } while (0)
+
+#define MAKEFILENAME_I(name, namelen, prefix, path, id, i) \
+ do { if (strlen(prefix) + strlen(path) + 22 > namelen) { \
+ fprintf( stderr, "name (length %d) too short for file name at line %d\n",\
+ namelen, __LINE__ );\
+ MPI_Abort( MPI_COMM_WORLD, 1 );\
+ } else { sprintf(name, "%s/%s%d_%d", path, prefix, i, id); } } while (0)
+
+#define MAKEFILENAME_S(name, namelen, prefix, path, suffix, id) \
+ do { if (strlen(prefix) + strlen(path) + strlen(suffix)+ 12 > namelen) { \
+ fprintf( stderr, "name (length %d) too short for file name at line %d\n",\
+ namelen, __LINE__ );\
+ MPI_Abort( MPI_COMM_WORLD, 1 );\
+ } else { sprintf(name, "%s/%s%d_%s", path, prefix, id, suffix); } } while (0)
+
+#define START_TIME \
+ test_start_time = time(NULL);
+
+#define STOP_TIME \
+ test_stop_time = time(NULL);
+
+#define REPORT_TIME \
+ if (myid == 0) { \
+ elapsed_time = test_stop_time - test_start_time; \
+ total_time += elapsed_time; \
+ fprintf(stderr, \
+ "********** " \
+ "Elapsed time for iteration %d was %d secs\n", \
+ i, (int)elapsed_time); \
+ }
+
+#define REPORT_AVERAGE \
+ if (myid == 0) { \
+ fprintf(stderr, \
+ "******************** Average test time was" \
+ " %d secs\n", \
+ (int)(total_time / count)); \
+ }
+
+#define CHECK(a) \
+{ \
+ if (!(a)) { \
+ fprintf(stderr, \
+ "(%d)Error at node %d, line %d of test program\n", \
+ myid, myid, __LINE__); \
+ fflush(stderr); \
+ MPI_Abort(MPI_COMM_WORLD, -1); \
+ } \
+}
+
+#define CHECKINTS(a, b) \
+{ \
+ CHECK((int)(a) == (int)(b)); \
+ if ((int)(a) != (int)(b)) { \
+ fprintf(stderr, "(%d)got: %x expected: %x, line %d of test program\n", \
+ myid, (int)(a), (int)(b), __LINE__ ); \
+ fflush(stderr); \
+ MPI_Abort(MPI_COMM_WORLD, -1); \
+ } \
+}
+
+/* The original code had CHECK((int)(a) ==(int)(b)) as the first executable
+ line. However, this is not correct for tests like
+
+ CHECKERRS( mpio_result, MPI_ERR_FILE )
+
+ since the error *code* in mpio_result may not be MPI_ERR_FILE, even
+ though the error *class* is. To fix this, the CHECK call is moved
+ into the final test on the error class
+ WDG - 9/4/03
+*/
+#define CHECKERRS(a, b) \
+{ \
+ char got_string[MPI_MAX_ERROR_STRING]; \
+ char expected_string[MPI_MAX_ERROR_STRING]; \
+ int string_len; \
+ int ca, cb; \
+ if ((int)(a) != (int)(b)) { \
+ MPI_Error_class(a, &ca); \
+ MPI_Error_class(b, &cb); \
+ CHECKINTS(ca, cb); \
+ if (ca != cb) { \
+ CHECK((int)(a) == (int)(b)); \
+ MPI_Error_string(a, got_string, &string_len); \
+ MPI_Error_string(b, expected_string, &string_len); \
+ fprintf(stderr, "(%d)got %d in class %d: %s\n", \
+ myid, (int)(a), (int)ca, got_string); \
+ fprintf(stderr, "(%d)expected %d in class %d: %s\n", \
+ myid, (int)(b), (int)cb, expected_string); \
+ fflush(stderr); \
+ MPI_Abort(MPI_COMM_WORLD, -1); \
+ } \
+ } \
+}
+/* WDG, 3/27/12.
+ Check that the error (a) is of either the error class in b or c.
+ If the test fails, report using error class b (c is not the preferred class)
+ */
+#define CHECKERRS2(a, b, c) \
+{ \
+ char got_string[MPI_MAX_ERROR_STRING]; \
+ char expected_string[MPI_MAX_ERROR_STRING]; \
+ int string_len; \
+ int ca; \
+ if ((int)(a) != (int)(b)) { \
+ MPI_Error_class(a, &ca); \
+ if (ca != b && ca != c) { \
+ MPI_Error_string(a, got_string, &string_len); \
+ MPI_Error_string(b, expected_string, &string_len); \
+ CHECKINTS(ca, b); \
+ if (ca != b) { \
+ CHECK((int)(a) == (int)(b)); \
+ fprintf(stderr, "(%d)got %d in class %d: %s\n", \
+ myid, (int)(a), (int)ca, got_string); \
+ fprintf(stderr, "(%d)expected %d in class %d: %s\n", \
+ myid, (int)(b), (int)b, expected_string); \
+ fflush(stderr); \
+ MPI_Abort(MPI_COMM_WORLD, -1); \
+ } \
+ } \
+ } \
+}
+
+#define RETURN \
+ goto endtest;
+
+#define RETURNERRS(a, b) \
+ CHECKERRS(a, b); \
+ if ((int)(a) != (int)(b)) \
+ RETURN;
+
+#define EXITERR(a) \
+ if ((a) != MPI_SUCCESS) { \
+ fprintf(stderr,"Failed to initialize MPI: %d\n", a); \
+ exit(-1); \
+ }
+
+#define CHECKSTRINGS(a, b, count) \
+{ int check; \
+ check = memcmp(a, b, count); \
+ CHECK(check == 0); \
+ if (check != 0) { \
+ { int i; \
+ for (i=0; i<count; i++) \
+ if (a[i] != b[i]) { \
+ fprintf(stderr, \
+ "(%d)Error: sent[%d]: %c (%d) " \
+ "received[%d]: %c (%d)\n", \
+ myid, i, a[i], a[i], i, b[i], b[i]); \
+ fflush(stderr); \
+ MPI_Abort(MPI_COMM_WORLD, -1); \
+ break; \
+ } \
+ } \
+ } \
+}
+
+void dotests(void);
+void test_collective(int numprocs, int myid);
+#ifdef HAVE_MPI_REGISTER_DATAREP
+void test_datareps(int numprocs, int myid);
+#endif
+void test_errhandlers(int numprocs, int myid);
+void test_filecontrol(int numprocs, int myid);
+void test_localpointer(int numprocs, int myid);
+void test_manyopens(int numprocs, int myid);
+void test_manycomms(int numprocs, int myid);
+void test_openclose(int numprocs, int myid);
+void test_openmodes(int numprocs, int myid);
+void test_nb_collective(int numprocs, int myid);
+void test_nb_localpointer(int numprocs, int myid);
+void test_nb_rdwr(int numprocs, int myid);
+void test_nb_readwrite(int numprocs, int myid);
+void test_nb_sharedpointer(int numprocs, int myid);
+void test_rdwr(int numprocs, int myid);
+void test_readwrite(int numprocs, int myid);
+void test_sharedpointer(int numprocs, int myid);
+
+static int basepid;
+static char userpath[MAX_PATH_LEN];
+static char default_path[] = "/";
+static int wrank = 0; /* Rank in MPI_COMM_WORLD */
+
+MPI_Info hints_to_test = MPI_INFO_NULL;
+
+
+/*===========================================================================
+ *
+ * Function: main
+ *
+ * Synopsis:
+ * int main(
+ * int argc, ** IN
+ * char ** argv ** IN
+ * )
+ *
+ * Parameters:
+ * argc number of command line args
+ * argv command line argument strings
+ *
+ * Description:
+ * Initializes MPI-IO and performs the mpio tests (dotests). Tests
+ * will be executed repeatedly, according to a command line
+ * argument. Simple timing results are reported.
+ *
+ * Other Inputs:
+ * Command line arguments:
+ * <#iterations> number of iterations of tests to perform
+ *
+ * Outputs:
+ * Prints out various test results.
+ *
+ * Interfaces:
+ * dotests
+ * MPI_Bcast
+ * MPI_Comm_rank
+ * MPI_Err_handler_set
+ * MPI_Finalize
+ * MPI_Get_version
+ * MPI_Info_create
+ * MPI_Info_free
+ * MPI_Info_set
+ * MPI_Init
+ *
+ *-------------------------------------------------------------------------*/
+
+int main(
+ int argc,
+ char ** argv
+)
+{
+ int mpio_result;
+ int myid;
+ int i;
+ int count;
+ time_t test_start_time, test_stop_time, elapsed_time;
+ time_t total_time = 0;
+ char * path;
+ int mpi_version;
+ int mpi_subversion;
+
+ /* Set up mpi environment */
+
+ mpio_result = MPI_Init(&argc, &argv);
+ EXITERR(mpio_result);
+
+ /* Try to keep going after all errors */
+
+ mpio_result = MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ mpio_result = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ wrank = myid; /* Save a global wrank since myid is passed to routines
+ and could someday be different from the rank in
+ COMM_WORLD */
+
+ DEBUG_TRACE("MPI_Init complete");
+
+ mpio_result = MPI_Get_version(&mpi_version, &mpi_subversion);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (myid == 0) {
+ fprintf(stderr,"***Current MPI version is %d.%d\n",
+ mpi_version, mpi_subversion);
+ }
+
+ if (argc != 2 && argc != 3) {
+ if (myid == 0) {
+ fprintf(stderr, "Usage: %s <#runs> [ detail ]\n", argv[0]);
+ fflush(stderr);
+ }
+ /* Barrier to give the fprintf a chance */
+ MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Abort( MPI_COMM_WORLD, 1 );
+ /* Should not reach here */
+ RETURN;
+ }
+
+ count = atol(argv[1]);
+
+ /* Get optional level of detail to output */
+ if (argc == 3)
+ detailLevel = atol(argv[2]);
+
+ path = getenv("MPIO_USER_PATH");
+ if (path == NULL) {
+ strncpy(userpath, default_path, MAX_PATH_LEN-1);
+ }
+ else {
+ strncpy(userpath, path, MAX_PATH_LEN-1);
+ userpath[MAX_PATH_LEN-1] = '\0';
+ }
+
+ basepid = getpid();
+
+#ifdef VERBOSE
+ fprintf(stderr, "(%d)pid = %d, userpath = %s\n",
+ myid, basepid, userpath);
+#endif
+
+ mpio_result = MPI_Info_create(&hints_to_test);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ /*
+ * Share node 0's pid among all nodes so they all use the same;
+ * this lets us create per-run filenames so simultaneous tests
+ * don't interfere with each other.
+ */
+
+ for (i = 0; i < count; i++) {
+ mpio_result = MPI_Bcast(&basepid, 1, MPI_INT, 0,
+ MPI_COMM_WORLD);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ START_TIME;
+
+ dotests();
+
+ STOP_TIME;
+
+ REPORT_TIME;
+
+ basepid++;
+ }
+
+ REPORT_AVERAGE;
+
+endtest:
+
+ if (hints_to_test != MPI_INFO_NULL) {
+ mpio_result = MPI_Info_free(&hints_to_test);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ }
+
+ mpio_result = MPI_Finalize();
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ DEBUG_TRACE("MPI_Finalize complete");
+
+ LEAVING("testmpio main");
+
+ return 0;
+
+} /* main */
+
+
+/*===========================================================================
+ *
+ * Function: dotests
+ *
+ * Synopsis:
+ * void dotests(
+ * void
+ * )
+ *
+ * Parameters:
+ * None.
+ *
+ * Description:
+ * Determines the number of processes and the rank of the current
+ * process, and runs all the MPI-IO tests.
+ *
+ * Outputs:
+ * None.
+ *
+ * Interfaces:
+ * MPI_Comm_rank
+ * MPI_Comm_size
+ * test_collective
+ * test_datareps
+ * test_errhandlers
+ * test_filecontrol
+ * test_localpointer
+ * test_manycomms
+ * test_manyopens
+ * test_nb_readwrite
+ * test_nb_rdwr
+ * test_nb_localpointer
+ * test_nb_sharedpointer
+ * test_nb_collective
+ * test_openclose
+ * test_openmodes
+ * test_readwrite
+ * test_rdwr
+ * test_sharedpointer
+ *
+ *-------------------------------------------------------------------------*/
+
+void dotests(
+ void
+)
+{
+ int numprocs, myid;
+ int mpio_result;
+
+ mpio_result = MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ mpio_result = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ ENTERING("dotests");
+
+ test_manycomms(numprocs, myid);
+ test_manyopens(numprocs, myid);
+ test_openclose(numprocs, myid);
+ test_openmodes(numprocs, myid);
+ test_filecontrol(numprocs, myid);
+ test_readwrite(numprocs, myid);
+ test_rdwr(numprocs, myid);
+ test_localpointer(numprocs, myid);
+#ifdef DAOS_UNSUPPORTED
+ test_sharedpointer(numprocs, myid);
+#endif
+ test_collective(numprocs, myid);
+ test_nb_readwrite(numprocs, myid);
+ test_nb_rdwr(numprocs, myid);
+ test_nb_localpointer(numprocs, myid);
+#ifdef DAOS_UNSUPPORTED
+ test_nb_sharedpointer(numprocs, myid);
+#endif
+ test_nb_collective(numprocs, myid);
+ test_errhandlers(numprocs, myid);
+#ifdef HAVE_MPI_REGISTER_DATAREP
+ test_datareps(numprocs, myid);
+#endif
+
+endtest:
+
+ LEAVING("dotests");
+
+} /* dotests */
+
+
+/*===========================================================================
+ *
+ * Function: test_openclose
+ *
+ * Synopsis:
+ * void test_openclose(
+ * int numprocs, ** IN
+ * int myid ** IN
+ * )
+ *
+ * Parameters:
+ * numprocs how many processors are running test
+ * myid node number of this processor
+ *
+ * Description:
+ * Opens and closes an MPI file collectively, without accessing
+ * its contents.
+ *
+ * Outputs:
+ * Logging and error messages are printed.
+ *
+ * Interfaces:
+ * MPI_File_close
+ * MPI_File_open
+ *
+ *-------------------------------------------------------------------------*/
+
+void test_openclose(
+ int numprocs,
+ int myid
+)
+{
+ MPI_File mpio_fh;
+ int mpio_result;
+ char name[MAX_PATH_LEN];
+ int amode;
+
+ ENTERING("test_openclose");
+
+ DEBUG_TRACE("Checking open and close file handles");
+
+ MAKEFILENAME(name, sizeof(name), "mpio_openclose", userpath, basepid);
+
+ amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
+
+ mpio_result = MPI_File_open(MPI_COMM_WORLD, name, amode,
+ hints_to_test, &mpio_fh);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ CHECK(mpio_fh != MPI_FILE_NULL);
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ CHECK(mpio_fh == MPI_FILE_NULL);
+
+ /* Try to close a file that isn't open; should fail but not crash */
+
+ DEBUG_TRACE("Checking close of file that isn't open");
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS2(mpio_result, MPI_ERR_FILE, MPI_ERR_ARG);
+
+ CHECK(mpio_fh == MPI_FILE_NULL);
+
+#ifndef NO_NON_LOCAL_ERRTESTS
+ if (numprocs > 1) {
+
+ DEBUG_TRACE("Checking file open argument consistency");
+
+ /*
+ * Check error if amodes not the same
+ */
+
+ amode = (myid % 2) ?
+ MPI_MODE_CREATE :
+ MPI_MODE_DELETE_ON_CLOSE;
+ amode |= MPI_MODE_RDWR;
+
+ mpio_result = MPI_File_open(MPI_COMM_WORLD, name, amode,
+ hints_to_test, &mpio_fh);
+ RETURNERRS(mpio_result, MPI_ERR_NOT_SAME);
+
+ CHECK(mpio_fh == MPI_FILE_NULL);
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS2(mpio_result, MPI_ERR_FILE, MPI_ERR_ARG);
+
+ CHECK(mpio_fh == MPI_FILE_NULL);
+
+ }
+#endif
+
+endtest:
+
+ LEAVING("test_openclose");
+
+} /* test_openclose */
+
+
+/*===========================================================================
+ *
+ * Function: test_readwrite
+ *
+ * Synopsis:
+ * void test_readwrite(
+ * int numprocs, ** IN
+ * int myid ** IN
+ * )
+ *
+ * Parameters:
+ * numprocs how many processors are running test
+ * myid node number of this processor
+ *
+ * Description:
+ * Tests independent I/O calls, using MPI_BYTE buffer and file types.
+ * Each node writes some bytes to a separate part of the same file
+ * and then reads them back and checks to see that they match.
+ *
+ * Outputs:
+ * Logging and error messages are printed.
+ *
+ * Interfaces:
+ * MPI_File_close
+ * MPI_File_open
+ * MPI_File_read_at
+ * MPI_File_sync
+ * MPI_File_write_at
+ * MPI_Get_count
+ *
+ *-------------------------------------------------------------------------*/
+
+void test_readwrite(
+ int numprocs,
+ int myid
+)
+{
+ MPI_File mpio_fh;
+ MPI_Status mpi_status;
+ int mpio_result;
+ int count;
+ char outbuf[BUFLEN];
+ char inbuf[BUFLEN];
+ MPI_Offset myoffset = myid * BUFLEN;
+ char name[MAX_PATH_LEN];
+ int amode;
+
+ ENTERING("test_readwrite");
+
+ MAKEFILENAME(name, sizeof(name), "mpio_readwrite", userpath, basepid);
+
+ amode = MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE;
+
+ mpio_result = MPI_File_open(MPI_COMM_WORLD, name, amode,
+ hints_to_test, &mpio_fh);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ DEBUG_TRACE("Checking independent I/O, default filetypes");
+
+ /* Buffer contains A's for node 0, B's for node 1, etc. */
+
+ memset(outbuf, 'A' + myid, BUFLEN);
+
+ /* Test writing 0 bytes */
+
+ mpio_result = MPI_File_write_at(mpio_fh,
+ myoffset, outbuf,
+ 0, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ /* Wrote correct number of bytes? */
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, 0);
+ }
+
+ mpio_result = MPI_File_write_at(mpio_fh,
+ myoffset, outbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ /* Wrote correct number of bytes? */
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, BUFLEN);
+
+ /* Clear buffer before reading back into it */
+ memset(inbuf, 0, BUFLEN);
+
+ /* Test reading 0 bytes */
+ mpio_result = MPI_File_read_at(mpio_fh,
+ myoffset, inbuf,
+ 0, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ /* Read correct number of bytes? */
+ mpio_result =
+ MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, 0);
+ }
+
+ mpio_result = MPI_File_sync(mpio_fh);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ mpio_result = MPI_File_read_at(mpio_fh,
+ myoffset, inbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ /* Read correct number of bytes? */
+ mpio_result =
+ MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, BUFLEN);
+ CHECKSTRINGS(outbuf, inbuf, BUFLEN);
+ }
+ }
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+endtest:
+
+ LEAVING("test_readwrite");
+
+} /* test_readwrite */
+
+
+/*===========================================================================
+ *
+ * Function: test_openmodes
+ *
+ * Synopsis:
+ * void test_openmodes(
+ * int numprocs, ** IN
+ * int myid ** IN
+ * )
+ *
+ * Parameters:
+ * numprocs how many processors are running test
+ * myid node number of this processor
+ *
+ * Description:
+ * Open a file using each of the modes and see if the file modes
+ * work as they should.
+ *
+ * Outputs:
+ * Logging and error messages are printed.
+ *
+ * Interfaces:
+ * MPI_File_close
+ * MPI_File_open
+ * MPI_File_read_at
+ * MPI_File_write_at
+ * MPI_Get_count
+ *
+ *-------------------------------------------------------------------------*/
+
+void test_openmodes(
+ int numprocs,
+ int myid
+)
+{
+ MPI_File mpio_fh;
+ MPI_Status mpi_status;
+ int mpio_result;
+ int count;
+ char outbuf[BUFLEN];
+ char inbuf[BUFLEN];
+ MPI_Offset myoffset = myid * BUFLEN;
+ char name[MAX_PATH_LEN];
+ int amode;
+
+ ENTERING("test_openmodes");
+
+ /* Test WRITE ONLY and CREATE */
+
+ MAKEFILENAME(name, sizeof(name), "mpio_openmodes", userpath, basepid);
+
+ DEBUG_TRACE("Checking create and wronly modes");
+
+ amode = MPI_MODE_CREATE | MPI_MODE_WRONLY;
+
+ mpio_result = MPI_File_open(MPI_COMM_WORLD, name, amode,
+ hints_to_test, &mpio_fh);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ /* Try to write it */
+
+ memset(outbuf, 'A' + myid, BUFLEN);
+
+ mpio_result = MPI_File_write_at(mpio_fh,
+ myoffset, outbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, BUFLEN);
+ }
+
+ /* Try to read it (this should fail) */
+
+ mpio_result = MPI_File_read_at(mpio_fh,
+ myoffset, inbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ /* WDG - FIXME: MPI_ERR_UNSUPPORTED_OPERATION is another
+ valid class for this error */
+ CHECKERRS2(mpio_result, MPI_ERR_ACCESS,MPI_ERR_UNSUPPORTED_OPERATION);
+
+#ifdef STATUS_VALID_AFTER_ERROR
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, 0);
+#endif
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ /* Test RDONLY and DELETE_ON_CLOSE */
+
+ DEBUG_TRACE("Checking rdonly and delete_on_close modes ");
+
+ amode = MPI_MODE_RDONLY | MPI_MODE_DELETE_ON_CLOSE;
+
+ mpio_result = MPI_File_open(MPI_COMM_WORLD, name, amode,
+ hints_to_test, &mpio_fh);
+ RETURNERRS(mpio_result, MPI_SUCCESS);
+
+ /* Try to read it */
+
+ /* Clear buffer before reading into it */
+
+ memset(inbuf, 0, BUFLEN);
+
+ mpio_result = MPI_File_read_at(mpio_fh,
+ myoffset, inbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ if (mpio_result == MPI_SUCCESS) {
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, BUFLEN);
+ CHECKSTRINGS(outbuf, inbuf, BUFLEN);
+ }
+
+ /* Try to write it (should fail) */
+
+ mpio_result = MPI_File_write_at(mpio_fh,
+ myoffset, outbuf,
+ BUFLEN, MPI_BYTE,
+ &mpi_status);
+ /* WDG - FIXME: MPI_ERR_READ_ONLY also valid, and in fact,
+ should be prefered */
+ /* CHECKERRS(mpio_result, MPI_ERR_ACCESS); */
+ CHECKERRS2(mpio_result, MPI_ERR_READ_ONLY, MPI_ERR_ACCESS);
+
+#ifdef STATUS_VALID_AFTER_ERROR
+ mpio_result = MPI_Get_count(&mpi_status, MPI_BYTE, &count);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+ CHECKINTS(count, 0);
+#endif
+
+ mpio_result = MPI_File_close(&mpio_fh);
+ CHECKERRS(mpio_result, MPI_SUCCESS);
+
+ /*
+ * Test open without CREATE to see if DELETE_ON_CLOSE worked.
+ * This should fail if file was deleted correctly.
+ */
+
+ amode = MPI_MODE_RDONLY;