Skip to content

Commit 76c2e55

Browse files
committed
Revert full numerical checks for some lfric targets
1 parent bc37ac4 commit 76c2e55

7 files changed

Lines changed: 109 additions & 23 deletions

File tree

.github/workflows/lfric_test.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ on:
4242
push
4343

4444
env:
45-
LFRIC_APPS_HASH: bea4e73b4fafebb6406aa91cc3aceb39b050f68c
45+
LFRIC_APPS_HASH: 7c8582ccbbffedf315da5784cb27c1b38ceec29e
4646
PYTHON_VERSION: "3.14"
4747
GNU_TOOLCHAIN: gnu14_openmpi
4848
NVHPC_TOOLCHAIN: nvhpc26_3_openmpi
@@ -127,7 +127,7 @@ jobs:
127127
export OMP_NUM_THREADS=1
128128
export START_TIME=$SECONDS
129129
mpirun -n 12 ../bin/gungho_model configuration.nml
130-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-12r-1t.txt gungho_model-checksums.txt || true
130+
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-12r-1t.txt gungho_model-checksums.txt
131131
export VAR_TIME=$((${SECONDS}-${START_TIME}))
132132
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
133133
@@ -150,7 +150,7 @@ jobs:
150150
# Clean previous version and compile again
151151
rm -rf working-gh-ompoffload
152152
export BUILD_START="${SECONDS}"
153-
LFRIC_OFFLOAD_DIRECTIVES=omp ./build/local_build.py -j ${NUM_PARALLEL} -p psyclone-test \
153+
LFRIC_OFFLOAD_DIRECTIVES=omp_uniform ./build/local_build.py -j ${NUM_PARALLEL} -p psyclone-test \
154154
-w working-gh-ompoffload gungho_model |& tee output.txt
155155
# Piping to tee ignores the errcode of the first command, make sure we account for it
156156
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
@@ -164,7 +164,8 @@ jobs:
164164
export CUDA_VISIBLE_DEVICES=1
165165
export START_TIME=$SECONDS
166166
mpirun -n 1 ../bin/gungho_model configuration.nml
167-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-nvhpc-1r-12t.txt gungho_model-checksums.txt || true
167+
# TODO #3207: Results not fully_reproducible with CPU
168+
python ${PSYCLONE_LFRIC_DIR}/compare_output.py ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-nvhpc-1r-12t.txt gungho_model-checksums.txt
168169
export VAR_TIME=$((${SECONDS}-${START_TIME}))
169170
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
170171
echo "build_time=${BUILD_ELAPSED}" >> "${GITHUB_OUTPUT}"
@@ -187,15 +188,16 @@ jobs:
187188
cp ${PSYCLONE_LFRIC_DIR}/gpu_offloading.py ${OPT_DIR}/global.py
188189
# Clean previous version and compile again
189190
rm -rf working-gh-accoffload
190-
LFRIC_OFFLOAD_DIRECTIVES=acc ./build/local_build.py -j ${NUM_PARALLEL} -p psyclone-test \
191+
LFRIC_OFFLOAD_DIRECTIVES=acc_uniform ./build/local_build.py -j ${NUM_PARALLEL} -p psyclone-test \
191192
-w working-gh-accoffload gungho_model
192193
cd applications/gungho_model/example
193194
rm -f timer.txt gungho_model-checksums.txt # In case there were from a previous run
194195
export OMP_NUM_THREADS=12
195196
export CUDA_VISIBLE_DEVICES=1
196197
export START_TIME=$SECONDS
197198
mpirun -n 1 ../bin/gungho_model configuration.nml
198-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-nvhpc-1r-12t.txt gungho_model-checksums.txt || true
199+
# TODO #3207: Results not fully_reproducible with CPU
200+
python ${PSYCLONE_LFRIC_DIR}/compare_output.py ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-nvhpc-1r-12t.txt gungho_model-checksums.txt
199201
export VAR_TIME=$((${SECONDS}-${START_TIME}))
200202
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
201203
@@ -224,7 +226,7 @@ jobs:
224226
export OMP_NUM_THREADS=4
225227
export START_TIME=$SECONDS
226228
mpirun -n 6 ../bin/gungho_model configuration.nml
227-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-6r-4t.txt gungho_model-checksums.txt || true
229+
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-6r-4t.txt gungho_model-checksums.txt
228230
export VAR_TIME=$((${SECONDS}-${START_TIME}))
229231
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
230232
@@ -253,7 +255,8 @@ jobs:
253255
export OMP_NUM_THREADS=4
254256
export START_TIME=$SECONDS
255257
mpirun -n 6 ../bin/gungho_model configuration.nml
256-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-6r-4t.txt gungho_model-checksums.txt || true
258+
# TODO #3207: Results not fully_reproducible (one digit divergence)
259+
python ${PSYCLONE_LFRIC_DIR}/compare_output.py ${PSYCLONE_LFRIC_DIR}/KGOs/gungho_model-checksums-gnu-6r-4t.txt gungho_model-checksums.txt
257260
export VAR_TIME=$((${SECONDS}-${START_TIME}))
258261
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
259262
@@ -281,7 +284,7 @@ jobs:
281284
OMP_NUM_THREADS=8 mpirun -n 1 ../bin/lfric_atm configuration.nml
282285
283286
# And compare the results
284-
diff ${PSYCLONE_LFRIC_DIR}/KGOs/lfric_atm-checksums-gnu-1r-8t.txt lfric_atm-checksums.txt || true
287+
diff ${PSYCLONE_LFRIC_DIR}/KGOs/lfric_atm-checksums-gnu-1r-8t.txt lfric_atm-checksums.txt
285288
export VAR_TIME=$((${SECONDS}-${START_TIME}))
286289
echo "time=${VAR_TIME}" >> "${GITHUB_OUTPUT}"
287290
echo "build_time=${BUILD_ELAPSED}" >> "${GITHUB_OUTPUT}"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Inner product checksum rho = 40D0CC8DC064B3E1
2-
Inner product checksum theta = 41FCE985F2DD2756
3-
Inner product checksum u = 450134BD797FD66E
1+
Inner product checksum rho = 40D0CC8DC064EC64
2+
Inner product checksum theta = 41FCE985F2DCC442
3+
Inner product checksum u = 450134BD7975D4C1
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Inner product checksum rho = 40D0CC8DC0650BE9
2-
Inner product checksum theta = 41FCE985F2DD42FF
3-
Inner product checksum u = 450134BD79897C7B
1+
Inner product checksum rho = 40D0CC8DC0646402
2+
Inner product checksum theta = 41FCE985F2DD5BB9
3+
Inner product checksum u = 450134BD79977C0C

