Skip to content

Commit 7d6d0cd

Browse files
authored
Merge pull request #1759 from danielpeter/devel
updates GPU source kernels; adds GPU kernel testing in github actions
2 parents 056d6a8 + 848ee8d commit 7d6d0cd

File tree

58 files changed

+6425
-715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6425
-715
lines changed

.github/scripts/run_build.sh

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,52 @@ else
4040
adios=()
4141
fi
4242

43+
## HDF5
44+
if [ "${HDF5}" == "true" ]; then
45+
echo
46+
echo "enabling HDF5"
47+
echo
48+
hdf=(--with-hdf5 HDF5_INC="/usr/include/hdf5/openmpi/" HDF5_LIBS="-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi")
49+
else
50+
hdf=()
51+
fi
52+
53+
## HIP
54+
if [ "${HIP}" == "true" ]; then
55+
echo
56+
echo "enabling HIP"
57+
echo
58+
hip=(--with-hip HIPCC=g++ HIP_FLAGS="-O2 -g -std=c++17" HIP_PLATFORM=cpu HIP_INC=./external_libs/ROCm-HIP-CPU/include HIP_LIBS="-ltbb -lpthread -lstdc++")
59+
else
60+
hip=()
61+
fi
62+
63+
## special testflags
64+
if [ "${TESTFLAGS}" == "check-mcmodel-medium" ]; then
65+
# note: this is a work-around as using the 'env:' parameter in the workflow 'CI.yml' with TESTFLAGS: FLAGS_CHECK=".."
66+
# won't work as the FLAGS_CHECK string will then get split up and ./configure .. complains about unknown parameters.
67+
# here, we re-define TESTFLAGS with a single quote around FLAGS_CHECK=".." to avoid the splitting.
68+
# use FLAGS_CHECK
69+
flags=(FLAGS_CHECK="-O3 -mcmodel=medium -std=f2008 -Wall -Wno-do-subscript -Wno-conversion -Wno-maybe-uninitialized")
70+
TESTFLAGS="" # reset
71+
else
72+
flags=()
73+
fi
74+
4375
# configuration
4476
echo
4577
echo "configuration:"
4678
echo
4779

80+
# split TESTFLAGS into individual items
81+
set -- ${TESTFLAGS}
82+
4883
./configure \
49-
${adios[@]} \
50-
FC=gfortran MPIFC=mpif90 CC=gcc ${TESTFLAGS}
84+
"${adios[@]}" \
85+
"${hdf[@]}" \
86+
"${hip[@]}" \
87+
"${flags[@]}" \
88+
FC=gfortran MPIFC=mpif90 CC=gcc "$@"
5189

5290
# checks
5391
if [[ $? -ne 0 ]]; then echo "configuration failed:"; cat config.log; echo ""; echo "exiting..."; exit 1; fi
@@ -62,8 +100,14 @@ sed -i "s:IMAIN .*:IMAIN = ISTANDARD_OUTPUT:" setup/constants.h
62100

63101
# compilation
64102
echo
65-
echo "compilation:"
66-
make clean; make -j2 all
103+
echo "clean"
104+
echo
105+
make clean
106+
107+
echo
108+
echo "compilation"
109+
echo
110+
make -j4 all
67111

68112
# checks
69113
if [[ $? -ne 0 ]]; then exit 1; fi

.github/scripts/run_install.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ if [[ $? -ne 0 ]]; then exit 1; fi
1515
# fortran/openMPI compiler
1616
sudo apt-get install -yq --no-install-recommends gfortran g++ openmpi-bin libopenmpi-dev
1717

18-
# parallel hdf5
19-
if [[ "${TEST}" == *"with-hdf5"* ]]; then
18+
## parallel HDF5
19+
if [ "${HDF5}" == "true" ]; then
2020
echo
21-
echo "additional installation: ${TEST}"
21+
echo "HDF5 additional installation:"
2222
echo
2323
sudo apt-get install -yq --no-install-recommends libhdf5-mpi-dev
2424
## checks installation paths
@@ -34,6 +34,14 @@ if [[ "${TEST}" == *"with-hdf5"* ]]; then
3434
#echo
3535
fi
3636

37+
## HIP
38+
if [ "${HIP}" == "true" ]; then
39+
echo
40+
echo "HIP additionals installation:"
41+
echo
42+
sudo apt-get install -yq --no-install-recommends libtbb-dev
43+
fi
44+
3745
# checks exit code
3846
if [[ $? -ne 0 ]]; then exit 1; fi
3947
echo

.github/scripts/run_tests.sh

Lines changed: 121 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,67 @@ echo
2222

