Skip to content

Commit

Permalink
Merge pull request #71 from HDFGroup/feature/select_io_tconv
Browse files Browse the repository at this point in the history
Feature/select io tconv
  • Loading branch information
vchoi-hdfgroup authored Mar 16, 2023
2 parents 4716568 + 08b8e82 commit a25b005
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 25 deletions.
27 changes: 18 additions & 9 deletions src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2562,15 +2562,12 @@ H5D__chunk_may_use_select_io(const H5D_io_info_t *io_info, const H5D_dset_io_inf
dataset = dset_info->dset;
HDassert(dataset);

/* Don't use selection I/O if it's globally disabled, there is a type
* conversion, or if there are filters on the dataset (for now) */
if (dset_info->io_ops.single_read != H5D__select_read || dataset->shared->dcpl_cache.pline.nused > 0)
/* Don't use selection I/O if there are filters on the dataset (for now) */
if (dataset->shared->dcpl_cache.pline.nused > 0)
ret_value = FALSE;
else {
hbool_t page_buf_enabled;

HDassert(dset_info->io_ops.single_write == H5D__select_write);

/* Check if the page buffer is enabled */
if (H5PB_enabled(io_info->f_sh, H5FD_MEM_DRAW, &page_buf_enabled) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if page buffer is enabled")
Expand Down Expand Up @@ -2768,7 +2765,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info)
chunk_node = H5D_CHUNK_GET_NEXT_NODE(dset_info, chunk_node);
} /* end while */

/* Only perform I/O if not performing multi dataset I/O, otherwise the
/* Only perform I/O if not performing multi dataset I/O or type conversion, otherwise the
* higher level will handle it after all datasets have been processed */
if (H5D_LAYOUT_CB_PERFORM_IO(io_info)) {
/* Issue selection I/O call (we can skip the page buffer because we've
Expand All @@ -2789,7 +2786,13 @@ H5D__chunk_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info)
chunk_addrs = H5MM_xfree(chunk_addrs);
} /* end if */
} /* end if */
} /* end if */

#ifdef H5_HAVE_PARALLEL
/* Report that collective chunk I/O was used (will only be set on the DXPL if collective I/O was
* requested) */
io_info->actual_io_mode |= H5D_MPIO_CHUNK_COLLECTIVE;
#endif /* H5_HAVE_PARALLEL */
} /* end if */
else {
H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */
H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */
Expand Down Expand Up @@ -3151,7 +3154,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info)
chunk_node = H5D_CHUNK_GET_NEXT_NODE(dset_info, chunk_node);
} /* end while */

/* Only perform I/O if not performing multi dataset I/O, otherwise the
/* Only perform I/O if not performing multi dataset I/O or type conversion, otherwise the
* higher level will handle it after all datasets have been processed */
if (H5D_LAYOUT_CB_PERFORM_IO(io_info)) {
/* Issue selection I/O call (we can skip the page buffer because we've
Expand All @@ -3172,7 +3175,13 @@ H5D__chunk_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info)
chunk_addrs = H5MM_xfree(chunk_addrs);
} /* end if */
} /* end if */
} /* end if */

#ifdef H5_HAVE_PARALLEL
/* Report that collective chunk I/O was used (will only be set on the DXPL if collective I/O was
* requested) */
io_info->actual_io_mode |= H5D_MPIO_CHUNK_COLLECTIVE;
#endif /* H5_HAVE_PARALLEL */
} /* end if */
else {
/* Iterate through nodes in chunk skip list */
chunk_node = H5D_CHUNK_GET_FIRST_NODE(dset_info);
Expand Down
24 changes: 17 additions & 7 deletions src/H5Dcontig.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ H5D__contig_io_init(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo)
/* Check if we're performing selection I/O if it hasn't been disabled
* already */
if (io_info->use_select_io) {
if ((use_selection_io = H5D__contig_may_use_select_io(io_info, dinfo, H5D_IO_OP_READ)) < 0)
if ((use_selection_io = H5D__contig_may_use_select_io(io_info, dinfo, io_info->op_type)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if selection I/O is possible")
io_info->use_select_io = (hbool_t)use_selection_io;
}
Expand Down Expand Up @@ -808,8 +808,8 @@ H5D__contig_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo)
HDassert(dinfo->file_space);

if (io_info->use_select_io) {
/* Only perform I/O if not performing multi dataset I/O with selection
* I/O, otherwise the higher level will handle it after all datasets
/* Only perform I/O if not performing multi dataset I/O or type conversion,
* otherwise the higher level will handle it after all datasets
* have been processed */
if (H5D_LAYOUT_CB_PERFORM_IO(io_info)) {
size_t dst_type_size = dinfo->type_info.dst_type_size;
Expand Down Expand Up @@ -843,7 +843,12 @@ H5D__contig_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo)
io_info->pieces_added++;
}
}
} /* end if */

#ifdef H5_HAVE_PARALLEL
/* Report that collective contiguous I/O was used */
io_info->actual_io_mode |= H5D_MPIO_CONTIGUOUS_COLLECTIVE;
#endif /* H5_HAVE_PARALLEL */
} /* end if */
else
/* Read data through legacy (non-selection I/O) pathway */
if ((dinfo->io_ops.single_read)(io_info, dinfo) < 0)
Expand Down Expand Up @@ -880,8 +885,8 @@ H5D__contig_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo)
HDassert(dinfo->file_space);

