From fbb0728f5423ba88de5a7bbe4f4d06825ed82aaa Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 26 Sep 2019 01:19:13 -0700 Subject: Marked up H5Fget/set_mpi_atomicity() to use the VOL. --- src/H5Fmpi.c | 116 +++++++++++++++++++++++++++++++++++++------------- src/H5Fprivate.h | 2 + src/H5VLnative.h | 2 + src/H5VLnative_file.c | 18 ++++++++ testpar/t_dset.c | 8 ++-- 5 files changed, 113 insertions(+), 33 deletions(-) diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index bb422ac..1630d6b 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -38,6 +38,8 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -234,12 +236,43 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_set_mpi_atomicity + * + * Purpose: Private call to set the atomicity mode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + /* Check args */ + HDassert(file); + + /* Check VFD */ + if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); + + /* Set atomicity value */ + if (H5FD_set_mpio_atomicity(file->shared->lf, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_set_mpi_atomicity() */ + + +/*------------------------------------------------------------------------- * Function: H5Fset_mpi_atomicity * * Purpose: Sets the atomicity mode * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Mohamad Chaarawi @@ -250,27 +283,57 @@ done: herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE2("e", "ib", file_id, flag); + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Set atomicity value */ + if (H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, va_flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); + +done: + FUNC_LEAVE_API(ret_value); +} /* end H5Fset_mpi_atomicity() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_mpi_atomicity + * + * Purpose: Private call to get the atomicity mode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HDassert(file); + HDassert(flag); /* Check VFD */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode") + if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); - /* set atomicity value */ - if (H5FD_set_mpio_atomicity (file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag") + /* Get atomicity value */ + if (H5FD_get_mpio_atomicity(file->shared->lf, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag"); done: - FUNC_LEAVE_API(ret_value) -} + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_get_mpi_atomicity() */ /*------------------------------------------------------------------------- @@ -279,7 +342,6 @@ done: * Purpose: Returns the atomicity mode * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Mohamad Chaarawi @@ -290,27 +352,23 @@ done: herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", file_id, flag); - /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - - /* Check VFD */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode") + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); - /* get atomicity value */ - if (H5FD_get_mpio_atomicity (file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag") + /* Get atomicity value */ + if (H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: - FUNC_LEAVE_API(ret_value) -} + FUNC_LEAVE_API(ret_value); +} /* end H5Fget_mpi_atomicity() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 8c70663..7e87f79 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -855,6 +855,8 @@ H5_DLL int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); H5_DLL int H5F_mpi_get_size(const H5F_t *f); H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); H5_DLL herr_t H5F_get_mpi_info(const H5F_t *f, MPI_Info **f_info); +H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); +H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h index a8d5720..82a99e4 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -71,6 +71,8 @@ typedef int H5VL_native_file_optional_t; #define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 24 /* H5Fset_latest_format/libver_bounds */ #define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 25 /* H5Fget_dset_no_attrs_hint */ #define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 26 /* H5Fset_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 27 /* H5Fget_mpi_atomicity */ +#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 28 /* H5Fset_mpi_atomicity */ /* Typedef and values for native VOL connector group optional VOL operations */ typedef int H5VL_native_group_optional_t; diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 0ac70e3..bb77822 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -789,6 +789,24 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR break; } + /* H5Fget_mpi_atomicity */ + case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: + { + hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); + if (H5F_get_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); + break; + } + + /* H5Fset_mpi_atomicity */ + case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: + { + hbool_t flag = (hbool_t)HDva_arg(arguments, int); + if (H5F_set_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") } /* end switch */ diff --git a/testpar/t_dset.c b/testpar/t_dset.c index d4e556d..6c91a41 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -4162,7 +4162,7 @@ dataset_atomicity(void) } /* should fail */ - ret = H5Fset_mpi_atomicity (fid , TRUE); + ret = H5Fset_mpi_atomicity(fid , TRUE); VRFY((ret == FAIL), "H5Fset_mpi_atomicity failed"); if(MAINPROCESS){ @@ -4184,7 +4184,7 @@ dataset_atomicity(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded"); - ret = H5Fset_mpi_atomicity (fid , TRUE); + ret = H5Fset_mpi_atomicity(fid , TRUE); VRFY((ret >= 0), "H5Fset_mpi_atomicity succeeded"); /* open dataset1 (contiguous case) */ @@ -4203,7 +4203,7 @@ dataset_atomicity(void) } /* check that the atomicity flag is set */ - ret = H5Fget_mpi_atomicity (fid , &atomicity); + ret = H5Fget_mpi_atomicity(fid , &atomicity); VRFY((ret >= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); @@ -4272,7 +4272,7 @@ dataset_atomicity(void) atomicity = FALSE; /* check that the atomicity flag is set */ - ret = H5Fget_mpi_atomicity (fid , &atomicity); + ret = H5Fget_mpi_atomicity(fid , &atomicity); VRFY((ret >= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); -- cgit v0.12