summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2013-07-09 15:16:46 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2013-07-09 15:16:46 (GMT)
commit46b5d073b56090829f6f6519553b4a427703e129 (patch)
tree78087e067c6b941a1cd3e4c5e21f3a77d5e8f896
parente74f49bdc142517aab4ab2e6823edef186895971 (diff)
downloadhdf5-46b5d073b56090829f6f6519553b4a427703e129.zip
hdf5-46b5d073b56090829f6f6519553b4a427703e129.tar.gz
hdf5-46b5d073b56090829f6f6519553b4a427703e129.tar.bz2
[svn-r23876] - Add functionality to generate IOD hyperslabs for HDF5 dataspace selections
- Fix some bugs & valgrind warnings
-rw-r--r--examples/test_client.c2
-rw-r--r--examples/test_server.c4
-rw-r--r--src/H5EQpublic.h15
-rw-r--r--src/H5Shyper.c76
-rw-r--r--src/H5Spublic.h7
-rw-r--r--src/H5VLiod_attr.c12
-rw-r--r--src/H5VLiod_common.h2
-rw-r--r--src/H5VLiod_dset.c192
-rw-r--r--src/H5VLiod_dtype.c18
-rw-r--r--src/H5VLiod_encdec.c12
-rw-r--r--src/H5VLiod_group.c17
-rw-r--r--src/H5VLiod_link.c5
-rw-r--r--src/H5VLiod_server.c155
-rw-r--r--src/H5VLiod_server.h5
14 files changed, 441 insertions, 81 deletions
diff --git a/examples/test_client.c b/examples/test_client.c
index 74abac2..b88c3db 100644
--- a/examples/test_client.c
+++ b/examples/test_client.c
@@ -612,6 +612,7 @@ int main(int argc, char **argv) {
H5Sclose(mem_space);
}
+ H5Sclose(dataspaceId);
assert(H5Dclose(did1) == 0);
/* open attribute on dataset D1. This is asynchronous */
@@ -658,7 +659,6 @@ int main(int argc, char **argv) {
H5EQclose(event_q);
H5Pclose(fapl_id);
- H5Sclose(dataspaceId);
/*
assert(H5AOwait(&req1, &status1) == 0);
diff --git a/examples/test_server.c b/examples/test_server.c
index 5d71e35..dc5f4a4 100644
--- a/examples/test_server.c
+++ b/examples/test_server.c
@@ -24,7 +24,7 @@ int main(int argc, char **argv) {
MPI_Comm_size(MPI_COMM_WORLD, &my_size);
printf("Number of server processes = %d, my rank is %d\n", my_size, my_rank);
- H5open();
+ //H5open();
/* This call initiliazes the FS for the server processes (create metadata and
bulk data handles). It also registers with the Function shipper the
HDF5 VOL server routines that will be executed when the clients ship the VOL
@@ -40,7 +40,7 @@ int main(int argc, char **argv) {
Finally, when all clients send a terminate call, the function shipper interface
is finalized the operation returns. */
H5VLiod_start_handler(MPI_COMM_WORLD, MPI_INFO_NULL);
- H5close();
+ //H5close();
MPI_Finalize();
return 0;
diff --git a/src/H5EQpublic.h b/src/H5EQpublic.h
index 2992d4e..12b4328 100644
--- a/src/H5EQpublic.h
+++ b/src/H5EQpublic.h
@@ -22,15 +22,13 @@
/* System headers needed by this file */
/* Public headers needed by this file */
+#include "H5public.h"
+#include "H5Ipublic.h"
/*****************/
/* Public Macros */
/*****************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*******************/
/* Public Typedefs */
/*******************/
@@ -43,7 +41,7 @@ typedef void * H5_request_t;
/********************/
/* Asynchronous operation status */
-typedef enum {
+typedef enum H5_status_t{
H5AO_PENDING, /* Operation has not yet completed */
H5AO_SUCCEEDED, /* Operation has completed, successfully */
H5AO_FAILED, /* Operation has completed, but failed */
@@ -53,12 +51,16 @@ typedef enum {
#define H5_REQUEST_NULL NULL
#define H5_EVENT_QUEUE_NULL -1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*********************/
/* Public Prototypes */
/*********************/
/* API wrappers */
-H5_DLL hid_t H5EQcreate(hid_t fapl_id);
+H5_DLL hid_t H5EQcreate(hid_t fapl_id);
H5_DLL herr_t H5EQinsert(hid_t event_q, H5_request_t req);
H5_DLL herr_t H5EQpop(hid_t event_q, H5_request_t *req);
H5_DLL herr_t H5EQwait(hid_t event_q, int *num_requests, H5_status_t **status);
@@ -73,5 +75,4 @@ H5_DLL herr_t H5AOwait(H5_request_t req, H5_status_t *status);
#ifdef __cplusplus
}
#endif
-
#endif /* _H5EQpublic_H */
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index d88ac35..4029d9e 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -8853,3 +8853,79 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_hyper_get_seq_list() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sselect_is_regular
+ PURPOSE
+ Check if hyperslab selection is a regular selection
+ RETURNS
+ TRUE/FALSE/FAIL
+--------------------------------------------------------------------------*/
+htri_t
+H5Sselect_is_regular(hid_t space_id)
+{
+ H5S_t *space; /* dataspace to modify */
+ htri_t ret_value;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("t", "i", space_id);
+
+ /* Check args and all the boring stuff. */
+ if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
+
+ if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "not a hyperslab selection")
+
+ if(space->select.sel_info.hslab->diminfo_valid)
+ ret_value = TRUE;
+ else
+ ret_value = FALSE;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+}
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_reg_hyperslab_params
+ PURPOSE
+ retrieve the start, stride, count, block arrays of a regular
+ hyperslab selection
+ RETURNS
+ TRUE/FALSE/FAIL
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_reg_hyperslab_params(hid_t space_id, hsize_t start[], hsize_t stride[],
+ hsize_t count[], hsize_t block[])
+{
+ H5S_t *space = NULL; /* Dataspace to get selection of */
+ const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
+ unsigned ndims; /* Rank of the dataspace */
+ unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE5("e", "i*h*h*h*h", space_id, start, stride, count, block);
+
+ /* Check args */
+ if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+ if(!space->select.sel_info.hslab->diminfo_valid)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "not a regular hyperslab selection")
+
+ diminfo = space->select.sel_info.hslab->opt_diminfo;
+ ndims = space->extent.rank;
+
+ for(u=0 ; u<ndims; u++) {
+ start[u] = diminfo[u].start;
+ stride[u] = diminfo[u].stride;
+ count[u] = diminfo[u].count;
+ block[u] = diminfo[u].block;
+ }
+
+done:
+ FUNC_LEAVE_API(ret_value)
+}
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 6e87a65..f4f28f6 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -113,6 +113,13 @@ H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
const hsize_t _stride[],
const hsize_t count[],
const hsize_t _block[]);
+H5_DLL htri_t H5Sselect_is_regular(hid_t space_id);
+H5_DLL herr_t H5Sget_reg_hyperslab_params(hid_t space_id,
+ hsize_t start[],
+ hsize_t stride[],
+ hsize_t count[],
+ hsize_t block[]);
+
/* #define NEW_HYPERSLAB_API */
/* Note that these haven't been working for a while and were never
* publicly released - QAK */
diff --git a/src/H5VLiod_attr.c b/src/H5VLiod_attr.c
index d7863dd..dda7b6a 100644
--- a/src/H5VLiod_attr.c
+++ b/src/H5VLiod_attr.c
@@ -286,9 +286,12 @@ H5VL_iod_server_attr_open_cb(AXE_engine_t UNUSED axe_engine,
if(iod_obj_get_scratch(cur_oh, IOD_TID_UNKNOWN, &sp, NULL, NULL) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't get scratch pad for object");
+ /* MSC - Dont do this check until we have a real IOD */
+#if 0
/* if attribute KV does not exist, return error*/
if(IOD_ID_UNDEFINED == sp.attr_id)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes");
+#endif
/* open the attribute KV in scratch pad */
if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0)
@@ -656,11 +659,14 @@ H5VL_iod_server_attr_exists_cb(AXE_engine_t UNUSED axe_engine,
iod_obj_close(cur_oh, NULL, NULL);
}
+ /* MSC - Dont do this check until we have a real IOD */
+#if 0
/* if attribute KV does not exist, return false*/
if(IOD_ID_UNDEFINED == sp.attr_id) {
ret = FALSE;
HGOTO_DONE(SUCCEED);
}
+#endif
/* open the attribute KV in scratch pad */
if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0)
@@ -757,9 +763,12 @@ H5VL_iod_server_attr_rename_cb(AXE_engine_t UNUSED axe_engine,
iod_obj_close(cur_oh, NULL, NULL);
}
+ /* MSC - Dont do this check until we have a real IOD */
+#if 0
/* if attribute KV does not exist, return error*/
if(IOD_ID_UNDEFINED == sp.attr_id)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes");
+#endif
/* open the attribute KV in scratch pad */
if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0)
@@ -865,9 +874,12 @@ H5VL_iod_server_attr_remove_cb(AXE_engine_t UNUSED axe_engine,
iod_obj_close(cur_oh, NULL, NULL);
}
+ /* MSC - Dont do this check until we have a real IOD */
+#if 0
/* if attribute KV does not exist, return error*/
if(IOD_ID_UNDEFINED == sp.attr_id)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "Object has no attributes");
+#endif
/* open the attribute KV in scratch pad */
if (iod_obj_open_write(coh, sp.attr_id, NULL /*hints*/, &attr_kv_oh, NULL) < 0)
diff --git a/src/H5VLiod_common.h b/src/H5VLiod_common.h
index 72a2607..92cb3eb 100644
--- a/src/H5VLiod_common.h
+++ b/src/H5VLiod_common.h
@@ -19,7 +19,7 @@
#ifndef _H5VLiod_common_H
#define _H5VLiod_common_H
-#include "H5Pprivate.h" /* Property lists */
+#include "H5public.h"
#include "H5VLpublic.h"
#include "H5VLiod.h" /* Iod VOL plugin */
diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c
index 40c35ef..d20c693 100644
--- a/src/H5VLiod_dset.c
+++ b/src/H5VLiod_dset.c
@@ -115,14 +115,6 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine,
/* for the process that succeeded in creating the dataset, update
the parent KV, create scratch pad */
if(0 == ret) {
- kv.key = HDstrdup(last_comp);
- kv.value = &dset_id;
- kv.value_len = sizeof(iod_obj_id_t);
- /* insert new dataset in kv store of current group */
- if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
- HDfree(kv.key);
-
/* create the metadata KV object for the dataset */
if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV,
NULL, NULL, &mdkv_id, NULL) < 0)
@@ -197,6 +189,14 @@ H5VL_iod_server_dset_create_cb(AXE_engine_t UNUSED axe_engine,
/* close the Metadata KV object */
if(iod_obj_close(mdkv_oh, NULL, NULL))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object");
+
+ kv.key = HDstrdup(last_comp);
+ kv.value = &dset_id;
+ kv.value_len = sizeof(iod_obj_id_t);
+ /* insert new dataset in kv store of current group */
+ if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
+ HDfree(kv.key);
}
/* close parent group if it is not the location we started the
@@ -447,8 +447,12 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine,
hg_bulk_request_t bulk_request;
iod_mem_desc_t mem_desc;
iod_array_iodesc_t file_desc;
+ iod_hyperslab_t *hslabs = NULL;
size_t size, buf_size, src_size, dst_size;
void *buf;
+ uint8_t *buf_ptr;
+ hssize_t num_descriptors = 0, n;
+ int ndims, i;
uint32_t cs = 0;
size_t nelmts;
na_addr_t dest = HG_Handler_get_addr(op_data->hg_handle);
@@ -466,7 +470,8 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine,
size = HG_Bulk_handle_get_size(bulk_handle);
- nelmts = (size_t)H5Sget_simple_extent_npoints(space_id);
+ nelmts = (size_t)H5Sget_select_npoints(space_id);
+
src_size = H5Tget_size(src_id);
dst_size = H5Tget_size(dst_id);
@@ -486,28 +491,77 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine,
if(NULL == (buf = malloc(buf_size)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate read buffer");
+ /* get the rank of the dataspace */
+ if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion");
+
+ /* get the number of decriptors required, i.e. the numbers of iod
+ I/O operations needed */
+ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection");
+
+ /* allocate the IOD hyperslab descriptors needed */
+ if(NULL == (hslabs = (iod_hyperslab_t *)malloc
+ (sizeof(iod_hyperslab_t) * (size_t)num_descriptors)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors");
+
+ for(n=0 ; n<num_descriptors ; n++) {
+ hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ }
+
+ /* generate the descriptors after allocating the array */
+ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection");
+
+ buf_ptr = (uint8_t *)buf;
+
+ /* read each descriptore from the IOD container */
+ for(n=0 ; n<num_descriptors ; n++) {
+ hsize_t num_bytes = 0;
+ hsize_t num_elems = 0;
+
+ /* determine how many bytes the current descriptor holds */
+ for(i=0 ; i<ndims ; i++)
+ num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]);
+ num_bytes = num_elems * src_size;
+
#if 0
- mem_desc.nfrag = 1;
- mem_desc.frag->addr = buf;
- mem_desc.frag->len = (iod_size_t)buf_size;
+ /* set the memory descriptor */
+ mem_desc.nfrag = 1;
+ mem_desc.frag->addr = (void *)buf_ptr;
+ mem_desc.frag->len = (iod_size_t)num_bytes;
+#endif
+
+ buf_ptr += num_bytes;
- /* MSC TODO - populate file location hyperslab */
+ /* set the file descriptor */
+ file_desc = hslabs[n];
+
+#if H5VL_IOD_DEBUG
+ for(i=0 ; i<ndims ; i++) {
+ fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n",
+ i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i],
+ (size_t)file_desc.block[i], (size_t)file_desc.count[i]);
+ }
#endif
- /* read from array object */
- if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object");
+ /* read from array object */
+ if(iod_array_read(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read from array object");
+ }
{
- int i;
hbool_t flag = FALSE;
- int *buf_ptr = (int *)buf;
+ int *ptr = (int *)buf;
#if H5_DO_NATIVE
ret_value = H5Dread(iod_oh.cookie, src_id, H5S_ALL, space_id, dxpl_id, buf);
#else /* fake data */
for(i=0;i<60;++i)
- buf_ptr[i] = i;
+ ptr[i] = i;
#endif
if(H5Tconvert(src_id, dst_id, nelmts, buf, NULL, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
@@ -520,7 +574,7 @@ H5VL_iod_server_dset_read_cb(AXE_engine_t UNUSED axe_engine,
HGOTO_ERROR(H5E_SYM, H5E_READERROR, FAIL, "can't read property list");
if(flag) {
fprintf(stderr, "Injecting a bad data value to cause corruption \n");
- buf_ptr[0] = 10;
+ ptr[0] = 10;
}
}
@@ -552,6 +606,16 @@ done:
op_data = (op_data_t *)H5MM_xfree(op_data);
free(buf);
+ /* free allocated descriptors */
+ for(n=0 ; n<num_descriptors ; n++) {
+ free(hslabs[n].start);
+ free(hslabs[n].stride);
+ free(hslabs[n].block);
+ free(hslabs[n].count);
+ }
+ if(hslabs)
+ free(hslabs);
+
/* close the dataset if we opened it in this routine */
if(opened_locally) {
if(iod_obj_close(iod_oh, NULL, NULL))
@@ -589,15 +653,19 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine,
hid_t space_id = input->space_id;
hid_t dxpl_id = input->dxpl_id;
uint32_t cs = input->checksum;
- uint32_t data_cs = 0;
hid_t src_id = input->mem_type_id;
hid_t dst_id = input->dset_type_id;
+ uint32_t data_cs = 0;
hg_bulk_block_t bulk_block_handle;
hg_bulk_request_t bulk_request;
iod_mem_desc_t mem_desc;
iod_array_iodesc_t file_desc;
+ iod_hyperslab_t *hslabs = NULL;
size_t size, buf_size, src_size, dst_size;
+ hssize_t num_descriptors = 0, n;
+ int ndims, i;
void *buf;
+ uint8_t *buf_ptr;
size_t nelmts;
hbool_t flag = FALSE;
na_addr_t source = HG_Handler_get_addr(op_data->hg_handle);
@@ -619,7 +687,8 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine,
/* Read bulk data here and wait for the data to be here */
size = HG_Bulk_handle_get_size(bulk_handle);
- nelmts = (size_t)H5Sget_simple_extent_npoints(space_id);
+ nelmts = (size_t)H5Sget_select_npoints(space_id);
+
src_size = H5Tget_size(src_id);
dst_size = H5Tget_size(dst_id);
@@ -676,27 +745,76 @@ H5VL_iod_server_dset_write_cb(AXE_engine_t UNUSED axe_engine,
#if H5VL_IOD_DEBUG
{
- int i;
- int *buf_ptr = (int *)buf;
+ int *ptr = (int *)buf;
fprintf(stderr, "DWRITE Received a buffer of size %d with values: ", size);
for(i=0;i<60;++i)
- fprintf(stderr, "%d ", buf_ptr[i]);
+ fprintf(stderr, "%d ", ptr[i]);
fprintf(stderr, "\n");
}
#endif
+ /* get the rank of the dataspace */
+ if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion");
+
+ /* get the number of decriptors required, i.e. the numbers of iod
+ I/O operations needed */
+ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection");
+
+ /* allocate the IOD hyperslab descriptors needed */
+ if(NULL == (hslabs = (iod_hyperslab_t *)malloc
+ (sizeof(iod_hyperslab_t) * (size_t)num_descriptors)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate iod array descriptors");
+
+ for(n=0 ; n<num_descriptors ; n++) {
+ hslabs[n].start = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].stride = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].block = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ hslabs[n].count = (iod_size_t *)malloc(sizeof(iod_size_t) * ndims);
+ }
+
+ /* generate the descriptors after allocating the array */
+ if(H5VL_iod_get_file_desc(space_id, &num_descriptors, hslabs) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to generate IOD file descriptor from dataspace selection");
+
+ buf_ptr = (uint8_t *)buf;
+
+ /* write each descriptore to the IOD container */
+ for(n=0 ; n<num_descriptors ; n++) {
+ hsize_t num_bytes = 0;
+ hsize_t num_elems = 0;
+
+ /* determine how many bytes the current descriptor holds */
+ for(i=0 ; i<ndims ; i++)
+ num_elems *= (hslabs[n].count[i] * hslabs[n].block[i]);
+ num_bytes = num_elems * dst_size;
+
#if 0
- mem_desc.nfrag = 1;
- mem_desc.frag->addr = buf;
- mem_desc.frag->len = (iod_size_t)buf_size;
+ /* set the memory descriptor */
+ mem_desc.nfrag = 1;
+ mem_desc.frag->addr = (void *)buf_ptr;
+ mem_desc.frag->len = (iod_size_t)num_bytes;
+#endif
+
+ buf_ptr += num_bytes;
- /* MSC TODO - populate file location hyperslab */
+ /* set the file descriptor */
+ file_desc = hslabs[n];
+
+#if H5VL_IOD_DEBUG
+ for(i=0 ; i<ndims ; i++) {
+ fprintf(stderr, "Dim %d: start %zu stride %zu block %zu count %zu\n",
+ i, (size_t)file_desc.start[i], (size_t)file_desc.stride[i],
+ (size_t)file_desc.block[i], (size_t)file_desc.count[i]);
+ }
#endif
- /* write from array object */
- if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, &cs, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "can't write to array object");
+ /* write from array object */
+ if(iod_array_write(iod_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, &cs, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to array object");
+ }
#if H5_DO_NATIVE
ret_value = H5Dwrite(iod_oh.cookie, H5T_NATIVE_INT, H5S_ALL, space_id, dxpl_id, buf);
@@ -719,6 +837,16 @@ done:
op_data = (op_data_t *)H5MM_xfree(op_data);
free(buf);
+ /* free allocated descriptors */
+ for(n=0 ; n<num_descriptors ; n++) {
+ free(hslabs[n].start);
+ free(hslabs[n].stride);
+ free(hslabs[n].block);
+ free(hslabs[n].count);
+ }
+ if(hslabs)
+ free(hslabs);
+
/* close the dataset if we opened it in this routine */
if(opened_locally) {
if(iod_obj_close(iod_oh, NULL, NULL))
diff --git a/src/H5VLiod_dtype.c b/src/H5VLiod_dtype.c
index 4be26ec..06585e8 100644
--- a/src/H5VLiod_dtype.c
+++ b/src/H5VLiod_dtype.c
@@ -93,14 +93,6 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine,
/* for the process that succeeded in creating the datatype, update
the parent KV, create scratch pad */
if(0 == ret) {
- kv.key = HDstrdup(last_comp);
- kv.value = &dtype_id;
- kv.value_len = sizeof(iod_obj_id_t);
- /* insert new datatype in kv store of current group */
- if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
- HDfree(kv.key);
-
/* create the metadata KV object for the datatype */
if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV,
NULL, NULL, &mdkv_id, NULL) < 0)
@@ -142,7 +134,7 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine,
#endif
/* write the serialized type value to the BLOB object */
- if(iod_blob_write(cur_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0)
+ if(iod_blob_write(dtype_oh, IOD_TID_UNKNOWN, NULL, &mem_desc, &file_desc, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write BLOB object");
/* MSC - TODO store things */
@@ -181,6 +173,14 @@ H5VL_iod_server_dtype_commit_cb(AXE_engine_t UNUSED axe_engine,
/* close the Metadata KV object */
if(iod_obj_close(mdkv_oh, NULL, NULL))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object");
+
+ kv.key = HDstrdup(last_comp);
+ kv.value = &dtype_id;
+ kv.value_len = sizeof(iod_obj_id_t);
+ /* insert new datatype in kv store of current group */
+ if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
+ HDfree(kv.key);
}
#if H5_DO_NATIVE
cur_oh.cookie = H5Tcopy(input->type_id);
diff --git a/src/H5VLiod_encdec.c b/src/H5VLiod_encdec.c
index 5652716..c342984 100644
--- a/src/H5VLiod_encdec.c
+++ b/src/H5VLiod_encdec.c
@@ -19,6 +19,8 @@
*/
#include "H5MMprivate.h" /* Memory management */
+#include "H5Ppublic.h"
+#include "H5Spublic.h"
#include "H5VLiod_common.h" /* IOD Common Header */
#ifdef H5_HAVE_EFF
@@ -176,7 +178,7 @@ int hg_proc_dims_t(hg_proc_t proc, void *data)
break;
case HG_DECODE:
if(struct_data->rank)
- struct_data->size = malloc (sizeof(hsize_t) * struct_data->rank);
+ struct_data->size = (hsize_t *)malloc (sizeof(hsize_t) * struct_data->rank);
for(i=0 ; i<struct_data->rank ; i++) {
ret = hg_proc_uint64_t(proc, &struct_data->size[i]);
@@ -204,7 +206,8 @@ int hg_proc_name_t(hg_proc_t proc, void *data)
size_t size;
name_t *struct_data = (name_t *) data;
- ret = hg_proc_int64_t(proc, struct_data->value_size);
+ ret = hg_proc_memcpy(proc, struct_data->value_size, sizeof(ssize_t));
+ //ret = hg_proc_int64_t(proc, struct_data->value_size);
if (ret != HG_SUCCESS) {
HG_ERROR_DEFAULT("Proc error");
ret = HG_FAIL;
@@ -212,7 +215,8 @@ int hg_proc_name_t(hg_proc_t proc, void *data)
}
size = (size_t)(*struct_data->value_size);
- ret = hg_proc_uint64_t(proc, &struct_data->size);
+ ret = hg_proc_memcpy(proc, &struct_data->size, sizeof(size_t));
+ //ret = hg_proc_uint64_t(proc, &struct_data->size);
if (ret != HG_SUCCESS) {
HG_ERROR_DEFAULT("Proc error");
ret = HG_FAIL;
@@ -221,7 +225,7 @@ int hg_proc_name_t(hg_proc_t proc, void *data)
if(NULL != struct_data->value && struct_data->size != 0) {
ret = hg_proc_raw(proc, struct_data->value,
- MIN(size+1, struct_data->size));
+ MIN(size, struct_data->size));
if (ret != HG_SUCCESS) {
HG_ERROR_DEFAULT("Proc error");
ret = HG_FAIL;
diff --git a/src/H5VLiod_group.c b/src/H5VLiod_group.c
index 33a8fad..c50e902 100644
--- a/src/H5VLiod_group.c
+++ b/src/H5VLiod_group.c
@@ -91,14 +91,6 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine,
/* for the process that succeeded in creating the group, create
the scratch pad for it too */
if(0 == ret) {
- /* insert new group in kv store of parent object */
- kv.key = HDstrdup(last_comp);
- kv.value = &grp_id;
- kv.value_len = sizeof(iod_obj_id_t);
- if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
- HDfree(kv.key);
-
/* create the metadata KV object for the group */
if(iod_obj_create(coh, IOD_TID_UNKNOWN, NULL, IOD_OBJ_KV,
NULL, NULL, &mdkv_id, NULL) < 0)
@@ -122,6 +114,14 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine,
if(iod_obj_close(mdkv_oh, NULL, NULL))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't close object");
+
+ /* insert new group in kv store of parent object */
+ kv.key = HDstrdup(last_comp);
+ kv.value = &grp_id;
+ kv.value_len = sizeof(iod_obj_id_t);
+ if (iod_kv_set(cur_oh, IOD_TID_UNKNOWN, NULL, &kv, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
+ HDfree(kv.key);
} /* end if */
/* close parent group if it is not the location we started the
@@ -129,6 +129,7 @@ H5VL_iod_server_group_create_cb(AXE_engine_t UNUSED axe_engine,
if(loc_handle.cookie != cur_oh.cookie) {
iod_obj_close(cur_oh, NULL, NULL);
}
+
#if H5_DO_NATIVE
grp_oh.cookie = H5Gcreate2(loc_handle.cookie, name, input->lcpl_id,
input->gcpl_id, input->gapl_id);
diff --git a/src/H5VLiod_link.c b/src/H5VLiod_link.c
index bf24949..bab9663 100644
--- a/src/H5VLiod_link.c
+++ b/src/H5VLiod_link.c
@@ -135,10 +135,7 @@ H5VL_iod_server_link_create_cb(AXE_engine_t UNUSED axe_engine,
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't set KV pair in parent");
HDfree(kv.key);
- /* close the source group */
- if(src_oh.cookie != input->loc_oh.cookie) {
- iod_obj_close(src_oh, NULL, NULL);
- }
+ iod_obj_close(src_oh, NULL, NULL);
/* open the target object */
if (iod_obj_open_write(coh, target_id, NULL, &target_oh, NULL) < 0)
diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c
index 66b0787..800d382 100644
--- a/src/H5VLiod_server.c
+++ b/src/H5VLiod_server.c
@@ -14,22 +14,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define H5G_PACKAGE /*suppress error about including H5Gpkg */
-#define H5D_PACKAGE /*suppress error about including H5Dpkg */
-#include "H5private.h" /* Generic Functions */
-#include "H5Apublic.h" /* Attributes */
-#include "H5Dpkg.h" /* Dataset functions */
-#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Sprivate.h" /* Dataspaces */
-#include "H5Tprivate.h" /* Datatypes */
-#include "H5VLprivate.h" /* VOL plugins */
-#include "H5VLiod_server.h"
+#include "H5Sprivate.h" /* Dataspaces */
#include "H5WBprivate.h" /* Wrapped Buffers */
+#include "H5VLiod_server.h"
#ifdef H5_HAVE_EFF
@@ -355,6 +344,7 @@ H5VL_iod_server_file_create(hg_handle_t handle)
op_data->hg_handle = handle;
op_data->input = (void *)input;
+
if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_id, 0, NULL, 0, NULL,
H5VL_iod_server_file_create_cb, op_data, NULL))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HG_FAIL, "can't insert task into async engine");
@@ -1441,6 +1431,18 @@ H5VL_iod_server_dset_close(hg_handle_t handle)
op_data->input = (void *)input;
if(input->parent_axe_ids.count) {
+#if 0
+ int i;
+ AXE_status_t status;
+ for(i=0 ; i<input->parent_axe_ids.count ; i++) {
+ if(AXEget_status(engine, input->parent_axe_ids.ids[i], &status) < 0) {
+ fprintf(stderr, "GET STATUS FAILED\n");
+ exit(1);
+ }
+ fprintf(stderr, "%d: AXE ID %llu status %d\n",
+ i, input->parent_axe_ids.ids[i], status);
+ }
+#endif
if (AXE_SUCCEED != AXEcreate_task(engine, input->axe_id,
input->parent_axe_ids.count, input->parent_axe_ids.ids,
0, NULL,
@@ -2334,6 +2336,133 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
+herr_t
+H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs)
+{
+ hssize_t num_descriptors = 0, n;
+ int ndims = 0, i;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* get the rank of this dataspace */
+ if((ndims = H5Sget_simple_extent_ndims(space_id)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion");
+
+ switch(H5Sget_select_type(space_id)) {
+ case H5S_SEL_NONE:
+ /* nothing selected */
+ num_descriptors = 0;
+ HGOTO_DONE(SUCCEED);
+ case H5S_SEL_ALL:
+ /* The entire dataspace is selected, 1 large iod hyperslab is needed */
+ num_descriptors = 1;
+
+ if(NULL != hslabs) {
+ hsize_t dims[H5S_MAX_RANK];
+
+ /* get the dimensions sizes of the dataspace */
+ if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataspace dimesnsion sizes");
+ /* populate the hyperslab */
+ for(i=0 ; i<ndims ; i++) {
+ hslabs[0].start[i] = 0;
+ hslabs[0].stride[i] = 1;
+ hslabs[0].block[i] = dims[i];
+ hslabs[0].count[i] = 1;
+ }
+ }
+ break;
+ case H5S_SEL_POINTS:
+ {
+ /* we need a hyperslab element for each point */
+ if((num_descriptors = H5Sget_select_elem_npoints(space_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid point selection");
+
+ if(NULL != hslabs) {
+ hsize_t *points = NULL;
+
+ if(NULL == (points = (hsize_t *)malloc(sizeof(hsize_t) * ndims *
+ (hsize_t)num_descriptors)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords");
+
+ if(H5Sget_select_elem_pointlist(space_id, (hsize_t)0,
+ (hsize_t)num_descriptors, points) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates");
+
+ /* populate the hyperslab */
+ for(n=0 ; n<num_descriptors ; n++) {
+ for(i=0 ; i<ndims ; i++) {
+ hslabs[n].start[i] = *points++;
+ hslabs[n].stride[i] = 1;
+ hslabs[n].block[i] = 1;
+ hslabs[n].count[i] = 1;
+ }
+ }
+ free(points);
+ }
+ break;
+ }
+ case H5S_SEL_HYPERSLABS:
+ {
+ /* if the selection is a regular hyperslab
+ selection, only 1 iod hyperslab object is
+ needed */
+ if(H5Sselect_is_regular(space_id)) {
+ num_descriptors = 1;
+
+ if(NULL != hslabs) {
+ if(H5Sget_reg_hyperslab_params(space_id,
+ hslabs[0].start,
+ hslabs[0].stride,
+ hslabs[0].count,
+ hslabs[0].block) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve hyperslab selection");
+ }
+ }
+ /* Otherwise populate the hslabs by gettinge very block */
+ else {
+ if((num_descriptors = H5Sget_select_hyper_nblocks(space_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "invalid hyperslab selection");
+
+ if(NULL != hslabs) {
+ hsize_t *blocks;
+
+ if(NULL == (blocks = (hsize_t *)malloc(sizeof(hsize_t) * 2 *
+ ndims * num_descriptors)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords");
+
+ if(H5Sget_select_hyper_blocklist(space_id, (hsize_t)0,
+ (hsize_t)num_descriptors, blocks) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "Failed to retrieve point coordinates");
+
+ /* populate the hyperslab */
+ for(n=0 ; n<num_descriptors ; n++) {
+ for(i=0 ; i<ndims ; i++) {
+ hslabs[n].start[i] = *blocks++;
+ hslabs[n].stride[i] = 1;
+ hslabs[n].block[i] = 1;
+ hslabs[n].count[i] = *blocks++;
+ }
+ }
+
+ free(blocks);
+ }
+ }
+ break;
+ }
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "Invalid Selection type");
+ }
+
+ *count = num_descriptors;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
#if 0
/*-------------------------------------------------------------------------
diff --git a/src/H5VLiod_server.h b/src/H5VLiod_server.h
index 2aedf08..2110de4 100644
--- a/src/H5VLiod_server.h
+++ b/src/H5VLiod_server.h
@@ -19,6 +19,10 @@
#ifndef _H5VLiod_server_H
#define _H5VLiod_server_H
+#include "H5Eprivate.h" /* Error handling */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Ppublic.h"
+#include "H5Spublic.h"
#include "H5VLiod_common.h"
#ifdef H5_HAVE_EFF
@@ -216,6 +220,7 @@ H5_DLL void H5VL_iod_server_object_get_comment_cb(AXE_engine_t UNUSED axe_engine
H5_DLL herr_t H5VL_iod_server_traverse(iod_handle_t coh, iod_obj_id_t loc_id, iod_handle_t loc_handle,
const char *path, hbool_t create_interm_grps,
char **last_comp, iod_obj_id_t *iod_id, iod_handle_t *iod_oh);
+H5_DLL herr_t H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs);
#endif /* H5_HAVE_EFF */
#endif /* _H5VLiod_server_H */