/**************************************************************************** * NCSA HDF * * Software Development Group * * National Center for Supercomputing Applications * * University of Illinois at Urbana-Champaign * * 605 E. Springfield, Champaign IL 61820 * * * * For conditions of distribution and use, see the accompanying * * hdf/COPYING file. * * * ****************************************************************************/ #ifdef RCSID static char RcsId[] = "$Revision$"; #endif /* $Id$ */ /*********************************************************** * * Test program: tselect * * Test the Dataspace selection functionality * *************************************************************/ #include #include #define FILENAME "tselect.h5" /* 3-D dataset with fixed dimensions */ #define SPACE1_NAME "Space1" #define SPACE1_RANK 3 #define SPACE1_DIM1 3 #define SPACE1_DIM2 15 #define SPACE1_DIM3 13 /* 2-D dataset with fixed dimensions */ #define SPACE2_NAME "Space2" #define SPACE2_RANK 2 #define SPACE2_DIM1 30 #define SPACE2_DIM2 26 /* 2-D dataset with fixed dimensions */ #define SPACE3_NAME "Space3" #define SPACE3_RANK 2 #define SPACE3_DIM1 15 #define SPACE3_DIM2 26 /* 3-D dataset with fixed dimensions */ #define SPACE4_NAME "Space4" #define SPACE4_RANK 3 #define SPACE4_DIM1 11 #define SPACE4_DIM2 13 #define SPACE4_DIM3 17 /* Number of random hyperslabs to test */ #define NHYPERSLABS 10 /* Number of random hyperslab tests performed */ #define NRAND_HYPER 100 /* 5-D dataset with fixed dimensions */ #define SPACE5_NAME "Space5" #define SPACE5_RANK 5 #define SPACE5_DIM1 10 #define SPACE5_DIM2 10 #define SPACE5_DIM3 10 #define SPACE5_DIM4 10 #define SPACE5_DIM5 10 /* 1-D dataset with same size as 5-D dataset */ #define SPACE6_NAME "Space6" #define SPACE6_RANK 1 #define SPACE6_DIM1 (SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5) /* Element selection information */ #define POINT1_NPOINTS 10 /* Location comparison function */ int compare_size_t(const void *s1, const void *s2); herr_t test_select_hyper_iter1(void *elem,hid_t type_id, hsize_t ndim, hssize_t *point, void *operator_data); herr_t test_select_point_iter1(void *elem,hid_t type_id, hsize_t ndim, hssize_t *point, void *operator_data); herr_t test_select_all_iter1(void *elem,hid_t type_id, hsize_t ndim, hssize_t *point, void *operator_data); herr_t test_select_none_iter1(void *elem,hid_t type_id, hsize_t ndim, hssize_t *point, void *operator_data); herr_t test_select_hyper_iter2(void *_elem, hid_t UNUSED type_id, hsize_t ndim, hssize_t *point, void *_operator_data); /**************************************************************** ** ** test_select_hyper_iter1(): Iterator for checking hyperslab iteration ** ****************************************************************/ herr_t test_select_hyper_iter1(void *_elem,hid_t UNUSED type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void *_operator_data) { uint8_t *tbuf=(uint8_t *)_elem, /* temporary buffer pointer */ **tbuf2=(uint8_t **)_operator_data; /* temporary buffer handle */ if(*tbuf!=**tbuf2) return(-1); else { (*tbuf2)++; return(0); } } /* end test_select_hyper_iter1() */ /**************************************************************** ** ** test_select_hyper(): Test basic H5S (dataspace) selection code. ** Tests hyperslabs of various sizes and dimensionalities. ** ****************************************************************/ static void test_select_hyper(void) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1,sid2; /* Dataspace ID */ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; hssize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ uint8_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf; /* temporary buffer pointer */ intn i,j; /* Counters */ herr_t ret; /* Generic return value */ H5S_class_t ext_type; /* Extent type */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions\n")); /* Allocate write & read buffers */ wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2); /* Initialize write buffer */ for(i=0, tbuf=wbuf; ibuf+(pnt_info->coord[pnt_info->offset][0]*SPACE2_DIM2)+pnt_info->coord[pnt_info->offset][1]; if(*elem!=*tmp) return(-1); else { pnt_info->offset++; return(0); } } /* end test_select_hyper_iter1() */ /**************************************************************** ** ** test_select_point(): Test basic H5S (dataspace) selection code. ** Tests element selections between dataspaces of various sizes ** and dimensionalities. ** ****************************************************************/ static void test_select_point(void) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1,sid2; /* Dataspace ID */ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; hssize_t coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ hssize_t temp_coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ hssize_t coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ hssize_t temp_coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ hssize_t coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ hssize_t temp_coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ uint8_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf; /* temporary buffer pointer */ intn i,j; /* Counters */ struct pnt_iter pi; /* Custom Pointer iterator struct */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Element Selection Functions\n")); /* Allocate write & read buffers */ wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i*(const size_t *)s2) return(1); else return(0); } /**************************************************************** ** ** test_select_hyper_stride(): Test H5S (dataspace) selection code. ** Tests strided hyperslabs of various sizes and dimensionalities. ** ****************************************************************/ static void test_select_hyper_stride(void) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1,sid2; /* Dataspace ID */ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; hssize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ uint16_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf, /* temporary buffer pointer */ *tbuf2; /* temporary buffer pointer */ size_t loc1[72]={ /* Gruesomely ugly way to make certain hyperslab locations are checked correctly */ 27, 28, 29, 53, 54, 55, 79, 80, 81, /* Block #1 */ 32, 33, 34, 58, 59, 60, 84, 85, 86, /* Block #2 */ 157,158,159,183,184,185,209,210,211, /* Block #3 */ 162,163,164,188,189,190,214,215,216, /* Block #4 */ 287,288,289,313,314,315,339,340,341, /* Block #5 */ 292,293,294,318,319,320,344,345,346, /* Block #6 */ 417,418,419,443,444,445,469,470,471, /* Block #7 */ 422,423,424,448,449,450,474,475,476, /* Block #8 */ }; size_t loc2[72]={ 0, 1, 2, 26, 27, 28, /* Block #1 */ 4, 5, 6, 30, 31, 32, /* Block #2 */ 8, 9, 10, 34, 35, 36, /* Block #3 */ 12, 13, 14, 38, 39, 40, /* Block #4 */ 104,105,106,130,131,132, /* Block #5 */ 108,109,110,134,135,136, /* Block #6 */ 112,113,114,138,139,140, /* Block #7 */ 116,117,118,142,143,144, /* Block #8 */ 208,209,210,234,235,236, /* Block #9 */ 212,213,214,238,239,240, /* Block #10 */ 216,217,218,242,243,244, /* Block #11 */ 220,221,222,246,247,248, /* Block #12 */ }; intn i,j; /* Counters */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n")); /* Allocate write & read buffers */ wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2); rbuf=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i