Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align with "parallel fence" changes #479

Merged
merged 4 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/testh5cc.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ temp_FILES="a.out $applib"
cat > $appmain <<EOF
#include "hdf5.h"
#define H5FILE_NAME "tmp.h5"
extern void sub1(void);
extern void sub2(void);
int
main (void)
{
Expand All @@ -115,6 +117,8 @@ EOF

# generate prog1
cat > $prog1 <<EOF
#include <stdio.h>
void
sub1(void)
{
printf("in sub1\n");
Expand All @@ -123,6 +127,8 @@ EOF

# generate prog2
cat > $prog2 <<EOF
#include <stdio.h>
void
sub2(void)
{
printf("in sub2\n");
Expand Down
15 changes: 5 additions & 10 deletions src/H5AC.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,14 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co
if (NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create candidate entry list")

if (aux_ptr != NULL)
if (aux_ptr->mpi_rank == 0)
f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE,
(H5AC_NTYPES - 1), H5AC_class_s, H5AC__check_if_write_permitted,
TRUE, H5AC__log_flushed_entry, (void *)aux_ptr);
else
f->shared->cache =
H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1),
H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, (void *)aux_ptr);
if (aux_ptr->mpi_rank == 0)
f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE,
(H5AC_NTYPES - 1), H5AC_class_s, H5AC__check_if_write_permitted,
TRUE, H5AC__log_flushed_entry, (void *)aux_ptr);
else
f->shared->cache =
H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1),
H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, NULL);
H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, (void *)aux_ptr);
} /* end if */
else {
#endif /* H5_HAVE_PARALLEL */
Expand Down
12 changes: 3 additions & 9 deletions src/H5ACmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f)
if (aux_ptr->write_done)
(aux_ptr->write_done)();

/* to prevent "messages from the past" we must synchronize all
/* To prevent "messages from the past" we must synchronize all
* processes again before we go on.
*/
if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm)))
Expand Down Expand Up @@ -1514,7 +1514,7 @@ H5AC__receive_and_apply_clean_list(H5F_t *f)
HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't receive clean list")

if (num_entries > 0)
/* mark the indicated entries as clean */
/* Mark the indicated entries as clean */
if (H5C_mark_entries_as_clean(f, num_entries, haddr_buf_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't mark entries clean.")

Expand Down Expand Up @@ -1900,28 +1900,22 @@ H5AC__rsp__p0_only__flush(H5F_t *f)

/* Check for error on the write operation */
if (result < 0)

HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.")

/* this code exists primarily for the test bed -- it allows us to
* enforce POSIX semantics on the server that pretends to be a
* file system in our parallel tests.
*/
if (aux_ptr->write_done) {

if (aux_ptr->write_done)
(aux_ptr->write_done)();
}
} /* end if */

/* Propagate cleaned entries to other ranks. */
if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0)

HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate clean entries list.")

done:

FUNC_LEAVE_NOAPI(ret_value)

} /* H5AC__rsp__p0_only__flush() */

/*-------------------------------------------------------------------------
Expand Down
31 changes: 6 additions & 25 deletions src/H5C.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@
* things which exist on disk, and which may be
* unambiguously referenced by their disk addresses.
*
* The code in this module was initially written in
* support of a complete re-write of the metadata cache
* in H5AC.c However, other uses for the cache code
* suggested themselves, and thus this file was created
* in an attempt to support re-use.
*
* For a detailed overview of the cache, please see the
* header comment for H5C_t in H5Cpkg.h.
* For a detailed overview of the cache, please see the
* header comment for H5C_t in H5Cpkg.h.
*
*-------------------------------------------------------------------------
*/
Expand All @@ -39,9 +33,7 @@
*
* Code Changes:
*
* - Remove extra functionality in H5C__flush_single_entry()?
*
* - Change protect/unprotect to lock/unlock.
* - Change protect/unprotect to lock/unlock.
*
* - Flush entries in increasing address order in
* H5C__make_space_in_cache().
Expand All @@ -53,18 +45,9 @@
* I/O overhead. Can't do this just yet as some entries are not
* contiguous. Do this in parallel only or in serial as well?
*
* - Create MPI type for dirty objects when flushing in parallel.
*
* - Now that TBBT routines aren't used, fix nodes in memory to
* point directly to the skip list node from the LRU list, eliminating
* skip list lookups when evicting objects from the cache.
*
* Tests:
*
* - Trim execution time. (This is no longer a major issue with the
* shift from the TBBT to a hash table for indexing.)
*
* - Add random tests.
* - Fix nodes in memory to point directly to the skip list node from
* the LRU list, eliminating skip list lookups when evicting objects
* from the cache.
*
**************************************************************************/

Expand Down Expand Up @@ -6650,9 +6633,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags)
}

if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < 0)

HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write image to file")

#ifdef H5_HAVE_PARALLEL
}
#endif /* H5_HAVE_PARALLEL */
Expand Down
67 changes: 24 additions & 43 deletions src/H5Cmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,12 @@ static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned
* Programmer: John Mainzer
* 3/17/10
*
* Changes: Updated sanity checks to allow for the possibility that
* the slist is disabled.
* JRM -- 8/3/20
*
*-------------------------------------------------------------------------
*/
herr_t
H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr,
int mpi_rank, int mpi_size)
{
int i;
int m;
unsigned n;
unsigned first_entry_to_flush;
unsigned last_entry_to_flush;
unsigned total_entries_to_clear = 0;
Expand All @@ -176,15 +169,13 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha
unsigned entries_to_clear[H5C_RING_NTYPES];
haddr_t addr;
H5C_cache_entry_t *entry_ptr = NULL;

#if H5C_DO_SANITY_CHECKS
haddr_t last_addr;
#endif /* H5C_DO_SANITY_CHECKS */

#if H5C_APPLY_CANDIDATE_LIST__DEBUG
char tbl_buf[1024];
#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */

unsigned m, n;
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */

Expand Down Expand Up @@ -226,9 +217,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha
} /* end if */

