summaryrefslogtreecommitdiffstats
path: root/src/H5Dchunk.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2020-03-11 21:23:56 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2020-03-11 21:23:56 (GMT)
commita24b0c4a848c08454831ad9c561e234c1248a821 (patch)
tree4412536a98ccd371aba07260d173629ad84942a5 /src/H5Dchunk.c
parentc5ab2285639a801f87a77987db1a0b609a020314 (diff)
parent9abbdeaa66c70a00b6a7bedee9c76d2493a8e947 (diff)
downloadhdf5-a24b0c4a848c08454831ad9c561e234c1248a821.zip
hdf5-a24b0c4a848c08454831ad9c561e234c1248a821.tar.gz
hdf5-a24b0c4a848c08454831ad9c561e234c1248a821.tar.bz2
Merge pull request #26 in ~VCHOI/my_third_fork from develop to bugfix/develop_seg_fault_sel_compat
* commit '9abbdeaa66c70a00b6a7bedee9c76d2493a8e947': (31 commits) Remove system command from valgrind reports Whitespace Fix incorrect FUNC_LEAVE macro (should match FUNC_ENTER_*_TAG). Add semicolons to more PASSED() invocations. So that I can use PASSED(); anywhere a statement can go, #define PASSED() with a do-while wrapper. revert type cast Switch the 'get offset' operation from a dataset 'get' callback to a [native] dataset 'optional' operation. Modfy expression to match mpicc build with Intel as intel compiler, not gcc. Complete the comment on thread_main(), explaining why the barrier is used. Fixed issue building HDF5 with NAG Fortran 7.0. The first implementation seemed to allow for the possibility that a thread could block at the barrier, wake and exit the barrier, re-acquire the barrier lock and increase `nentered` before the other blocked threads woke and checked `nentered % count == 0`. Then the other blocked threads would check `nentered % count == 0` and, finding it false, go back to sleep in the barrier. This new implementation waits for a looser condition to obtain so that threads don't go back to sleep in the barrier. Add java version and reference libsettings Test the right condition for the EBUSY return in pthread_barrier_destroy(). s/exit_failure/EXIT_FAILURE/g Implement pthread_barrier(3) for Darwin using a counter, condition variable, and mutex. Untested. Update examples and fix old version references. Move MODEL check to before usage in CTestScript.cmake. Copy generated files instead creating twice Fix standalone link Fix Fortran macro use and jni comment ...
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r--src/H5Dchunk.c51
1 files changed, 46 insertions, 5 deletions
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() */