examples/lfric/scripts/KGOs/lfric_psyclone.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ precision_map = i_def: 4,
9494
r_um: 8
9595

9696
# Specify whether we generate code to perform runtime correctness checks
97-
RUN_TIME_CHECKS = false
97+
RUN_TIME_CHECKS = none
9898

9999
# Number of ANY_SPACE and ANY_DISCONTINUOUS_SPACE function spaces
100-
NUM_ANY_SPACE = 10
100+
NUM_ANY_SPACE = 20
101101
NUM_ANY_DISCONTINUOUS_SPACE = 20

examples/lfric/scripts/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636

3737
include ../../common.mk
3838

39-
# Get all psyclone scripts in this folder, which are all python files
40-
SCRIPTS = $(wildcard *.py)
39+
# Get all psyclone scripts in this folder, which are all python files excluding
40+
# the compare_output.py script
41+
SCRIPTS = $(filter-out compare_output.py, $(wildcard *.py))
4142

4243
# The kernel-extraction script generates driver source files.
4344
GENERATED_FILES += driver-*.F90
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# -----------------------------------------------------------------------------
2+
# BSD 3-Clause License
3+
#
4+
# Copyright (c) 2023-2026, Science and Technology Facilities Council
5+
# All rights reserved.
6+
#
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions are met:
9+
#
10+
# * Redistributions of source code must retain the above copyright notice, this
11+
# list of conditions and the following disclaimer.
12+
#
13+
# * Redistributions in binary form must reproduce the above copyright notice,
14+
# this list of conditions and the following disclaimer in the documentation
15+
# and/or other materials provided with the distribution.
16+
#
17+
# * Neither the name of the copyright holder nor the names of its
18+
# contributors may be used to endorse or promote products derived from
19+
# this software without specific prior written permission.
20+
#
21+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
# POSSIBILITY OF SUCH DAMAGE.
33+
# -----------------------------------------------------------------------------
34+
# Author: S. Siso, STFC Daresbury Lab
35+
# -----------------------------------------------------------------------------
36+
37+
''' Script to compare LFRic output files. '''
38+
39+
import sys
40+
import os
41+
42+
TOLERANCE_DIGITS = 8
43+
44+
45+
def main():
46+
''' Compare the two provided LFRic output files, it checks that the
47+
checksum values are equivalent (within a tolerance). '''
48+
49+
# Parse input arguments
50+
if len(sys.argv) - 1 != 2:
51+
sys.exit(f"This script expects exactly 2 arguments with the two files "
52+
f"to compare, but got: {sys.argv}")
53+
filename1 = sys.argv[1]
54+
filename2 = sys.argv[2]
55+
if not os.path.isfile(filename1):
56+
sys.exit(f"The first argument '{filename1}' must point to a file.")
57+
if not os.path.isfile(filename2):
58+
sys.exit(f"The second argument '{filename2}' must point to a file.")
59+
60+
# Compare filename1 with filename2
61+
with open(filename1, 'r', encoding="utf-8") as file1, \
62+
open(filename2, 'r', encoding="utf-8") as file2:
63+
line_f1 = file1.readline()
64+
line_f2 = file2.readline()
65+
while line_f1 and line_f2:
66+
value1 = line_f1.split('=')[-1][:TOLERANCE_DIGITS]
67+
value2 = line_f2.split('=')[-1][:TOLERANCE_DIGITS]
68+
if value1 != value2:
69+
sys.exit(f"The values are not equal:\n{line_f1}{line_f2}")
70+
71+
# Get next lines
72+
line_f1 = file1.readline()
73+
line_f2 = file2.readline()
74+
75+
if file1.readline() or file2.readline():
76+
sys.exit("The files have a different number of lines")
77+
78+
sys.exit(0) # Successful comparison
79+
80+
81+
if __name__ == "__main__":
82+
main()

