Skip to content

Commit

Permalink
Implementation of the mpio driver with selection I/O.
Browse files Browse the repository at this point in the history
This also addresses the review comments of the previous PR HDFGroup#3058 which will be closed.
  • Loading branch information
vchoi-hdfgroup committed Jul 3, 2023
1 parent e6a845d commit 25c434e
Show file tree
Hide file tree
Showing 5 changed files with 1,734 additions and 98 deletions.
258 changes: 256 additions & 2 deletions src/H5FD.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ H5FDread_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_read_selection_id(file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
if (H5FD_read_selection_id(SKIP_NO_CB, file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file selection read request failed")

Expand Down Expand Up @@ -1820,14 +1820,268 @@ H5FDwrite_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_write_selection_id(file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
if (H5FD_write_selection_id(SKIP_NO_CB, file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file selection write request failed")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDwrite_selection() */

/*
* Translate selections to vector CB if possible, if not, scalar CB
* --skip selection CB
*/
herr_t
H5FDread_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
size_t element_sizes[], void *bufs[] /* out */)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE9("e", "*#MtiIu*i*i*a*zx", file, type, dxpl_id, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs);

/* Check arguments */
if (!file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")

if (!file->cls)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")

if ((!mem_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mem_spaces parameter can't be NULL if count is positive")

if ((!file_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_spaces parameter can't be NULL if count is positive")

if ((!offsets) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offsets parameter can't be NULL if count is positive")

if ((!element_sizes) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"element_sizes parameter can't be NULL if count is positive")

if ((!bufs) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs parameter can't be NULL if count is positive")

if ((count > 0) && (element_sizes[0] == 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sizes[0] can't be 0")

if ((count > 0) && (bufs[0] == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs[0] can't be NULL")

/* 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 a data transfer property list")
}

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_read_vector_from_selection(file, type, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file selection read request failed")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDread_vector_from_selection() */

/*
* Translate selections to vector CB if possible, if not, scalar CB
* --skip selection CB
*/
herr_t
H5FDwrite_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
size_t element_sizes[], const void *bufs[])
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE9("e", "*#MtiIu*i*i*a*z**x", file, type, dxpl_id, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs);

/* Check arguments */
if (!file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")

if (!file->cls)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")

if ((!mem_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mem_spaces parameter can't be NULL if count is positive")

if ((!file_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_spaces parameter can't be NULL if count is positive")

if ((!offsets) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offsets parameter can't be NULL if count is positive")

if ((!element_sizes) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"element_sizes parameter can't be NULL if count is positive")

if ((!bufs) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs parameter can't be NULL if count is positive")

if ((count > 0) && (element_sizes[0] == 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sizes[0] can't be 0")

if ((count > 0) && (bufs[0] == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs[0] can't be NULL")

/* 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 a data transfer property list")
}

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_write_vector_from_selection(file, type, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file selection write request failed")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDwrite_vector_from_selection() */

/*
* Translate selections to scalar CB
* --skip selection CB
* --skip vector CB
*/
herr_t
H5FDread_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count, hid_t mem_space_ids[],
hid_t file_space_ids[], haddr_t offsets[], size_t element_sizes[], void *bufs[])
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE9("e", "*#MtiIu*i*i*a*z**x", file, type, dxpl_id, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs);

/* Check arguments */
if (!file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")

if (!file->cls)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")

if ((!mem_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mem_spaces parameter can't be NULL if count is positive")

if ((!file_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_spaces parameter can't be NULL if count is positive")

if ((!offsets) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offsets parameter can't be NULL if count is positive")

if ((!element_sizes) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"element_sizes parameter can't be NULL if count is positive")

if ((!bufs) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs parameter can't be NULL if count is positive")

if ((count > 0) && (element_sizes[0] == 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sizes[0] can't be 0")

if ((count > 0) && (bufs[0] == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs[0] can't be NULL")

/* 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 a data transfer property list")
}

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_read_from_selection(file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file selection read request failed")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDread_from_selection() */

/*
* Translate selections to scalar CB
* --skip selection CB
* --skip vector CB
*/
herr_t
H5FDwrite_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count, hid_t mem_space_ids[],
hid_t file_space_ids[], haddr_t offsets[], size_t element_sizes[],
const void *bufs[])
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE9("e", "*#MtiIu*i*i*a*z**x", file, type, dxpl_id, count, mem_space_ids, file_space_ids, offsets,
element_sizes, bufs);

/* Check arguments */
if (!file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")

if (!file->cls)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")

if ((!mem_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mem_spaces parameter can't be NULL if count is positive")

if ((!file_space_ids) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_spaces parameter can't be NULL if count is positive")

if ((!offsets) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offsets parameter can't be NULL if count is positive")

if ((!element_sizes) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"element_sizes parameter can't be NULL if count is positive")

if ((!bufs) && (count > 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs parameter can't be NULL if count is positive")

if ((count > 0) && (element_sizes[0] == 0))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sizes[0] can't be 0")

if ((count > 0) && (bufs[0] == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bufs[0] can't be NULL")

/* 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 a data transfer property list")
}

/* Call private function */
/* (Note compensating for base address addition in internal routine) */
if (H5FD_write_from_selection(file, type, count, mem_space_ids, file_space_ids, offsets, element_sizes,
bufs) < 0)
HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file selection write request failed")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDwrite_from_selection() */


/*-------------------------------------------------------------------------
* Function: H5FDflush
*
Expand Down
16 changes: 14 additions & 2 deletions src/H5FDdevelop.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ typedef struct H5FD_class_t {
size_t sizes[], void *bufs[]);
herr_t (*write_vector)(H5FD_t *file, hid_t dxpl, uint32_t count, H5FD_mem_t types[], haddr_t addrs[],
size_t sizes[], const void *bufs[]);
herr_t (*read_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, size_t count, hid_t mem_spaces[],
herr_t (*read_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count, hid_t mem_spaces[],
hid_t file_spaces[], haddr_t offsets[], size_t element_sizes[],
void *bufs[] /*out*/);
herr_t (*write_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, size_t count, hid_t mem_spaces[],
herr_t (*write_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count, hid_t mem_spaces[],
hid_t file_spaces[], haddr_t offsets[], size_t element_sizes[],
const void *bufs[] /*in*/);
herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
Expand Down Expand Up @@ -281,6 +281,18 @@ H5_DLL herr_t H5FDread_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
H5_DLL herr_t H5FDwrite_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
size_t element_sizes[], const void *bufs[]);
H5_DLL herr_t H5FDread_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
size_t element_sizes[], void *bufs[] /* out */);
H5_DLL herr_t H5FDwrite_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
size_t element_sizes[], const void *bufs[] /* in */);
H5_DLL herr_t H5FDread_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
size_t element_sizes[], void *bufs[] /* out */);
H5_DLL herr_t H5FDwrite_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
size_t element_sizes[], const void *bufs[] /* in */);
H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw);
Expand Down
Loading

0 comments on commit 25c434e

Please sign in to comment.