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

Add macro for consistent sunrealtype formatting #517

Merged
merged 66 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3f3be17
Squash commits
Steven-Roberts Jun 21, 2024
39b1620
Merge branch 'develop' into feature/real-format3
gardner48 Jun 22, 2024
c32face
Merge branch 'develop' into feature/real-format3
gardner48 Jun 22, 2024
83905c8
update .out files
gardner48 Jun 24, 2024
65e9da0
Merge branch 'develop' into feature/real-format3
gardner48 Jun 27, 2024
50f32bb
Apply suggestions from code review
Steven-Roberts Jun 28, 2024
fe7f76d
Update src/sundials/sundials_utils.h
Steven-Roberts Jun 28, 2024
84024ab
Remove final newline from matrix output
Steven-Roberts Jun 29, 2024
494f217
Merge branch 'feature/real-format3' of github.com:LLNL/sundials into …
Steven-Roberts Jun 29, 2024
bdb5bbb
Switch IDA to sunfprintf_*
Steven-Roberts Jun 29, 2024
df13a2a
Switch to SUN_FORMAT_*
Steven-Roberts Jun 29, 2024
817ed11
Switch to 'e' format for MRI tables
Steven-Roberts Jun 29, 2024
a415ce9
Apply formatter
Steven-Roberts Jun 29, 2024
9b654df
Use space consistently in format
Steven-Roberts Jun 29, 2024
e9c9a71
Fix ida real stats
Steven-Roberts Jun 29, 2024
7cd0509
Switch Butcher table to 'e' format
Steven-Roberts Jun 29, 2024
9aaddfe
update output files
gardner48 Jun 30, 2024
fbd7ad0
Merge branch 'develop' into feature/real-format3
gardner48 Jul 3, 2024
77f6135
Merge branch 'develop' into feature/real-format3
Steven-Roberts Jul 27, 2024
aef939b
Remove sign padding from g format
Steven-Roberts Jul 27, 2024
50d8d8c
Merge branch 'develop' into feature/real-format3
Steven-Roberts Aug 29, 2024
9ec1fad
Merge branch 'develop' into feature/real-format3
Steven-Roberts Sep 6, 2024
e7d6397
Merge branch 'develop' into feature/real-format3
Steven-Roberts Sep 17, 2024
5399b9e
Revert out files to make future merges easier
Steven-Roberts Sep 17, 2024
9bfb997
Merge branch 'develop' into feature/real-format3
Steven-Roberts Oct 17, 2024
629611b
Merge branch 'develop' into feature/real-format3
Steven-Roberts Nov 23, 2024
9067dd7
Remove RSYM from LSRKStep
Steven-Roberts Nov 23, 2024
fe5a7e3
Finish updating print all stats functions
Steven-Roberts Nov 23, 2024
96b9a24
Merge branch 'develop' into feature/real-format3
Steven-Roberts Dec 6, 2024
813c630
Remove RSYM and old style PrintAllStats from newly merged code
Steven-Roberts Dec 6, 2024
307cd5a
Merge branch 'develop' into feature/real-format3
Steven-Roberts Dec 13, 2024
dea1b28
Remove RSYM macro after merge
Steven-Roberts Dec 13, 2024
5d127d7
Add todo comment
Steven-Roberts Dec 13, 2024
303fa90
Merge branch 'develop' into feature/real-format3
Steven-Roberts Dec 17, 2024
819a649
Remove sunsnprintf
Steven-Roberts Dec 17, 2024
2725918
Update logging out files
Steven-Roberts Dec 17, 2024
f38cb88
Apply formatter
Steven-Roberts Dec 17, 2024
dc34825
Update include/sundials/sundials_types.h
Steven-Roberts Dec 18, 2024
77092bf
Add signed format macro
Steven-Roberts Dec 18, 2024
bfddd84
Add developer docs on format macros and print utilities
Steven-Roberts Dec 19, 2024
c864eea
Apply suggestions from code review
Steven-Roberts Dec 19, 2024
096125e
Merge branch 'develop' into feature/real-format3
Steven-Roberts Dec 20, 2024
9578fc0
Merge branch 'develop' into feature/real-format3
Steven-Roberts Jan 2, 2025
250beed
Merge branch 'develop' into feature/real-format3
Steven-Roberts Jan 10, 2025
9d06461
Ignore new format macro in swig
Steven-Roberts Jan 10, 2025
e5380c4
Merge branch 'develop' into feature/real-format3
Steven-Roberts Jan 14, 2025
a64a298
Update single precision out files
Steven-Roberts Jan 14, 2025
e2f2664
Update double precision out files
Steven-Roberts Jan 14, 2025
39d6168
Enable logging artifacts
Steven-Roberts Jan 14, 2025
2e89854
Update logging out files
Steven-Roberts Jan 14, 2025
1d9b811
Update level 3 logging out files
Steven-Roberts Jan 14, 2025
b749730
Update splittingstep test out file
Steven-Roberts Jan 14, 2025
f2e060c
Update level 4 logging out files
Steven-Roberts Jan 14, 2025
e8d12cd
Fix division by 0 error in test runner
Steven-Roberts Jan 14, 2025
c18f337
Update logging out files from new ARKODE steppers
Steven-Roberts Jan 14, 2025
e765624
update output files
gardner48 Jan 15, 2025
38eb813
fix SUN_FORMAT_SG for long double
gardner48 Jan 15, 2025
df2c9fc
fix truncation warning
gardner48 Jan 15, 2025
b43fb51
fix warnings with long double
gardner48 Jan 15, 2025
3703d6d
formatting
gardner48 Jan 15, 2025
1a8c019
Apply suggestions from code review
Steven-Roberts Jan 15, 2025
1c2e80b
update output files
gardner48 Jan 15, 2025
6c4c1d7
update answer submodule
gardner48 Jan 15, 2025
0d25aa8
update answers submodule
gardner48 Jan 15, 2025
52c25d3
update answers submodule
gardner48 Jan 15, 2025
1c890ce
update answer submodule
gardner48 Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .github/workflows/ubuntu-clang-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ jobs:
--label-regex logging \
--verbose

