From ed2df01de27101bf24f6c16a5893ac9345ae7327 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Mon, 17 Jun 2013 15:49:19 -0500 Subject: [svn-r23791] Add FF version of H5DO* routines Fix bug in IOD set extent to resize the local dataspace Add test for FF version of H5DO* routines --- examples/CMakeLists.txt | 3 + examples/Makefile.am | 2 +- examples/Makefile.in | 2 +- examples/test_client.c | 26 +++---- examples/test_client_acg.c | 164 +++++++++++++++++++++++++++++++++++++++++++++ src/H5FF.c | 49 +++++++------- src/H5VLiod.c | 23 ++++++- src/H5VLiod_server.c | 1 + src/H5VLnative.c | 1 + test/dsets.c | 6 +- test/tattr.c | 2 +- 11 files changed, 234 insertions(+), 45 deletions(-) create mode 100644 examples/test_client_acg.c diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4a8a8ac..bd96062 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -58,6 +58,9 @@ IF (H5_HAVE_EFF) ADD_EXECUTABLE (test_client ${HDF5_EXAMPLES_SOURCE_DIR}/test_client.c) TARGET_LINK_LIBRARIES (test_client ${HDF5_LIB_TARGET}) SET_TARGET_PROPERTIES (test_client PROPERTIES FOLDER examples) + ADD_EXECUTABLE (test_client_acg ${HDF5_EXAMPLES_SOURCE_DIR}/test_client_acg.c) + TARGET_LINK_LIBRARIES (test_client_acg ${HDF5_LIB_TARGET}) + SET_TARGET_PROPERTIES (test_client_acg PROPERTIES FOLDER examples) ENDIF (H5_HAVE_EFF) IF (BUILD_TESTING) diff --git a/examples/Makefile.am b/examples/Makefile.am index d81bace..096c9fc 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -30,7 +30,7 @@ endif if BUILD_EFF_CONDITIONAL INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/test LDADD = $(LIBH5TEST) $(LIBHDF5) $(MYAXE_LIBS) $(MYIOD_LIBS) - EXAMPLE_PROG_EFF = test_server test_client test_client_old_api + EXAMPLE_PROG_EFF = test_server test_client test_client_old_api test_client_acg endif # Example programs. diff --git a/examples/Makefile.in b/examples/Makefile.in index f2308d2..47dc829 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -401,7 +401,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog $(EXTLINK_DIRS) *.h5 @BUILD_EFF_CONDITIONAL_TRUE@LDADD = $(LIBH5TEST) $(LIBHDF5) $(MYAXE_LIBS) $(MYIOD_LIBS) @BUILD_PARALLEL_CONDITIONAL_TRUE@LDADD = $(LIBH5TEST) $(LIBHDF5) @BUILD_PARALLEL_CONDITIONAL_TRUE@EXAMPLE_PROG_PARA = ph5example -@BUILD_EFF_CONDITIONAL_TRUE@EXAMPLE_PROG_EFF = test_server test_client test_client_old_api +@BUILD_EFF_CONDITIONAL_TRUE@EXAMPLE_PROG_EFF = test_server test_client test_client_old_api test_client_acg # Example programs. # Don't tell automake about them, because if it knew they were programs, diff --git a/examples/test_client.c b/examples/test_client.c index cfa20bf..0d46e0c 100644 --- a/examples/test_client.c +++ b/examples/test_client.c @@ -1,5 +1,5 @@ /* - * test_client.c: Client side of Milestone 3.3 Asynchronous I/O and initial + * test_client.c: Client side of Milestone 4.2 Asynchronous I/O and initial * IOD VOL plugin demonstration. This is, in effect, the application program that * would run on one or more compute nodes and make calls to the HDF5 API. */ @@ -21,6 +21,7 @@ int main(int argc, char **argv) { hid_t fapl_id, dxpl_id; const unsigned int nelem=60; int *data = NULL, *r_data = NULL, *r2_data = NULL, *data2 = NULL; + int *buf = NULL; int16_t *data3 = NULL; int16_t *r3_data = NULL; int *a_data = NULL, *ra_data = NULL; @@ -348,7 +349,7 @@ int main(int argc, char **argv) { H5Pclose(plist_id); /* change the dataset dimensions for Dataset D1. */ - ret = H5Dset_extent_ff(did1, &extent, 0, event_q); + ret = H5Dset_extent_ff(did3, &extent, 0, event_q); assert(ret == 0); } @@ -597,7 +598,6 @@ int main(int argc, char **argv) { hsize_t stride = 2; hsize_t count = 60; hsize_t block = 1; - int *buf = NULL; buf = calloc (120, sizeof(int)); @@ -610,19 +610,7 @@ int main(int argc, char **argv) { ret = H5Dread_ff(did1, H5T_STD_I32LE, mem_space, dataspaceId, H5P_DEFAULT, buf, 0, event_q); assert(ret == 0); - - if(H5EQpop(event_q, &req1) < 0) - exit(1); - assert(H5AOwait(req1, &status1) == 0); - assert (status1); - - fprintf(stderr, "Printing all Dataset values. We should have a 0 after each element: "); - for(i=0;i<120;++i) - fprintf(stderr, "%d ", buf[i]); - fprintf(stderr, "\n"); - H5Sclose(mem_space); - free(buf); } assert(H5Dclose(did1) == 0); @@ -652,10 +640,17 @@ int main(int argc, char **argv) { fprintf(stderr, "\n"); free(status); + fprintf(stderr, "Printing all Dataset values. We should have a 0 after each element: "); + for(i=0;i<120;++i) + fprintf(stderr, "%d ", buf[i]); + fprintf(stderr, "\n"); + + /* fprintf(stderr, "Printing Attribute data (after EQ wait): "); for(i=0;i +#include +#include +#include +#include "mpi.h" +#include "hdf5.h" + +int main(int argc, char **argv) { + const char file_name[]="acg_file.h5"; + hid_t file_id; + hid_t dsid = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t curr_size; + unsigned u; /* Local index variable */ + unsigned write_elem[60], read_elem[60]; /* Element written/read */ + hid_t fapl_id, dxpl_id; + int my_rank, my_size; + int provided; + hid_t event_q; + H5_status_t *status = NULL; + int num_requests = 0, i; + herr_t ret; + H5_request_t req1; + H5_status_t status1; + + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); + if(MPI_THREAD_MULTIPLE != provided) { + fprintf(stderr, "MPI does not have MPI_THREAD_MULTIPLE support\n"); + exit(1); + } + + /* Call EFF_init to initialize the EFF stack. + As a result of this call, the Function Shipper client is started, + and HDF5 VOL calls are registered with the function shipper. + An "IOD init" call is forwarded from the FS client to the FS server + which should already be running. */ + EFF_init(MPI_COMM_WORLD, MPI_INFO_NULL); + + MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); + MPI_Comm_size(MPI_COMM_WORLD, &my_size); + fprintf(stderr, "APP processes = %d, my rank is %d\n", my_size, my_rank); + + fprintf(stderr, "Create the FAPL to set the IOD VOL plugin and create the file\n"); + /* Choose the IOD VOL plugin to use with this file. + First we create a file access property list. Then we call a new routine to set + the IOD plugin to use with this fapl */ + fapl_id = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_fapl_iod(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); + + /* create an event Queue for managing asynchronous requests. + + Event Queues will releive the use from managing and completing + individual requests for every operation. Instead of passing a + request for every operation, the event queue is passed and + internally the HDF5 library creates a request and adds it to + the event queue. + + Multiple Event queue can be created used by the application. */ + event_q = H5EQcreate(fapl_id); + assert(event_q); + + /* create the file. This is asynchronous, but the file_id can be used. */ + file_id = H5Fcreate_ff(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id, event_q); + assert(file_id); + + /* Create 1-D dataspace */ + dim = 0; + max_dim = H5S_UNLIMITED; + if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) + return 1; + + /* Create 1-D chunked dataset */ + if((dsid = H5Dcreate_ff(file_id, "dset", H5T_NATIVE_UINT, sid, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, 0 , event_q)) < 0) + return 1; + + /* Close dataspace */ + H5Sclose(sid); + + /* Initialize data elements */ + for(u = 0; u < 60; u++) + write_elem[u] = u; + + printf("App Dataset Id = %d File id = %d\n", dsid, file_id); + ret = H5DOappend_ff(dsid, H5P_DEFAULT, 1, 10, H5T_NATIVE_UINT, + write_elem, 0 , event_q); + assert(ret<0); + + /* Append 60 elements to dataset, along proper axis */ + if(H5DOappend_ff(dsid, H5P_DEFAULT, 0, 60, H5T_NATIVE_UINT, + write_elem, 0 , event_q) < 0) + return 1; + + /* Get the dataset's dataspace now */ + if((sid = H5Dget_space(dsid)) < 0) + return 1; + + if(H5Sget_simple_extent_dims(sid, &curr_size, NULL) < 0) + return 1; + + /* Verify dataset is correct size */ + if(curr_size != 60) + return 1; + + /* Close dataspace */ + if(H5Sclose(sid) < 0) + return 1; + + /* Read elements back, with sequence operation */ + memset(read_elem, 0, sizeof(read_elem)); + + /* Sequence 10 elements from dataset, along bad axis */ + ret = H5DOsequence_ff(dsid, H5P_DEFAULT, 1, 0, 60, H5T_NATIVE_UINT, + read_elem, 0 , event_q); + + /* Sequence first 60 elements from dataset, along proper axis */ + ret = H5DOsequence_ff(dsid, H5P_DEFAULT, 0, 0, 60, H5T_NATIVE_UINT, + read_elem, 0 , event_q); + assert(ret == 0); + + /* close dataset */ + assert(H5Dclose_ff(dsid, event_q) == 0); + + /* closing the container also acts as a wait all on all pending requests + on the container. */ + assert(H5Fclose_ff(file_id, event_q) == 0); + + fprintf(stderr, "\n*****************************************************************************************************************\n"); + fprintf(stderr, "Wait on everything in EQ and check Results of operations in EQ\n"); + fprintf(stderr, "*****************************************************************************************************************\n"); + + /* wait on all requests and print completion status */ + H5EQwait(event_q, &num_requests, &status); + fprintf(stderr, "%d requests in event queue. Completions: ", num_requests); + for(i=0 ; iremote_dset.space_id, + H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + + /* Check if we are shrinking or expanding any of the dimensions */ + if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); + + /* Modify the size of the data space */ + if(H5S_set_extent(space, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space"); + } done: axe_parents = (uint64_t *)H5MM_xfree(axe_parents); FUNC_LEAVE_NOAPI(ret_value) @@ -2883,7 +2903,8 @@ H5VL_iod_dataset_get(void *_dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, hid_t *ret_id = va_arg (arguments, hid_t *); if((*ret_id = H5Scopy(dset->remote_dset.space_id)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get dataspace ID of dataset") + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get dataspace ID of dataset"); + break; } case H5VL_DATASET_GET_SPACE_STATUS: { diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c index 3c0f913..d3141c1 100644 --- a/src/H5VLiod_server.c +++ b/src/H5VLiod_server.c @@ -3480,6 +3480,7 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine, } else { buf_size = src_size * nelmts; + fprintf(stderr, "%d %d\n", buf_size, size); assert(buf_size == size); } diff --git a/src/H5VLnative.c b/src/H5VLnative.c index be62be2..346adc7 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1084,6 +1084,7 @@ H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *n if(NULL == (type = H5T_open(&type_loc, dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + type->vol_obj = NULL; ret_value = (void *)type; done: if(NULL == type) diff --git a/test/dsets.c b/test/dsets.c index d1f9706..898e546 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -9762,14 +9762,14 @@ main(void) nerrors += (test_append_sequence_1d(my_fapl) < 0 ? 1 : 0); nerrors += (test_append_sequence_2d(my_fapl) < 0 ? 1 : 0); nerrors += (test_set_get(my_fapl) < 0 ? 1 : 0); - exit(0); + if(H5Fclose(file) < 0) goto error; } /* end for */ /* Close 2nd FAPL */ if(H5Pclose(fapl2) < 0) TEST_ERROR - +#if 0 /* Tests that do not use files */ nerrors += (test_scatter() < 0 ? 1 : 0); nerrors += (test_gather() < 0 ? 1 : 0); @@ -9778,7 +9778,7 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - +#endif if(nerrors) goto error; printf("All dataset tests passed.\n"); diff --git a/test/tattr.c b/test/tattr.c index 25e8241..6556e09 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -10118,7 +10118,7 @@ test_attr_bug5(hid_t fcpl, hid_t fapl) /* Open the datatype attribute twice */ aidt1 = H5Aopen(tid1, BUG3_ATTR_NAME, H5P_DEFAULT); CHECK(aidt1, FAIL, "H5Aopen"); - aidt2 = H5Aopen(tid1, BUG3_ATTR_NAME, H5P_DEFAULT); + aidt2 = H5Aopen(tid2, BUG3_ATTR_NAME, H5P_DEFAULT); CHECK(aidt2, FAIL, "H5Aopen"); /* Close all attributes */ -- cgit v0.12