-
Notifications
You must be signed in to change notification settings - Fork 133
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
Add macro for consistent sunrealtype formatting #517
base: develop
Are you sure you want to change the base?
Conversation
test/answers
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to open a PR in the answers repo to merge these updates into main
test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out
Outdated
Show resolved
Hide resolved
Co-authored-by: David Gardner <[email protected]>
Co-authored-by: David Gardner <[email protected]>
…feature/real-format3
include/sundials/sundials_types.h
Outdated
#if defined(SUNDIALS_SINGLE_PRECISION) | ||
|
||
typedef float sunrealtype; | ||
#define SUN_RCONST(x) x##F | ||
#define SUN_BIG_REAL FLT_MAX | ||
#define SUN_SMALL_REAL FLT_MIN | ||
#define SUN_UNIT_ROUNDOFF FLT_EPSILON | ||
#define SUN_FORMAT_E "% ." SUN_STRING(FLT_DIG) "e" | ||
#define SUN_FORMAT_G "% ." SUN_STRING(FLT_DIG) "g" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the updated outputs with "% ."
I think it would be better to have this macro not include %
(i.e., use #define SUN_FORMAT_G "." SUN_STRING(FLT_DIG) "g"
. This way the space after %
can be added locally in the format string when it's needed for alignment (i.e., outputting matrix/vector entries) and in other cases (like PrintAllStats
) the space can be excluded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the new output file format is not ideal with double spaces for positive numbers. What about this?
#define SUN_FORMAT_E "% ." SUN_STRING(FLT_DIG) "e"
#define SUN_FORMAT_G "%." SUN_STRING(FLT_DIG) "g"
Note I just removed a space from the g format. We can use SUN_FORMAT_E
for cases where alignment is needed (I think this is already the case), and SUN_FORMAT_G
elsewhere. We could even rename them to SUN_FORMAT_ALIGNED
and SUN_FORMAT
. I like the simplicity and consistency of just two macros which contain the entire format specifier. Let's discuss at tomorrow's meeting.
Aside from updating outfiles, I think this is ready. Before I spend the time updating all of those (just logging test out files updated for now) which will make the PR diff enormous, I wanted to see if there's any suggestions on the format, name of macros, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback on the PR. Overall I think this is really helpful, but I have a few questions.
@@ -1290,132 +1290,63 @@ int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) | |||
retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); | |||
if (retval != ARK_SUCCESS) { return (retval); } | |||
|
|||
switch (fmt) | |||
/* function evaluations */ | |||
sunfprintf_long(outfile, fmt, SUNFALSE, "Explicit RHS fn evals", step_mem->nfe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how the new sunfprintf
functions really tighten things up with the table-vs-csv output, but it would be nice if these were documented somewhere (e.g., in the developer guide), since it took me a while to discover their definitions inside src/sundials/sundials_utils.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, have the outputs from these been compared with the previous outputs (especially for the CSV)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how the new sunfprintf functions really tighten things up with the table-vs-csv output
Credit to @gardner48 from an earlier incarnation of this PR
it would be nice if these were documented somewhere
Agreed
Also, have the outputs from these been compared with the previous outputs (especially for the CSV)?
I haven't. Looks like there's some test that use CSV output, so I'll check those diffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice if these were documented somewhere
Agreed
The documentation could go in this section of the developer guide.
Also, have the outputs from these been compared with the previous outputs (especially for the CSV)?
I haven't. Looks like there's some test that use CSV output, so I'll check those diffs.
I checked this manually in the initial implementation but we should add a unit test to catch any regressions
%ignore SUN_FORMAT_E; | ||
%ignore SUN_FORMAT_G; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these %ignore
have undesirable consequences, e.g., if Swig ends up processing a header file that includes a print statement that uses one of these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format macros are only used in src/**/*.c
files, so I don't think it should be a problem. No compilation issues for me. Any concerns @balos1?
@@ -1290,132 +1290,63 @@ int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) | |||
retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); | |||
if (retval != ARK_SUCCESS) { return (retval); } | |||
|
|||
switch (fmt) | |||
/* function evaluations */ | |||
sunfprintf_long(outfile, fmt, SUNFALSE, "Explicit RHS fn evals", step_mem->nfe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice if these were documented somewhere
Agreed
The documentation could go in this section of the developer guide.
Also, have the outputs from these been compared with the previous outputs (especially for the CSV)?
I haven't. Looks like there's some test that use CSV output, so I'll check those diffs.
I checked this manually in the initial implementation but we should add a unit test to catch any regressions
The
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor doc formatting items otherwise this looks good to me
Replaces #498 after v7.1.0 update