- name: Archive build files from failed build
uses: actions/upload-artifact@v4
if: failure()
with:
name: build_files
path: |
${{ github.workspace }}/build
!${{ github.workspace }}/build/Testing/output

- name: Archive output files from failed build
uses: actions/upload-artifact@v4
if: failure()
with:
name: output_files
path: |
${{ github.workspace }}/build/Testing/

build_cycle_profiling:
runs-on: ubuntu-latest

Expand All @@ -82,3 +99,20 @@ jobs:
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Archive build files from failed build
uses: actions/upload-artifact@v4
if: failure()
with:
name: build_files
path: |
${{ github.workspace }}/build
!${{ github.workspace }}/build/Testing/output

- name: Archive output files from failed build
uses: actions/upload-artifact@v4
if: failure()
with:
name: output_files
path: |
${{ github.workspace }}/build/Testing/
3 changes: 3 additions & 0 deletions doc/superbuild/source/developers/source_code/Rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,7 @@ not adhere to all of these rules.
``sunindextype`` for it. Instead use the appropriate integer type (e.g., ``uint64_t``) directly.
Do not use ``sunindextype`` for counters either.

#. Use the print functions, format macros, and output guidelines detailed in
:ref:`Style.Output`.

#. Follow the logging style detailed in :ref:`Style.Logging`.
83 changes: 81 additions & 2 deletions doc/superbuild/source/developers/source_code/Style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,83 @@ doing this type of line break is useful for readability too.
.. See the clang-tidy documentation for more details.


.. _Style.Output:

Output
------

For consistent formatting of :c:type:`sunrealtype`, the following macros are
available.

.. c:macro:: SUN_FORMAT_E

A format specifier for scientific notation. This should be used when
displaying arrays, matrices, and tables where fixed width alignment aids with
readability.

**Example usage:**

.. code-block:: C

for (i = 0; i < N; i++) {
fprintf(outfile, SUN_FORMAT_E "\n", xd[i]);
}

.. c:macro:: SUN_FORMAT_G

A format specifier for scientific or standard notation, whichever is more
compact. It is more reader-friendly than :c:macro:`SUN_FORMAT_E` and should
be used in all cases not covered by that macro.

**Example usage:**

.. code-block:: C

SSUNLogInfo(sunctx->logger, "label", "x = " SUN_FORMAT_G, x);
Steven-Roberts marked this conversation as resolved.
Show resolved Hide resolved

.. c:macro:: SUN_FORMAT_SG

Like :c:macro:`SUN_FORMAT_G` but with a leading plus or minus sign.


To aid in printing statistics in functions like :c:func:`CVodePrintAllStats`,
the following utility functions are available.

.. c:function:: void sunfprintf_real(FILE* fp, SUNOutputFormat fmt, sunbooleantype start, const char* name, sunrealtype value)

Writes a :c:type:`sunrealtype` value to a file pointer using the specified
format.

:param fp: Pointer to output file.
Steven-Roberts marked this conversation as resolved.
Show resolved Hide resolved
:param fmt: The output format.
:param start: :c:macro:`SUNTRUE` if the value is the first in a series of
statistics, and :c:macro:`SUNFALSE` otherwise.
:param name: The name of the statistic.
:param value: The value of the statistic.

