summaryrefslogtreecommitdiffstats
path: root/test/vol.c
blob: da42a1e7bbf3b34f0de6ccb81a1b62a175f5fe52 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 * Purpose: Tests the virtual object layer (H5VL)
 *
 *          This is a minimal test to ensure VOL usage (setting a VOL, etc.)
 *          works as expected. Actual VOL functionality is tested using
 *          other mechanisms.
 */

#include "h5test.h"

/* Filename */
const char *FILENAME[] = {
    "native_vol_test",
    NULL
};

#define NATIVE_VOL_TEST_GROUP_NAME      "test_group"
#define NATIVE_VOL_TEST_DATASET_NAME    "test_dataset"
#define NATIVE_VOL_TEST_ATTRIBUTE_NAME  "test_dataset"
#define NATIVE_VOL_TEST_HARD_LINK_NAME  "test_hard_link"
#define NATIVE_VOL_TEST_SOFT_LINK_NAME  "test_soft_link"
#define NATIVE_VOL_TEST_MOVE_LINK_NAME  "test_move_link"
#define NATIVE_VOL_TEST_COPY_LINK_NAME  "test_copy_link"
#define NATIVE_VOL_TEST_DATATYPE_NAME   "test_datatype"

#define N_ELEMENTS  10

#define FAKE_VOL_NAME   "fake"

/* A VOL class struct that describes a VOL class with no
 * functionality.
 */
static const H5VL_class_t fake_vol_g = {
    0,                                              /* version      */
    (H5VL_class_value_t)501,                        /* value        */
    FAKE_VOL_NAME,                                  /* name         */
    0,                                              /* capability flags */
    NULL,                                           /* initialize   */
    NULL,                                           /* terminate    */
    {   /* info_cls */
        (size_t)0,                                  /* size    */
        NULL,                                       /* copy    */
        NULL,                                       /* compare */
        NULL,                                       /* free    */
        NULL,                                       /* to_str  */
        NULL,                                       /* from_str */
    },
    {   /* wrap_cls */
        NULL,                                       /* get_object   */
        NULL,                                       /* get_wrap_ctx */
        NULL,                                       /* wrap_object  */
        NULL,                                       /* unwrap_object */
        NULL,                                       /* free_wrap_ctx */
    },
    {   /* attribute_cls */
        NULL,                                       /* create       */
        NULL,                                       /* open         */
        NULL,                                       /* read         */
        NULL,                                       /* write        */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* close        */
    },
    {   /* dataset_cls */
        NULL,                                       /* create       */
        NULL,                                       /* open         */
        NULL,                                       /* read         */
        NULL,                                       /* write        */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* close        */
    },
    {   /* datatype_cls */
        NULL,                                       /* commit       */
        NULL,                                       /* open         */
        NULL,                                       /* get_size     */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* close        */
    },
    {   /* file_cls */
        NULL,                                       /* create       */
        NULL,                                       /* open         */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* close        */
    },
    {   /* group_cls */
        NULL,                                       /* create       */
        NULL,                                       /* open         */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* close        */
    },
    {   /* link_cls */
        NULL,                                       /* create       */
        NULL,                                       /* copy         */
        NULL,                                       /* move         */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL                                        /* optional     */
    },
    {   /* object_cls */
        NULL,                                       /* open         */
        NULL,                                       /* copy         */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL                                        /* optional     */
    },
    {   /* request_cls */
        NULL,                                       /* wait         */
        NULL,                                       /* notify       */
        NULL,                                       /* cancel       */
        NULL,                                       /* specific     */
        NULL,                                       /* optional     */
        NULL                                        /* free         */
    },
    {   /* blob_cls */
        NULL,                                       /* put          */
        NULL,                                       /* get          */
        NULL,                                       /* specific     */
        NULL                                        /* optional     */
    },
    NULL                                            /* optional     */
};


/*-------------------------------------------------------------------------
 * Function:    test_vol_registration()
 *
 * Purpose:     Tests if we can load, register, and close a simple
 *              VOL connector.
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_vol_registration(void)
{
    hid_t native_id = H5I_INVALID_HID;
    hid_t lapl_id = H5I_INVALID_HID;
    hid_t vipl_id = H5I_INVALID_HID;
    herr_t ret = SUCCEED;
    htri_t is_registered = FAIL;
    hid_t vol_id = H5I_INVALID_HID;
    hid_t vol_id2 = H5I_INVALID_HID;

    TESTING("VOL registration");

    /* The test/fake VOL connector should not be registered at the start of the test */
    if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0)
        TEST_ERROR;
    if (is_registered > 0)
        FAIL_PUTS_ERROR("VOL connector is inappropriately registered");

    /* Test registering a connector with an incorrect property list (SHOULD FAIL) */
    if ((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0)
        TEST_ERROR;
    H5E_BEGIN_TRY {
        vol_id = H5VLregister_connector(&fake_vol_g, lapl_id);
    } H5E_END_TRY;
    if (H5I_INVALID_HID != vol_id)
        FAIL_PUTS_ERROR("should not be able to register a connector with an incorrect property list");
    if (H5Pclose(lapl_id) < 0)
        TEST_ERROR;

    /* Load a VOL interface
     * The vipl_id does nothing without a VOL that needs it, but we do need to
     * test creating a property list of that class and passing it along as a
     * smoke check.
     */
    if ((vipl_id = H5Pcreate(H5P_VOL_INITIALIZE)) < 0)
        TEST_ERROR;
    if ((vol_id = H5VLregister_connector(&fake_vol_g, vipl_id)) < 0)
        TEST_ERROR;
    if (H5Pclose(vipl_id) < 0)
        TEST_ERROR;

    /* The test/fake VOL connector should be registered now */
    if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0)
        TEST_ERROR;
    if (0 == is_registered)
        FAIL_PUTS_ERROR("VOL connector is un-registered");

    /* Re-register a VOL connector */
    if ((vol_id2 = H5VLregister_connector(&fake_vol_g, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* The test/fake VOL connector should still be registered now */
    if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0)
        TEST_ERROR;
    if (0 == is_registered)
        FAIL_PUTS_ERROR("VOL connector is un-registered");

    /* Unregister the second test/fake VOL ID */
    if (H5VLunregister_connector(vol_id2) < 0)
        TEST_ERROR;

    /* The test/fake VOL connector should still be registered now */
    if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0)
        TEST_ERROR;
    if (0 == is_registered)
        FAIL_PUTS_ERROR("VOL connector is un-registered");

    /* Unregister the original test/fake VOL ID */
    if (H5VLunregister_connector(vol_id) < 0)
        TEST_ERROR;

    /* Try to unregister the native VOL connector (should fail) */
    if (H5I_INVALID_HID == (native_id = H5VLget_connector_id(H5VL_NATIVE_NAME)))
        TEST_ERROR;
    H5E_BEGIN_TRY {
        ret = H5VLunregister_connector(native_id);
    } H5E_END_TRY;
    if (FAIL != ret)
        FAIL_PUTS_ERROR("should not be able to unregister the native VOL connector");

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5VLunregister_connector(vol_id);
        H5Pclose(lapl_id);
        H5Pclose(vipl_id);
    } H5E_END_TRY;
    return FAIL;

} /* end test_vol_registration() */