examples/lfric/scripts/gpu_offloading.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def trans(psyir):
113113
mod_inline_trans = KernelModuleInlineTrans()
114114
inline_trans = InlineTrans()
115115

116-
if OFFLOAD_DIRECTIVES == "omp":
116+
if OFFLOAD_DIRECTIVES.startswith("omp"):
117117
# Use OpenMP offloading
118118
loop_offloading_trans = OMPLoopTrans(
119119
omp_directive="teamsdistributeparalleldo",
@@ -124,16 +124,16 @@ def trans(psyir):
124124
kernels_trans = None
125125
gpu_region_trans = OMPTargetTrans()
126126
gpu_annotation_trans = OMPDeclareTargetTrans()
127-
elif OFFLOAD_DIRECTIVES == "acc":
127+
elif OFFLOAD_DIRECTIVES.startswith("acc"):
128128
# Use OpenACC offloading
129129
loop_offloading_trans = ACCLoopTrans()
130130
kernels_trans = ACCKernelsTrans()
131131
gpu_region_trans = ACCParallelTrans(default_present=False)
132132
gpu_annotation_trans = ACCRoutineTrans()
133133
else:
134134
print(f"The PSyclone transformation script expects the "
135-
f"LFRIC_OFFLOAD_DIRECTIVES to be set to 'omp' or 'acc' "
136-
f"but found '{OFFLOAD_DIRECTIVES}'.")
135+
f"LFRIC_OFFLOAD_DIRECTIVES to be set to 'omp', 'omp_uniform', "
136+
f"'acc' or 'acc_uniform' but found '{OFFLOAD_DIRECTIVES}'.")
137137
sys.exit(-1)
138138

139139
print(f"PSy name = '{psyir.name}'")

0 commit comments

Comments
 (0)