diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/H5D.c | 2 | ||||
-rw-r--r-- | src/H5Dchunk.c | 51 | ||||
-rw-r--r-- | src/H5Ochunk.c | 2 | ||||
-rw-r--r-- | src/H5TS.c | 4 | ||||
-rw-r--r-- | src/H5VLconnector.h | 1 | ||||
-rw-r--r-- | src/H5VLnative.h | 1 | ||||
-rw-r--r-- | src/H5VLnative_dataset.c | 48 | ||||
-rw-r--r-- | src/H5private.h | 4 | ||||
-rw-r--r-- | src/H5trace.c | 6 |
10 files changed, 71 insertions, 50 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 070cf62..f582056 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.12) project (HDF5_SRC C) #----------------------------------------------------------------------------- @@ -598,7 +598,7 @@ H5Dget_offset(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") /* Get the offset */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 556e367..e760f63 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -323,6 +323,7 @@ static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfil #ifdef H5_HAVE_PARALLEL static herr_t H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf); +static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2); #endif /* H5_HAVE_PARALLEL */ static int @@ -4958,6 +4959,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, MPI_Datatype mem_type, file_type; H5FD_mpio_xfer_t prev_xfer_mode; /* Previous data xfer mode */ hbool_t have_xfer_mode = FALSE; /* Whether the previous xffer mode has been retrieved */ + hbool_t need_addr_sort = FALSE; int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5006,19 +5008,28 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* make sure that the addresses in the datatype are monotonically non decreasing */ - if(i) - HDassert(chunk_disp_array[i] > chunk_disp_array[i - 1]); - } /* end if */ + if(i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) + need_addr_sort = TRUE; + } /* end for */ /* calculate if there are any leftover blocks after evenly distributing. If there are, then round robin the distribution to processes 0 -> leftover. */ if(leftover && leftover > mpi_rank) { chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[blocks*mpi_size + mpi_rank]; + if(blocks && (chunk_disp_array[blocks] < chunk_disp_array[blocks - 1])) + need_addr_sort = TRUE; block_lens[blocks] = block_len; blocks++; } + /* + * Ensure that the blocks are sorted in monotonically non-decreasing + * order of offset in the file. + */ + if(need_addr_sort) + HDqsort(chunk_disp_array, blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); + /* MSC - should use this if MPI_type_create_hindexed block is working: * mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, &file_type); */ @@ -5073,6 +5084,36 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_fill() */ + + +static int +H5D__chunk_cmp_addr(const void *addr1, const void *addr2) +{ + MPI_Aint _addr1 = (MPI_Aint)0, _addr2 = (MPI_Aint)0; + int ret_value = 0; + + FUNC_ENTER_STATIC_NOERR + + _addr1 = *((const MPI_Aint *) addr1); + _addr2 = *((const MPI_Aint *) addr2); + +#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1 + { + MPI_Aint diff = MPI_Aint_diff(_addr1, _addr2); + + if(diff < (MPI_Aint)0) + ret_value = -1; + else if(diff > (MPI_Aint)0) + ret_value = 1; + else + ret_value = 0; + } +#else + ret_value = (_addr1 > _addr2) - (_addr1 < _addr2); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__chunk_cmp_addr() */ #endif /* H5_HAVE_PARALLEL */ @@ -7162,7 +7203,7 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_num_chunks() */ @@ -7300,7 +7341,7 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ } /* end if H5F_addr_defined */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info() */ diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 9ce5a46..72402e4 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -358,7 +358,7 @@ H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_update_idx() */ @@ -262,7 +262,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) if (ret_value) return ret_value; - if(mutex->lock_count && pthread_equal(HDpthread_self(), mutex->owner_thread)) { + if(mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) { /* already owned by self - increment count */ mutex->lock_count++; } else { @@ -271,7 +271,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); /* After we've received the signal, take ownership of the mutex */ - mutex->owner_thread = HDpthread_self(); + mutex->owner_thread = pthread_self(); mutex->lock_count = 1; } diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index baa4cca..39d9b14 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -91,7 +91,6 @@ typedef int H5VL_attr_optional_t; typedef enum H5VL_dataset_get_t { H5VL_DATASET_GET_DAPL, /* access property list */ H5VL_DATASET_GET_DCPL, /* creation property list */ - H5VL_DATASET_GET_OFFSET, /* offset */ H5VL_DATASET_GET_SPACE, /* dataspace */ H5VL_DATASET_GET_SPACE_STATUS, /* space status */ H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h index e1f3f93..b607abc 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -48,6 +48,7 @@ #define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ #define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ #define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ +#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ /* Values for native VOL connector file optional VOL operations */ #define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index bea2c50..8660e80 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -297,18 +297,6 @@ H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, break; } - /* H5Dget_offset */ - case H5VL_DATASET_GET_OFFSET: - { - haddr_t *ret = HDva_arg(arguments, haddr_t *); - - /* Set return value */ - *ret = H5D__get_offset(dset); - if(!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; - break; - } - default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") } /* end switch */ @@ -391,16 +379,17 @@ herr_t H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - H5D_t *dset = NULL; /* Dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; /* Dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE + /* Sanity checks */ + HDassert(dset); + switch(optional_type) { case H5VL_NATIVE_DATASET_FORMAT_CONVERT: { /* H5Dformat_convert */ - dset = (H5D_t *)obj; - switch(dset->shared->layout.type) { case H5D_CHUNKED: /* Convert the chunk indexing type to version 1 B-tree if not */ @@ -436,8 +425,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, { /* H5Dget_chunk_index_type */ H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); - dset = (H5D_t *)obj; - /* Make sure the dataset is chunked */ if(H5D_CHUNKED != dset->shared->layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") @@ -453,8 +440,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hsize_t *offset = HDva_arg(arguments, hsize_t *); hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); - dset = (H5D_t *)obj; - /* Make sure the dataset is chunked */ if(H5D_CHUNKED != dset->shared->layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") @@ -472,8 +457,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t space_id = HDva_arg(arguments, hid_t); hsize_t *nchunks = HDva_arg(arguments, hsize_t *); - dset = (H5D_t *)obj; - HDassert(dset); HDassert(dset->shared); HDassert(dset->shared->space); @@ -505,8 +488,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, haddr_t *addr = HDva_arg(arguments, haddr_t *); hsize_t *size = HDva_arg(arguments, hsize_t *); - dset = (H5D_t *)obj; - HDassert(dset); HDassert(dset->shared); HDassert(dset->shared->space); @@ -534,8 +515,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, haddr_t *addr = HDva_arg(arguments, haddr_t *); hsize_t *size = HDva_arg(arguments, hsize_t *); - dset = (H5D_t *)obj; - HDassert(dset); HDassert(dset->shared); /* Make sure the dataset is chunked */ @@ -556,8 +535,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, void *buf = HDva_arg(arguments, void *); hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - dset = (H5D_t *)obj; - /* Check arguments */ if(NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") @@ -585,8 +562,6 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, const void *buf = HDva_arg(arguments, const void *); hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - dset = (H5D_t *)obj; - /* Check arguments */ if(NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") @@ -612,13 +587,22 @@ H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t space_id = HDva_arg(arguments, hid_t); hsize_t *size = HDva_arg(arguments, hsize_t *); - dset = (H5D_t *)obj; - if(H5D__vlen_get_buf_size(dset, type_id, space_id, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed") break; } + /* H5Dget_offset */ + case H5VL_NATIVE_DATASET_GET_OFFSET: + { + haddr_t *ret = HDva_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if(!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") diff --git a/src/H5private.h b/src/H5private.h index 3759446..f570723 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1570,10 +1570,6 @@ extern char *strdup(const char *s); #define HDstrdup(S) strdup(S) #endif /* HDstrdup */ -#ifndef HDpthread_self - #define HDpthread_self() pthread_self() -#endif /* HDpthread_self */ - /* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */ /* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */ #define H5_STRINGIZE(x) #x diff --git a/src/H5trace.c b/src/H5trace.c index ec5c6a2..7168d5d 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -2746,9 +2746,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_DATASET_GET_STORAGE_SIZE: HDfprintf(out, "H5VL_DATASET_GET_STORAGE_SIZE"); break; - case H5VL_DATASET_GET_OFFSET: - HDfprintf(out, "H5VL_DATASET_GET_OFFSET"); - break; default: HDfprintf(out, "%ld", (long)get); break; @@ -3276,6 +3273,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: HDfprintf(out, "H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE"); break; + case H5VL_NATIVE_DATASET_GET_OFFSET: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_OFFSET"); + break; default: HDfprintf(out, "%ld", (long)optional); break; |