2323
# bash function for checking seismogram output with reference solutions
2424
my_test(){
25-
echo "testing seismograms:"
25+
echo "######################################################################################################################"
26+
echo "testing seismograms"
2627
ln -s $WORKDIR/utils/scripts/compare_seismogram_correlations.py
2728
./compare_seismogram_correlations.py REF_SEIS/ OUTPUT_FILES/
2829
if [[ $? -ne 0 ]]; then exit 1; fi
2930
./compare_seismogram_correlations.py REF_SEIS/ OUTPUT_FILES/ | grep min/max | cut -d \| -f 3 | awk '{print "correlation:",$1; if ($1 < 0.999 ){print $1,"failed"; exit 1;}else{ print $1,"good"; exit 0;}}'
3031
if [[ $? -ne 0 ]]; then exit 1; fi
32+
echo "######################################################################################################################"
33+
}
34+
35+
my_kernel_test(){
36+
# kernel value test - checks rho/kappa/mu kernel value outputs
37+
echo "######################################################################################################################"
38+
echo "testing kernel values"
39+
file_ref=REF_KERNEL/output_solver.txt
40+
file_out=output.log # captures the OUTPUT_FILES/output_solver.txt when running solver since IMAIN was set to standard out
41+
if [ ! -e $file_ref ]; then echo "Please check if file $file_ref exists..."; ls -alR ./; exit 1; fi
42+
if [ ! -e $file_out ]; then echo "Please check if file $file_out exists..."; ls -alR ./; exit 1; fi
43+
# gets reference expected kernel values from REF_KERNEL/ folder
44+
RHO=`grep -E 'maximum value of rho[[:space:]]+kernel' $file_ref | cut -d = -f 2 | tr -d ' '`
45+
KAPPA=`grep -E 'maximum value of kappa[[:space:]]+kernel' $file_ref | cut -d = -f 2 | tr -d ' '`
46+
MU=`grep -E 'maximum value of mu[[:space:]]+kernel' $file_ref | cut -d = -f 2 | tr -d ' '`
47+
# need at least rho & kappa (for acoustic kernels)
48+
if [ "$RHO" == "" ] || [ "$KAPPA" == "" ]; then
49+
echo " missing reference kernel values: RHO=$RHO KAPPA=$KAPPA MU=$MU"
50+
echo
51+
exit 1
52+
else
53+
echo " reference kernel values: RHO=$RHO KAPPA=$KAPPA MU=$MU"
54+
fi
55+
# compares with test output - using a relative tolerance of 0.001 (1 promille) with respect to expected value
56+
# final test result
57+
PASSED=0
58+
# checks rho kernel value
59+
if [ "$RHO" != "" ]; then
60+
VAL=`grep -E 'maximum value of rho[[:space:]]+kernel' $file_out | cut -d = -f 2 | tr -d ' '`
61+
echo "kernel rho : $VAL"
62+
echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.001){print " failed"; exit 1;}else{print " good"; exit 0;} }' ex=$RHO val=$VAL
63+
if [[ $? -ne 0 ]]; then PASSED=1; fi
64+
fi
65+
# checks kappa kernel value
66+
if [ "$KAPPA" != "" ]; then
67+
VAL=`grep -E 'maximum value of kappa[[:space:]]+kernel' $file_out | cut -d = -f 2 | tr -d ' '`
68+
echo "kernel kappa : $VAL"
69+
echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.001){print " failed"; exit 1;}else{print " good"; exit 0;} }' ex=$KAPPA val=$VAL
70+
if [[ $? -ne 0 ]]; then PASSED=1; fi
71+
fi
72+
# checks mu kernel value (if available for elastic kernel)
73+
if [ "$MU" != "" ]; then
74+
VAL=`grep -E 'maximum value of mu[[:space:]]+kernel' $file_out | cut -d = -f 2 | tr -d ' '`
75+
echo "kernel mu : $VAL"
76+
echo "" | awk '{diff=ex-val;diff_abs=(diff >= 0)? diff:-diff;diff_rel=diff_abs/ex;print " value: expected = "ex" gotten = "val" - difference absolute = "diff_abs" relative = "diff_rel; if (diff_rel>0.001){print " failed"; exit 1;}else{print " good"; exit 0;} }' ex=$MU val=$VAL
77+
if [[ $? -ne 0 ]]; then PASSED=1; fi
78+
fi
79+
# overall pass
80+
if [[ $PASSED -ne 0 ]]; then
81+
echo "testing kernel values: failed"; exit 1;
82+
else
83+
echo "testing kernel values: all good"
84+
fi
85+
echo "######################################################################################################################"
3186
}
3287

3388
# test example
@@ -37,7 +92,7 @@ cd $dir
3792
# limit time steps for testing
3893
sed -i "s:^NSTEP .*:NSTEP = 200:" DATA/Par_file
3994
# shortens output interval to avoid timeouts
40-
sed -i "s:^NTSTEP_BETWEEN_OUTPUT_INFO .*:NTSTEP_BETWEEN_OUTPUT_INFO = 50:" DATA/Par_file
95+
sed -i "s:^NTSTEP_BETWEEN_OUTPUT_INFO .*:NTSTEP_BETWEEN_OUTPUT_INFO = 100:" DATA/Par_file
4196