.. c:function:: void sunfprintf_long(FILE* fp, SUNOutputFormat fmt, sunbooleantype start, const char* name, long value)

Writes a long value to a file pointer using the specified format.

:param fp: Pointer to output file.
Steven-Roberts marked this conversation as resolved.
Show resolved Hide resolved
:param fmt: The output format.
:param start: :c:macro:`SUNTRUE` if the value is the first in a series of
statistics, and :c:macro:`SUNFALSE` otherwise.
:param name: The name of the statistic.
:param value: The value of the statistic.

.. c:function:: void sunfprintf_long_array(FILE* fp, SUNOutputFormat fmt, sunbooleantype start, const char* name, long* value, size_t count)

Writes an array of long values to a file pointer using the specified format.

:param fp: Pointer to output file.
Steven-Roberts marked this conversation as resolved.
Show resolved Hide resolved
:param fmt: The output format.
:param start: :c:macro:`SUNTRUE` if the value is the first in a series of
statistics, and :c:macro:`SUNFALSE` otherwise.
:param name: The name of the statistic.
:param value: Pointer to the array.
:param count: The number of elements in the array.

.. _Style.Logging:

Logging
Expand All @@ -128,10 +205,12 @@ equals sign with a space on either side e.g.,
.. code-block:: C

/* log an informational message */
SUNLogInfo(sunctx->logger, "begin-step", "t = %g, h = %g", t, h);
SUNLogInfo(sunctx->logger, "begin-step", "t = " SUN_FORMAT_G ", h = " SUN_FORMAT_G, t, h);

/* log a debugging message */
SUNLogDebug(sunctx->logger, "error-estimates", "eqm1 = %g, eq = %g, eqp1 = %g", eqm1, eq, eqp1);
SUNLogDebug(sunctx->logger, "error-estimates",
"eqm1 = " SUN_FORMAT_G ", eq = " SUN_FORMAT_G ", eqp1 = " SUN_FORMAT_G,
eqm1, eq, eqp1);

or the name of a vector/array followed by ``(:) =`` with each vector/array entry
written to a separate line e.g., a vector may be logged with
Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/CXX_manyvector/ark_sod_lsrk.out
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Accuracy limited steps = 397
Error test fails = 15
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 1.122284259749542e-14
Last step size = 0.0002334416078592081
Current step size = 0.0002334416078592081
Initial step size = 1.12228425974954e-14
Last step size = 0.000233441607859208
Current step size = 0.000233441607859208
RHS fn evals = 3957
Number of stages used = 10
7 changes: 4 additions & 3 deletions examples/arkode/CXX_parallel/ark_heat2D_lsrk_p_--np_2_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ Accuracy limited steps = 617
Error test fails = 0
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 2.877680248425019e-06
Last step size = 0.0003228665778641779
Current step size = 0.0003228665778641779
Initial step size = 2.87768024842502e-06
Last step size = 0.000322866577864178
Current step size = 0.000322866577864178
RHS fn evals = 17225
RHS fn evals = 17225
Number of dom_eig updates = 25
Max. num. of stages used = 46
Expand Down
7 changes: 4 additions & 3 deletions examples/arkode/CXX_serial/ark_heat2D_lsrk.out
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ Accuracy limited steps = 617
Error test fails = 0
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 2.877680248425025e-06
Last step size = 0.0003199001977636226
Current step size = 0.0003199001977636226
Initial step size = 2.87768024842502e-06
Last step size = 0.000319900197763623
Current step size = 0.000319900197763623
RHS fn evals = 17225
RHS fn evals = 17225
Number of dom_eig updates = 25
Max. num. of stages used = 46
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Error test fails = 0
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 0.06
Last step size = 0.03999999999999956
Last step size = 0.0399999999999996
Current step size = 0.06
Partition 0 evolves = 17
Partition 1 evolves = 17
Partition 2 evolves = 17
Partition 3 evolves = 17

Advection Stepper Statistics:
Current time = 1
Expand All @@ -52,9 +52,9 @@ Accuracy limited steps = 64
Error test fails = 9
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 2.059355438929501e-06
Last step size = 0.004032057223863014
Current step size = 0.004032057223863014
Initial step size = 2.0593554389295e-06
Last step size = 0.00403205722386301
Current step size = 0.00403205722386301
RHS fn evals = 185