n = num_candidates / (unsigned)mpi_size;
if (num_candidates % (unsigned)mpi_size > INT_MAX)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "m overflow")
m = (int)(num_candidates % (unsigned)mpi_size);
m = num_candidates % (unsigned)mpi_size;

if (NULL ==
(candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1))))
Expand All @@ -239,31 +228,31 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha
candidate_assignment_table[mpi_size] = num_candidates;

if (m == 0) { /* mpi_size is an even divisor of num_candidates */
for (i = 1; i < mpi_size; i++)
candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n;
for (u = 1; u < (unsigned)mpi_size; u++)
candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n;
} /* end if */
else {
for (i = 1; i <= m; i++)
candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n + 1;
for (u = 1; u <= m; u++)
candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n + 1;

if (num_candidates < (unsigned)mpi_size) {
for (i = m + 1; i < mpi_size; i++)
candidate_assignment_table[i] = num_candidates;
for (u = m + 1; u < (unsigned)mpi_size; u++)
candidate_assignment_table[u] = num_candidates;
} /* end if */
else {
for (i = m + 1; i < mpi_size; i++)
candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n;
for (u = m + 1; u < (unsigned)mpi_size; u++)
candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n;
} /* end else */
} /* end else */
HDassert((candidate_assignment_table[mpi_size - 1] + n) == num_candidates);

#if H5C_DO_SANITY_CHECKS
/* Verify that the candidate assignment table has the expected form */
for (i = 1; i < mpi_size - 1; i++) {
for (u = 1; u < (unsigned)(mpi_size - 1); u++) {
unsigned a, b;

a = candidate_assignment_table[i] - candidate_assignment_table[i - 1];
b = candidate_assignment_table[i + 1] - candidate_assignment_table[i];
a = candidate_assignment_table[u] - candidate_assignment_table[u - 1];
b = candidate_assignment_table[u + 1] - candidate_assignment_table[u];

HDassert(n + 1 >= a);
HDassert(a >= b);
Expand All @@ -275,11 +264,11 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha
last_entry_to_flush = candidate_assignment_table[mpi_rank + 1] - 1;

#if H5C_APPLY_CANDIDATE_LIST__DEBUG
for (i = 0; i < 1024; i++)
tbl_buf[i] = '\0';
for (u = 0; u < 1024; u++)
tbl_buf[u] = '\0';
HDsprintf(&(tbl_buf[0]), "candidate assignment table = ");
for (i = 0; i <= mpi_size; i++)
HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[i]);
for (u = 0; u <= (unsigned)mpi_size; u++)
HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[u]);
HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
HDfprintf(stdout, "%s", tbl_buf);

Expand Down Expand Up @@ -354,9 +343,9 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha
#if H5C_DO_SANITY_CHECKS
m = 0;
n = 0;
for (i = 0; i < H5C_RING_NTYPES; i++) {
m += (int)entries_to_flush[i];
n += entries_to_clear[i];
for (u = 0; u < H5C_RING_NTYPES; u++) {
m += entries_to_flush[u];
n += entries_to_clear[u];
} /* end if */

HDassert((unsigned)m == total_entries_to_flush);
Expand Down Expand Up @@ -957,10 +946,8 @@ H5C__collective_write(H5F_t *f)
int * length_array = NULL;
MPI_Aint * buf_array = NULL;
MPI_Aint * offset_array = NULL;
MPI_Datatype btype;
hbool_t btype_created = FALSE;
MPI_Datatype ftype;
hbool_t ftype_created = FALSE;
MPI_Datatype btype = MPI_BYTE;
MPI_Datatype ftype = MPI_BYTE;
int mpi_code;
char unused = 0; /* Unused, except for non-NULL pointer value */
size_t buf_count;
Expand Down Expand Up @@ -1032,26 +1019,20 @@ H5C__collective_write(H5F_t *f)
if (MPI_SUCCESS !=
(mpi_code = MPI_Type_create_hindexed(count, length_array, buf_array, MPI_BYTE, &btype)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
btype_created = TRUE;
if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&btype)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)

/* Create file MPI type */
if (MPI_SUCCESS !=
(mpi_code = MPI_Type_create_hindexed(count, length_array, offset_array, MPI_BYTE, &ftype)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code)
ftype_created = TRUE;
if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&ftype)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code)

/* MPI count to write */
buf_count = 1;
} /* end if */
else {
/* Pass trivial buf type, file type to the file driver */
btype = MPI_BYTE;
ftype = MPI_BYTE;

/* Set non-NULL pointer for I/O operation */
base_buf = &unused;

Expand All @@ -1074,9 +1055,9 @@ H5C__collective_write(H5F_t *f)
offset_array = (MPI_Aint *)H5MM_xfree(offset_array);

/* Free MPI Types */
if (btype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype)))
if (MPI_BYTE != btype && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype)))
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)
if (ftype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype)))
if (MPI_BYTE != ftype && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype)))
HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code)

/* Reset transfer mode in API context, if changed */
Expand Down
Loading