/*-------------------------------------------------------------------------
 * Function:    test_native_vol_init()
 *
 * Purpose:     Tests if the native VOL connector gets initialized.
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_native_vol_init(void)
{
    htri_t is_registered;

    TESTING("Native VOL connector initialization");

    /* The native VOL connector should always be registered */
    if ((is_registered = H5VLis_connector_registered(H5VL_NATIVE_NAME)) < 0)
        TEST_ERROR;
    if (0 == is_registered)
        FAIL_PUTS_ERROR("native VOL connector is un-registered");

    PASSED();
    return SUCCEED;

error:
    return FAIL;

} /* end test_native_vol_init() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_file_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL file operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_file_operation(const char *env_h5_drvr)
{
    hid_t fid           = H5I_INVALID_HID;
    hid_t fid_reopen    = H5I_INVALID_HID;
    hid_t fapl_id       = H5I_INVALID_HID;
    hid_t fapl_id2      = H5I_INVALID_HID;
    hid_t fcpl_id       = H5I_INVALID_HID;

    char            filename[1024];
    ssize_t         obj_count;
    hid_t           obj_id_list[1];
    hsize_t         file_size;
    unsigned        intent;
    void           *os_file_handle = NULL;
    H5F_info2_t     finfo;
    char            name[32];

    TESTING("Basic VOL file operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    /* Set the file close degree to a non-default value, to make the H5Pequal
     *  work out.  This is kinda odd, but the library's current behavior with
     *  a default value is to return the value chosen (H5F_CLOSE_SEMI) instead
     *  of the default value (H5F_CLOSE_DEFAULT) from the property and then
     *  the H5Pequal doesn't detect that the property lists are the same.  Since
     *  this is the documented behavior for file close degree for many years,
     *  I'm not fighting it, just getting the testing to verify that the VOL
     *  connector property is returned correctly.  -QAK, 2018/11/17
     */
    if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0)
        TEST_ERROR;
    if(H5Pset_metadata_read_attempts(fapl_id, 9) < 0)
        TEST_ERROR

    /* H5Fcreate */
    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;

    /* H5Fget_obj_count */
    if ((obj_count = H5Fget_obj_count(fid, H5F_OBJ_FILE)) < 0)
        TEST_ERROR;
    if ((obj_count = H5Fget_obj_count(fid, H5F_OBJ_ALL)) < 0)
        TEST_ERROR;
    if ((obj_count = H5Fget_obj_count((hid_t)H5F_OBJ_ALL, H5F_OBJ_DATASET)) < 0)
        TEST_ERROR;

    /* H5Fget_obj_ids */
    if ((obj_count = H5Fget_obj_ids(fid, H5F_OBJ_ALL, 2, obj_id_list)) < 0)
        TEST_ERROR;
    if ((obj_count = H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_DATASET, 2, obj_id_list)) < 0)
        TEST_ERROR;

    /* Can't compare VFD properties for split / multi / family VFDs */
    if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) {
        /* H5Fget_access_plist */
        if ((fapl_id2 = H5Fget_access_plist(fid)) < 0)
            TEST_ERROR;
        if (H5Pequal(fapl_id, fapl_id2) != TRUE)
            TEST_ERROR;
        if (H5Pclose(fapl_id2) < 0)
            TEST_ERROR;
    } /* end if */

    /* H5Fget_create_plist */
    if ((fcpl_id = H5Fget_create_plist(fid)) < 0)
        TEST_ERROR;
    if (H5Pclose(fcpl_id) < 0)
        TEST_ERROR;

    /* H5Fget_filesize */
    if (H5Fget_filesize(fid, &file_size) < 0)
        TEST_ERROR;

    /* Can't retrieve VFD handle for split / multi / family VFDs */
    if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) {
        /* H5Fget_vfd_handle */
        if (H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0)
            TEST_ERROR;
    } /* end if */

    /* H5Fget_intent */
    if (H5Fget_intent(fid, &intent) < 0)
        TEST_ERROR;

    /* H5Fget_info2 */
    if (H5Fget_info2(fid, &finfo) < 0)
        TEST_ERROR;

    /* H5Fget_name */
    if (H5Fget_name(fid, name, 32) < 0)
        TEST_ERROR;

    /* H5Fclear_elink_file_cache */
    if (H5Fclear_elink_file_cache(fid) < 0)
        TEST_ERROR;

    /* H5Fflush */
    if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
        TEST_ERROR;

    /* H5Fclose */
    if (H5Fclose(fid) < 0)
        TEST_ERROR;

    /* H5Fis_accessible */
    if (H5Fis_accessible(filename, fapl_id) < 0)
        TEST_ERROR;

    /* H5Fopen */
    if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
        TEST_ERROR;

    /* Can't compare VFD properties for split / multi / family VFDs */
    if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) {
        /* H5Fget_access_plist */
        if((fapl_id2 = H5Fget_access_plist(fid)) < 0)
            TEST_ERROR;
        if(H5Pequal(fapl_id, fapl_id2) != TRUE)
            TEST_ERROR;
        if(H5Pclose(fapl_id2) < 0)
            TEST_ERROR;
    } /* end if */

    if ((fid_reopen = H5Freopen(fid)) < 0)
        TEST_ERROR;

    /* Can't compare VFD properties for split / multi / family VFDs */
    if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) {
        /* H5Fget_access_plist */
        if((fapl_id2 = H5Fget_access_plist(fid_reopen)) < 0)
            TEST_ERROR;
        if(H5Pequal(fapl_id, fapl_id2) != TRUE)
            TEST_ERROR;
        if(H5Pclose(fapl_id2) < 0)
            TEST_ERROR;
    } /* end if */

    if (H5Fclose(fid) < 0)
        TEST_ERROR;
    if (H5Fclose(fid_reopen) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Fclose(fid_reopen);
        H5Pclose(fapl_id);
        H5Pclose(fapl_id2);
        H5Pclose(fcpl_id);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_file_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_group_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL group operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_group_operation(void)
{
    hid_t fid = H5I_INVALID_HID;
    hid_t fapl_id = H5I_INVALID_HID;
    hid_t gid = H5I_INVALID_HID;
    hid_t gid_a = H5I_INVALID_HID;
    hid_t gcpl_id = H5I_INVALID_HID;
    char filename[1024];
    H5G_info_t info;

    TESTING("Basic VOL group operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;

    /* H5Gcreate */
    if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Gget_create_plist */
    if ((gcpl_id = H5Gget_create_plist(gid)) < 0)
        TEST_ERROR;
    if (H5Pclose(gcpl_id) < 0)
        TEST_ERROR;

    /* H5Gget_info */
    if (H5Gget_info(gid, &info) < 0)
        TEST_ERROR;
    if (H5Gget_info(fid, &info) < 0)
        TEST_ERROR;

    /* H5Gget_info_by_name */
    if (H5Gget_info_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, &info, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Gget_info_by_idx */
    if (H5Gget_info_by_idx(fid, "/", H5_INDEX_NAME, H5_ITER_NATIVE, 0, &info, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Gflush */
    if (H5Gflush(gid) < 0)
        TEST_ERROR;

    /* H5Gclose */
    if (H5Gclose(gid) < 0)
        TEST_ERROR;

    /* H5Gopen */
    if ((gid = H5Gopen2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Gcreate_anon */
    if ((gid_a = H5Gcreate_anon(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Grefresh */
    if (H5Grefresh(gid) < 0)
        TEST_ERROR;

    if (H5Gclose(gid) < 0)
        TEST_ERROR;
    if (H5Gclose(gid_a) < 0)
        TEST_ERROR;
    if (H5Fclose(fid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Gclose(gid);
        H5Pclose(fapl_id);
        H5Pclose(gcpl_id);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_group_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_dataset_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL dataset operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_dataset_operation(void)
{
    hid_t fid       = H5I_INVALID_HID;
    hid_t fapl_id   = H5I_INVALID_HID;
    hid_t dcpl_id   = H5I_INVALID_HID;
    hid_t dapl_id   = H5I_INVALID_HID;
    hid_t did       = H5I_INVALID_HID;
    hid_t did_a     = H5I_INVALID_HID;
    hid_t sid       = H5I_INVALID_HID;
    hid_t tid       = H5I_INVALID_HID;

    char filename[1024];

    hsize_t curr_dims   = 0;
    hsize_t max_dims    = H5S_UNLIMITED;

    hsize_t storage_size;
    haddr_t offset;
    H5D_space_status_t status;

    int in_buf[N_ELEMENTS];
    int out_buf[N_ELEMENTS];

    int i;

    TESTING("Basic VOL dataset operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;
    for (i = 0; i < N_ELEMENTS; i++) {
        in_buf[i] = i;
        out_buf[i] = 0;
    }

    /* H5Dcreate */
    curr_dims = 0;
    if ((sid = H5Screate_simple(1, &curr_dims, &max_dims)) < 0)
        TEST_ERROR;
    curr_dims = N_ELEMENTS;
    if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
        TEST_ERROR;
    if (H5Pset_chunk(dcpl_id, 1, &curr_dims) < 0)
        TEST_ERROR;
    if ((did = H5Dcreate2(fid, NATIVE_VOL_TEST_DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Dcreate_anon */
    if ((did_a = H5Dcreate_anon(fid, H5T_NATIVE_INT, sid, dcpl_id, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    if (H5Sclose(sid) < 0)
        TEST_ERROR;
    if (H5Pclose(dcpl_id) < 0)
        TEST_ERROR;

    /* H5Dset_extent */
    curr_dims = N_ELEMENTS;
    if (H5Dset_extent(did, &curr_dims) < 0)
        TEST_ERROR;

    /* H5Dflush */
    if (H5Dflush(did) < 0)
        TEST_ERROR;

    /* H5Dwrite */
    if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, in_buf) < 0)
        TEST_ERROR;

    /* H5Drefresh */
    if (H5Drefresh(did) < 0)
        TEST_ERROR;

    /* H5Dclose */
    if (H5Dclose(did) < 0)
        TEST_ERROR;
    if (H5Dclose(did_a) < 0)
        TEST_ERROR;

    /* H5Dopen */
    if ((did = H5Dopen2(fid, NATIVE_VOL_TEST_DATASET_NAME, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Dget_space */
    if ((sid = H5Dget_space(did)) < 0)
        TEST_ERROR;
    if (H5Sclose(sid) < 0)
        TEST_ERROR;

    /* H5Dget_space_status */
    if (H5Dget_space_status(did, &status) < 0)
        TEST_ERROR;

    /* H5Dget_type */
    if ((tid = H5Dget_type(did)) < 0)
        TEST_ERROR;
    if (H5Tclose(tid) < 0)
        TEST_ERROR;

    /* H5Tcopy (when used w/ a dataset, it gets an H5VL struct */
    if ((tid = H5Tcopy(did)) < 0)
        TEST_ERROR;
    if (H5Tclose(tid) < 0)
        TEST_ERROR;

    /* H5Dget_create_plist */
    if ((dcpl_id = H5Dget_create_plist(did)) < 0)
        TEST_ERROR;
    if (H5Pclose(dcpl_id) < 0)
        TEST_ERROR;

    /* H5Dget_access_plist */
    if ((dapl_id = H5Dget_access_plist(did)) < 0)
        TEST_ERROR;
    if (H5Pclose(dapl_id) < 0)
        TEST_ERROR;

    /* H5Dget_storage_size */
    /* XXX: This is a terrible API call that can't truly indicate failure */
    if (0 == (storage_size = H5Dget_storage_size(did)))
        TEST_ERROR;

    /* H5Dget_offset */
    /* XXX: Another bad API call that can't flag error values. Also, this
     *      returns HADDR_UNDEF for chunked datasets, which is bizarre.
     */
    if (HADDR_UNDEF != (offset = H5Dget_offset(did)))
        TEST_ERROR;

    /* H5Dread */
    if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, out_buf) < 0)
        TEST_ERROR;

    for (i = 0; i < N_ELEMENTS; i++)
        if (in_buf[i] != out_buf[i])
            TEST_ERROR;

    if (H5Dclose(did) < 0)
        TEST_ERROR;
    if (H5Fclose(fid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Dclose(did);
        H5Dclose(did_a);
        H5Sclose(sid);
        H5Tclose(tid);
        H5Pclose(fapl_id);
        H5Pclose(dapl_id);
        H5Pclose(dcpl_id);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_dataset_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_attribute_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL attribute operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_attribute_operation(void)
{
    hid_t fid       = H5I_INVALID_HID;
    hid_t fapl_id   = H5I_INVALID_HID;
    hid_t gid       = H5I_INVALID_HID;
    hid_t aid       = H5I_INVALID_HID;
    hid_t aid_name  = H5I_INVALID_HID;
    hid_t sid       = H5I_INVALID_HID;

    char    filename[1024];

    hsize_t dims    = 1;

    int     data_in     = 42;
    int     data_out    = 0;

    TESTING("Basic VOL attribute operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;
    if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;
    dims = 1;
    if ((sid = H5Screate_simple(1, &dims, &dims)) < 0)
        TEST_ERROR;

    /* H5Acreate */
    if ((aid = H5Acreate2(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Awrite */
    if (H5Awrite(aid, H5T_NATIVE_INT, &data_in) < 0)
        TEST_ERROR;

    /* H5Aread */
    if (H5Aread(aid, H5T_NATIVE_INT, &data_out) < 0)
        TEST_ERROR;
    if (data_in != data_out)
        TEST_ERROR;

    /* H5Aclose */
    if (H5Aclose(aid) < 0)
        TEST_ERROR;

    /* H5Aopen */
    if ((aid = H5Aopen(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5P_DEFAULT)) < 0)
        TEST_ERROR;
    if (H5Aclose(aid) < 0)
        TEST_ERROR;

    /* H5Adelete */
    if (H5Adelete(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME) < 0)
        TEST_ERROR;

    /* H5Acreate_by_name */
    if ((aid_name = H5Acreate_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;
    /* H5Aclose */
    if (H5Aclose(aid_name) < 0)
        TEST_ERROR;

    /* H5Adelete_by_name */
    if (H5Adelete_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5P_DEFAULT) < 0)
        TEST_ERROR;

    if (H5Sclose(sid) < 0)
        TEST_ERROR;
    if (H5Gclose(gid) < 0)
        TEST_ERROR;
    if (H5Fclose(fid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Pclose(fapl_id);
        H5Gclose(gid);
        H5Sclose(sid);
        H5Aclose(aid);
        H5Aclose(aid_name);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_attribute_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_object_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL object operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_object_operation(void)
{
    hid_t fid       = H5I_INVALID_HID;
    hid_t fapl_id   = H5I_INVALID_HID;
    hid_t gid       = H5I_INVALID_HID;
    hid_t oid       = H5I_INVALID_HID;

    char filename[1024];
    H5O_info_t object_info;

    TESTING("Basic VOL object operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;
    if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Oget_info */
    if (H5Oget_info2(fid, &object_info, H5O_INFO_ALL) < 0)
        TEST_ERROR;

    /* H5Oget_info_by_name */
    if (H5Oget_info_by_name2(fid, NATIVE_VOL_TEST_GROUP_NAME, &object_info, H5O_INFO_ALL, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Oexists_by_name */
    if (H5Oexists_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT) != TRUE) 
        TEST_ERROR;

    /* H5Oopen/close */
    if ((oid = H5Oopen(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT)) < 0) 
        TEST_ERROR;
    if (H5Oclose(oid) < 0)
        TEST_ERROR;

    if (H5Fclose(fid) < 0)
        TEST_ERROR;
    if (H5Gclose(gid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;


    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Pclose(fapl_id);
        H5Gclose(gid);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_object_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_link_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL link operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_link_operation(void)
{
    hid_t fid       = H5I_INVALID_HID;
    hid_t gid       = H5I_INVALID_HID;
    hid_t fapl_id   = H5I_INVALID_HID;
    char filename[1024];

    TESTING("Basic VOL link operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;
    if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Lcreate_hard */
    if (H5Lcreate_hard(fid, "/", gid, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Lcreate_soft (to itself) */
    if (H5Lcreate_soft("/", fid, NATIVE_VOL_TEST_SOFT_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Lexists */
    if (H5Lexists(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT) < 0)
        TEST_ERROR;
    if (H5Lexists(fid, NATIVE_VOL_TEST_SOFT_LINK_NAME, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Lcopy */
    if (H5Lcopy(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, fid, NATIVE_VOL_TEST_COPY_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Lmove */
    if (H5Lmove(fid, NATIVE_VOL_TEST_COPY_LINK_NAME, gid, NATIVE_VOL_TEST_MOVE_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    if (H5Fclose(fid) < 0)
        TEST_ERROR;
    if (H5Gclose(gid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;


    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Fclose(fid);
        H5Fclose(gid);
        H5Pclose(fapl_id);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_link_operation() */


/*-------------------------------------------------------------------------
 * Function:    test_basic_datatype_operation()
 *
 * Purpose:     Uses the native VOL connector to test basic VOL datatype operations
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_basic_datatype_operation(void)
{
    hid_t fid       = H5I_INVALID_HID;
    hid_t fapl_id   = H5I_INVALID_HID;
    hid_t tid       = H5I_INVALID_HID;
    hid_t tid_anon  = H5I_INVALID_HID;
    hid_t tcpl_id   = H5I_INVALID_HID;
    char filename[1024];

    TESTING("Basic VOL datatype operations");

    /* Retrieve the file access property for testing */
    fapl_id = h5_fileaccess();
    h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);

    if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
        TEST_ERROR;
    if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
        TEST_ERROR;

    /* H5Tcommit */
    if (H5Tcommit2(fid, NATIVE_VOL_TEST_DATATYPE_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    /* H5Tflush */
    if (H5Tflush(tid) < 0)
        TEST_ERROR;

    /* H5Trefresh */
    if (H5Trefresh(tid) < 0)
        TEST_ERROR;

    /* H5Tclose */
    if (H5Tclose(tid) < 0)
        TEST_ERROR;

    /* H5Topen */
    if ((tid = H5Topen2(fid, NATIVE_VOL_TEST_DATATYPE_NAME, H5P_DEFAULT)) < 0)
        TEST_ERROR;

    /* H5Tget_create_plist */
    if ((tcpl_id = H5Tget_create_plist(tid)) < 0)
        TEST_ERROR;

    /* H5Tcommit_anon */
    if ((tid_anon = H5Tcopy(H5T_NATIVE_INT)) < 0)
        TEST_ERROR;
    if (H5Tcommit_anon(fid, tid_anon, H5P_DEFAULT, H5P_DEFAULT) < 0)
        TEST_ERROR;

    if (H5Pclose(tcpl_id) < 0)
        TEST_ERROR;
    if (H5Tclose(tid) < 0)
        TEST_ERROR;
    if (H5Tclose(tid_anon) < 0)
        TEST_ERROR;
    if (H5Fclose(fid) < 0)
        TEST_ERROR;

    h5_delete_test_file(FILENAME[0], fapl_id);

    /* H5Pclose */
    if (H5Pclose(fapl_id) < 0)
        TEST_ERROR;

    PASSED();
    return SUCCEED;

error:
    H5E_BEGIN_TRY {
        H5Pclose(tcpl_id);
        H5Fclose(fid);
        H5Pclose(fapl_id);
        H5Tclose(tid);
        H5Tclose(tid_anon);
    } H5E_END_TRY;

    return FAIL;

} /* end test_basic_datatype_operation() */


/*-------------------------------------------------------------------------
 * Function:    main
 *
 * Purpose:     Tests the virtual object layer interface (H5VL)
 *
 * Return:      EXIT_SUCCESS/EXIT_FAILURE
 *
 *-------------------------------------------------------------------------
 */
int
main(void)
{
    const char  *env_h5_drvr;   /* File driver value from environment */
    int nerrors = 0;

    /* Get the VFD to use */
    env_h5_drvr = HDgetenv("HDF5_DRIVER");
    if(env_h5_drvr == NULL)
        env_h5_drvr = "nomatch";

    h5_reset();

    HDputs("Testing basic Virtual Object Layer (VOL) functionality.");

    nerrors += test_vol_registration() < 0          ? 1 : 0;
    nerrors += test_native_vol_init() < 0           ? 1 : 0;
    nerrors += test_basic_file_operation(env_h5_drvr) < 0 ? 1 : 0;
    nerrors += test_basic_group_operation() < 0     ? 1 : 0;
    nerrors += test_basic_dataset_operation() < 0   ? 1 : 0;
    nerrors += test_basic_attribute_operation() < 0 ? 1 : 0;
    nerrors += test_basic_object_operation() < 0    ? 1 : 0;
    nerrors += test_basic_link_operation() < 0      ? 1 : 0;
    nerrors += test_basic_datatype_operation() < 0  ? 1 : 0;

    if (nerrors) {
        HDprintf("***** %d Virtual Object Layer TEST%s FAILED! *****\n",
            nerrors, nerrors > 1 ? "S" : "");
        HDexit(EXIT_FAILURE);
    }

    HDputs("All Virtual Object Layer (VOL) tests passed.");

    HDexit(EXIT_SUCCESS);

} /* end main() */

pan>), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET3, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); /* create a file dataspace independently */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); if (mpi_rank_g == 0) { ret = H5Sselect_all(file_dataspace); VRFY_G((ret >= 0), "H5Sset_all succeeded"); } else { ret = H5Sselect_none(file_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); if (mpi_rank_g != 0) { ret = H5Sselect_none(mem_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* fill the local slab with some trivial data */ fill_datasets(start, dims, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); } ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); /* Point selection */ if (mpi_rank_g == 0) HDprintf("\nTesting Dataset4 write point selection\n"); /* Create a large dataset */ dims[0] = bigcount; dims[1] = (hsize_t)(mpi_size_g * 4); sid = H5Screate_simple(RANK, dims, NULL); VRFY_G((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET4, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); block[0] = dims[0] / 2; block[1] = 2; stride[0] = dims[0] / 2; stride[1] = 2; count[0] = 1; count[1] = 1; start[0] = 0; start[1] = dims[1] / (hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; num_points = bigcount; coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); VRFY_G((coords != NULL), "coords malloc succeeded"); set_coords(start, count, stride, block, num_points, coords, IN_ORDER); /* create a file dataspace */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((ret >= 0), "H5Sselect_elements succeeded"); if (coords) free(coords); fill_datasets(start, block, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } /* create a memory dataspace */ /* Warning: H5Screate_simple requires an array of hsize_t elements * even if we only pass only a single value. Attempting anything else * appears to cause problems with 32 bit compilers. */ mem_dataspace = H5Screate_simple(1, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); HDfree(wdata); H5Fclose(fid); } /* * Example of using the parallel HDF5 library to read two datasets * in one HDF5 file with collective parallel access support. * The Datasets are of sizes (number-of-mpi-processes x dim0) x dim1. * Each process controls only a slab of size dim0 x dim1 within each * dataset. [Note: not so yet. Datasets are of sizes dim0xdim1 and * each process controls a hyperslab within.] */ static void dataset_big_read(void) { hid_t fid; /* HDF5 file ID */ hid_t acc_tpl; /* File access templates */ hid_t xfer_plist; /* Dataset transfer properties list */ hid_t file_dataspace; /* File dataspace ID */ hid_t mem_dataspace; /* memory dataspace ID */ hid_t dataset; B_DATATYPE *rdata = NULL; /* data buffer */ B_DATATYPE *wdata = NULL; /* expected data buffer */ hsize_t dims[RANK]; /* dataset dim sizes */ hsize_t start[RANK]; /* for hyperslab setting */ hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ hsize_t block[RANK]; /* for hyperslab setting */ size_t num_points; hsize_t *coords = NULL; herr_t ret; /* Generic return value */ /* allocate memory for data buffer */ rdata = (B_DATATYPE *)HDmalloc(bigcount * sizeof(B_DATATYPE)); VRFY_G((rdata != NULL), "rdata malloc succeeded"); wdata = (B_DATATYPE *)HDmalloc(bigcount * sizeof(B_DATATYPE)); VRFY_G((wdata != NULL), "wdata malloc succeeded"); HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); /* setup file access template */ acc_tpl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((acc_tpl >= 0), "H5P_FILE_ACCESS"); H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); /* open the file collectively */ fid = H5Fopen(FILENAME[0], H5F_ACC_RDONLY, acc_tpl); VRFY_G((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY_G((ret >= 0), ""); if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset1 by COL\n"); dataset = H5Dopen2(fid, DATASET1, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; /* Each process takes a slabs of cols. */ block[0] = dims[0]; block[1] = dims[1] / (hsize_t)mpi_size_g; stride[0] = block[0]; stride[1] = block[1]; count[0] = 1; count[1] = 1; start[0] = 0; start[1] = (hsize_t)mpi_rank_g * block[1]; /* create a file dataspace independently */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill dataset with test data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset1 succeeded"); /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); if (ret) { HDfprintf(stderr, "verify failed\n"); exit(1); } /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset2 by ROW\n"); HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); dataset = H5Dopen2(fid, DATASET2, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; /* Each process takes a slabs of rows. */ block[0] = dims[0] / (hsize_t)mpi_size_g; block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; count[0] = 1; count[1] = 1; start[0] = (hsize_t)mpi_rank_g * block[0]; start[1] = 0; /* create a file dataspace independently */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill dataset with test data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset2 succeeded"); /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); if (ret) { HDfprintf(stderr, "verify failed\n"); exit(1); } /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset3 read select ALL proc 0, NONE others\n"); HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); dataset = H5Dopen2(fid, DATASET3, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); dims[0] = bigcount; dims[1] = 1; /* create a file dataspace independently */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); if (mpi_rank_g == 0) { ret = H5Sselect_all(file_dataspace); VRFY_G((ret >= 0), "H5Sset_all succeeded"); } else { ret = H5Sselect_none(file_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } /* create a memory dataspace independently */ mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); if (mpi_rank_g != 0) { ret = H5Sselect_none(mem_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } /* fill dataset with test data */ fill_datasets(start, dims, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); } /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset3 succeeded"); if (mpi_rank_g == 0) { /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); if (ret) { HDfprintf(stderr, "verify failed\n"); exit(1); } } /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset4 with Point selection\n"); dataset = H5Dopen2(fid, DATASET4, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); dims[0] = bigcount; dims[1] = (hsize_t)(mpi_size_g * 4); block[0] = dims[0] / 2; block[1] = 2; stride[0] = dims[0] / 2; stride[1] = 2; count[0] = 1; count[1] = 1; start[0] = 0; start[1] = dims[1] / (hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; fill_datasets(start, block, wdata); MESG("data_array initialized"); if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } num_points = bigcount; coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); VRFY_G((coords != NULL), "coords malloc succeeded"); set_coords(start, count, stride, block, num_points, coords, IN_ORDER); /* create a file dataspace */ file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((ret >= 0), "H5Sselect_elements succeeded"); if (coords) HDfree(coords); /* create a memory dataspace */ /* Warning: H5Screate_simple requires an array of hsize_t elements * even if we only pass only a single value. Attempting anything else * appears to cause problems with 32 bit compilers. */ mem_dataspace = H5Screate_simple(1, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset1 succeeded"); ret = verify_data(start, count, stride, block, rdata, wdata); if (ret) { HDfprintf(stderr, "verify failed\n"); exit(1); } /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); HDfree(wdata); HDfree(rdata); wdata = NULL; rdata = NULL; /* We never wrote Dataset5 in the write section, so we can't * expect to read it... */ file_dataspace = -1; mem_dataspace = -1; xfer_plist = -1; dataset = -1; /* release all temporary handles. */ if (file_dataspace != -1) H5Sclose(file_dataspace); if (mem_dataspace != -1) H5Sclose(mem_dataspace); if (xfer_plist != -1) H5Pclose(xfer_plist); if (dataset != -1) { ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); } H5Fclose(fid); /* release data buffers */ if (rdata) HDfree(rdata); if (wdata) HDfree(wdata); } /* dataset_large_readAll */ /* * Create the appropriate File access property list */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) { hid_t ret_pl = -1; herr_t ret; /* generic return value */ int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) return (ret_pl); if (l_facc_type == FACC_MPIO) { /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(ret_pl, comm, info); VRFY_G((ret >= 0), ""); ret = H5Pset_all_coll_metadata_ops(ret_pl, TRUE); VRFY_G((ret >= 0), ""); ret = H5Pset_coll_metadata_write(ret_pl, TRUE); VRFY_G((ret >= 0), ""); return (ret_pl); } if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { hid_t mpio_pl; mpio_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((mpio_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(mpio_pl, comm, info); VRFY_G((ret >= 0), ""); /* setup file access template */ ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((ret_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); VRFY_G((ret >= 0), "H5Pset_fapl_split succeeded"); H5Pclose(mpio_pl); return (ret_pl); } /* unknown file access types */ return (ret_pl); } /*------------------------------------------------------------------------- * Function: coll_chunk1 * * Purpose: Wrapper to test the collective chunk IO for regular JOINT selection with a single chunk * * Return: Success: 0 * * Failure: -1 * * Programmer: Unknown * July 12th, 2004 * *------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ * Descriptions for the selection: One big singular selection inside one chunk * Two dimensions, * * dim1 = space_dim1(5760)*mpi_size * dim2 = space_dim2(3) * chunk_dim1 = dim1 * chunk_dim2 = dim2 * block = 1 for all dimensions * stride = 1 for all dimensions * count0 = space_dim1(5760) * count1 = space_dim2(3) * start0 = mpi_rank*space_dim1 * start1 = 0 * ------------------------------------------------------------------------ */ void coll_chunk1(void) { const char *filename = FILENAME[0]; if (mpi_rank_g == 0) HDprintf("coll_chunk1\n"); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, HYPER, POINT, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, ALL, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, POINT, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, HYPER, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, ALL, IN_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, POINT, IN_ORDER); coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, HYPER, IN_ORDER); } /*------------------------------------------------------------------------- * Function: coll_chunk2 * * Purpose: Wrapper to test the collective chunk IO for regular DISJOINT selection with a single chunk * * Return: Success: 0 * * Failure: -1 * * Programmer: Unknown * July 12th, 2004 * * Modifications: * *------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ * Descriptions for the selection: many disjoint selections inside one chunk * Two dimensions, * * dim1 = space_dim1*mpi_size(5760) * dim2 = space_dim2(3) * chunk_dim1 = dim1 * chunk_dim2 = dim2 * block = 1 for all dimensions * stride = 3 for all dimensions * count0 = space_dim1/stride0(5760/3) * count1 = space_dim2/stride(3/3 = 1) * start0 = mpi_rank*space_dim1 * start1 = 0 * * ------------------------------------------------------------------------ */ void coll_chunk2(void) { const char *filename = FILENAME[0]; if (mpi_rank_g == 0) HDprintf("coll_chunk2\n"); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, HYPER, POINT, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, ALL, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, POINT, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, HYPER, OUT_OF_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, ALL, IN_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, POINT, IN_ORDER); coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, HYPER, IN_ORDER); } /*------------------------------------------------------------------------- * Function: coll_chunk3 * * Purpose: Wrapper to test the collective chunk IO for regular JOINT selection with at least number of 2*mpi_size chunks * * Return: Success: 0 * * Failure: -1 * * Programmer: Unknown * July 12th, 2004 * *------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ * Descriptions for the selection: one singular selection across many chunks * Two dimensions, Num of chunks = 2* mpi_size * * dim1 = space_dim1*mpi_size * dim2 = space_dim2(3) * chunk_dim1 = space_dim1 * chunk_dim2 = dim2/2 * block = 1 for all dimensions * stride = 1 for all dimensions * count0 = space_dim1 * count1 = space_dim2(3) * start0 = mpi_rank*space_dim1 * start1 = 0 * * ------------------------------------------------------------------------ */ void coll_chunk3(void) { const char *filename = FILENAME[0]; if (mpi_rank_g == 0) HDprintf("coll_chunk3\n"); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, HYPER, POINT, OUT_OF_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, ALL, OUT_OF_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, POINT, OUT_OF_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, HYPER, OUT_OF_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, ALL, IN_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, POINT, IN_ORDER); coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, HYPER, IN_ORDER); } //------------------------------------------------------------------------- // Borrowed/Modified (slightly) from t_coll_chunk.c /*------------------------------------------------------------------------- * Function: coll_chunktest * * Purpose: The real testing routine for regular selection of collective chunking storage testing both write and read, If anything fails, it may be read or write. There is no separation test between read and write. * * Return: Success: 0 * * Failure: -1 * * Programmer: Unknown * July 12th, 2004 * *------------------------------------------------------------------------- */ static void coll_chunktest(const char *filename, int chunk_factor, int select_factor, int api_option, int file_selection, int mem_selection, int mode) { hid_t file, dataset, file_dataspace, mem_dataspace; hid_t acc_plist, xfer_plist, crp_plist; hsize_t dims[RANK], chunk_dims[RANK]; int *data_array1 = NULL; int *data_origin1 = NULL; hsize_t start[RANK], count[RANK], stride[RANK], block[RANK]; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY unsigned prop_value; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ herr_t status; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; size_t num_points; /* for point selection */ hsize_t *coords = NULL; /* for point selection */ /* Create the data space */ acc_plist = create_faccess_plist(comm, info, facc_type); VRFY_G((acc_plist >= 0), ""); file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_plist); VRFY_G((file >= 0), "H5Fcreate succeeded"); status = H5Pclose(acc_plist); VRFY_G((status >= 0), ""); /* setup dimensionality object */ dims[0] = space_dim1 * (hsize_t)mpi_size_g; dims[1] = space_dim2; /* allocate memory for data buffer */ data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); VRFY_G((data_array1 != NULL), "data_array1 malloc succeeded"); /* set up dimensions of the slab this process accesses */ ccslab_set(mpi_rank_g, mpi_size_g, start, count, stride, block, select_factor); /* set up the coords array selection */ num_points = block[0] * block[1] * count[0] * count[1]; coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); VRFY_G((coords != NULL), "coords malloc succeeded"); point_set(start, count, stride, block, num_points, coords, mode); /* Warning: H5Screate_simple requires an array of hsize_t elements * even if we only pass only a single value. Attempting anything else * appears to cause problems with 32 bit compilers. */ file_dataspace = H5Screate_simple(2, dims, NULL); VRFY_G((file_dataspace >= 0), "file dataspace created succeeded"); if (ALL != mem_selection) { mem_dataspace = H5Screate_simple(2, dims, NULL); VRFY_G((mem_dataspace >= 0), "mem dataspace created succeeded"); } else { /* Putting the warning about H5Screate_simple (above) into practice... */ hsize_t dsdims[1] = {num_points}; mem_dataspace = H5Screate_simple(1, dsdims, NULL); VRFY_G((mem_dataspace >= 0), "mem_dataspace create succeeded"); } crp_plist = H5Pcreate(H5P_DATASET_CREATE); VRFY_G((crp_plist >= 0), ""); /* Set up chunk information. */ chunk_dims[0] = dims[0] / (hsize_t)chunk_factor; /* to decrease the testing time, maintain bigger chunk size */ (chunk_factor == 1) ? (chunk_dims[1] = space_dim2) : (chunk_dims[1] = space_dim2 / 2); status = H5Pset_chunk(crp_plist, 2, chunk_dims); VRFY_G((status >= 0), "chunk creation property list succeeded"); dataset = H5Dcreate2(file, DSET_COLLECTIVE_CHUNK_NAME, H5T_NATIVE_INT, file_dataspace, H5P_DEFAULT, crp_plist, H5P_DEFAULT); VRFY_G((dataset >= 0), "dataset created succeeded"); status = H5Pclose(crp_plist); VRFY_G((status >= 0), ""); /*put some trivial data in the data array */ ccdataset_fill(start, stride, count, block, data_array1, mem_selection); MESG("data_array initialized"); switch (file_selection) { case HYPER: status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((status >= 0), "hyperslab selection succeeded"); break; case POINT: if (num_points) { status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((status >= 0), "Element selection succeeded"); } else { status = H5Sselect_none(file_dataspace); VRFY_G((status >= 0), "none selection succeeded"); } break; case ALL: status = H5Sselect_all(file_dataspace); VRFY_G((status >= 0), "H5Sselect_all succeeded"); break; } switch (mem_selection) { case HYPER: status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((status >= 0), "hyperslab selection succeeded"); break; case POINT: if (num_points) { status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((status >= 0), "Element selection succeeded"); } else { status = H5Sselect_none(mem_dataspace); VRFY_G((status >= 0), "none selection succeeded"); } break; case ALL: status = H5Sselect_all(mem_dataspace); VRFY_G((status >= 0), "H5Sselect_all succeeded"); break; } /* set up the collective transfer property list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((status >= 0), "MPIO collective transfer property succeeded"); if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); VRFY_G((status >= 0), "set independent IO collectively succeeded"); } switch (api_option) { case API_LINK_HARD: status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_ONE_IO); VRFY_G((status >= 0), "collective chunk optimization succeeded"); break; case API_MULTI_HARD: status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_MULTI_IO); VRFY_G((status >= 0), "collective chunk optimization succeeded "); break; case API_LINK_TRUE: status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 2); VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); break; case API_LINK_FALSE: status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 6); VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); break; case API_MULTI_COLL: status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 50); VRFY_G((status >= 0), "collective chunk optimization set chunk ratio succeeded"); break; case API_MULTI_IND: status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 100); VRFY_G((status >= 0), "collective chunk optimization set chunk ratio succeeded"); break; default:; } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY if (facc_type == FACC_MPIO) { switch (api_option) { case API_LINK_HARD: prop_value = H5D_XFER_COLL_CHUNK_DEF;