summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2016-11-29 22:33:45 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2016-11-29 22:33:45 (GMT)
commit46cfbdf4d5b0be60cd69e416e6673ca7a8643148 (patch)
treebd42c683d0b2ac1814dbc46660022eeef40de263
parent9d0edcfd4124f115ccfc729352b195081d04ce31 (diff)
downloadhdf5-46cfbdf4d5b0be60cd69e416e6673ca7a8643148.zip
hdf5-46cfbdf4d5b0be60cd69e416e6673ca7a8643148.tar.gz
hdf5-46cfbdf4d5b0be60cd69e416e6673ca7a8643148.tar.bz2
Initial implementation of dataset reads and writes. Untested. Does not
support partial I/O or datatype conversions. Also added h5dsm examples.
-rw-r--r--examples/Makefile.am16
-rw-r--r--examples/h5dsm_dset_create.c81
-rw-r--r--examples/h5dsm_dset_open.c64
-rw-r--r--examples/h5dsm_dset_read.c86
-rw-r--r--examples/h5dsm_dset_write.c83
-rw-r--r--examples/h5dsm_example.h13
-rw-r--r--examples/h5dsm_file_create.c50
-rw-r--r--examples/h5dsm_file_open.c40
-rw-r--r--src/H5FF.c104
-rw-r--r--src/H5VLdaosm.c217
10 files changed, 747 insertions, 7 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c8c96e8..2bb8bf4 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -41,7 +41,9 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_vol_external_log_native \
h5_vds h5_vds-exc \
h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \
- h5_vds-percival-unlim h5_vds-percival-unlim-maxmin
+ h5_vds-percival-unlim h5_vds-percival-unlim-maxmin \
+ h5dsm_file_create h5dsm_file_open h5dsm_dset_create h5dsm_dset_open
+ h5dsm_dset_write h5dsm_dset_read
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
@@ -54,9 +56,11 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
h5_ref2reg.c h5_shared_mesg.c ph5example.c \
h5_vol_external_log_native.c \
- h5_vds.c h5_vds-exc.c \
+ h5_vds.c h5_vds-exc.c \
h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \
- h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
+ h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c \
+ h5dsm_file_create.c h5dsm_file_open.c h5dsm_dset_create.c \
+ h5dsm_dset_open.c h5dsm_dset_write.c h5dsm_dset_read.c
@@ -134,6 +138,12 @@ h5_vds-simpleIO: $(srcdir)/h5_vds-simpleIO.c
h5_vds-percival: $(srcdir)/h5_vds-percival.c
h5_vds-percival-unlim: $(srcdir)/h5_vds-percival-unlim.c
h5_vds-percival-unlim-maxmin: $(srcdir)/h5_vds-percival-unlim-maxmin.c
+h5dsm_file_create: $(srcdir)/h5dsm_file_create.c
+h5dsm_file_open: $(srcdir)/h5dsm_file_open.c
+h5dsm_dset_create: $(srcdir)/h5dsm_dset_create.c
+h5dsm_dset_open: $(srcdir)/h5dsm_dset_open.c
+h5dsm_dset_write: $(srcdir)/h5dsm_dset_write.c
+h5dsm_dset_read: $(srcdir)/h5dsm_dset_read.c
if BUILD_SHARED_SZIP_CONDITIONAL
LD_LIBRARY_PATH=$(LL_PATH)
diff --git a/examples/h5dsm_dset_create.c b/examples/h5dsm_dset_create.c
new file mode 100644
index 0000000..441a53f
--- /dev/null
+++ b/examples/h5dsm_dset_create.c
@@ -0,0 +1,81 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, dset = -1, trans = -1, space = -1, fapl = -1;
+ hsize_t dims[2] = {4, 6};
+ uint64_t trans_num;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ if(argc != 4)
+ PRINTF_ERROR("argc != 4\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Set up dataspace */
+ if((space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDWR, fapl, &trans)) < 0)
+ ERROR;
+
+ /* Get next transaction */
+ if(H5TRget_trans_num(trans, &trans_num) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if((trans = H5TRcreate(file, trans_num + 1)) < 0)
+ ERROR;
+
+ /* Create dataset */
+ if((dset = H5Dcreate_ff(file, argv[3], H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, trans)) < 0)
+ ERROR;
+
+ /* Commit transaction */
+ if(H5TRcommit(trans) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose_ff(dset, -1) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose_ff(dset, -1);
+ H5TRclose(trans);
+ H5Fclose(file);
+ H5Sclose(space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_dset_open.c b/examples/h5dsm_dset_open.c
new file mode 100644
index 0000000..c45147a
--- /dev/null
+++ b/examples/h5dsm_dset_open.c
@@ -0,0 +1,64 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, dset = -1, trans = -1, fapl = -1;
+ hsize_t dims[1] = {1};
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ if(argc != 4)
+ PRINTF_ERROR("argc != 4\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDONLY, fapl, &trans)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose_ff(dset, -1) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose_ff(dset, -1);
+ H5TRclose(trans);
+ H5Fclose(file);
+ H5Sclose(space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_dset_read.c b/examples/h5dsm_dset_read.c
new file mode 100644
index 0000000..aeb9d71
--- /dev/null
+++ b/examples/h5dsm_dset_read.c
@@ -0,0 +1,86 @@
+#include "h5dsm_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, dset = -1, trans = -1, fapl = -1;
+ int buf[4][6];
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 4)
+ PRINTF_ERROR("argc != 4\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDONLY, fapl, &trans)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 0)
+ ERROR;
+
+ /* Initialize buffer */
+ for(i = 0; i < 4; i++)
+ for(j = 0; j < 6; j++)
+ buf[i][j] = -1;
+
+ /* Read data */
+ if(H5Dread_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ /* Print buffer */
+ printf("Successfully read data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++)
+ printf("%d ", buf[i][j]);
+ printf("\n");
+ }
+
+ /* Close */
+ if(H5Dclose_ff(dset, -1) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose_ff(dset, -1);
+ H5TRclose(trans);
+ H5Fclose(file);
+ H5Sclose(space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_dset_write.c b/examples/h5dsm_dset_write.c
new file mode 100644
index 0000000..a49265d
--- /dev/null
+++ b/examples/h5dsm_dset_write.c
@@ -0,0 +1,83 @@
+#include "h5dsm_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, dset = -1, trans = -1, fapl = -1;
+ int buf[4][6];
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 4)
+ PRINTF_ERROR("argc != 4\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDWR, fapl, &trans)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 0)
+ ERROR;
+
+ /* Fill and print buffer */
+ printf("Writing data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++) {
+ buf[i][j] = rand() % 10;
+ printf("%d ", buf[i][j]);
+ }
+ printf("\n");
+ }
+
+ /* Write data */
+ if(H5Dwrite_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose_ff(dset, -1) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose_ff(dset, -1);
+ H5TRclose(trans);
+ H5Fclose(file);
+ H5Sclose(space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_example.h b/examples/h5dsm_example.h
new file mode 100644
index 0000000..cbaff5a
--- /dev/null
+++ b/examples/h5dsm_example.h
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include <hdf5.h>
+#include <daos.h>
+
+/* Macros for printing standard messages and issuing errors */
+#define AT() printf (" at %s:%d in %s()...\n", __FILE__, __LINE__, __FUNCTION__)
+#define FAILED() do {puts("*FAILED*");fflush(stdout);} while(0)
+#define ERROR do {FAILED(); AT(); goto error;} while(0)
+#define PRINTF_ERROR(...) do {FAILED(); AT(); printf(" " __VA_ARGS__); printf("\n"); goto error;} while(0)
+
diff --git a/examples/h5dsm_file_create.c b/examples/h5dsm_file_create.c
new file mode 100644
index 0000000..cb28778
--- /dev/null
+++ b/examples/h5dsm_file_create.c
@@ -0,0 +1,50 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, fapl = -1;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Create file */
+ if((file = H5Fcreate_ff(argv[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl, NULL)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_file_open.c b/examples/h5dsm_file_open.c
new file mode 100644
index 0000000..7016699
--- /dev/null
+++ b/examples/h5dsm_file_open.c
@@ -0,0 +1,40 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = "daos_tier0";
+ hid_t file = -1, fapl = -1;
+
+ (void)MPI_Init(&argc, &argv);
+ (void)daos_init();
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDONLY, fapl, NULL)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+ (void)daos_fini();
+ (void)MPI_Finalize();
+
+ return 0;
+}
+
diff --git a/src/H5FF.c b/src/H5FF.c
index 649d84f..3de57be 100644
--- a/src/H5FF.c
+++ b/src/H5FF.c
@@ -523,6 +523,110 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Dwrite_ff
+ *
+ * Purpose: Asynchronous wrapper around H5Dwrite().
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Neil Fortner
+ * Monday, November 28, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dwrite_ff(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t dxpl_id, const void *buf, hid_t trans_id)
+{
+ H5VL_object_t *dset = NULL;
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+
+ /* check arguments */
+ if(!dset_id)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+
+ /* Get the default dataset transfer property list if the user didn't provide one */
+ if(H5P_DEFAULT == dxpl_id)
+ dxpl_id= H5P_DATASET_XFER_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+
+ /* store the transaction ID in the dxpl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ if(H5P_set(plist, H5VL_TRANS_ID, &trans_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for trans_id")
+
+ /* Write the data through the VOL */
+ if((ret_value = H5VL_dataset_write(dset->vol_obj, dset->vol_info->vol_cls, mem_type_id, mem_space_id,
+ file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")=
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dwrite_ff() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Dread_ff
+ *
+ * Purpose: Asynchronous wrapper around H5Dread().
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Neil Fortner
+ * Monday, November 28, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Dread_ff(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t dxpl_id, void *buf, hid_t rcxt_id)
+{
+ H5VL_object_t *dset = NULL;
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+
+ if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ if(mem_space_id < 0 || file_space_id < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+
+ /* Get the default dataset transfer property list if the user didn't provide one */
+ if (H5P_DEFAULT == dxpl_id)
+ dxpl_id= H5P_DATASET_XFER_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+
+ /* store the transaction ID in the dxpl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ if(H5P_set(plist, H5VL_CONTEXT_ID, &rcxt_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for rcxt_id")
+
+ /* Read the data through the VOL */
+ if((ret_value = H5VL_dataset_read(dset->vol_obj, dset->vol_info->vol_cls, mem_type_id, mem_space_id,
+ file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dread_ff() */
+
+
+
+/*-------------------------------------------------------------------------
* Function: H5Dclose_ff
*
* Purpose: Closes access to a dataset (DATASET_ID) and releases
diff --git a/src/H5VLdaosm.c b/src/H5VLdaosm.c
index 0a36905..4f53a5b 100644
--- a/src/H5VLdaosm.c
+++ b/src/H5VLdaosm.c
@@ -42,6 +42,7 @@ hid_t H5VL_DAOSM_g = 0;
#define H5VL_DAOSM_TYPE_KEY "Datatype"
#define H5VL_DAOSM_SPACE_KEY "Dataspace"
#define H5VL_DAOSM_DCPL_KEY "Creation Property List"
+#define H5VL_DAOSM_CHUNK_KEY 0u
/* Prototypes */
static void *H5VL_daosm_fapl_copy(const void *_old_fa);
@@ -59,11 +60,11 @@ static herr_t H5VL_daosm_group_close(void *grp, hid_t dxpl_id, void **req);
/* Dataset callbacks */
static void *H5VL_daosm_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
static void *H5VL_daosm_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
-/*static herr_t H5VL_daosm_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+static herr_t H5VL_daosm_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, void **req);
static herr_t H5VL_daosm_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
-static herr_t H5VL_daosm_dataset_specific(void *_dset, H5VL_dataset_specific_t specific_type,
+/*static herr_t H5VL_daosm_dataset_specific(void *_dset, H5VL_dataset_specific_t specific_type,
hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_daosm_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);*/
static herr_t H5VL_daosm_dataset_close(void *dt, hid_t dxpl_id, void **req);
@@ -104,8 +105,8 @@ static H5VL_class_t H5VL_daosm_g = {
{ /* dataset_cls */
H5VL_daosm_dataset_create, /* create */
H5VL_daosm_dataset_open, /* open */
- NULL,//H5VL_iod_dataset_read, /* read */
- NULL,//H5VL_iod_dataset_write, /* write */
+ H5VL_daosm_dataset_read, /* read */
+ H5VL_daosm_dataset_write, /* write */
NULL,//H5VL_iod_dataset_get, /* get */
NULL,//H5VL_iod_dataset_specific, /* specific */
NULL, /* optional */
@@ -1587,6 +1588,214 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_daos_dataset_read
+ *
+ * Purpose: Reads raw data from a dataset into a buffer.
+ *
+ * Return: Success: 0
+ * Failure: -1, dataset not read.
+ *
+ * Programmer: Neil Fortner
+ * November, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_iod_dataset_read(void *_dset, hid_t H5_ATTR_UNUSED mem_type_id, hid_t H5_ATTR_UNUSED mem_space_id,
+ hid_t H5_ATTR_UNUSED file_space_id, hid_t dxpl_id, void *buf,
+ void H5_ATTR_UNUSED **req)
+{
+ H5VL_daosm_dset_t *dset = (H5VL_daosm_dset_t *)_dset;
+ H5P_genplist_t *plist = NULL; /* Property list pointer */
+ hid_t trans_id;
+ H5TR_t *tr = NULL;
+ int ndims;
+ hsize_t dim[H5S_MAX_RANK];
+ uint64_t chunk_coords[H5S_MAX_RANK];
+ daos_dkey_t dkey;
+ daos_vec_iod_t iod;
+ daos_recx_t recx;
+ daos_sg_list_t sgl;
+ daos_iov_t sg_iov;
+ uint8_t dkey_buf[1 + H5S_MAX_RANK];
+ uint8_t akey = H5VL_DAOSM_CHUNK_KEY;
+ size_t type_size;
+ uint64_t chunk_size;
+ uint8_t *p;
+ int i;
+ void *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* get the transaction ID */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID");
+ if(H5P_get(plist, H5VL_TRANS_ID, &trans_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for trans_id");
+
+ /* get the TR object */
+ if(NULL == (tr = (H5TR_t *)H5I_object_verify(trans_id, H5I_TR)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a Transaction ID")
+
+ /* Get dataspace extent */
+ if((ndims = H5Sget_simple_extent_ndims(dset->space_id)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of dimensions")
+ if(ndims != H5Sget_simple_extent_dims(dset->space_id, dim, NULL))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dimensions")
+
+ /* Get datatype size */
+ if((type_size = H5Tget_size(dset->type_id)) == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size")
+
+ /* Calculate chunk size */
+ chunk_size = (uint64_t)1;
+ for(i = 0; i < ndims; i++)
+ chunk_size *= (uint64_t)dim[i];
+
+ /* Encode dkey (chunk coordinates). Prefix with '/' to avoid accidental
+ * collisions with other d-keys in this object. For now just 1 chunk,
+ * starting at 0. */
+ HDmemset(chunk_coords, 0, sizeof(chunk_coords)); //DSMINC
+ p = dkey_buf;
+ *p++ == (uint8_t)'/';
+ for(i = 0; i < ndims; i++)
+ UINT64ENCODE(p, chunk_coords[i])
+
+ /* Set up operation to write data */
+ /* Set up dkey */
+ daos_iov_set(&dkey, dkey_buf, (daos_size_t)(1 + (ndims * sizeof(chunk_coords[0]))));
+
+ /* Set up recx */
+ recx.rx_rsize = (uint64_t)type_size;
+ recx.rx_idx = (uint64_t)0;
+ recx.rx_nr = chunk_size;
+
+ /* Set up iod */
+ HDmemset(&iod, 0, sizeof(iod));
+ daos_iov_set(&iod.vd_name, (void *)&akey, (daos_size_t)(sizeof(akey)));
+ daos_csum_set(&iod.vd_kcsum, NULL, 0);
+ iod.vd_nr = 1u;
+ iod.vd_recxs = &recx;
+
+ /* Set up sgl */
+ daos_iov_set(&sg_iov, buf, (daos_size_t)(chunk_size * (uint64_t)type_size));
+ sgl.sg_nr.num = 1;
+ sgl.sg_iovs = &sg_iov;
+
+ /* Write data to dataset */
+ if(0 != (ret = daos_obj_fetch(dset->obj_oh, tr->epoch, &dkey, 1, &iod, &sgl, NULL /*maps*/, NULL /*event*/)))
+ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, NULL, "can't read data from dataset: %d", ret)
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_iod_dataset_read() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_daos_dataset_write
+ *
+ * Purpose: Writes raw data from a buffer into a dataset.
+ *
+ * Return: Success: 0
+ * Failure: -1, dataset not written.
+ *
+ * Programmer: Neil Fortner
+ * November, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_iod_dataset_write(void *_dset, hid_t H5_ATTR_UNUSED mem_type_id, hid_t H5_ATTR_UNUSED mem_space_id,
+ hid_t H5_ATTR_UNUSED file_space_id, hid_t dxpl_id, const void *buf,
+ void H5_ATTR_UNUSED **req)
+{
+ H5VL_daosm_dset_t *dset = (H5VL_daosm_dset_t *)_dset;
+ H5P_genplist_t *plist = NULL; /* Property list pointer */
+ hid_t trans_id;
+ H5TR_t *tr = NULL;
+ int ndims;
+ hsize_t dim[H5S_MAX_RANK];
+ uint64_t chunk_coords[H5S_MAX_RANK];
+ daos_dkey_t dkey;
+ daos_vec_iod_t iod;
+ daos_recx_t recx;
+ daos_sg_list_t sgl;
+ daos_iov_t sg_iov;
+ uint8_t dkey_buf[1 + H5S_MAX_RANK];
+ uint8_t akey = H5VL_DAOSM_CHUNK_KEY;
+ size_t type_size;
+ uint64_t chunk_size;
+ uint8_t *p;
+ int i;
+ void *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* get the transaction ID */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID");
+ if(H5P_get(plist, H5VL_TRANS_ID, &trans_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for trans_id");
+
+ /* get the TR object */
+ if(NULL == (tr = (H5TR_t *)H5I_object_verify(trans_id, H5I_TR)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a Transaction ID")
+
+ /* Get dataspace extent */
+ if((ndims = H5Sget_simple_extent_ndims(dset->space_id)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of dimensions")
+ if(ndims != H5Sget_simple_extent_dims(dset->space_id, dim, NULL))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dimensions")
+
+ /* Get datatype size */
+ if((type_size = H5Tget_size(dset->type_id)) == 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size")
+
+ /* Calculate chunk size */
+ chunk_size = (uint64_t)1;
+ for(i = 0; i < ndims; i++)
+ chunk_size *= (uint64_t)dim[i];
+
+ /* Encode dkey (chunk coordinates). Prefix with '/' to avoid accidental
+ * collisions with other d-keys in this object. For now just 1 chunk,
+ * starting at 0. */
+ HDmemset(chunk_coords, 0, sizeof(chunk_coords)); //DSMINC
+ p = dkey_buf;
+ *p++ == (uint8_t)'/';
+ for(i = 0; i < ndims; i++)
+ UINT64ENCODE(p, chunk_coords[i])
+
+ /* Set up operation to write data */
+ /* Set up dkey */
+ daos_iov_set(&dkey, dkey_buf, (daos_size_t)(1 + (ndims * sizeof(chunk_coords[0]))));
+
+ /* Set up recx */
+ recx.rx_rsize = (uint64_t)type_size;
+ recx.rx_idx = (uint64_t)0;
+ recx.rx_nr = chunk_size;
+
+ /* Set up iod */
+ HDmemset(&iod, 0, sizeof(iod));
+ daos_iov_set(&iod.vd_name, (void *)&akey, (daos_size_t)(sizeof(akey)));
+ daos_csum_set(&iod.vd_kcsum, NULL, 0);
+ iod.vd_nr = 1u;
+ iod.vd_recxs = &recx;
+
+ /* Set up sgl */
+ daos_iov_set(&sg_iov, (void *)buf, (daos_size_t)(chunk_size * (uint64_t)type_size));
+ sgl.sg_nr.num = 1;
+ sgl.sg_iovs = &sg_iov;
+
+ /* Write data to dataset */
+ if(0 != (ret = daos_obj_update(dset->obj_oh, tr->epoch, &dkey, 1, &iod, &sgl, NULL /*event*/)))
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, NULL, "can't write data to dataset: %d", ret)
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_iod_dataset_write() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_daosm_dataset_close
*
* Purpose: Closes a daos-m HDF5 dataset.