if (io_info->use_select_io) {
/* Only perform I/O if not performing multi dataset I/O with selection
* I/O, otherwise the higher level will handle it after all datasets
/* Only perform I/O if not performing multi dataset I/O or type conversion,
* otherwise the higher level will handle it after all datasets
* have been processed */
if (H5D_LAYOUT_CB_PERFORM_IO(io_info)) {
size_t dst_type_size = dinfo->type_info.dst_type_size;
Expand Down Expand Up @@ -915,7 +920,12 @@ H5D__contig_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo)
io_info->pieces_added++;
}
}
} /* end if */

#ifdef H5_HAVE_PARALLEL
/* Report that collective contiguous I/O was used */
io_info->actual_io_mode |= H5D_MPIO_CONTIGUOUS_COLLECTIVE;
#endif /* H5_HAVE_PARALLEL */
} /* end if */
else
/* Write data through legacy (non-selection I/O) pathway */
if ((dinfo->io_ops.single_write)(io_info, dinfo) < 0)
Expand Down
30 changes: 30 additions & 0 deletions src/H5Dio.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "selection read failed")
}
}

#ifdef H5_HAVE_PARALLEL
/* Report the actual I/O mode to the application if appropriate */
if (io_info.using_mpi_vfd) {
H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */

/* Get the parallel I/O transfer mode */
if (H5CX_get_io_xfer_mode(&xfer_mode) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode")

/* Only report the collective I/O mode if we're actually performing collective I/O */
if (xfer_mode == H5FD_MPIO_COLLECTIVE)
H5CX_set_mpio_actual_io_mode(io_info.actual_io_mode);
}
#endif /* H5_HAVE_PARALLEL */
}

done:
Expand Down Expand Up @@ -781,6 +796,21 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "selection write failed")
}
}

#ifdef H5_HAVE_PARALLEL
/* Report the actual I/O mode to the application if appropriate */
if (io_info.using_mpi_vfd) {
H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */

/* Get the parallel I/O transfer mode */
if (H5CX_get_io_xfer_mode(&xfer_mode) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode")

/* Only report the collective I/O mode if we're actually performing collective I/O */
if (xfer_mode == H5FD_MPIO_COLLECTIVE)
H5CX_set_mpio_actual_io_mode(io_info.actual_io_mode);
}
#endif /* H5_HAVE_PARALLEL */
}

#ifdef OLD_WAY
Expand Down
7 changes: 1 addition & 6 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,13 +1437,8 @@ H5D__link_piece_collective_io(H5D_io_info_t *io_info, int mpi_rank)
HDassert(io_info->dsets_info[i].dset->shared->dcpl_cache.pline.nused == 0);
if (io_info->dsets_info[i].layout->type == H5D_CHUNKED)
actual_io_mode |= H5D_MPIO_CHUNK_COLLECTIVE;
else if (io_info->dsets_info[i].layout->type == H5D_CONTIGUOUS) {
else if (io_info->dsets_info[i].layout->type == H5D_CONTIGUOUS)
actual_io_mode |= H5D_MPIO_CONTIGUOUS_COLLECTIVE;

/* if only single-dset */
if (1 == io_info->count)
actual_chunk_opt_mode = H5D_MPIO_NO_CHUNK_OPTIMIZATION;
}
else
HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout")
}
Expand Down
3 changes: 3 additions & 0 deletions src/H5Dpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ typedef struct H5D_io_info_t {
conversion */
hbool_t
must_fill_bkg; /* Whether any datasets need a background buffer filled with destination contents */
#ifdef H5_HAVE_PARALLEL
H5D_mpio_actual_io_mode_t actual_io_mode; /* Actual type of collective or independent I/O */
#endif /* H5_HAVE_PARALLEL */
} H5D_io_info_t;

/* Created to pass both at once for callback func */
Expand Down
1 change: 0 additions & 1 deletion src/H5Ppublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ typedef enum H5D_mpio_actual_io_mode_t {
H5D_MPIO_CHUNK_MIXED = 0x1 | 0x2,
/**< HDF5 performed one the chunk collective optimization schemes and some
chunks were accessed independently, some collectively. */
/** \internal The contiguous case is separate from the bit field. */
H5D_MPIO_CONTIGUOUS_COLLECTIVE = 0x4
/**< Collective I/O was performed on a contiguous dataset */
} H5D_mpio_actual_io_mode_t;
Expand Down
6 changes: 4 additions & 2 deletions testpar/t_select_io_dset.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ check_io_mode(hid_t dxpl, unsigned chunked)
if (actual_io_mode != H5D_MPIO_CHUNK_COLLECTIVE) {
nerrors++;
if (MAINPROCESS)
HDprintf("\n Failed: Incorrect I/O mode (chunked) ");
HDprintf("\n Failed: Incorrect I/O mode (expected chunked, returned %u)",
(unsigned)actual_io_mode);
}
}
else if (actual_io_mode != H5D_MPIO_CONTIGUOUS_COLLECTIVE) {
nerrors++;
if (MAINPROCESS)
HDprintf("\n Failed: Incorrect I/O mode (contiguous) ");
HDprintf("\n Failed: Incorrect I/O mode (expected contiguous, returned %u)",
(unsigned)actual_io_mode);
}

} /* check_io_mode() */
Expand Down

0 comments on commit a25b005

Please sign in to comment.