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

scda: Write and read block sections #201

Merged
merged 24 commits into from
Sep 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
35b0ffb
feature-scda: Introduce more section header macros
tim-griesbach Aug 21, 2024
db724ac
feature-scda: Introduce two versions of mod padding
tim-griesbach Aug 21, 2024
44562fb
feature-scda: Introduce two versions of fixed padding
tim-griesbach Aug 21, 2024
f8f8b08
feature-scda: Fix offsets
tim-griesbach Aug 21, 2024
b4a333d
feature-scda: Implement fwrite_block
tim-griesbach Aug 21, 2024
a30bd07
feature-scda: Check count length
tim-griesbach Aug 22, 2024
a445716
feature-scda: Read block section header
tim-griesbach Aug 22, 2024
edc9f94
feature-scda: Start fread_block_data
tim-griesbach Aug 22, 2024
ccec211
feature-scda: Typo
tim-griesbach Aug 26, 2024
3077b7f
feature-scda: Padding macro and assert fix
tim-griesbach Aug 27, 2024
3947d4f
feature-scda: Factor out mod padding check
tim-griesbach Aug 27, 2024
5d9e7ff
feature-scda: Check padding in fread_block_data
tim-griesbach Aug 27, 2024
9b0b3a2
feature-scda: First test of reading block sec.
tim-griesbach Aug 27, 2024
e889d9c
feature-scda: Introduce and use HEADER_ROOT macro
tim-griesbach Aug 27, 2024
5efe2d9
feature-scda: Add buffer helper function
tim-griesbach Aug 27, 2024
3db39d4
feature-scda: Implement checker func. for coll. param.
tim-griesbach Aug 27, 2024
1ffa859
feature-scda: Use general func. to check for coll. params.
tim-griesbach Aug 27, 2024
b2098bb
feature-scda: Test coll. parameter checking
tim-griesbach Aug 27, 2024
ded3d9a
feature-scda: Print time-dependent seed
tim-griesbach Aug 27, 2024
19a0179
feature-scda: Check block_size in fread_block_data
tim-griesbach Aug 27, 2024
245dba7
feature-scda: Print seed only for activated fuzzy testing
tim-griesbach Aug 28, 2024
ea25a0d
feature-scda: Generalize pad_to_mod_len
tim-griesbach Aug 28, 2024
cdf43fe
feature-scda: Extend tests
tim-griesbach Aug 28, 2024
662314e
feature-scda: Init output variables
tim-griesbach Aug 28, 2024
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
Prev Previous commit
Next Next commit
feature-scda: Use general func. to check for coll. params.
tim-griesbach committed Aug 27, 2024
commit 1ffa859687aa5ec59b384be52bd4d76e7d2253ac
49 changes: 14 additions & 35 deletions src/sc_scda.c
Original file line number Diff line number Diff line change
@@ -674,43 +674,16 @@ sc_scda_examine_options (sc_scda_fopen_options_t * opt, sc_scda_fcontext_t *fc,
SC_ASSERT (fc != NULL);

if (opt != NULL) {
int mpiret;
int local_fuzzy_params_cmp, collective_fuzzy_params;
/* byte buffer since it is not clear which data type is larger */
/* we use a char array as a byte buffer, cf. \ref sc_array_index */
char buf[sizeof (unsigned) + sizeof (sc_rand_state_t)];
unsigned bcast_everyn;
sc_rand_state_t bcast_seed;
sc_scda_ret_t ret;

/* check if fuzzy_everyn and fuzzy_seed are collective */
ret = sc_scda_check_coll_params (fc, (const char *) &opt->fuzzy_everyn,
sizeof (unsigned),
(const char *) &opt->fuzzy_seed,
sizeof (sc_rand_state_t), NULL, 0);
SC_ASSERT (ret == SC_SCDA_FERR_SUCCESS || ret == SC_SCDA_FERR_ARG);

/* copy fuzzy parameters to byte buffer */
sc_scda_copy_bytes (buf, (char *) &opt->fuzzy_everyn, sizeof (unsigned));
sc_scda_copy_bytes (&buf[sizeof (unsigned)], (char *) &opt->fuzzy_seed,
sizeof (sc_rand_state_t));

/* For the sake of simplicity, we use a Bcast followed by an Allreduce
* instead of one Allreduce call with a custom reduction function.
*/
mpiret = sc_MPI_Bcast (buf, sizeof (unsigned) + sizeof (sc_rand_state_t),
sc_MPI_BYTE, 0, fc->mpicomm);
SC_CHECK_MPI (mpiret);

/* get actual data from the byte buffer */
bcast_everyn = *((unsigned *) buf);
bcast_seed = *((sc_rand_state_t *) & buf[sizeof (unsigned)]);

/* compare fuzzy parameters */
local_fuzzy_params_cmp = bcast_everyn != opt->fuzzy_everyn
|| bcast_seed != opt->fuzzy_seed;

/* synchronize comparison results */
mpiret = sc_MPI_Allreduce (&local_fuzzy_params_cmp,
&collective_fuzzy_params, 1, sc_MPI_INT,
sc_MPI_LOR, fc->mpicomm);
SC_CHECK_MPI (mpiret);

if (collective_fuzzy_params) {
if (ret == SC_SCDA_FERR_ARG) {
/* non-collective fuzzy parameters */
/* no fuzzy error testing in case of an error */
fc->fuzzy_everyn = 0;
@@ -1677,6 +1650,7 @@ sc_scda_fwrite_block (sc_scda_fcontext_t *fc, const char *user_string,
{
int count_err;
size_t num_pad_bytes;
sc_scda_ret_t ret;

SC_ASSERT (fc != NULL);
SC_ASSERT (user_string != NULL);
@@ -1685,7 +1659,12 @@ sc_scda_fwrite_block (sc_scda_fcontext_t *fc, const char *user_string,
SC_ASSERT (fc->mpirank != root || block_data != NULL);
SC_ASSERT (errcode != NULL);

/* TODO: Check if block_size is collective. */
/* check if block_size is collective */
ret = sc_scda_check_coll_params (fc, (const char*) &block_size,
sizeof (size_t), NULL, 0, NULL, 0);
sc_scda_scdaret_to_errcode (ret, errcode, fc);
SC_SCDA_CHECK_COLL_ERR (errcode, fc, "fwrite_block: block_size not "
"collective");

/* TODO: respect encode parameter */