4297
# limit time steps for specific examples
4398
# simple mesh example
@@ -105,27 +160,45 @@ if [ "$TESTDIR" == "EXAMPLES/applications/meshfem3D_examples/sep_bathymetry/" ];
105160
sed -i "s:^NSTEP .*:NSTEP = 1000:" DATA/Par_file
106161
fi
107162

108-
# hdf5 i/o example
109-
if [[ "${TEST}" == *"with-hdf5"* ]]; then
163+
## HDF5 - i/o example
164+
if [ "${HDF5}" == "true" ]; then
110165
echo
111-
echo "test run: ${TEST}"
166+
echo "test run w/ HDF5"
112167
echo
168+
# turns on HDF5
169+
echo "turning on HDF5"
113170
sed -i "s:^HDF5_ENABLED .*:HDF5_ENABLED = .true.:" DATA/Par_file
114171
sed -i "s:^HDF5_FOR_MOVIES .*:HDF5_FOR_MOVIES = .true.:" DATA/Par_file
115172
sed -i "s:^HDF5_IO_NODES .*:HDF5_IO_NODES = 1:" DATA/Par_file
116173
# replaces run script
117174
cp -v run_this_example_HDF5_IO_server.sh run_this_example.sh
118175
fi
119176

120-
# adios
177+
## adios
121178
if [ "${ADIOS2}" == "true" ]; then
122179
# turns on ADIOS
180+
echo "turning on ADIOS"
123181
sed -i "s:^ADIOS_ENABLED .*:ADIOS_ENABLED = .true.:" DATA/Par_file
124182
fi
125183

126-
# default script
127-
./run_this_example.sh
184+
## GPU
185+
if [ "${GPU}" == "true" ]; then
186+
# turns on GPU
187+
echo "turning on GPU"
188+
sed -i "s:^GPU_MODE .*:GPU_MODE = .true.:" DATA/Par_file
189+
fi
190+
191+
# save Par_file state
192+
cp -v DATA/Par_file DATA/Par_file.bak
128193

194+
# use kernel script
195+
if [ "${RUN_KERNEL}" == "true" ]; then
196+
# use kernel script
197+
./run_this_example_kernel.sh | tee output.log
198+
else
199+
# default script
200+
./run_this_example.sh
201+
fi
129202
# checks exit code
130203
if [[ $? -ne 0 ]]; then exit 1; fi
131204

@@ -136,15 +209,52 @@ echo `date`
136209
echo
137210

138211
# seismogram comparison
139-
if [ "${DEBUG}" == "true" ]; then
212+
if [ "${DEBUG}" == "true" ] || [ "${RUN_KERNEL}" == "true" ]; then
140213
# no comparisons
141-
continue
214+
: # do nothing
142215
else
143216
my_test
144217
fi
218+
# checks exit code
219+
if [[ $? -ne 0 ]]; then exit 1; fi
220+
221+
# kernel test
222+
if [ "${RUN_KERNEL}" == "true" ]; then
223+
# check kernel values
224+
my_kernel_test
225+
# checks exit code
226+
if [[ $? -ne 0 ]]; then exit 1; fi
227+
# clean up
228+
rm -rf OUTPUT_FILES/ SEM/ output.log
229+
230+
# re-run kernel test w/ UNDO_ATT
231+
echo
232+
echo "*****************************************"
233+
echo "run kernel w/ UNDO_ATTENUATION_AND_OR_PML"
234+
echo "*****************************************"
235+
echo
236+
237+
# turns on UNDO_ATTENUATION_AND_OR_PML
238+
echo "turning on UNDO_ATTENUATION_AND_OR_PML"
239+
sed -i "s:^UNDO_ATTENUATION_AND_OR_PML .*:UNDO_ATTENUATION_AND_OR_PML = .true.:" DATA/Par_file
240+
241+
# use kernel script
242+
./run_this_example_kernel.sh | tee output.log
243+
# checks exit code
244+
if [[ $? -ne 0 ]]; then exit 1; fi
245+
# kernel test
246+
my_kernel_test
247+
# checks exit code
248+
if [[ $? -ne 0 ]]; then exit 1; fi
249+
fi
250+
251+
# restore original Par_file
252+
cp -v DATA/Par_file.bak DATA/Par_file
145253

146254
# cleanup
147-
rm -rf OUTPUT_FILES/ DATABASES_MPI/
255+
rm -rf OUTPUT_FILES/
256+
if [ -e DATABASES_MPI ]; then rm -rf DATABASES_MPI/; fi
257+
if [ -e SEM ]; then rm -rf SEM/; fi
148258

149259
echo
150260
echo "all good"

0 commit comments

Comments
 (0)