Skip to content

Commit

Permalink
Add H5_CHECK_MPI_VERSION macro to check for at least MPI version of (…
Browse files Browse the repository at this point in the history
…version, subversion) (#1556)

* Fix MPI version check for MPI_Aint_diff usage

* Add H5_CHECK_MPI_VERSION macro

Adds new H5_CHECK_MPI_VERSION macro to check for MPI library version/subversion pair of at least the specified pair
  • Loading branch information
jhendersonHDF authored Mar 30, 2022
1 parent 82bf2e9 commit ab48ed6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5403,7 +5403,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_fill_info_t *chunk_
if (MPI_SUCCESS != (mpi_code = MPI_Get_address(partial_chunk_fill_buf, &partial_fill_buf_addr)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code)

#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1
#if H5_CHECK_MPI_VERSION(3, 1)
partial_fill_buf_disp = MPI_Aint_diff(partial_fill_buf_addr, fill_buf_addr);
#else
partial_fill_buf_disp = partial_fill_buf_addr - fill_buf_addr;
Expand Down
10 changes: 5 additions & 5 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3801,7 +3801,7 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk
H5D_filtered_collective_io_info_t **chunk_hash_table,
unsigned char ***chunk_msg_bufs, int *chunk_msg_bufs_len)
{
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
H5D_filtered_collective_io_info_t *chunk_table = NULL;
H5S_sel_iter_t * mem_iter = NULL;
unsigned char ** msg_send_bufs = NULL;
Expand Down Expand Up @@ -4023,7 +4023,7 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk
* post a non-blocking receive to receive it
*/
if (msg_flag) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
MPI_Count msg_size = 0;

if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&status, MPI_BYTE, &msg_size)))
Expand Down Expand Up @@ -5768,7 +5768,7 @@ H5D__mpio_collective_filtered_io_type(H5D_filtered_collective_io_info_t *chunk_l
* offset and base chunk data buffer.
*/
if (op_type == H5D_IO_OP_WRITE) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[0].buf, &base_buf)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code)
#else
Expand All @@ -5793,7 +5793,7 @@ H5D__mpio_collective_filtered_io_type(H5D_filtered_collective_io_info_t *chunk_l
* data buffer if we haven't already
*/
if (!H5F_addr_defined(base_offset)) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[i].buf, &base_buf)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code)
#else
Expand Down Expand Up @@ -5830,7 +5830,7 @@ H5D__mpio_collective_filtered_io_type(H5D_filtered_collective_io_info_t *chunk_l
* Set the displacement of the chunk entry's chunk data buffer,
* relative to the first entry's data buffer
*/
#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1
#if H5_CHECK_MPI_VERSION(3, 1)
if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[i].buf, &chunk_buf)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code)

Expand Down
14 changes: 7 additions & 7 deletions src/H5FDmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
MPI_Status mpi_stat; /* Status from I/O operation */
MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */
int size_i; /* Integer copy of 'size' to read */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
MPI_Count bytes_read = 0; /* Number of bytes read in */
MPI_Count type_size; /* MPI datatype used for I/O's size */
MPI_Count io_size; /* Actual number of bytes requested */
Expand Down Expand Up @@ -1382,7 +1382,7 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
/* Only retrieve bytes read if this rank _actually_ participated in I/O */
if (!rank0_bcast || (rank0_bcast && file->mpi_rank == 0)) {
/* How many bytes were actually read? */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) {
#else
if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) {
Expand All @@ -1407,15 +1407,15 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
* of the data. (QAK - 2019/1/2)
*/
if (rank0_bcast)
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_COUNT, 0, file->comm))
#else
if (MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_INT, 0, file->comm))
#endif
HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", 0)

/* Get the type's size */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size)))
#else
if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size)))
Expand Down Expand Up @@ -1482,7 +1482,7 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h
MPI_Offset mpi_off;
MPI_Status mpi_stat; /* Status from I/O operation */
MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
MPI_Count bytes_written;
MPI_Count type_size; /* MPI datatype used for I/O's size */
MPI_Count io_size; /* Actual number of bytes requested */
Expand Down Expand Up @@ -1628,15 +1628,15 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h
} /* end else */

/* How many bytes were actually written? */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written)))
#else
if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written)))
#endif
HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code)

/* Get the type's size */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size)))
#else
if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size)))
Expand Down
6 changes: 3 additions & 3 deletions src/H5Smpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *

/* Check whether standard or BIGIO processing will be employeed */
if (bigio_count >= num_points) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
/* Create an MPI datatype for the whole point selection */
if (MPI_SUCCESS !=
(mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type)))
Expand Down Expand Up @@ -284,7 +284,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *
#endif

for (i = 0; i < num_big_types; i++) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, 1,
&disp[(hsize_t)i * bigio_count],
elmt_type, &inner_types[i])))
Expand All @@ -300,7 +300,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *
} /* end for*/

if (remaining_points) {
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(
remaining_points, 1, &disp[(hsize_t)num_big_types * bigio_count],
elmt_type, &inner_types[num_big_types])))
Expand Down
4 changes: 2 additions & 2 deletions src/H5mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ H5_mpio_gatherv_alloc(void *send_buf, int send_count, MPI_Datatype send_type, co
{
size_t recv_buf_num_entries = 0;
void * recv_buf = NULL;
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
MPI_Count type_lb;
MPI_Count type_extent;
#else
Expand All @@ -645,7 +645,7 @@ H5_mpio_gatherv_alloc(void *send_buf, int send_count, MPI_Datatype send_type, co
HDassert(out_buf && out_buf_num_entries);

/* Retrieve the extent of the MPI Datatype being used */
#if MPI_VERSION >= 3
#if H5_CHECK_MPI_VERSION(3, 0)
if (MPI_SUCCESS != (mpi_code = MPI_Type_get_extent_x(recv_type, &type_lb, &type_extent)))
#else
if (MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(recv_type, &type_lb, &type_extent)))
Expand Down
9 changes: 9 additions & 0 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,15 @@ typedef struct H5_debug_t {
} H5_debug_t;

#ifdef H5_HAVE_PARALLEL

/*
* Check that the MPI library version is at least version
* `mpi_version` and subversion `mpi_subversion`
*/
#define H5_CHECK_MPI_VERSION(mpi_version, mpi_subversion) \
((MPI_VERSION > (mpi_version)) || \
((MPI_VERSION == (mpi_version)) && (MPI_SUBVERSION >= (mpi_subversion))))

extern hbool_t H5_coll_api_sanity_check_g;
#endif /* H5_HAVE_PARALLEL */

Expand Down

0 comments on commit ab48ed6

Please sign in to comment.