Skip to content

Commit 648c230

Browse files
committed
CI: Test extended precision (#740)
Re-enable tests with extended precision
1 parent fab78f3 commit 648c230

File tree

6 files changed

+76
-47
lines changed

6 files changed

+76
-47
lines changed

.github/workflows/build-llvm-container.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
jobs:
77
build_llvm_container:
88
runs-on: ubuntu-22.04
9-
steps:
9+
steps:
1010
- name: Check out repository code
1111
uses: actions/checkout@v4
12-
12+
1313
- name: Free up disk space
1414
uses: ./.github/actions/free-space-ubuntu
1515

@@ -27,11 +27,11 @@ jobs:
2727
run: |
2828
spack mirror add v0.21.0 https://binaries.spack.io/v0.21.0
2929
spack mirror add --oci-username ${{ github.actor }} --oci-password ${{ secrets.OCI_TOKEN }} sundials_spack_cache oci://ghcr.io/LLNL/sundials_spack_cache
30-
spack buildcache keys --install --trust
30+
spack buildcache keys --install --trust
3131
3232
- name: Install llvm@17.0.4
3333
run: spack install --no-check-signature llvm@17.0.4
34-
34+
3535
- name: Push to buildcache
3636
if: ${{ !cancelled() }}
3737
run: |

.github/workflows/ubuntu-latest.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@ jobs:
2525
max-parallel: 2
2626
matrix:
2727
indexsize: [32, 64]
28-
# Disable extended tests until compiler warnings are addressed
29-
precision: ['single', 'double']
28+
precision: ['single', 'double', 'extended']
3029
buildtype: ['Debug', 'Release', 'RelWithDebInfo']
3130
tpls: ['ON']
3231
exclude:
3332
- buildtype: Debug
3433
precision: single
35-
# - buildtype: Debug
36-
# precision: extended
34+
- buildtype: Debug
35+
precision: extended
3736
- buildtype: Release
3837
precision: single
39-
# - buildtype: Release
40-
# precision: extended
38+
- buildtype: Release
39+
precision: extended
4140
- buildtype: RelWithDebInfo
4241
precision: double
4342

scripts/updateOutFiles.py

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,32 @@
1919
# -----------------------------------------------------------------------------
2020

2121

22+
class colors:
23+
SUCCESS = "\033[92m"
24+
WARNING = "\033[93m"
25+
ERROR = "\033[91m"
26+
END = "\033[0m"
27+
28+
29+
def print_success(msg):
30+
print(f"{colors.SUCCESS}{msg}{colors.END}")
31+
32+
33+
def print_warning(msg):
34+
print(f"{colors.WARNING}{msg}{colors.END}")
35+
36+
37+
def print_error(msg):
38+
print(f"{colors.ERROR}{msg}{colors.END}")
39+
40+
2241
# -----------------------------------------------------------------------------
2342
# main routine
2443
# -----------------------------------------------------------------------------
2544
def main():
2645

2746
import argparse
28-
import sys, os, shutil
47+
import os, shutil
2948

3049
parser = argparse.ArgumentParser(description="Update output files")
3150

@@ -44,68 +63,80 @@ def main():
4463

4564
# check inputs
4665
if not os.path.isdir(args.source):
47-
print(f"Error: could not find {args.source}")
66+
print_error(f"Error: could not find {args.source}")
4867
return -1
4968

5069
if not os.path.isdir(args.destination):
51-
print(f"Error: could not find {args.destination}")
70+
print_error(f"Error: could not find {args.destination}")
5271
return -1
5372

5473
# check that the output directory exists
5574
output = os.path.join(args.source, "Testing", "output")
5675
if not os.path.isdir(output):
57-
print(f"Error: could not find {output}")
76+
print_error(f"Error: could not find {output}")
5877
return -1
5978

60-
# create a list of all test run or just the failed tests
61-
tests = []
79+
# create a list of output files for all tests run or just the failed tests
80+
output_files = []
6281

6382
if args.all:
6483
# get names of all .out files
6584
for f in os.listdir(output):
6685
if f.endswith(".out"):
67-
tests.append(f)
86+
output_files.append(f)
6887
else:
6988
failed = os.path.join(args.source, "Testing", "Temporary", "LastTestsFailed.log")
7089

7190
# extract test names from list and append .out
7291
with open(failed, "r") as f:
7392
for line in f:
74-
tests.append(line.split(":")[1].rstrip() + ".out")
93+
output_files.append(line.split(":")[1].rstrip() + ".out")
7594

7695
# if failed tests were found update the output files
77-
if tests:
96+
if output_files:
97+
num_output_files = len(output_files)
7898
paths = [
7999
os.path.join(args.destination, "examples"),
80100
os.path.join(args.destination, "test", "unit_tests"),
81101
args.destination,
82102
]
83-
for t in tests:
103+
for idx, out_file in enumerate(output_files):
84104
if args.verbose > 0:
85-
print(f"Searching for {t}")
105+
print(f"[{idx + 1} of {num_output_files}] Test {out_file[:-4]}")
106+
# Some tests do not have an output file (e.g., unit tests)
107+
if not os.path.isfile(os.path.join(output, out_file)):
108+
print_warning(f" Warning: did not find the output file {out_file}")
109+
continue
110+
if args.verbose > 1:
111+
print(f" Searching for answer file {out_file}")
86112
found = False
87113
for p in paths:
114+
if not os.path.isdir(p):
115+
continue
88116
if args.verbose == 2:
89117
print(f" Looking in {p}")
90-
for root, dirs, files in os.walk(p):
118+
for root, _, files in os.walk(p):
91119
if args.verbose == 3:
92120
print(f" Looking in {root}")
93-
if t in files:
121+
if out_file in files:
94122
if args.verbose == 1:
95123
print(f" Found file in {root}")
96124
if args.verbose > 1:
97125
print(" Found file")
98-
shutil.copy(os.path.join(output, t), os.path.join(root, t))
126+
shutil.copy(os.path.join(output, out_file), os.path.join(root, out_file))
99127
found = True
128+
if args.verbose > 0:
129+
print_success(f" Answer file updated")
100130
break
101131
if found:
102132
break
103133
if not found:
134+
print_warning(f" Warning: did not find the answer file {out_file}")
104135
if args.copy:
105-
print(f"Warning: did not find {t}, copying to {args.destination}")
106-
shutil.copy(os.path.join(output, t), os.path.join(args.destination, t))
107-
else:
108-
print(f"Warning: did not find {t}")
136+
print(f" Copying {out_file} to {args.destination}")
137+
shutil.copy(
138+
os.path.join(output, out_file), os.path.join(args.destination, out_file)
139+
)
109140

110141

111142
# -----------------------------------------------------------------------------

test/answers

Submodule answers updated 291 files

test/test_driver.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,20 +405,13 @@ case "$testtype" in
405405
tarball=sundials
406406

407407
# Test configs
408-
for rt in single double extended; do
409-
for is in 32 64; do
410-
args_realtypes+=("${rt}")
411-
args_indexsizes+=("${is}")
412-
args_libtypes+=("static")
413-
args_tpls+=("ON")
414-
# Development test output files created with double
415-
if [[ "${rt}" == "double" ]]; then
416-
args_suntests+=("DEV")
417-
else
418-
args_suntests+=("STD")
419-
fi
420-
args_phase+=("")
421-
done
408+
for is in 32 64; do
409+
args_realtypes+=("double")
410+
args_indexsizes+=("${is}")
411+
args_libtypes+=("static")
412+
args_tpls+=("ON")
413+
args_suntests+=("DEV")
414+
args_phase+=("")
422415
done
423416
;;
424417

test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ int main(int argc, char* argv[])
116116
printf("ERROR: Both the initial and final time are required\n");
117117
return (1);
118118
}
119-
T0 = (sunrealtype)atof(argv[3]);
120-
Tf = (sunrealtype)atof(argv[4]);
119+
T0 = SUNStrToReal(argv[3]);
120+
Tf = SUNStrToReal(argv[4]);
121121
if (SUNRabs(T0) >= SUNRabs(Tf))
122122
{
123123
printf("ERROR: |T0| must be less than |Tf|\n");
@@ -132,8 +132,8 @@ int main(int argc, char* argv[])
132132
printf("ERROR: Both tshift and tscale are required\n");
133133
return (1);
134134
}
135-
tshift = (sunrealtype)atof(argv[5]);
136-
tscale = (sunrealtype)atof(argv[6]);
135+
tshift = SUNStrToReal(argv[5]);
136+
tscale = SUNStrToReal(argv[6]);
137137
if (SUNRabs(tscale) < TINY)
138138
{
139139
printf("ERROR: |tscale| must be greater than %" GSYM "\n", TINY);
@@ -397,6 +397,12 @@ int main(int argc, char* argv[])
397397
printf("IMEX solution:\n");
398398
N_VPrint_Serial(y);
399399

400+
#if defined(SUNDIALS_EXTENDED_PRECISION)
401+
/* The 5th order case with extended precision tends to slightly under solve
402+
so we loosen the comparison tolerance by 5% */
403+
if (order == 5) { reltol *= SUN_RCONST(1.05); };
404+
#endif
405+
400406
/* check the solution error */
401407
flag = compute_error(y, ans, tmp, reltol, abstol);
402408
if (flag != 0) { return (1); }

0 commit comments

Comments
 (0)