1
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * Copyright by The HDF Group. *
4 * Copyright by the Board of Trustees of the University of Illinois. *
5 * All rights reserved. *
6 * *
7 * This file is part of HDF5. The full HDF5 copyright notice, including *
8 * terms governing use, modification, and redistribution, is contained in *
9 * the COPYING file, which can be found at the root of the source code *
10 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
11 * If you do not have access to either file, you may request a copy from *
12 * help@hdfgroup.org. *
13 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14
15 /*
16 This program will test irregular hyperslab selections with collective write and read.
17 The way to test whether collective write and read works is to use independent IO
18 output to verify the collective output.
19
20 1) We will write two datasets with the same hyperslab selection settings;
21 one in independent mode,
22 one in collective mode,
23 2) We will read two datasets with the same hyperslab selection settings,
24 1. independent read to read independent output,
25 independent read to read collecive output,
26 Compare the result,
27 If the result is the same, then collective write succeeds.
28 2. collective read to read independent output,
29 independent read to read independent output,
30 Compare the result,
31 If the result is the same, then collective read succeeds.
32
33 */
34
35 #define H5S_FRIEND /*suppress error about including H5Spkg */
36
37 /* Define this macro to indicate that the testing APIs should be available */
38 #define H5S_TESTING
39
40 #include "hdf5.h"
41 #include "H5private.h"
42 #include "H5Spkg.h" /* Dataspaces */
43 #include "testphdf5.h"
44
45
46 static void coll_write_test(int chunk_factor);
47 static void coll_read_test(int chunk_factor);
48
49
50 /*-------------------------------------------------------------------------
51 * Function: coll_irregular_cont_write
52 *
53 * Purpose: Wrapper to test the collectively irregular hyperslab write in
54 * contiguous storage
55 *
56 * Return: Success: 0
57 *
58 * Failure: -1
59 *
60 * Programmer: Unknown
61 * Dec 2nd, 2004
62 *
63 *-------------------------------------------------------------------------
64 */
65 void
coll_irregular_cont_write(void)66 coll_irregular_cont_write(void)
67 {
68
69 coll_write_test(0);
70
71 }
72
73
74
75 /*-------------------------------------------------------------------------
76 * Function: coll_irregular_cont_read
77 *
78 * Purpose: Wrapper to test the collectively irregular hyperslab read in
79 * contiguous storage
80 *
81 * Return: Success: 0
82 *
83 * Failure: -1
84 *
85 * Programmer: Unknown
86 * Dec 2nd, 2004
87 *
88 *-------------------------------------------------------------------------
89 */
90 void
coll_irregular_cont_read(void)91 coll_irregular_cont_read(void)
92 {
93
94 coll_read_test(0);
95
96 }
97
98
99 /*-------------------------------------------------------------------------
100 * Function: coll_irregular_simple_chunk_write
101 *
102 * Purpose: Wrapper to test the collectively irregular hyperslab write in
103 * chunk storage(1 chunk)
104 *
105 * Return: Success: 0
106 *
107 * Failure: -1
108 *
109 * Programmer: Unknown
110 * Dec 2nd, 2004
111 *
112 *-------------------------------------------------------------------------
113 */
114 void
coll_irregular_simple_chunk_write(void)115 coll_irregular_simple_chunk_write(void)
116 {
117
118 coll_write_test(1);
119
120 }
121
122
123
124 /*-------------------------------------------------------------------------
125 * Function: coll_irregular_simple_chunk_read
126 *
127 * Purpose: Wrapper to test the collectively irregular hyperslab read in chunk
128 * storage(1 chunk)
129 *
130 * Return: Success: 0
131 *
132 * Failure: -1
133 *
134 * Programmer: Unknown
135 * Dec 2nd, 2004
136 *
137 *-------------------------------------------------------------------------
138 */
139 void
coll_irregular_simple_chunk_read(void)140 coll_irregular_simple_chunk_read(void)
141 {
142
143 coll_read_test(1);
144
145 }
146
147 /*-------------------------------------------------------------------------
148 * Function: coll_irregular_complex_chunk_write
149 *
150 * Purpose: Wrapper to test the collectively irregular hyperslab write in chunk
151 * storage(4 chunks)
152 *
153 * Return: Success: 0
154 *
155 * Failure: -1
156 *
157 * Programmer: Unknown
158 * Dec 2nd, 2004
159 *
160 *-------------------------------------------------------------------------
161 */
162 void
coll_irregular_complex_chunk_write(void)163 coll_irregular_complex_chunk_write(void)
164 {
165
166 coll_write_test(4);
167
168 }
169
170
171
172 /*-------------------------------------------------------------------------
173 * Function: coll_irregular_complex_chunk_read
174 *
175 * Purpose: Wrapper to test the collectively irregular hyperslab read in chunk
176 * storage(1 chunk)
177 *
178 * Return: Success: 0
179 *
180 * Failure: -1
181 *
182 * Programmer: Unknown
183 * Dec 2nd, 2004
184 *
185 *-------------------------------------------------------------------------
186 */
187 void
coll_irregular_complex_chunk_read(void)188 coll_irregular_complex_chunk_read(void)
189 {
190
191 coll_read_test(4);
192
193 }
194
195
196 /*-------------------------------------------------------------------------
197 * Function: coll_write_test
198 *
199 * Purpose: To test the collectively irregular hyperslab write in chunk
200 * storage
201 * Input: number of chunks on each dimension
202 * if number is equal to 0, contiguous storage
203 * Return: Success: 0
204 *
205 * Failure: -1
206 *
207 * Programmer: Unknown
208 * Dec 2nd, 2004
209 *
210 *-------------------------------------------------------------------------
211 */
coll_write_test(int chunk_factor)212 void coll_write_test(int chunk_factor)
213 {
214
215 const char *filename;
216 hid_t facc_plist,dxfer_plist,dcrt_plist;
217 hid_t file, datasetc,dataseti; /* File and dataset identifiers */
218 hid_t mspaceid1, mspaceid, fspaceid,fspaceid1; /* Dataspace identifiers */
219
220 hsize_t mdim1[1]; /* Dimension size of the first dataset (in memory) */
221 hsize_t fsdim[2]; /* Dimension sizes of the dataset (on disk) */
222 hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we
223 * read selection from the dataset on the disk
224 */
225
226 hsize_t start[2]; /* Start of hyperslab */
227 hsize_t stride[2]; /* Stride of hyperslab */
228 hsize_t count[2]; /* Block count */
229 hsize_t block[2]; /* Block sizes */
230 hsize_t chunk_dims[2];
231
232 herr_t ret;
233 unsigned i;
234 int fillvalue = 0; /* Fill value for the dataset */
235
236 int *matrix_out = NULL;
237 int *matrix_out1 = NULL; /* Buffer to read from the dataset */
238 int *vector = NULL;
239
240 int mpi_size,mpi_rank;
241
242 MPI_Comm comm = MPI_COMM_WORLD;
243 MPI_Info info = MPI_INFO_NULL;
244
245 /*set up MPI parameters */
246 MPI_Comm_size(comm,&mpi_size);
247 MPI_Comm_rank(comm,&mpi_rank);
248
249 /* Obtain file name */
250 filename = GetTestParameters();
251
252 /*
253 * Buffers' initialization.
254 */
255
256 mdim1[0] = MSPACE1_DIM *mpi_size;
257 mdim[0] = MSPACE_DIM1;
258 mdim[1] = MSPACE_DIM2*mpi_size;
259 fsdim[0] = FSPACE_DIM1;
260 fsdim[1] = FSPACE_DIM2*mpi_size;
261
262 vector = (int*)HDmalloc(sizeof(int)*mdim1[0]*mpi_size);
263 matrix_out = (int*)HDmalloc(sizeof(int)*mdim[0]*mdim[1]*mpi_size);
264 matrix_out1 = (int*)HDmalloc(sizeof(int)*mdim[0]*mdim[1]*mpi_size);
265
266 HDmemset(vector,0,sizeof(int)*mdim1[0]*mpi_size);
267 vector[0] = vector[MSPACE1_DIM*mpi_size - 1] = -1;
268 for (i = 1; i < MSPACE1_DIM*mpi_size - 1; i++) vector[i] = i;
269
270 /* Grab file access property list */
271 facc_plist = create_faccess_plist(comm, info, facc_type);
272 VRFY((facc_plist >= 0),"");
273
274 /*
275 * Create a file.
276 */
277 file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, facc_plist);
278 VRFY((file >= 0),"H5Fcreate succeeded");
279
280 /*
281 * Create property list for a dataset and set up fill values.
282 */
283 dcrt_plist = H5Pcreate(H5P_DATASET_CREATE);
284 VRFY((dcrt_plist >= 0),"");
285
286 ret = H5Pset_fill_value(dcrt_plist, H5T_NATIVE_INT, &fillvalue);
287 VRFY((ret >= 0),"Fill value creation property list succeeded");
288
289 if(chunk_factor != 0) {
290 chunk_dims[0] = fsdim[0] / chunk_factor;
291 chunk_dims[1] = fsdim[1] / chunk_factor;
292 ret = H5Pset_chunk(dcrt_plist, 2, chunk_dims);
293 VRFY((ret >= 0),"chunk creation property list succeeded");
294 }
295
296 /*
297 *
298 * Create dataspace for the first dataset in the disk.
299 * dim1 = 9
300 * dim2 = 3600
301 *
302 *
303 */
304 fspaceid = H5Screate_simple(FSPACE_RANK, fsdim, NULL);
305 VRFY((fspaceid >= 0),"file dataspace created succeeded");
306
307 /*
308 * Create dataset in the file. Notice that creation
309 * property list dcrt_plist is used.
310 */
311 datasetc = H5Dcreate2(file, "collect_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT);
312 VRFY((datasetc >= 0),"dataset created succeeded");
313
314 dataseti = H5Dcreate2(file, "independ_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT);
315 VRFY((dataseti >= 0),"dataset created succeeded");
316
317 /* The First selection for FILE
318 *
319 * block (3,2)
320 * stride(4,3)
321 * count (1,768/mpi_size)
322 * start (0,1+768*3*mpi_rank/mpi_size)
323 *
324 */
325
326 start[0] = FHSTART0;
327 start[1] = FHSTART1 + mpi_rank * FHSTRIDE1 * FHCOUNT1;
328 stride[0] = FHSTRIDE0;
329 stride[1] = FHSTRIDE1;
330 count[0] = FHCOUNT0;
331 count[1] = FHCOUNT1;
332 block[0] = FHBLOCK0;
333 block[1] = FHBLOCK1;
334
335 ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block);
336 VRFY((ret >= 0),"hyperslab selection succeeded");
337
338 /* The Second selection for FILE
339 *
340 * block (3,768)
341 * stride (1,1)
342 * count (1,1)
343 * start (4,768*mpi_rank/mpi_size)
344 *
345 */
346
347 start[0] = SHSTART0;
348 start[1] = SHSTART1+SHCOUNT1*SHBLOCK1*mpi_rank;
349 stride[0] = SHSTRIDE0;
350 stride[1] = SHSTRIDE1;
351 count[0] = SHCOUNT0;
352 count[1] = SHCOUNT1;
353 block[0] = SHBLOCK0;
354 block[1] = SHBLOCK1;
355
356 ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block);
357 VRFY((ret >= 0),"hyperslab selection succeeded");
358
359 /*
360 * Create dataspace for the first dataset in the memory
361 * dim1 = 27000
362 *
363 */
364 mspaceid1 = H5Screate_simple(MSPACE1_RANK, mdim1, NULL);
365 VRFY((mspaceid1 >= 0),"memory dataspace created succeeded");
366
367 /*
368 * Memory space is 1-D, this is a good test to check
369 * whether a span-tree derived datatype needs to be built.
370 * block 1
371 * stride 1
372 * count 6912/mpi_size
373 * start 1
374 *
375 */
376 start[0] = MHSTART0;
377 stride[0] = MHSTRIDE0;
378 count[0] = MHCOUNT0;
379 block[0] = MHBLOCK0;
380
381 ret = H5Sselect_hyperslab(mspaceid1, H5S_SELECT_SET, start, stride, count, block);
382 VRFY((ret >= 0),"hyperslab selection succeeded");
383
384 /* independent write */
385 ret = H5Dwrite(dataseti, H5T_NATIVE_INT, mspaceid1, fspaceid, H5P_DEFAULT, vector);
386 VRFY((ret >= 0),"dataset independent write succeed");
387
388 dxfer_plist = H5Pcreate(H5P_DATASET_XFER);
389 VRFY((dxfer_plist >= 0),"");
390
391 ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE);
392 VRFY((ret >= 0),"MPIO data transfer property list succeed");
393 if(dxfer_coll_type == DXFER_INDEPENDENT_IO) {
394 ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist,H5FD_MPIO_INDIVIDUAL_IO);
395 VRFY((ret>= 0),"set independent IO collectively succeeded");
396 }
397
398
399 /* collective write */
400 ret = H5Dwrite(datasetc, H5T_NATIVE_INT, mspaceid1, fspaceid, dxfer_plist, vector);
401 VRFY((ret >= 0),"dataset collective write succeed");
402
403 ret = H5Sclose(mspaceid1);
404 VRFY((ret >= 0),"");
405
406 ret = H5Sclose(fspaceid);
407 VRFY((ret >= 0),"");
408
409 /*
410 * Close dataset.
411 */
412 ret = H5Dclose(datasetc);
413 VRFY((ret >= 0),"");
414
415 ret = H5Dclose(dataseti);
416 VRFY((ret >= 0),"");
417
418 /*
419 * Close the file.
420 */
421 ret = H5Fclose(file);
422 VRFY((ret >= 0),"");
423 /*
424 * Close property list
425 */
426
427 ret = H5Pclose(facc_plist);
428 VRFY((ret >= 0),"");
429 ret = H5Pclose(dxfer_plist);
430 VRFY((ret >= 0),"");
431 ret = H5Pclose(dcrt_plist);
432 VRFY((ret >= 0),"");
433
434 /*
435 * Open the file.
436 */
437
438 /***
439
440 For testing collective hyperslab selection write
441 In this test, we are using independent read to check
442 the correctedness of collective write compared with
443 independent write,
444
445 In order to throughly test this feature, we choose
446 a different selection set for reading the data out.
447
448
449 ***/
450
451 /* Obtain file access property list with MPI-IO driver */
452 facc_plist = create_faccess_plist(comm, info, facc_type);
453 VRFY((facc_plist >= 0),"");
454
455 file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist);
456 VRFY((file >= 0),"H5Fopen succeeded");
457
458 /*
459 * Open the dataset.
460 */
461 datasetc = H5Dopen2(file,"collect_write", H5P_DEFAULT);
462 VRFY((datasetc >= 0),"H5Dopen2 succeeded");
463
464 dataseti = H5Dopen2(file,"independ_write", H5P_DEFAULT);
465 VRFY((dataseti >= 0),"H5Dopen2 succeeded");
466
467 /*
468 * Get dataspace of the open dataset.
469 */
470 fspaceid = H5Dget_space(datasetc);
471 VRFY((fspaceid >= 0),"file dataspace obtained succeeded");
472
473 fspaceid1 = H5Dget_space(dataseti);
474 VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded");
475
476
477 /* The First selection for FILE to read
478 *
479 * block (1,1)
480 * stride(1.1)
481 * count (3,768/mpi_size)
482 * start (1,2+768*mpi_rank/mpi_size)
483 *
484 */
485 start[0] = RFFHSTART0;
486 start[1] = RFFHSTART1+mpi_rank*RFFHCOUNT1;
487 block[0] = RFFHBLOCK0;
488 block[1] = RFFHBLOCK1;
489 stride[0] = RFFHSTRIDE0;
490 stride[1] = RFFHSTRIDE1;
491 count[0] = RFFHCOUNT0;
492 count[1] = RFFHCOUNT1;
493
494
495 /* The first selection of the dataset generated by collective write */
496 ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block);
497 VRFY((ret >= 0),"hyperslab selection succeeded");
498
499 /* The first selection of the dataset generated by independent write */
500 ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block);
501 VRFY((ret >= 0),"hyperslab selection succeeded");
502
503 /* The Second selection for FILE to read
504 *
505 * block (1,1)
506 * stride(1.1)
507 * count (3,1536/mpi_size)
508 * start (2,4+1536*mpi_rank/mpi_size)
509 *
510 */
511
512 start[0] = RFSHSTART0;
513 start[1] = RFSHSTART1+RFSHCOUNT1*mpi_rank;
514 block[0] = RFSHBLOCK0;
515 block[1] = RFSHBLOCK1;
516 stride[0] = RFSHSTRIDE0;
517 stride[1] = RFSHSTRIDE0;
518 count[0] = RFSHCOUNT0;
519 count[1] = RFSHCOUNT1;
520
521 /* The second selection of the dataset generated by collective write */
522 ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block);
523 VRFY((ret >= 0),"hyperslab selection succeeded");
524
525 /* The second selection of the dataset generated by independent write */
526 ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block);
527 VRFY((ret >= 0),"hyperslab selection succeeded");
528
529 /*
530 * Create memory dataspace.
531 * rank = 2
532 * mdim1 = 9
533 * mdim2 = 3600
534 *
535 */
536 mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL);
537
538 /*
539 * Select two hyperslabs in memory. Hyperslabs has the same
540 * size and shape as the selected hyperslabs for the file dataspace
541 * Only the starting point is different.
542 * The first selection
543 * block (1,1)
544 * stride(1.1)
545 * count (3,768/mpi_size)
546 * start (0,768*mpi_rank/mpi_size)
547 *
548 */
549
550
551 start[0] = RMFHSTART0;
552 start[1] = RMFHSTART1+mpi_rank*RMFHCOUNT1;
553 block[0] = RMFHBLOCK0;
554 block[1] = RMFHBLOCK1;
555 stride[0] = RMFHSTRIDE0;
556 stride[1] = RMFHSTRIDE1;
557 count[0] = RMFHCOUNT0;
558 count[1] = RMFHCOUNT1;
559
560 ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block);
561 VRFY((ret >= 0),"hyperslab selection succeeded");
562
563 /*
564 * Select two hyperslabs in memory. Hyperslabs has the same
565 * size and shape as the selected hyperslabs for the file dataspace
566 * Only the starting point is different.
567 * The second selection
568 * block (1,1)
569 * stride(1,1)
570 * count (3,1536/mpi_size)
571 * start (1,2+1536*mpi_rank/mpi_size)
572 *
573 */
574 start[0] = RMSHSTART0;
575 start[1] = RMSHSTART1+mpi_rank*RMSHCOUNT1;
576 block[0] = RMSHBLOCK0;
577 block[1] = RMSHBLOCK1;
578 stride[0] = RMSHSTRIDE0;
579 stride[1] = RMSHSTRIDE1;
580 count[0] = RMSHCOUNT0;
581 count[1] = RMSHCOUNT1;
582
583 ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block);
584 VRFY((ret >= 0),"hyperslab selection succeeded");
585
586 /*
587 * Initialize data buffer.
588 */
589
590 HDmemset(matrix_out,0,sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
591 HDmemset(matrix_out1,0,sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
592 /*
593 * Read data back to the buffer matrix_out.
594 */
595
596 ret = H5Dread(datasetc, H5T_NATIVE_INT, mspaceid, fspaceid,
597 H5P_DEFAULT, matrix_out);
598 VRFY((ret >= 0),"H5D independent read succeed");
599
600
601 ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid,
602 H5P_DEFAULT, matrix_out1);
603 VRFY((ret >= 0),"H5D independent read succeed");
604
605 ret = 0;
606
607 for (i = 0; i < MSPACE_DIM1*MSPACE_DIM2*mpi_size; i++){
608 if(matrix_out[i]!=matrix_out1[i]) ret = -1;
609 if(ret < 0) break;
610 }
611
612 VRFY((ret >= 0),"H5D irregular collective write succeed");
613
614 /*
615 * Close memory file and memory dataspaces.
616 */
617 ret = H5Sclose(mspaceid);
618 VRFY((ret >= 0),"");
619 ret = H5Sclose(fspaceid);
620 VRFY((ret >= 0),"");
621
622 /*
623 * Close dataset.
624 */
625 ret = H5Dclose(dataseti);
626 VRFY((ret >= 0),"");
627
628 ret = H5Dclose(datasetc);
629 VRFY((ret >= 0),"");
630
631 /*
632 * Close property list
633 */
634
635 ret = H5Pclose(facc_plist);
636 VRFY((ret >= 0),"");
637
638
639 /*
640 * Close the file.
641 */
642 ret = H5Fclose(file);
643 VRFY((ret >= 0),"");
644
645 if (vector)
646 HDfree(vector);
647 if (matrix_out)
648 HDfree(matrix_out);
649 if (matrix_out1)
650 HDfree(matrix_out1);
651
652 return ;
653 }
654
655 /*-------------------------------------------------------------------------
656 * Function: coll_read_test
657 *
658 * Purpose: To test the collectively irregular hyperslab read in chunk
659 * storage
660 * Input: number of chunks on each dimension
661 * if number is equal to 0, contiguous storage
662 * Return: Success: 0
663 *
664 * Failure: -1
665 *
666 * Programmer: Unknown
667 * Dec 2nd, 2004
668 *
669 *-------------------------------------------------------------------------
670 */
671 static void
coll_read_test(int chunk_factor)672 coll_read_test(int chunk_factor)
673 {
674
675 const char *filename;
676 hid_t facc_plist,dxfer_plist;
677 hid_t file, dataseti; /* File and dataset identifiers */
678 hid_t mspaceid, fspaceid1; /* Dataspace identifiers */
679
680
681 /* Dimension sizes of the dataset (on disk) */
682 hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we
683 * read selection from the dataset on the disk
684 */
685
686 hsize_t start[2]; /* Start of hyperslab */
687 hsize_t stride[2]; /* Stride of hyperslab */
688 hsize_t count[2]; /* Block count */
689 hsize_t block[2]; /* Block sizes */
690 herr_t ret;
691
692 unsigned i;
693
694 int *matrix_out;
695 int *matrix_out1; /* Buffer to read from the dataset */
696
697 int mpi_size,mpi_rank;
698
699 MPI_Comm comm = MPI_COMM_WORLD;
700 MPI_Info info = MPI_INFO_NULL;
701
702 /*set up MPI parameters */
703 MPI_Comm_size(comm,&mpi_size);
704 MPI_Comm_rank(comm,&mpi_rank);
705
706
707 /* Obtain file name */
708 filename = GetTestParameters();
709
710
711 /* Initialize the buffer */
712
713 mdim[0] = MSPACE_DIM1;
714 mdim[1] = MSPACE_DIM2*mpi_size;
715 matrix_out =(int*)HDmalloc(sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
716 matrix_out1=(int*)HDmalloc(sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
717
718 /*** For testing collective hyperslab selection read ***/
719
720 /* Obtain file access property list */
721 facc_plist = create_faccess_plist(comm, info, facc_type);
722 VRFY((facc_plist >= 0),"");
723
724 /*
725 * Open the file.
726 */
727 file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist);
728 VRFY((file >= 0),"H5Fopen succeeded");
729
730 /*
731 * Open the dataset.
732 */
733 dataseti = H5Dopen2(file,"independ_write", H5P_DEFAULT);
734 VRFY((dataseti >= 0),"H5Dopen2 succeeded");
735
736 /*
737 * Get dataspace of the open dataset.
738 */
739 fspaceid1 = H5Dget_space(dataseti);
740 VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded");
741
742 /* The First selection for FILE to read
743 *
744 * block (1,1)
745 * stride(1.1)
746 * count (3,768/mpi_size)
747 * start (1,2+768*mpi_rank/mpi_size)
748 *
749 */
750 start[0] = RFFHSTART0;
751 start[1] = RFFHSTART1+mpi_rank*RFFHCOUNT1;
752 block[0] = RFFHBLOCK0;
753 block[1] = RFFHBLOCK1;
754 stride[0] = RFFHSTRIDE0;
755 stride[1] = RFFHSTRIDE1;
756 count[0] = RFFHCOUNT0;
757 count[1] = RFFHCOUNT1;
758
759 ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block);
760 VRFY((ret >= 0),"hyperslab selection succeeded");
761
762 /* The Second selection for FILE to read
763 *
764 * block (1,1)
765 * stride(1.1)
766 * count (3,1536/mpi_size)
767 * start (2,4+1536*mpi_rank/mpi_size)
768 *
769 */
770 start[0] = RFSHSTART0;
771 start[1] = RFSHSTART1+RFSHCOUNT1*mpi_rank;
772 block[0] = RFSHBLOCK0;
773 block[1] = RFSHBLOCK1;
774 stride[0] = RFSHSTRIDE0;
775 stride[1] = RFSHSTRIDE0;
776 count[0] = RFSHCOUNT0;
777 count[1] = RFSHCOUNT1;
778
779 ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block);
780 VRFY((ret >= 0),"hyperslab selection succeeded");
781
782
783 /*
784 * Create memory dataspace.
785 */
786 mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL);
787
788 /*
789 * Select two hyperslabs in memory. Hyperslabs has the same
790 * size and shape as the selected hyperslabs for the file dataspace.
791 * Only the starting point is different.
792 * The first selection
793 * block (1,1)
794 * stride(1.1)
795 * count (3,768/mpi_size)
796 * start (0,768*mpi_rank/mpi_size)
797 *
798 */
799
800 start[0] = RMFHSTART0;
801 start[1] = RMFHSTART1+mpi_rank*RMFHCOUNT1;
802 block[0] = RMFHBLOCK0;
803 block[1] = RMFHBLOCK1;
804 stride[0] = RMFHSTRIDE0;
805 stride[1] = RMFHSTRIDE1;
806 count[0] = RMFHCOUNT0;
807 count[1] = RMFHCOUNT1;
808 ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block);
809 VRFY((ret >= 0),"hyperslab selection succeeded");
810
811 /*
812 * Select two hyperslabs in memory. Hyperslabs has the same
813 * size and shape as the selected hyperslabs for the file dataspace
814 * Only the starting point is different.
815 * The second selection
816 * block (1,1)
817 * stride(1,1)
818 * count (3,1536/mpi_size)
819 * start (1,2+1536*mpi_rank/mpi_size)
820 *
821 */
822 start[0] = RMSHSTART0;
823 start[1] = RMSHSTART1+mpi_rank*RMSHCOUNT1;
824 block[0] = RMSHBLOCK0;
825 block[1] = RMSHBLOCK1;
826 stride[0] = RMSHSTRIDE0;
827 stride[1] = RMSHSTRIDE1;
828 count[0] = RMSHCOUNT0;
829 count[1] = RMSHCOUNT1;
830 ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block);
831 VRFY((ret >= 0),"hyperslab selection succeeded");
832
833
834 /*
835 * Initialize data buffer.
836 */
837
838 HDmemset(matrix_out,0,sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
839 HDmemset(matrix_out1,0,sizeof(int)*MSPACE_DIM1*MSPACE_DIM2*mpi_size);
840
841 /*
842 * Read data back to the buffer matrix_out.
843 */
844
845 dxfer_plist = H5Pcreate(H5P_DATASET_XFER);
846 VRFY((dxfer_plist >= 0),"");
847
848 ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE);
849 VRFY((ret >= 0),"MPIO data transfer property list succeed");
850 if(dxfer_coll_type == DXFER_INDEPENDENT_IO) {
851 ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist,H5FD_MPIO_INDIVIDUAL_IO);
852 VRFY((ret>= 0),"set independent IO collectively succeeded");
853 }
854
855
856 /* Collective read */
857 ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1,
858 dxfer_plist, matrix_out);
859 VRFY((ret >= 0),"H5D collecive read succeed");
860
861 ret = H5Pclose(dxfer_plist);
862 VRFY((ret >= 0),"");
863
864 /* Independent read */
865 ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1,
866 H5P_DEFAULT, matrix_out1);
867 VRFY((ret >= 0),"H5D independent read succeed");
868
869 ret = 0;
870 for (i = 0; i < MSPACE_DIM1*MSPACE_DIM2*mpi_size; i++){
871 if(matrix_out[i]!=matrix_out1[i])ret = -1;
872 if(ret < 0) break;
873 }
874 VRFY((ret >= 0),"H5D contiguous irregular collective read succeed");
875
876 /*
877 * Close memory file and memory dataspaces.
878 */
879 ret = H5Sclose(mspaceid);
880 VRFY((ret >= 0),"");
881 ret = H5Sclose(fspaceid1);
882 VRFY((ret >= 0),"");
883
884 /*
885 * Close dataset.
886 */
887 ret = H5Dclose(dataseti);
888 VRFY((ret >= 0),"");
889
890 /*
891 * Close property list
892 */
893 ret = H5Pclose(facc_plist);
894 VRFY((ret >= 0),"");
895
896
897 /*
898 * Close the file.
899 */
900 ret = H5Fclose(file);
901 VRFY((ret >= 0),"");
902
903 return;
904 }
905
906
907 /****************************************************************
908 **
909 ** lower_dim_size_comp_test__select_checker_board():
910 **
911 ** Given a dataspace of tgt_rank, and dimensions:
912 **
913 ** (mpi_size + 1), edge_size, ... , edge_size
914 **
915 ** edge_size, and a checker_edge_size, select a checker
916 ** board selection of a sel_rank (sel_rank < tgt_rank)
917 ** dimensional slice through the dataspace parallel to the
918 ** sel_rank fastest changing indicies, with origin (in the
919 ** higher indicies) as indicated by the start array.
920 **
921 ** Note that this function, is hard coded to presume a
922 ** maximum dataspace rank of 5.
923 **
924 ** While this maximum is declared as a constant, increasing
925 ** it will require extensive coding in addition to changing
926 ** the value of the constant.
927 **
928 ** JRM -- 11/11/09
929 **
930 ****************************************************************/
931
932 #define LDSCT_DS_RANK 5
933 #define LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK 0
934
935 #define LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG 0
936
937 static void
lower_dim_size_comp_test__select_checker_board(const int mpi_rank,const hid_t tgt_sid,const int tgt_rank,const hsize_t dims[LDSCT_DS_RANK],const int checker_edge_size,const int sel_rank,hsize_t sel_start[])938 lower_dim_size_comp_test__select_checker_board(
939 const int mpi_rank,
940 const hid_t tgt_sid,
941 const int tgt_rank,
942 const hsize_t dims[LDSCT_DS_RANK],
943 const int checker_edge_size,
944 const int sel_rank,
945 hsize_t sel_start[])
946 {
947 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
948 const char * fcnName =
949 "lower_dim_size_comp_test__select_checker_board():";
950 #endif
951 hbool_t first_selection = TRUE;
952 int i, j, k, l, m;
953 int ds_offset;
954 int sel_offset;
955 const int test_max_rank = LDSCT_DS_RANK; /* must update code if */
956 /* this changes */
957 hsize_t base_count;
958 hsize_t offset_count;
959 hsize_t start[LDSCT_DS_RANK];
960 hsize_t stride[LDSCT_DS_RANK];
961 hsize_t count[LDSCT_DS_RANK];
962 hsize_t block[LDSCT_DS_RANK];
963 herr_t ret; /* Generic return value */
964
965 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
966 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
967 HDfprintf(stdout,
968 "%s:%d: dims/checker_edge_size = %d %d %d %d %d / %d\n",
969 fcnName, mpi_rank, (int)dims[0], (int)dims[1], (int)dims[2],
970 (int)dims[3], (int)dims[4], checker_edge_size);
971 }
972 #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */
973
974 HDassert( 0 < checker_edge_size );
975 HDassert( 0 < sel_rank );
976 HDassert( sel_rank <= tgt_rank );
977 HDassert( tgt_rank <= test_max_rank );
978 HDassert( test_max_rank <= LDSCT_DS_RANK );
979
980 sel_offset = test_max_rank - sel_rank;
981 HDassert( sel_offset >= 0 );
982
983 ds_offset = test_max_rank - tgt_rank;
984 HDassert( ds_offset >= 0 );
985 HDassert( ds_offset <= sel_offset );
986
987 HDassert( (hsize_t)checker_edge_size <= dims[sel_offset] );
988 HDassert( dims[sel_offset] == 10 );
989
990 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
991 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
992 HDfprintf(stdout, "%s:%d: sel_rank/sel_offset = %d/%d.\n",
993 fcnName, mpi_rank, sel_rank, sel_offset);
994 HDfprintf(stdout, "%s:%d: tgt_rank/ds_offset = %d/%d.\n",
995 fcnName, mpi_rank, tgt_rank, ds_offset);
996 }
997 #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */
998
999 /* First, compute the base count (which assumes start == 0
1000 * for the associated offset) and offset_count (which
1001 * assumes start == checker_edge_size for the associated
1002 * offset).
1003 *
1004 * Note that the following computation depends on the C99
1005 * requirement that integer division discard any fraction
1006 * (truncation towards zero) to function correctly. As we
1007 * now require C99, this shouldn't be a problem, but noting
1008 * it may save us some pain if we are ever obliged to support
1009 * pre-C99 compilers again.
1010 */
1011
1012 base_count = dims[sel_offset] / (checker_edge_size * 2);
1013
1014 if ( (dims[sel_rank] % (checker_edge_size * 2)) > 0 ) {
1015
1016 base_count++;
1017 }
1018
1019 offset_count =
1020 (hsize_t)((dims[sel_offset] - (hsize_t)checker_edge_size) /
1021 ((hsize_t)(checker_edge_size * 2)));
1022
1023 if ( ((dims[sel_rank] - (hsize_t)checker_edge_size) %
1024 ((hsize_t)(checker_edge_size * 2))) > 0 ) {
1025
1026 offset_count++;
1027 }
1028
1029 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
1030 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1031 HDfprintf(stdout, "%s:%d: base_count/offset_count = %d/%d.\n",
1032 fcnName, mpi_rank, base_count, offset_count);
1033 }
1034 #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */
1035
1036 /* Now set up the stride and block arrays, and portions of the start
1037 * and count arrays that will not be altered during the selection of
1038 * the checker board.
1039 */
1040 i = 0;
1041 while ( i < ds_offset ) {
1042
1043 /* these values should never be used */
1044 start[i] = 0;
1045 stride[i] = 0;
1046 count[i] = 0;
1047 block[i] = 0;
1048
1049 i++;
1050 }
1051
1052 while ( i < sel_offset ) {
1053
1054 start[i] = sel_start[i];
1055 stride[i] = 2 * dims[i];
1056 count[i] = 1;
1057 block[i] = 1;
1058
1059 i++;
1060 }
1061
1062 while ( i < test_max_rank ) {
1063
1064 stride[i] = (hsize_t)(2 * checker_edge_size);
1065 block[i] = (hsize_t)checker_edge_size;
1066
1067 i++;
1068 }
1069
1070 i = 0;
1071 do {
1072 if ( 0 >= sel_offset ) {
1073
1074 if ( i == 0 ) {
1075
1076 start[0] = 0;
1077 count[0] = base_count;
1078
1079 } else {
1080
1081 start[0] = (hsize_t)checker_edge_size;
1082 count[0] = offset_count;
1083
1084 }
1085 }
1086
1087 j = 0;
1088 do {
1089 if ( 1 >= sel_offset ) {
1090
1091 if ( j == 0 ) {
1092
1093 start[1] = 0;
1094 count[1] = base_count;
1095
1096 } else {
1097
1098 start[1] = (hsize_t)checker_edge_size;
1099 count[1] = offset_count;
1100
1101 }
1102 }
1103
1104 k = 0;
1105 do {
1106 if ( 2 >= sel_offset ) {
1107
1108 if ( k == 0 ) {
1109
1110 start[2] = 0;
1111 count[2] = base_count;
1112
1113 } else {
1114
1115 start[2] = (hsize_t)checker_edge_size;
1116 count[2] = offset_count;
1117
1118 }
1119 }
1120
1121 l = 0;
1122 do {
1123 if ( 3 >= sel_offset ) {
1124
1125 if ( l == 0 ) {
1126
1127 start[3] = 0;
1128 count[3] = base_count;
1129
1130 } else {
1131
1132 start[3] = (hsize_t)checker_edge_size;
1133 count[3] = offset_count;
1134
1135 }
1136 }
1137
1138 m = 0;
1139 do {
1140 if ( 4 >= sel_offset ) {
1141
1142 if ( m == 0 ) {
1143
1144 start[4] = 0;
1145 count[4] = base_count;
1146
1147 } else {
1148
1149 start[4] = (hsize_t)checker_edge_size;
1150 count[4] = offset_count;
1151
1152 }
1153 }
1154
1155 if ( ((i + j + k + l + m) % 2) == 0 ) {
1156
1157 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
1158 if ( mpi_rank ==
1159 LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1160
1161 HDfprintf(stdout,
1162 "%s%d: *** first_selection = %d ***\n",
1163 fcnName, mpi_rank, (int)first_selection);
1164 HDfprintf(stdout,
1165 "%s:%d: i/j/k/l/m = %d/%d/%d/%d/%d\n",
1166 fcnName, mpi_rank, i, j, k, l, m);
1167 HDfprintf(stdout,
1168 "%s:%d: start = %d %d %d %d %d.\n",
1169 fcnName, mpi_rank,
1170 (int)start[0], (int)start[1],
1171 (int)start[2], (int)start[3],
1172 (int)start[4]);
1173 HDfprintf(stdout,
1174 "%s:%d: stride = %d %d %d %d %d.\n",
1175 fcnName, mpi_rank,
1176 (int)stride[0], (int)stride[1],
1177 (int)stride[2], (int)stride[3],
1178 (int)stride[4]);
1179 HDfprintf(stdout,
1180 "%s:%d: count = %d %d %d %d %d.\n",
1181 fcnName, mpi_rank,
1182 (int)count[0], (int)count[1],
1183 (int)count[2], (int)count[3],
1184 (int)count[4]);
1185 HDfprintf(stdout,
1186 "%s:%d: block = %d %d %d %d %d.\n",
1187 fcnName, mpi_rank,
1188 (int)block[0], (int)block[1],
1189 (int)block[2], (int)block[3],
1190 (int)block[4]);
1191 HDfprintf(stdout,
1192 "%s:%d: n-cube extent dims = %d.\n",
1193 fcnName, mpi_rank,
1194 H5Sget_simple_extent_ndims(tgt_sid));
1195 HDfprintf(stdout,
1196 "%s:%d: selection rank = %d.\n",
1197 fcnName, mpi_rank, sel_rank);
1198 }
1199 #endif
1200
1201 if ( first_selection ) {
1202
1203 first_selection = FALSE;
1204
1205 ret = H5Sselect_hyperslab
1206 (
1207 tgt_sid,
1208 H5S_SELECT_SET,
1209 &(start[ds_offset]),
1210 &(stride[ds_offset]),
1211 &(count[ds_offset]),
1212 &(block[ds_offset])
1213 );
1214
1215 VRFY((ret != FAIL), "H5Sselect_hyperslab(SET) succeeded");
1216
1217 } else {
1218
1219 ret = H5Sselect_hyperslab
1220 (
1221 tgt_sid,
1222 H5S_SELECT_OR,
1223 &(start[ds_offset]),
1224 &(stride[ds_offset]),
1225 &(count[ds_offset]),
1226 &(block[ds_offset])
1227 );
1228
1229 VRFY((ret != FAIL), "H5Sselect_hyperslab(OR) succeeded");
1230
1231 }
1232 }
1233
1234 m++;
1235
1236 } while ( ( m <= 1 ) &&
1237 ( 4 >= sel_offset ) );
1238
1239 l++;
1240
1241 } while ( ( l <= 1 ) &&
1242 ( 3 >= sel_offset ) );
1243
1244 k++;
1245
1246 } while ( ( k <= 1 ) &&
1247 ( 2 >= sel_offset ) );
1248
1249 j++;
1250
1251 } while ( ( j <= 1 ) &&
1252 ( 1 >= sel_offset ) );
1253
1254
1255 i++;
1256
1257 } while ( ( i <= 1 ) &&
1258 ( 0 >= sel_offset ) );
1259
1260 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
1261 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1262 HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n",
1263 fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid));
1264 }
1265 #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */
1266
1267 /* Clip the selection back to the dataspace proper. */
1268
1269 for ( i = 0; i < test_max_rank; i++ ) {
1270
1271 start[i] = 0;
1272 stride[i] = dims[i];
1273 count[i] = 1;
1274 block[i] = dims[i];
1275 }
1276
1277 ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_AND,
1278 start, stride, count, block);
1279
1280 VRFY((ret != FAIL), "H5Sselect_hyperslab(AND) succeeded");
1281
1282 #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG
1283 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1284 HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n",
1285 fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid));
1286 HDfprintf(stdout, "%s%d: done.\n", fcnName, mpi_rank);
1287 }
1288 #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */
1289
1290 return;
1291
1292 } /* lower_dim_size_comp_test__select_checker_board() */
1293
1294
1295 /****************************************************************
1296 **
1297 ** lower_dim_size_comp_test__verify_data():
1298 **
1299 ** Examine the supplied buffer to see if it contains the
1300 ** expected data. Return TRUE if it does, and FALSE
1301 ** otherwise.
1302 **
1303 ** The supplied buffer is presumed to this process's slice
1304 ** of the target data set. Each such slice will be an
1305 ** n-cube of rank (rank -1) and the supplied edge_size with
1306 ** origin (mpi_rank, 0, ... , 0) in the target data set.
1307 **
1308 ** Further, the buffer is presumed to be the result of reading
1309 ** or writing a checker board selection of an m (1 <= m <
1310 ** rank) dimensional slice through this processes slice
1311 ** of the target data set. Also, this slice must be parallel
1312 ** to the fastest changing indicies.
1313 **
1314 ** It is further presumed that the buffer was zeroed before
1315 ** the read/write, and that the full target data set (i.e.
1316 ** the buffer/data set for all processes) was initialized
1317 ** with the natural numbers listed in order from the origin
1318 ** along the fastest changing axis.
1319 **
1320 ** Thus for a 20x10x10 dataset, the value stored in location
1321 ** (x, y, z) (assuming that z is the fastest changing index
1322 ** and x the slowest) is assumed to be:
1323 **
1324 ** (10 * 10 * x) + (10 * y) + z
1325 **
1326 ** Further, supposing that this is process 10, this process's
1327 ** slice of the dataset would be a 10 x 10 2-cube with origin
1328 ** (10, 0, 0) in the data set, and would be initialize (prior
1329 ** to the checkerboard selection) as follows:
1330 **
1331 ** 1000, 1001, 1002, ... 1008, 1009
1332 ** 1010, 1011, 1012, ... 1018, 1019
1333 ** . . . . .
1334 ** . . . . .
1335 ** . . . . .
1336 ** 1090, 1091, 1092, ... 1098, 1099
1337 **
1338 ** In the case of a read from the processors slice of another
1339 ** data set of different rank, the values expected will have
1340 ** to be adjusted accordingly. This is done via the
1341 ** first_expected_val parameter.
1342 **
1343 ** Finally, the function presumes that the first element
1344 ** of the buffer resides either at the origin of either
1345 ** a selected or an unselected checker. (Translation:
1346 ** if partial checkers appear in the buffer, they will
1347 ** intersect the edges of the n-cube oposite the origin.)
1348 **
1349 ****************************************************************/
1350
1351 #define LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG 0
1352
1353 static hbool_t
lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr,const int mpi_rank,const int rank,const int edge_size,const int checker_edge_size,uint32_t first_expected_val,hbool_t buf_starts_in_checker)1354 lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr,
1355 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1356 const int mpi_rank,
1357 #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */
1358 const int rank,
1359 const int edge_size,
1360 const int checker_edge_size,
1361 uint32_t first_expected_val,
1362 hbool_t buf_starts_in_checker)
1363 {
1364 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1365 const char * fcnName =
1366 "lower_dim_size_comp_test__verify_data():";
1367 #endif
1368 hbool_t good_data = TRUE;
1369 hbool_t in_checker;
1370 hbool_t start_in_checker[5];
1371 uint32_t expected_value;
1372 uint32_t * val_ptr;
1373 int i, j, k, l, m; /* to track position in n-cube */
1374 int v, w, x, y, z; /* to track position in checker */
1375 const int test_max_rank = 5; /* code changes needed if this is increased */
1376
1377 HDassert( buf_ptr != NULL );
1378 HDassert( 0 < rank );
1379 HDassert( rank <= test_max_rank );
1380 HDassert( edge_size >= 6 );
1381 HDassert( 0 < checker_edge_size );
1382 HDassert( checker_edge_size <= edge_size );
1383 HDassert( test_max_rank <= LDSCT_DS_RANK );
1384
1385 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1386 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1387 HDfprintf(stdout, "%s mpi_rank = %d.\n", fcnName, mpi_rank);
1388 HDfprintf(stdout, "%s rank = %d.\n", fcnName, rank);
1389 HDfprintf(stdout, "%s edge_size = %d.\n", fcnName, edge_size);
1390 HDfprintf(stdout, "%s checker_edge_size = %d.\n",
1391 fcnName, checker_edge_size);
1392 HDfprintf(stdout, "%s first_expected_val = %d.\n",
1393 fcnName, (int)first_expected_val);
1394 HDfprintf(stdout, "%s starts_in_checker = %d.\n",
1395 fcnName, (int)buf_starts_in_checker);
1396 }
1397 #endif
1398
1399 val_ptr = buf_ptr;
1400 expected_value = first_expected_val;
1401
1402 i = 0;
1403 v = 0;
1404 start_in_checker[0] = buf_starts_in_checker;
1405 do
1406 {
1407 if ( v >= checker_edge_size ) {
1408
1409 start_in_checker[0] = ! start_in_checker[0];
1410 v = 0;
1411 }
1412
1413 j = 0;
1414 w = 0;
1415 start_in_checker[1] = start_in_checker[0];
1416 do
1417 {
1418 if ( w >= checker_edge_size ) {
1419
1420 start_in_checker[1] = ! start_in_checker[1];
1421 w = 0;
1422 }
1423
1424 k = 0;
1425 x = 0;
1426 start_in_checker[2] = start_in_checker[1];
1427 do
1428 {
1429 if ( x >= checker_edge_size ) {
1430
1431 start_in_checker[2] = ! start_in_checker[2];
1432 x = 0;
1433 }
1434
1435 l = 0;
1436 y = 0;
1437 start_in_checker[3] = start_in_checker[2];
1438 do
1439 {
1440 if ( y >= checker_edge_size ) {
1441
1442 start_in_checker[3] = ! start_in_checker[3];
1443 y = 0;
1444 }
1445
1446 m = 0;
1447 z = 0;
1448 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1449 if ( mpi_rank ==
1450 LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1451 HDfprintf(stdout, "%d, %d, %d, %d, %d:", i, j, k, l, m);
1452 }
1453 #endif
1454 in_checker = start_in_checker[3];
1455 do
1456 {
1457 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1458 if ( mpi_rank ==
1459 LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1460 HDfprintf(stdout, " %d", (int)(*val_ptr));
1461 }
1462 #endif
1463 if ( z >= checker_edge_size ) {
1464
1465 in_checker = ! in_checker;
1466 z = 0;
1467 }
1468
1469 if ( in_checker ) {
1470
1471 if ( *val_ptr != expected_value ) {
1472
1473 good_data = FALSE;
1474 }
1475
1476 /* zero out buffer for re-use */
1477 *val_ptr = 0;
1478
1479 } else if ( *val_ptr != 0 ) {
1480
1481 good_data = FALSE;
1482
1483 /* zero out buffer for re-use */
1484 *val_ptr = 0;
1485
1486 }
1487
1488 val_ptr++;
1489 expected_value++;
1490 m++;
1491 z++;
1492
1493 } while ( ( rank >= (test_max_rank - 4) ) &&
1494 ( m < edge_size ) );
1495 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
1496 if ( mpi_rank ==
1497 LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1498 HDfprintf(stdout, "\n");
1499 }
1500 #endif
1501 l++;
1502 y++;
1503 } while ( ( rank >= (test_max_rank - 3) ) &&
1504 ( l < edge_size ) );
1505 k++;
1506 x++;
1507 } while ( ( rank >= (test_max_rank - 2) ) &&
1508 ( k < edge_size ) );
1509 j++;
1510 w++;
1511 } while ( ( rank >= (test_max_rank - 1) ) &&
1512 ( j < edge_size ) );
1513 i++;
1514 v++;
1515 } while ( ( rank >= test_max_rank ) &&
1516 ( i < edge_size ) );
1517
1518 return(good_data);
1519
1520 } /* lower_dim_size_comp_test__verify_data() */
1521
1522
1523 /*-------------------------------------------------------------------------
1524 * Function: lower_dim_size_comp_test__run_test()
1525 *
1526 * Purpose: Verify that a bug in the computation of the size of the
1527 * lower dimensions of a dataspace in H5S_obtain_datatype()
1528 * has been corrected.
1529 *
1530 * Return: void
1531 *
1532 * Programmer: JRM -- 11/11/09
1533 *
1534 *-------------------------------------------------------------------------
1535 */
1536
1537 #define LDSCT_DS_RANK 5
1538 #define LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG 0
1539
1540 static void
lower_dim_size_comp_test__run_test(const int chunk_edge_size,const hbool_t use_collective_io,const hid_t dset_type)1541 lower_dim_size_comp_test__run_test(const int chunk_edge_size,
1542 const hbool_t use_collective_io,
1543 const hid_t dset_type)
1544 {
1545 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1546 const char *fcnName = "lower_dim_size_comp_test__run_test()";
1547 int rank;
1548 hsize_t dims[32];
1549 hsize_t max_dims[32];
1550 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1551 const char *filename;
1552 hbool_t data_ok = FALSE;
1553 hbool_t mis_match = FALSE;
1554 int i;
1555 int start_index;
1556 int stop_index;
1557 int mrc;
1558 int mpi_rank;
1559 int mpi_size;
1560 MPI_Comm mpi_comm = MPI_COMM_NULL;
1561 MPI_Info mpi_info = MPI_INFO_NULL;
1562 hid_t fid; /* HDF5 file ID */
1563 hid_t acc_tpl; /* File access templates */
1564 hid_t xfer_plist = H5P_DEFAULT;
1565 size_t small_ds_size;
1566 size_t small_ds_slice_size;
1567 size_t large_ds_size;
1568 size_t large_ds_slice_size;
1569 uint32_t expected_value;
1570 uint32_t * small_ds_buf_0 = NULL;
1571 uint32_t * small_ds_buf_1 = NULL;
1572 uint32_t * large_ds_buf_0 = NULL;
1573 uint32_t * large_ds_buf_1 = NULL;
1574 uint32_t * ptr_0;
1575 uint32_t * ptr_1;
1576 hsize_t small_chunk_dims[LDSCT_DS_RANK];
1577 hsize_t large_chunk_dims[LDSCT_DS_RANK];
1578 hsize_t small_dims[LDSCT_DS_RANK];
1579 hsize_t large_dims[LDSCT_DS_RANK];
1580 hsize_t start[LDSCT_DS_RANK];
1581 hsize_t stride[LDSCT_DS_RANK];
1582 hsize_t count[LDSCT_DS_RANK];
1583 hsize_t block[LDSCT_DS_RANK];
1584 hsize_t small_sel_start[LDSCT_DS_RANK];
1585 hsize_t large_sel_start[LDSCT_DS_RANK];
1586 hid_t full_mem_small_ds_sid;
1587 hid_t full_file_small_ds_sid;
1588 hid_t mem_small_ds_sid;
1589 hid_t file_small_ds_sid;
1590 hid_t full_mem_large_ds_sid;
1591 hid_t full_file_large_ds_sid;
1592 hid_t mem_large_ds_sid;
1593 hid_t file_large_ds_sid;
1594 hid_t small_ds_dcpl_id = H5P_DEFAULT;
1595 hid_t large_ds_dcpl_id = H5P_DEFAULT;
1596 hid_t small_dataset; /* Dataset ID */
1597 hid_t large_dataset; /* Dataset ID */
1598 htri_t check; /* Shape comparison return value */
1599 herr_t ret; /* Generic return value */
1600
1601 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
1602 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
1603
1604 HDassert( mpi_size >= 1 );
1605
1606 mpi_comm = MPI_COMM_WORLD;
1607 mpi_info = MPI_INFO_NULL;
1608
1609 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1610 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1611 HDfprintf(stdout, "%s:%d: chunk_edge_size = %d.\n",
1612 fcnName, mpi_rank, (int)chunk_edge_size);
1613 HDfprintf(stdout, "%s:%d: use_collective_io = %d.\n",
1614 fcnName, mpi_rank, (int)use_collective_io);
1615 }
1616 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1617
1618
1619 small_ds_size = (size_t)((mpi_size + 1) * 1 * 1 * 10 * 10);
1620 small_ds_slice_size = (size_t) ( 1 * 1 * 10 * 10);
1621 large_ds_size = (size_t)((mpi_size + 1) * 10 * 10 * 10 * 10);
1622 large_ds_slice_size = (size_t) (10 * 10 * 10 * 10);
1623
1624 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1625 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1626 HDfprintf(stdout, "%s:%d: small ds size / slice size = %d / %d.\n",
1627 fcnName, mpi_rank,
1628 (int)small_ds_size, (int)small_ds_slice_size);
1629 HDfprintf(stdout, "%s:%d: large ds size / slice size = %d / %d.\n",
1630 fcnName, mpi_rank,
1631 (int)large_ds_size, (int)large_ds_slice_size);
1632 }
1633 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1634
1635 /* Allocate buffers */
1636 small_ds_buf_0 = (uint32_t *)HDmalloc(sizeof(uint32_t) * small_ds_size);
1637 VRFY((small_ds_buf_0 != NULL), "malloc of small_ds_buf_0 succeeded");
1638
1639 small_ds_buf_1 = (uint32_t *)HDmalloc(sizeof(uint32_t) * small_ds_size);
1640 VRFY((small_ds_buf_1 != NULL), "malloc of small_ds_buf_1 succeeded");
1641
1642 large_ds_buf_0 = (uint32_t *)HDmalloc(sizeof(uint32_t) * large_ds_size);
1643 VRFY((large_ds_buf_0 != NULL), "malloc of large_ds_buf_0 succeeded");
1644
1645 large_ds_buf_1 = (uint32_t *)HDmalloc(sizeof(uint32_t) * large_ds_size);
1646 VRFY((large_ds_buf_1 != NULL), "malloc of large_ds_buf_1 succeeded");
1647
1648
1649 /* initialize the buffers */
1650
1651 ptr_0 = small_ds_buf_0;
1652 ptr_1 = small_ds_buf_1;
1653
1654 for ( i = 0; i < (int)small_ds_size; i++ ) {
1655
1656 *ptr_0 = (uint32_t)i;
1657 *ptr_1 = 0;
1658
1659 ptr_0++;
1660 ptr_1++;
1661 }
1662
1663 ptr_0 = large_ds_buf_0;
1664 ptr_1 = large_ds_buf_1;
1665
1666 for ( i = 0; i < (int)large_ds_size; i++ ) {
1667
1668 *ptr_0 = (uint32_t)i;
1669 *ptr_1 = 0;
1670
1671 ptr_0++;
1672 ptr_1++;
1673 }
1674
1675
1676 /* get the file name */
1677
1678 filename = (const char *)GetTestParameters();
1679 HDassert( filename != NULL );
1680
1681
1682 /* ----------------------------------------
1683 * CREATE AN HDF5 FILE WITH PARALLEL ACCESS
1684 * ---------------------------------------*/
1685 /* setup file access template */
1686 acc_tpl = create_faccess_plist(mpi_comm, mpi_info, facc_type);
1687 VRFY((acc_tpl >= 0), "create_faccess_plist() succeeded");
1688
1689 /* create the file collectively */
1690 fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
1691 VRFY((fid >= 0), "H5Fcreate succeeded");
1692
1693 MESG("File opened.");
1694
1695 /* Release file-access template */
1696 ret = H5Pclose(acc_tpl);
1697 VRFY((ret >= 0), "H5Pclose(acc_tpl) succeeded");
1698
1699
1700 /* setup dims: */
1701 small_dims[0] = (hsize_t)(mpi_size + 1);
1702 small_dims[1] = 1;
1703 small_dims[2] = 1;
1704 small_dims[3] = 10;
1705 small_dims[4] = 10;
1706
1707 large_dims[0] = (hsize_t)(mpi_size + 1);
1708 large_dims[1] = 10;
1709 large_dims[2] = 10;
1710 large_dims[3] = 10;
1711 large_dims[4] = 10;
1712
1713 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1714 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1715 HDfprintf(stdout, "%s:%d: small_dims[] = %d %d %d %d %d\n",
1716 fcnName, mpi_rank, (int)small_dims[0], (int)small_dims[1],
1717 (int)small_dims[2], (int)small_dims[3], (int)small_dims[4]);
1718 HDfprintf(stdout, "%s:%d: large_dims[] = %d %d %d %d %d\n",
1719 fcnName, mpi_rank, (int)large_dims[0], (int)large_dims[1],
1720 (int)large_dims[2], (int)large_dims[3], (int)large_dims[4]);
1721 }
1722 #endif
1723
1724 /* create dataspaces */
1725
1726 full_mem_small_ds_sid = H5Screate_simple(5, small_dims, NULL);
1727 VRFY((full_mem_small_ds_sid != 0),
1728 "H5Screate_simple() full_mem_small_ds_sid succeeded");
1729
1730 full_file_small_ds_sid = H5Screate_simple(5, small_dims, NULL);
1731 VRFY((full_file_small_ds_sid != 0),
1732 "H5Screate_simple() full_file_small_ds_sid succeeded");
1733
1734 mem_small_ds_sid = H5Screate_simple(5, small_dims, NULL);
1735 VRFY((mem_small_ds_sid != 0),
1736 "H5Screate_simple() mem_small_ds_sid succeeded");
1737
1738 file_small_ds_sid = H5Screate_simple(5, small_dims, NULL);
1739 VRFY((file_small_ds_sid != 0),
1740 "H5Screate_simple() file_small_ds_sid succeeded");
1741
1742
1743 full_mem_large_ds_sid = H5Screate_simple(5, large_dims, NULL);
1744 VRFY((full_mem_large_ds_sid != 0),
1745 "H5Screate_simple() full_mem_large_ds_sid succeeded");
1746
1747 full_file_large_ds_sid = H5Screate_simple(5, large_dims, NULL);
1748 VRFY((full_file_large_ds_sid != 0),
1749 "H5Screate_simple() full_file_large_ds_sid succeeded");
1750
1751 mem_large_ds_sid = H5Screate_simple(5, large_dims, NULL);
1752 VRFY((mem_large_ds_sid != 0),
1753 "H5Screate_simple() mem_large_ds_sid succeeded");
1754
1755 file_large_ds_sid = H5Screate_simple(5, large_dims, NULL);
1756 VRFY((file_large_ds_sid != 0),
1757 "H5Screate_simple() file_large_ds_sid succeeded");
1758
1759
1760 /* Select the entire extent of the full small ds dataspaces */
1761 ret = H5Sselect_all(full_mem_small_ds_sid);
1762 VRFY((ret != FAIL), "H5Sselect_all(full_mem_small_ds_sid) succeeded");
1763
1764 ret = H5Sselect_all(full_file_small_ds_sid);
1765 VRFY((ret != FAIL), "H5Sselect_all(full_file_small_ds_sid) succeeded");
1766
1767
1768 /* Select the entire extent of the full large ds dataspaces */
1769 ret = H5Sselect_all(full_mem_large_ds_sid);
1770 VRFY((ret != FAIL), "H5Sselect_all(full_mem_large_ds_sid) succeeded");
1771
1772 ret = H5Sselect_all(full_file_large_ds_sid);
1773 VRFY((ret != FAIL), "H5Sselect_all(full_file_large_ds_sid) succeeded");
1774
1775
1776 /* if chunk edge size is greater than zero, set up the small and
1777 * large data set creation property lists to specify chunked
1778 * datasets.
1779 */
1780 if ( chunk_edge_size > 0 ) {
1781
1782 small_chunk_dims[0] = (hsize_t)(1);
1783 small_chunk_dims[1] = small_chunk_dims[2] = (hsize_t)1;
1784 small_chunk_dims[3] = small_chunk_dims[4] = (hsize_t)chunk_edge_size;
1785
1786 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1787 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1788 HDfprintf(stdout, "%s:%d: small chunk dims[] = %d %d %d %d %d\n",
1789 fcnName, mpi_rank, (int)small_chunk_dims[0],
1790 (int)small_chunk_dims[1], (int)small_chunk_dims[2],
1791 (int)small_chunk_dims[3], (int)small_chunk_dims[4]);
1792 }
1793 #endif
1794
1795 small_ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
1796 VRFY((ret != FAIL), "H5Pcreate() small_ds_dcpl_id succeeded");
1797
1798 ret = H5Pset_layout(small_ds_dcpl_id, H5D_CHUNKED);
1799 VRFY((ret != FAIL), "H5Pset_layout() small_ds_dcpl_id succeeded");
1800
1801 ret = H5Pset_chunk(small_ds_dcpl_id, 5, small_chunk_dims);
1802 VRFY((ret != FAIL), "H5Pset_chunk() small_ds_dcpl_id succeeded");
1803
1804 large_chunk_dims[0] = (hsize_t)(1);
1805 large_chunk_dims[1] = large_chunk_dims[2] =
1806 large_chunk_dims[3] = large_chunk_dims[4] = (hsize_t)chunk_edge_size;
1807
1808
1809 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1810 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1811 HDfprintf(stdout, "%s:%d: large chunk dims[] = %d %d %d %d %d\n",
1812 fcnName, mpi_rank, (int)large_chunk_dims[0],
1813 (int)large_chunk_dims[1], (int)large_chunk_dims[2],
1814 (int)large_chunk_dims[3], (int)large_chunk_dims[4]);
1815 }
1816 #endif
1817
1818 large_ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
1819 VRFY((ret != FAIL), "H5Pcreate() large_ds_dcpl_id succeeded");
1820
1821 ret = H5Pset_layout(large_ds_dcpl_id, H5D_CHUNKED);
1822 VRFY((ret != FAIL), "H5Pset_layout() large_ds_dcpl_id succeeded");
1823
1824 ret = H5Pset_chunk(large_ds_dcpl_id, 5, large_chunk_dims);
1825 VRFY((ret != FAIL), "H5Pset_chunk() large_ds_dcpl_id succeeded");
1826 }
1827
1828
1829 /* create the small dataset */
1830 small_dataset = H5Dcreate2(fid, "small_dataset", dset_type,
1831 file_small_ds_sid, H5P_DEFAULT,
1832 small_ds_dcpl_id, H5P_DEFAULT);
1833 VRFY((ret >= 0), "H5Dcreate2() small_dataset succeeded");
1834
1835
1836 /* create the large dataset */
1837 large_dataset = H5Dcreate2(fid, "large_dataset", dset_type,
1838 file_large_ds_sid, H5P_DEFAULT,
1839 large_ds_dcpl_id, H5P_DEFAULT);
1840 VRFY((ret >= 0), "H5Dcreate2() large_dataset succeeded");
1841
1842 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1843 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1844 HDfprintf(stdout,
1845 "%s:%d: small/large ds id = %d / %d.\n",
1846 fcnName, mpi_rank, (int)small_dataset,
1847 (int)large_dataset);
1848 }
1849 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1850
1851
1852 /* setup xfer property list */
1853 xfer_plist = H5Pcreate(H5P_DATASET_XFER);
1854 VRFY((xfer_plist >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded");
1855
1856 ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
1857 VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded");
1858
1859 if ( ! use_collective_io ) {
1860
1861 ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,
1862 H5FD_MPIO_INDIVIDUAL_IO);
1863 VRFY((ret>= 0), "H5Pset_dxpl_mpio_collective_opt() suceeded");
1864 }
1865
1866
1867 /* setup selection to write initial data to the small data sets */
1868 start[0] = (hsize_t)(mpi_rank + 1);
1869 start[1] = start[2] = start[3] = start[4] = 0;
1870
1871 stride[0] = (hsize_t)(2 * (mpi_size + 1));
1872 stride[1] = stride[2] = 2;
1873 stride[3] = stride[4] = 2 * 10;
1874
1875 count[0] = count[1] = count[2] = count[3] = count[4] = 1;
1876
1877 block[0] = block[1] = block[2] = 1;
1878 block[3] = block[4] = 10;
1879
1880 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1881 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1882 HDfprintf(stdout,
1883 "%s:%d: settings for small data set initialization.\n",
1884 fcnName, mpi_rank);
1885 HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n",
1886 fcnName, mpi_rank, (int)start[0], (int)start[1],
1887 (int)start[2], (int)start[3], (int)start[4]);
1888 HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n",
1889 fcnName, mpi_rank, (int)stride[0], (int)stride[1],
1890 (int)stride[2], (int)stride[3], (int)stride[4]);
1891 HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n",
1892 fcnName, mpi_rank, (int)count[0], (int)count[1],
1893 (int)count[2], (int)count[3], (int)count[4]);
1894 HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n",
1895 fcnName, mpi_rank, (int)block[0], (int)block[1],
1896 (int)block[2], (int)block[3], (int)block[4]);
1897 }
1898 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1899
1900 /* setup selections for writing initial data to the small data set */
1901 ret = H5Sselect_hyperslab(mem_small_ds_sid,
1902 H5S_SELECT_SET,
1903 start,
1904 stride,
1905 count,
1906 block);
1907 VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded");
1908
1909 ret = H5Sselect_hyperslab(file_small_ds_sid,
1910 H5S_SELECT_SET,
1911 start,
1912 stride,
1913 count,
1914 block);
1915 VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid, set) suceeded");
1916
1917 if ( MAINPROCESS ) { /* add an additional slice to the selections */
1918
1919 start[0] = 0;
1920
1921 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1922 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1923 HDfprintf(stdout,
1924 "%s:%d: added settings for main process.\n",
1925 fcnName, mpi_rank);
1926 HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n",
1927 fcnName, mpi_rank, (int)start[0], (int)start[1],
1928 (int)start[2], (int)start[3], (int)start[4]);
1929 HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n",
1930 fcnName, mpi_rank, (int)stride[0], (int)stride[1],
1931 (int)stride[2], (int)stride[3], (int)stride[4]);
1932 HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n",
1933 fcnName, mpi_rank, (int)count[0], (int)count[1],
1934 (int)count[2], (int)count[3], (int)count[4]);
1935 HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n",
1936 fcnName, mpi_rank, (int)block[0], (int)block[1],
1937 (int)block[2], (int)block[3], (int)block[4]);
1938 }
1939 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1940
1941 ret = H5Sselect_hyperslab(mem_small_ds_sid,
1942 H5S_SELECT_OR,
1943 start,
1944 stride,
1945 count,
1946 block);
1947 VRFY((ret>= 0), "H5Sselect_hyperslab(mem_small_ds_sid, or) suceeded");
1948
1949 ret = H5Sselect_hyperslab(file_small_ds_sid,
1950 H5S_SELECT_OR,
1951 start,
1952 stride,
1953 count,
1954 block);
1955 VRFY((ret>= 0), "H5Sselect_hyperslab(file_small_ds_sid, or) suceeded");
1956 }
1957
1958 check = H5Sselect_valid(mem_small_ds_sid);
1959 VRFY((check == TRUE),"H5Sselect_valid(mem_small_ds_sid) returns TRUE");
1960
1961 check = H5Sselect_valid(file_small_ds_sid);
1962 VRFY((check == TRUE),"H5Sselect_valid(file_small_ds_sid) returns TRUE");
1963
1964
1965 /* write the initial value of the small data set to file */
1966 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
1967 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
1968 HDfprintf(stdout, "%s:%d: writing init value of small ds to file.\n",
1969 fcnName, mpi_rank);
1970 }
1971 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
1972 ret = H5Dwrite(small_dataset,
1973 dset_type,
1974 mem_small_ds_sid,
1975 file_small_ds_sid,
1976 xfer_plist,
1977 small_ds_buf_0);
1978 VRFY((ret >= 0), "H5Dwrite() small_dataset initial write succeeded");
1979
1980
1981 /* read the small data set back to verify that it contains the
1982 * expected data. Note that each process reads in the entire
1983 * data set and verifies it.
1984 */
1985 ret = H5Dread(small_dataset,
1986 H5T_NATIVE_UINT32,
1987 full_mem_small_ds_sid,
1988 full_file_small_ds_sid,
1989 xfer_plist,
1990 small_ds_buf_1);
1991 VRFY((ret >= 0), "H5Dread() small_dataset initial read succeeded");
1992
1993
1994 /* sync with the other processes before checking data */
1995 mrc = MPI_Barrier(MPI_COMM_WORLD);
1996 VRFY((mrc==MPI_SUCCESS), "Sync after small dataset writes");
1997
1998
1999 /* verify that the correct data was written to the small data set,
2000 * and reset the buffer to zero in passing.
2001 */
2002 expected_value = 0;
2003 mis_match = FALSE;
2004 ptr_1 = small_ds_buf_1;
2005
2006 i = 0;
2007 for ( i = 0; i < (int)small_ds_size; i++ ) {
2008
2009 if ( *ptr_1 != expected_value ) {
2010
2011 mis_match = TRUE;
2012 }
2013
2014 *ptr_1 = (uint32_t)0;
2015
2016 ptr_1++;
2017 expected_value++;
2018 }
2019 VRFY( (mis_match == FALSE), "small ds init data good.");
2020
2021
2022
2023 /* setup selections for writing initial data to the large data set */
2024 start[0] = (hsize_t)(mpi_rank + 1);
2025 start[1] = start[2] = start[3] = start[4] = (hsize_t)0;
2026
2027 stride[0] = (hsize_t)(2 * (mpi_size + 1));
2028 stride[1] = stride[2] = stride[3] = stride[4] = (hsize_t)(2 * 10);
2029
2030 count[0] = count[1] = count[2] = count[3] = count[4] = (hsize_t)1;
2031
2032 block[0] = (hsize_t)1;
2033 block[1] = block[2] = block[3] = block[4] = (hsize_t)10;
2034
2035 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2036 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2037 HDfprintf(stdout,
2038 "%s:%d: settings for large data set initialization.\n",
2039 fcnName, mpi_rank);
2040 HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n",
2041 fcnName, mpi_rank, (int)start[0], (int)start[1],
2042 (int)start[2], (int)start[3], (int)start[4]);
2043 HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n",
2044 fcnName, mpi_rank, (int)stride[0], (int)stride[1],
2045 (int)stride[2], (int)stride[3], (int)stride[4]);
2046 HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n",
2047 fcnName, mpi_rank, (int)count[0], (int)count[1],
2048 (int)count[2], (int)count[3], (int)count[4]);
2049 HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n",
2050 fcnName, mpi_rank, (int)block[0], (int)block[1],
2051 (int)block[2], (int)block[3], (int)block[4]);
2052 }
2053 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2054
2055 ret = H5Sselect_hyperslab(mem_large_ds_sid,
2056 H5S_SELECT_SET,
2057 start,
2058 stride,
2059 count,
2060 block);
2061 VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_sid, set) suceeded");
2062
2063 ret = H5Sselect_hyperslab(file_large_ds_sid,
2064 H5S_SELECT_SET,
2065 start,
2066 stride,
2067 count,
2068 block);
2069 VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid, set) suceeded");
2070
2071 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2072 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2073 HDfprintf(stdout,
2074 "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n",
2075 fcnName, mpi_rank,
2076 (int)H5Sget_select_npoints(mem_large_ds_sid));
2077 HDfprintf(stdout,
2078 "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n",
2079 fcnName, mpi_rank,
2080 (int)H5Sget_select_npoints(file_large_ds_sid));
2081 }
2082 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2083
2084 if ( MAINPROCESS ) { /* add an additional slice to the selections */
2085
2086 start[0] = (hsize_t)0;
2087
2088 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2089 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2090 HDfprintf(stdout,
2091 "%s:%d: added settings for main process.\n",
2092 fcnName, mpi_rank);
2093 HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n",
2094 fcnName, mpi_rank, (int)start[0], (int)start[1],
2095 (int)start[2], (int)start[3], (int)start[4]);
2096 HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n",
2097 fcnName, mpi_rank, (int)stride[0], (int)stride[1],
2098 (int)stride[2], (int)stride[3], (int)stride[4]);
2099 HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n",
2100 fcnName, mpi_rank, (int)count[0], (int)count[1],
2101 (int)count[2], (int)count[3], (int)count[4]);
2102 HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n",
2103 fcnName, mpi_rank, (int)block[0], (int)block[1],
2104 (int)block[2], (int)block[3], (int)block[4]);
2105 }
2106 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2107
2108 ret = H5Sselect_hyperslab(mem_large_ds_sid,
2109 H5S_SELECT_OR,
2110 start,
2111 stride,
2112 count,
2113 block);
2114 VRFY((ret>= 0), "H5Sselect_hyperslab(mem_large_ds_sid, or) suceeded");
2115
2116 ret = H5Sselect_hyperslab(file_large_ds_sid,
2117 H5S_SELECT_OR,
2118 start,
2119 stride,
2120 count,
2121 block);
2122 VRFY((ret>= 0), "H5Sselect_hyperslab(file_large_ds_sid, or) suceeded");
2123
2124 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2125 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2126 HDfprintf(stdout,
2127 "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n",
2128 fcnName, mpi_rank,
2129 (int)H5Sget_select_npoints(mem_large_ds_sid));
2130 HDfprintf(stdout,
2131 "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n",
2132 fcnName, mpi_rank,
2133 (int)H5Sget_select_npoints(file_large_ds_sid));
2134 }
2135 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2136 }
2137
2138 /* try clipping the selection back to the large dataspace proper */
2139 start[0] = start[1] = start[2] = start[3] = start[4] = (hsize_t)0;
2140
2141 stride[0] = (hsize_t)(2 * (mpi_size + 1));
2142 stride[1] = stride[2] = stride[3] = stride[4] = (hsize_t)(2 * 10);
2143
2144 count[0] = count[1] = count[2] = count[3] = count[4] = (hsize_t)1;
2145
2146 block[0] = (hsize_t)(mpi_size + 1);
2147 block[1] = block[2] = block[3] = block[4] = (hsize_t)10;
2148
2149 ret = H5Sselect_hyperslab(mem_large_ds_sid, H5S_SELECT_AND,
2150 start, stride, count, block);
2151 VRFY((ret != FAIL),"H5Sselect_hyperslab(mem_large_ds_sid, and) succeeded");
2152
2153 ret = H5Sselect_hyperslab(file_large_ds_sid, H5S_SELECT_AND,
2154 start, stride, count, block);
2155 VRFY((ret != FAIL),"H5Sselect_hyperslab(file_large_ds_sid, and) succeeded");
2156
2157 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2158 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2159
2160 rank = H5Sget_simple_extent_dims(mem_large_ds_sid, dims, max_dims);
2161 HDfprintf(stdout,
2162 "%s:%d: mem_large_ds_sid dims[%d] = %d %d %d %d %d\n",
2163 fcnName, mpi_rank, rank, (int)dims[0], (int)dims[1],
2164 (int)dims[2], (int)dims[3], (int)dims[4]);
2165
2166 rank = H5Sget_simple_extent_dims(file_large_ds_sid, dims, max_dims);
2167 HDfprintf(stdout,
2168 "%s:%d: file_large_ds_sid dims[%d] = %d %d %d %d %d\n",
2169 fcnName, mpi_rank, rank, (int)dims[0], (int)dims[1],
2170 (int)dims[2], (int)dims[3], (int)dims[4]);
2171 }
2172 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2173
2174 check = H5Sselect_valid(mem_large_ds_sid);
2175 VRFY((check == TRUE),"H5Sselect_valid(mem_large_ds_sid) returns TRUE");
2176
2177 check = H5Sselect_valid(file_large_ds_sid);
2178 VRFY((check == TRUE),"H5Sselect_valid(file_large_ds_sid) returns TRUE");
2179
2180
2181 /* write the initial value of the large data set to file */
2182 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2183 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2184 HDfprintf(stdout, "%s:%d: writing init value of large ds to file.\n",
2185 fcnName, mpi_rank);
2186 HDfprintf(stdout,
2187 "%s:%d: large_dataset = %d.\n",
2188 fcnName, mpi_rank,
2189 (int)large_dataset);
2190 HDfprintf(stdout,
2191 "%s:%d: mem_large_ds_sid = %d, file_large_ds_sid = %d.\n",
2192 fcnName, mpi_rank,
2193 (int)mem_large_ds_sid, (int)file_large_ds_sid);
2194 }
2195 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2196
2197 ret = H5Dwrite(large_dataset,
2198 dset_type,
2199 mem_large_ds_sid,
2200 file_large_ds_sid,
2201 xfer_plist,
2202 large_ds_buf_0);
2203
2204 if ( ret < 0 ) H5Eprint2(H5E_DEFAULT, stderr);
2205 VRFY((ret >= 0), "H5Dwrite() large_dataset initial write succeeded");
2206
2207
2208 /* sync with the other processes before checking data */
2209 mrc = MPI_Barrier(MPI_COMM_WORLD);
2210 VRFY((mrc==MPI_SUCCESS), "Sync after large dataset writes");
2211
2212 /* read the large data set back to verify that it contains the
2213 * expected data. Note that each process reads in the entire
2214 * data set.
2215 */
2216 ret = H5Dread(large_dataset,
2217 H5T_NATIVE_UINT32,
2218 full_mem_large_ds_sid,
2219 full_file_large_ds_sid,
2220 xfer_plist,
2221 large_ds_buf_1);
2222 VRFY((ret >= 0), "H5Dread() large_dataset initial read succeeded");
2223
2224
2225 /* verify that the correct data was written to the large data set.
2226 * in passing, reset the buffer to zeros
2227 */
2228 expected_value = 0;
2229 mis_match = FALSE;
2230 ptr_1 = large_ds_buf_1;
2231
2232 i = 0;
2233 for ( i = 0; i < (int)large_ds_size; i++ ) {
2234
2235 if ( *ptr_1 != expected_value ) {
2236
2237 mis_match = TRUE;
2238 }
2239
2240 *ptr_1 = (uint32_t)0;
2241
2242 ptr_1++;
2243 expected_value++;
2244 }
2245 VRFY( (mis_match == FALSE), "large ds init data good.");
2246
2247 /***********************************/
2248 /***** INITIALIZATION COMPLETE *****/
2249 /***********************************/
2250
2251
2252 /* read a checkerboard selection of the process slice of the
2253 * small on disk data set into the process slice of the large
2254 * in memory data set, and verify the data read.
2255 */
2256
2257 small_sel_start[0] = (hsize_t)(mpi_rank + 1);
2258 small_sel_start[1] = small_sel_start[2] =
2259 small_sel_start[3] = small_sel_start[4] = 0;
2260
2261 lower_dim_size_comp_test__select_checker_board(mpi_rank,
2262 file_small_ds_sid,
2263 /* tgt_rank = */ 5,
2264 small_dims,
2265 /* checker_edge_size = */ 3,
2266 /* sel_rank */ 2,
2267 small_sel_start);
2268
2269 expected_value = (uint32_t)
2270 ((small_sel_start[0] * small_dims[1] * small_dims[2] *
2271 small_dims[3] * small_dims[4]) +
2272 (small_sel_start[1] * small_dims[2] * small_dims[3] *
2273 small_dims[4]) +
2274 (small_sel_start[2] * small_dims[3] * small_dims[4]) +
2275 (small_sel_start[3] * small_dims[4]) +
2276 (small_sel_start[4]));
2277
2278
2279 large_sel_start[0] = (hsize_t)(mpi_rank + 1);
2280 large_sel_start[1] = 5;
2281 large_sel_start[2] = large_sel_start[3] = large_sel_start[4] = 0;
2282
2283 lower_dim_size_comp_test__select_checker_board(mpi_rank,
2284 mem_large_ds_sid,
2285 /* tgt_rank = */ 5,
2286 large_dims,
2287 /* checker_edge_size = */ 3,
2288 /* sel_rank = */ 2,
2289 large_sel_start);
2290
2291
2292 /* verify that H5S_select_shape_same() reports the two
2293 * selections as having the same shape.
2294 */
2295 check = H5S_select_shape_same_test(mem_large_ds_sid, file_small_ds_sid);
2296 VRFY((check == TRUE), "H5S_select_shape_same_test passed (1)");
2297
2298
2299 ret = H5Dread(small_dataset,
2300 H5T_NATIVE_UINT32,
2301 mem_large_ds_sid,
2302 file_small_ds_sid,
2303 xfer_plist,
2304 large_ds_buf_1);
2305
2306 VRFY((ret >= 0), "H5Sread() slice from small ds succeeded.");
2307
2308 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2309 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2310 HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", fcnName, mpi_rank);
2311 }
2312 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2313
2314 /* verify that expected data is retrieved */
2315
2316 data_ok = TRUE;
2317
2318 start_index = (int)((large_sel_start[0] * large_dims[1] * large_dims[2] *
2319 large_dims[3] * large_dims[4]) +
2320 (large_sel_start[1] * large_dims[2] * large_dims[3] *
2321 large_dims[4]) +
2322 (large_sel_start[2] * large_dims[3] * large_dims[4]) +
2323 (large_sel_start[3] * large_dims[4]) +
2324 (large_sel_start[4]));
2325
2326 stop_index = start_index + (int)small_ds_slice_size;
2327
2328 HDassert( 0 <= start_index );
2329 HDassert( start_index < stop_index );
2330 HDassert( stop_index <= (int)large_ds_size );
2331
2332 ptr_1 = large_ds_buf_1;
2333
2334 for ( i = 0; i < start_index; i++ ) {
2335
2336 if ( *ptr_1 != (uint32_t)0 ) {
2337
2338 data_ok = FALSE;
2339 *ptr_1 = (uint32_t)0;
2340 }
2341
2342 ptr_1++;
2343 }
2344
2345 VRFY((data_ok == TRUE), "slice read from small ds data good(1).");
2346
2347
2348 data_ok = lower_dim_size_comp_test__verify_data(ptr_1,
2349 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
2350 mpi_rank,
2351 #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */
2352 /* rank */ 2,
2353 /* edge_size */ 10,
2354 /* checker_edge_size */ 3,
2355 expected_value,
2356 /* buf_starts_in_checker */ TRUE);
2357
2358 VRFY((data_ok == TRUE), "slice read from small ds data good(2).");
2359
2360 data_ok = TRUE;
2361
2362 ptr_1 += small_ds_slice_size;
2363
2364
2365 for ( i = stop_index; i < (int)large_ds_size; i++ ) {
2366
2367 if ( *ptr_1 != (uint32_t)0 ) {
2368
2369 data_ok = FALSE;
2370 *ptr_1 = (uint32_t)0;
2371 }
2372
2373 ptr_1++;
2374 }
2375
2376 VRFY((data_ok == TRUE), "slice read from small ds data good(3).");
2377
2378
2379
2380
2381
2382 /* read a checkerboard selection of a slice of the process slice of
2383 * the large on disk data set into the process slice of the small
2384 * in memory data set, and verify the data read.
2385 */
2386
2387 small_sel_start[0] = (hsize_t)(mpi_rank + 1);
2388 small_sel_start[1] = small_sel_start[2] =
2389 small_sel_start[3] = small_sel_start[4] = 0;
2390
2391 lower_dim_size_comp_test__select_checker_board(mpi_rank,
2392 mem_small_ds_sid,
2393 /* tgt_rank = */ 5,
2394 small_dims,
2395 /* checker_edge_size = */ 3,
2396 /* sel_rank */ 2,
2397 small_sel_start);
2398
2399 large_sel_start[0] = (hsize_t)(mpi_rank + 1);
2400 large_sel_start[1] = 5;
2401 large_sel_start[2] = large_sel_start[3] = large_sel_start[4] = 0;
2402
2403 lower_dim_size_comp_test__select_checker_board(mpi_rank,
2404 file_large_ds_sid,
2405 /* tgt_rank = */ 5,
2406 large_dims,
2407 /* checker_edge_size = */ 3,
2408 /* sel_rank = */ 2,
2409 large_sel_start);
2410
2411
2412 /* verify that H5S_select_shape_same() reports the two
2413 * selections as having the same shape.
2414 */
2415 check = H5S_select_shape_same_test(mem_small_ds_sid, file_large_ds_sid);
2416 VRFY((check == TRUE), "H5S_select_shape_same_test passed (2)");
2417
2418
2419 ret = H5Dread(large_dataset,
2420 H5T_NATIVE_UINT32,
2421 mem_small_ds_sid,
2422 file_large_ds_sid,
2423 xfer_plist,
2424 small_ds_buf_1);
2425
2426 VRFY((ret >= 0), "H5Sread() slice from large ds succeeded.");
2427
2428 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG
2429 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2430 HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", fcnName, mpi_rank);
2431 }
2432 #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */
2433
2434 /* verify that expected data is retrieved */
2435
2436 data_ok = TRUE;
2437
2438 expected_value = (uint32_t)
2439 ((large_sel_start[0] * large_dims[1] * large_dims[2] *
2440 large_dims[3] * large_dims[4]) +
2441 (large_sel_start[1] * large_dims[2] * large_dims[3] *
2442 large_dims[4]) +
2443 (large_sel_start[2] * large_dims[3] * large_dims[4]) +
2444 (large_sel_start[3] * large_dims[4]) +
2445 (large_sel_start[4]));
2446
2447 start_index = (int)(mpi_rank + 1) * (int)small_ds_slice_size;
2448
2449 stop_index = start_index + (int)small_ds_slice_size;
2450
2451 HDassert( 0 <= start_index );
2452 HDassert( start_index < stop_index );
2453 HDassert( stop_index <= (int)small_ds_size );
2454
2455 ptr_1 = small_ds_buf_1;
2456
2457 for ( i = 0; i < start_index; i++ ) {
2458
2459 if ( *ptr_1 != (uint32_t)0 ) {
2460
2461 data_ok = FALSE;
2462 *ptr_1 = (uint32_t)0;
2463 }
2464
2465 ptr_1++;
2466 }
2467
2468 VRFY((data_ok == TRUE), "slice read from large ds data good(1).");
2469
2470
2471 data_ok = lower_dim_size_comp_test__verify_data(ptr_1,
2472 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
2473 mpi_rank,
2474 #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */
2475 /* rank */ 2,
2476 /* edge_size */ 10,
2477 /* checker_edge_size */ 3,
2478 expected_value,
2479 /* buf_starts_in_checker */ TRUE);
2480
2481 VRFY((data_ok == TRUE), "slice read from large ds data good(2).");
2482
2483 data_ok = TRUE;
2484
2485 ptr_1 += small_ds_slice_size;
2486
2487
2488 for ( i = stop_index; i < (int)small_ds_size; i++ ) {
2489
2490 if ( *ptr_1 != (uint32_t)0 ) {
2491
2492 #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG
2493 if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) {
2494 HDfprintf(stdout, "%s:%d: unexpected value at index %d: %d.\n",
2495 fcnName, mpi_rank, (int)i, (int)(*ptr_1));
2496 }
2497 #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */
2498
2499 data_ok = FALSE;
2500 *ptr_1 = (uint32_t)0;
2501 }
2502
2503 ptr_1++;
2504 }
2505
2506 VRFY((data_ok == TRUE), "slice read from large ds data good(3).");
2507
2508
2509 /* Close dataspaces */
2510 ret = H5Sclose(full_mem_small_ds_sid);
2511 VRFY((ret != FAIL), "H5Sclose(full_mem_small_ds_sid) succeeded");
2512
2513 ret = H5Sclose(full_file_small_ds_sid);
2514 VRFY((ret != FAIL), "H5Sclose(full_file_small_ds_sid) succeeded");
2515
2516 ret = H5Sclose(mem_small_ds_sid);
2517 VRFY((ret != FAIL), "H5Sclose(mem_small_ds_sid) succeeded");
2518
2519 ret = H5Sclose(file_small_ds_sid);
2520 VRFY((ret != FAIL), "H5Sclose(file_small_ds_sid) succeeded");
2521
2522
2523 ret = H5Sclose(full_mem_large_ds_sid);
2524 VRFY((ret != FAIL), "H5Sclose(full_mem_large_ds_sid) succeeded");
2525
2526 ret = H5Sclose(full_file_large_ds_sid);
2527 VRFY((ret != FAIL), "H5Sclose(full_file_large_ds_sid) succeeded");
2528
2529 ret = H5Sclose(mem_large_ds_sid);
2530 VRFY((ret != FAIL), "H5Sclose(mem_large_ds_sid) succeeded");
2531
2532 ret = H5Sclose(file_large_ds_sid);
2533 VRFY((ret != FAIL), "H5Sclose(file_large_ds_sid) succeeded");
2534
2535
2536 /* Close Datasets */
2537 ret = H5Dclose(small_dataset);
2538 VRFY((ret != FAIL), "H5Dclose(small_dataset) succeeded");
2539
2540 ret = H5Dclose(large_dataset);
2541 VRFY((ret != FAIL), "H5Dclose(large_dataset) succeeded");
2542
2543
2544 /* close the file collectively */
2545 MESG("about to close file.");
2546 ret = H5Fclose(fid);
2547 VRFY((ret != FAIL), "file close succeeded");
2548
2549 /* Free memory buffers */
2550 if ( small_ds_buf_0 != NULL ) HDfree(small_ds_buf_0);
2551 if ( small_ds_buf_1 != NULL ) HDfree(small_ds_buf_1);
2552
2553 if ( large_ds_buf_0 != NULL ) HDfree(large_ds_buf_0);
2554 if ( large_ds_buf_1 != NULL ) HDfree(large_ds_buf_1);
2555
2556 return;
2557
2558 } /* lower_dim_size_comp_test__run_test() */
2559
2560
2561 /*-------------------------------------------------------------------------
2562 * Function: lower_dim_size_comp_test()
2563 *
2564 * Purpose: Test to see if an error in the computation of the size
2565 * of the lower dimensions in H5S_obtain_datatype() has
2566 * been corrected.
2567 *
2568 * Return: void
2569 *
2570 * Programmer: JRM -- 11/11/09
2571 *
2572 *-------------------------------------------------------------------------
2573 */
2574
2575 void
lower_dim_size_comp_test(void)2576 lower_dim_size_comp_test(void)
2577 {
2578 /* const char *fcnName = "lower_dim_size_comp_test()"; */
2579 int chunk_edge_size = 0;
2580 int use_collective_io;
2581
2582 HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned));
2583 for(use_collective_io = 0; use_collective_io <= 1; use_collective_io++) {
2584 chunk_edge_size = 0;
2585 lower_dim_size_comp_test__run_test(chunk_edge_size,
2586 (hbool_t)use_collective_io,
2587 H5T_NATIVE_UINT);
2588
2589 chunk_edge_size = 5;
2590 lower_dim_size_comp_test__run_test(chunk_edge_size,
2591 (hbool_t)use_collective_io,
2592 H5T_NATIVE_UINT);
2593 } /* end for */
2594
2595 return;
2596 } /* lower_dim_size_comp_test() */
2597
2598
2599 /*-------------------------------------------------------------------------
2600 * Function: link_chunk_collective_io_test()
2601 *
2602 * Purpose: Test to verify that an error in MPI type management in
2603 * H5D_link_chunk_collective_io() has been corrected.
2604 * In this bug, we used to free MPI types regardless of
2605 * whether they were basic or derived.
2606 *
2607 * This test is based on a bug report kindly provided by
2608 * Rob Latham of the MPICH team and ANL.
2609 *
2610 * The basic thrust of the test is to cause a process
2611 * to participate in a collective I/O in which it:
2612 *
2613 * 1) Reads or writes exactly one chunk,
2614 *
2615 * 2) Has no in memory buffer for any other chunk.
2616 *
2617 * The test differers from Rob Latham's bug report in
2618 * that is runs with an arbitrary number of proceeses,
2619 * and uses a 1 dimensional dataset.
2620 *
2621 * Return: void
2622 *
2623 * Programmer: JRM -- 12/16/09
2624 *
2625 *-------------------------------------------------------------------------
2626 */
2627
2628 #define LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE 16
2629
2630 void
link_chunk_collective_io_test(void)2631 link_chunk_collective_io_test(void)
2632 {
2633 /* const char *fcnName = "link_chunk_collective_io_test()"; */
2634 const char *filename;
2635 hbool_t mis_match = FALSE;
2636 int i;
2637 int mrc;
2638 int mpi_rank;
2639 int mpi_size;
2640 MPI_Comm mpi_comm = MPI_COMM_WORLD;
2641 MPI_Info mpi_info = MPI_INFO_NULL;
2642 hsize_t count[1] = {1};
2643 hsize_t stride[1] = {2 * LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE};
2644 hsize_t block[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE};
2645 hsize_t start[1];
2646 hsize_t dims[1];
2647 hsize_t chunk_dims[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE};
2648 herr_t ret; /* Generic return value */
2649 hid_t file_id;
2650 hid_t acc_tpl;
2651 hid_t dset_id;
2652 hid_t file_ds_sid;
2653 hid_t write_mem_ds_sid;
2654 hid_t read_mem_ds_sid;
2655 hid_t ds_dcpl_id;
2656 hid_t xfer_plist;
2657 double diff;
2658 double expected_value;
2659 double local_data_written[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE];
2660 double local_data_read[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE];
2661
2662 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
2663 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
2664
2665 HDassert( mpi_size > 0 );
2666
2667 /* get the file name */
2668 filename = (const char *)GetTestParameters();
2669 HDassert( filename != NULL );
2670
2671 /* setup file access template */
2672 acc_tpl = create_faccess_plist(mpi_comm, mpi_info, facc_type);
2673 VRFY((acc_tpl >= 0), "create_faccess_plist() succeeded");
2674
2675 /* create the file collectively */
2676 file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
2677 VRFY((file_id >= 0), "H5Fcreate succeeded");
2678
2679 MESG("File opened.");
2680
2681 /* Release file-access template */
2682 ret = H5Pclose(acc_tpl);
2683 VRFY((ret >= 0), "H5Pclose(acc_tpl) succeeded");
2684
2685 /* setup dims */
2686 dims[0] = ((hsize_t)mpi_size) * ((hsize_t)(LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE));
2687
2688 /* setup mem and file dataspaces */
2689 write_mem_ds_sid = H5Screate_simple(1, chunk_dims, NULL);
2690 VRFY((write_mem_ds_sid != 0),
2691 "H5Screate_simple() write_mem_ds_sid succeeded");
2692
2693 read_mem_ds_sid = H5Screate_simple(1, chunk_dims, NULL);
2694 VRFY((read_mem_ds_sid != 0),
2695 "H5Screate_simple() read_mem_ds_sid succeeded");
2696
2697 file_ds_sid = H5Screate_simple(1, dims, NULL);
2698 VRFY((file_ds_sid != 0),
2699 "H5Screate_simple() file_ds_sid succeeded");
2700
2701 /* setup data set creation property list */
2702 ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
2703 VRFY((ds_dcpl_id != FAIL), "H5Pcreate() ds_dcpl_id succeeded");
2704
2705 ret = H5Pset_layout(ds_dcpl_id, H5D_CHUNKED);
2706 VRFY((ret != FAIL), "H5Pset_layout() ds_dcpl_id succeeded");
2707
2708 ret = H5Pset_chunk(ds_dcpl_id, 1, chunk_dims);
2709 VRFY((ret != FAIL), "H5Pset_chunk() small_ds_dcpl_id succeeded");
2710
2711 /* create the data set */
2712 dset_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_DOUBLE,
2713 file_ds_sid, H5P_DEFAULT,
2714 ds_dcpl_id, H5P_DEFAULT);
2715 VRFY((dset_id >= 0), "H5Dcreate2() dataset succeeded");
2716
2717 /* close the dataset creation property list */
2718 ret = H5Pclose(ds_dcpl_id);
2719 VRFY((ret >= 0), "H5Pclose(ds_dcpl_id) succeeded");
2720
2721 /* setup local data */
2722 expected_value = (double)(LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE) *
2723 (double)(mpi_rank);
2724 for ( i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++ ) {
2725
2726 local_data_written[i] = expected_value;
2727 local_data_read[i] = 0.0;
2728 expected_value += 1.0;
2729 }
2730
2731 /* select the file and mem spaces */
2732 start[0] = (hsize_t)(mpi_rank * LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE);
2733 ret = H5Sselect_hyperslab(file_ds_sid,
2734 H5S_SELECT_SET,
2735 start,
2736 stride,
2737 count,
2738 block);
2739 VRFY((ret >= 0), "H5Sselect_hyperslab(file_ds_sid, set) suceeded");
2740
2741 ret = H5Sselect_all(write_mem_ds_sid);
2742 VRFY((ret != FAIL), "H5Sselect_all(mem_ds_sid) succeeded");
2743
2744 /* Note that we use NO SELECTION on the read memory dataspace */
2745
2746 /* setup xfer property list */
2747 xfer_plist = H5Pcreate(H5P_DATASET_XFER);
2748 VRFY((xfer_plist >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded");
2749
2750 ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
2751 VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded");
2752
2753 /* write the data set */
2754 ret = H5Dwrite(dset_id,
2755 H5T_NATIVE_DOUBLE,
2756 write_mem_ds_sid,
2757 file_ds_sid,
2758 xfer_plist,
2759 local_data_written);
2760
2761 VRFY((ret >= 0), "H5Dwrite() dataset initial write succeeded");
2762
2763 /* sync with the other processes before checking data */
2764 mrc = MPI_Barrier(MPI_COMM_WORLD);
2765 VRFY((mrc==MPI_SUCCESS), "Sync after dataset write");
2766
2767 /* read this processes slice of the dataset back in */
2768 ret = H5Dread(dset_id,
2769 H5T_NATIVE_DOUBLE,
2770 read_mem_ds_sid,
2771 file_ds_sid,
2772 xfer_plist,
2773 local_data_read);
2774 VRFY((ret >= 0), "H5Dread() dataset read succeeded");
2775
2776 /* close the xfer property list */
2777 ret = H5Pclose(xfer_plist);
2778 VRFY((ret >= 0), "H5Pclose(xfer_plist) succeeded");
2779
2780 /* verify the data */
2781 mis_match = FALSE;
2782 for ( i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++ ) {
2783
2784 diff = local_data_written[i] - local_data_read[i];
2785 diff = fabs(diff);
2786
2787 if ( diff >= 0.001 ) {
2788
2789 mis_match = TRUE;
2790 }
2791 }
2792 VRFY( (mis_match == FALSE), "dataset data good.");
2793
2794 /* Close dataspaces */
2795 ret = H5Sclose(write_mem_ds_sid);
2796 VRFY((ret != FAIL), "H5Sclose(write_mem_ds_sid) succeeded");
2797
2798 ret = H5Sclose(read_mem_ds_sid);
2799 VRFY((ret != FAIL), "H5Sclose(read_mem_ds_sid) succeeded");
2800
2801 ret = H5Sclose(file_ds_sid);
2802 VRFY((ret != FAIL), "H5Sclose(file_ds_sid) succeeded");
2803
2804 /* Close Dataset */
2805 ret = H5Dclose(dset_id);
2806 VRFY((ret != FAIL), "H5Dclose(dset_id) succeeded");
2807
2808 /* close the file collectively */
2809 ret = H5Fclose(file_id);
2810 VRFY((ret != FAIL), "file close succeeded");
2811
2812 return;
2813
2814 } /* link_chunk_collective_io_test() */
2815
2816