cburstedde / libsc

The "sc" auxiliary library
www.p4est.org/
GNU Lesser General Public License v2.1
36 stars 34 forks source link

scda: Fuzzy error synchronization and padding optimization #202

Closed tim-griesbach closed 1 month ago

tim-griesbach commented 1 month ago

scda: Fuzzy error synchronization and padding optimization

This PR continues the implementation of the scda file format (cf. https://github.com/cburstedde/libsc/pull/201) by adding two smaller changes.

  1. Parallel synchronization of the state of the random number generator for the fuzzy error testing. This is required since the serial code paths cause differing counts of drawn random samples on each MPI rank. This means that the fuzzy error return could make a collective error return to a non-collective error return, which is invalid behavior. Therefore, the state of the random number generator is synchronized after every non-collective code section. This change only impacts the code when fuzzy error return is enabled, leaving the normal scda code behavior unchanged.
  2. Introduce the function sc_scda_check_pad_to_fix_len to check fixed-length padding without extracting the raw data. This function enables more modularization, saves one unnecessary copy of the vendor string and makes the set of padding functions for both padding options symmetric.
cburstedde commented 1 month ago

Sounds good! Do we have a way to indicate in the code very clearly which parts are collective and which are not? This seems very important for the parallel consistency of error checking. Maybe by means of extra function calls into non-collective paths with proper naming? "Just" comments and conventions may not be sufficiently safe.

tim-griesbach commented 1 month ago

The non-collective code paths are already in separate functions and the current naming convention for these static functions is that their name ends with _internal. I could replace the current name endings by _serial to be more clear on the functions' purpose.