Diffusion Stepper Statistics:
Expand All @@ -66,14 +66,14 @@ Accuracy limited steps = 302
Error test fails = 55
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 2.059355438929501e-06
Last step size = 0.006555275857754277
Current step size = 0.006555275857754277
Initial step size = 2.0593554389295e-06
Last step size = 0.00655527585775428
Current step size = 0.00655527585775428
Explicit RHS fn evals = 0
Implicit RHS fn evals = 1831
NLS iters = 906
NLS fails = 0
NLS iters per step = 3.668016194331984
NLS iters per step = 3.66801619433198
LS setups = 213
Jac fn evals = 72
LS RHS fn evals = 0
Expand All @@ -84,7 +84,7 @@ LS fails = 0
Jac-times setups = 0
Jac-times evals = 0
LS iters per NLS iter = 0
Jac evals per NLS iter = 0.07947019867549669
Jac evals per NLS iter = 0.0794701986754967
Prec evals per NLS iter = 0

Reaction Stepper Statistics:
Expand All @@ -97,6 +97,6 @@ Error test fails = 7
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 0.00180442856879795
Last step size = 0.03999999999999956
Current step size = 0.03999999999999956
Last step size = 0.0399999999999996
Current step size = 0.0399999999999996
RHS fn evals = 166
9 changes: 5 additions & 4 deletions examples/arkode/C_serial/ark_analytic_lsrk.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@ Analytical ODE test problem:
---------------------

Final Statistics:
Current time = 10.00468816776983
Current time = 10.0046881677698
Steps = 1454
Step attempts = 1457
Stability limited steps = 30
Accuracy limited steps = 1457
Error test fails = 3
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 1.930101110942615e-10
Initial step size = 1.93010111094261e-10
Last step size = 0.019104
Current step size = 0.02996850857415225
Current step size = 0.0299685085741523
RHS fn evals = 160396
RHS fn evals = 160396
Number of dom_eig updates = 1
Max. num. of stages used = 196
Max. num. of stages allowed = 200
Max. spectral radius = 1010000
Min. spectral radius = 1010000

ACCURACY at the final time = 9.76996e-14
ACCURACY at the final time = 9.76996e-14
12 changes: 7 additions & 5 deletions examples/arkode/C_serial/ark_analytic_lsrk_varjac.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Analytical ODE test problem with a variable Jacobian:
The stiffness of the problem is directly proportional to
"lambda - alpha*cos((10 - t)/10*pi)"
Expand Down Expand Up @@ -30,14 +31,15 @@ Accuracy limited steps = 1653
Error test fails = 2
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 1.930101110942615e-10
Last step size = 0.02203090645841201
Current step size = 0.02203090645841201
Initial step size = 1.93010111094261e-10
Last step size = 0.022030906458412
Current step size = 0.022030906458412
RHS fn evals = 150640
RHS fn evals = 150640
Number of dom_eig updates = 68
Max. num. of stages used = 187
Max. num. of stages allowed = 200
Max. spectral radius = 1010099.739553962
Max. spectral radius = 1010099.73955396
Min. spectral radius = 1009899

ACCURACY at the final time = 1.54099e-13
ACCURACY at the final time = 1.54099e-13
8 changes: 4 additions & 4 deletions examples/arkode/C_serial/ark_analytic_nonlin.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ Analytical ODE test problem:
---------------------

Final Statistics:
Current time = 10.12157090914652
Current time = 10.1215709091465
Steps = 82
Step attempts = 83
Stability limited steps = 0
Accuracy limited steps = 83
Error test fails = 1
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 6.103515625000001e-12
Last step size = 0.4463519264234082
Current step size = 0.4463519264234082
Initial step size = 6.103515625e-12
Last step size = 0.446351926423408
Current step size = 0.446351926423408
RHS fn evals = 417
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Analytical ODE test problem:
Error: 0.00185186

Splitting Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 100
Step attempts = 100
Stability limited steps = 0
Expand All @@ -17,11 +17,11 @@ Inequality constraint fails = 0
Initial step size = 0.01
Last step size = 0.01
Current step size = 0.01
Partition 0 evolves = 100
Partition 1 evolves = 100
Partition 2 evolves = 100

Linear Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 500
Step attempts = 500
Stability limited steps = 0
Expand All @@ -35,7 +35,7 @@ Current step size = 0.002
RHS fn evals = 2500

Nonlinear Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 1000
Step attempts = 1000
Stability limited steps = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Analytical ODE test problem:
Error: 0.001796

Splitting Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 100
Step attempts = 100
Stability limited steps = 0
Expand All @@ -17,11 +17,11 @@ Inequality constraint fails = 0
Initial step size = 0.01
Last step size = 0.01
Current step size = 0.01
Partition 0 evolves = 100
Partition 1 evolves = 100
Partition 2 evolves = 100

Linear Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 500
Step attempts = 500
Stability limited steps = 0
Expand All @@ -35,7 +35,7 @@ Current step size = 0.002
RHS fn evals = 2500

Nonlinear Stepper Statistics:
Current time = 1.000000000000001
Current time = 1
Steps = 1000
Step attempts = 1000
Stability limited steps = 0
Expand Down
Loading
Loading