Skip to content

Commit

Permalink
Synchronize multi-threaded error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Nov 25, 2024
1 parent 85cd3ef commit 6ef874f
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 67 deletions.
2 changes: 2 additions & 0 deletions src/H5public.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ extern "C" {

#define H5_ATOMIC_STORE(dst, value) atomic_store(&dst, value)
#define H5_ATOMIC_LOAD(src) atomic_load(&src)
#define H5_ATOMIC_ADD(dst, value) atomic_fetch_add(&dst, value)

#else
#define H5_ATOMIC(type) type
Expand All @@ -427,6 +428,7 @@ extern "C" {

#define H5_ATOMIC_STORE(dst, value) (dst = value)
#define H5_ATOMIC_LOAD(src) (src)
#define H5_ATOMIC_ADD(dst, value) (dst += value)
#endif


Expand Down
51 changes: 31 additions & 20 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2704,9 +2704,11 @@ test_create_many_dataset(void)
goto error;
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < DATASET_NUMB; i++) {
printf("\r %u/%u", i + 1, DATASET_NUMB);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", i + 1, DATASET_NUMB);
sprintf(dset_name, "dset_%02u", i);
data = i % 256;

Expand Down Expand Up @@ -4400,7 +4402,7 @@ test_dataset_io_point_selections(void)
/* Perform with and without chunking */
for (do_chunk = FALSE;; do_chunk = TRUE) {
if (do_chunk) {
TESTING("point selection I/O with all selection in memory and points in file with chunking");
TESTING_2("point selection I/O with all selection in memory and points in file with chunking");

/* Create chunked dataset */
if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_CHUNK, H5T_NATIVE_INT, fspace_id,
Expand Down Expand Up @@ -4481,9 +4483,9 @@ test_dataset_io_point_selections(void)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and file (same shape) with chunking");
TESTING_2("point selection I/O with points in memory and file (same shape) with chunking");
else
TESTING("point selection I/O with points in memory and file (same shape)");
TESTING_2("point selection I/O with points in memory and file (same shape)");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -4547,9 +4549,9 @@ test_dataset_io_point_selections(void)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and file (different shape) with chunking");
TESTING_2("point selection I/O with points in memory and file (different shape) with chunking");
else
TESTING("point selection I/O with points in memory and file (different shape)");
TESTING_2("point selection I/O with points in memory and file (different shape)");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -4620,9 +4622,9 @@ test_dataset_io_point_selections(void)
PASSED();

if (do_chunk)
TESTING("point selection I/O with hyperslab in memory and points in file with chunking");
TESTING_2("point selection I/O with hyperslab in memory and points in file with chunking");
else
TESTING("point selection I/O with hyperslab in memory and points in file");
TESTING_2("point selection I/O with hyperslab in memory and points in file");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -4693,9 +4695,9 @@ test_dataset_io_point_selections(void)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and hyperslab in file with chunking");
TESTING_2("point selection I/O with points in memory and hyperslab in file with chunking");
else
TESTING("point selection I/O with points in memory and hyperslab in file");
TESTING_2("point selection I/O with points in memory and hyperslab in file");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -9460,11 +9462,13 @@ test_write_multi_chunk_dataset_diff_shape_read(void)
/*
* Read every chunk in the dataset, checking the data for each one.
*/
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < data_size / chunk_size; i++) {
size_t j;

printf("\r Reading chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Reading chunk %zu", i);

for (j = 0; j < DATASET_MULTI_CHUNK_WRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -9686,7 +9690,8 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void)
count[i] = chunk_dims[i];
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (niter = 0; niter < DATASET_MULTI_CHUNK_OVERWRITE_SAME_SPACE_READ_TEST_NITERS; niter++) {
memset(write_buf, 0, data_size);

Expand Down Expand Up @@ -9795,7 +9800,8 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void)
for (i = 0; i < data_size / chunk_size; i++) {
size_t j, k;

printf("\r Reading chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Reading chunk %zu", i);

for (j = 0; j < DATASET_MULTI_CHUNK_OVERWRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -10030,7 +10036,8 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void)
count[i] = chunk_dims[i];
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (niter = 0; niter < DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_NITERS; niter++) {
memset(write_buf, 0, data_size);

Expand Down Expand Up @@ -10139,7 +10146,8 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void)
for (i = 0; i < data_size / chunk_size; i++) {
size_t j;

printf("\r Reading chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Reading chunk %zu", i);

for (j = 0; j < DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -10550,7 +10558,8 @@ test_read_partial_chunk_hyperslab_selection(void)
/*
* Write and read each chunk in the dataset.
*/
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < FIXED_NCHUNKS; i++) {
hsize_t start[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK];
hsize_t count[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK];
Expand Down Expand Up @@ -10614,7 +10623,8 @@ test_read_partial_chunk_hyperslab_selection(void)
goto error;
}

printf("\r Writing chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Writing chunk %zu", i);

if (H5Dwrite(dset_id, DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_DTYPE, mspace_id, fspace_id,
H5P_DEFAULT, write_buf) < 0) {
Expand Down Expand Up @@ -10649,7 +10659,8 @@ test_read_partial_chunk_hyperslab_selection(void)
goto error;
}

printf("\r Reading chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Reading chunk %zu", i);

if (H5Dread(dset_id, DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_DTYPE, mspace_id, fspace_id,
H5P_DEFAULT, read_buf) < 0) {
Expand Down
13 changes: 9 additions & 4 deletions test/API/H5_api_group_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@ test_create_many_groups(void)
}

/* Create multiple groups under the parent group */
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < GROUP_NUMB_MANY; i++) {
printf("\r %u/%u", i + 1, GROUP_NUMB_MANY);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", i + 1, GROUP_NUMB_MANY);
sprintf(group_name, "group %02u", i);

if ((child_group_id =
H5Gcreate2(parent_group_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
Expand Down Expand Up @@ -292,7 +295,8 @@ test_create_deep_groups(void)
goto error;
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
if (create_group_recursive(group_id, 1) < 0)
TEST_ERROR;

Expand Down Expand Up @@ -328,7 +332,8 @@ create_group_recursive(hid_t parent_gid, unsigned counter)
hid_t child_gid = H5I_INVALID_HID;
char gname[NAME_BUF_SIZE];

printf("\r %u/%u", counter, GROUP_DEPTH);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", counter, GROUP_DEPTH);
if (counter == 1)
sprintf(gname, "2nd_child_group");
else if (counter == 2)
Expand Down
Loading

0 comments on commit 6ef874f

Please sign in to comment.