Skip to content

Commit 21e40fd

Browse files
authored
Merge pull request #1858 from danielpeter/devel
updates github actions
2 parents ece6276 + 1f81cc0 commit 21e40fd

File tree

15 files changed

+629
-65
lines changed

15 files changed

+629
-65
lines changed

.github/scripts/run_build.sh

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
if [ -f $HOME/.tmprc ]; then source $HOME/.tmprc; fi
88

99
WORKDIR=`pwd`
10+
TESTCOV=${TESTCOV:-}
1011

1112
# info
1213
echo "work directory: $WORKDIR"
1314
echo `date`
1415
echo
1516
echo "**********************************************************"
1617
echo
17-
echo "configuration test: TESTFLAGS=${TESTFLAGS} TESTNGLL=${TESTNGLL}"
18+
echo "configuration test: TESTFLAGS=${TESTFLAGS} TESTNGLL=${TESTNGLL} TESTCOV=${TESTCOV}"
19+
echo " CUDA=${CUDA} HIP=${HIP} ADIOS2=${ADIOS2} HDF5=${HDF5}"
1820
echo
1921
echo "**********************************************************"
2022
echo
@@ -50,12 +52,24 @@ else
5052
hdf=()
5153
fi
5254

55+
## CUDA
56+
if [ "${CUDA}" == "true" ]; then
57+
echo
58+
echo "enabling CUDA"
59+
echo
60+
cuda=(--with-cuda=cuda13 CUDA_LIB="${CUDA_HOME}/lib64" CUDA_INC="${CUDA_HOME}/include" \
61+
CUDA_FLAGS="-Xcompiler -Wall,-Wno-unused-function,-Wno-unused-const-variable,-Wfatal-errors -g -G")
62+
else
63+
cuda=()
64+
fi
65+
5366
## HIP
5467
if [ "${HIP}" == "true" ]; then
5568
echo
5669
echo "enabling HIP"
5770
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++")
71+
hip=(--with-hip HIPCC=g++ HIP_PLATFORM=cpu HIP_INC=./external_libs/ROCm-HIP-CPU/include HIP_LIBS="-ltbb -lpthread -lstdc++" \
72+
HIP_FLAGS="-O2 -g -std=c++17")
5973
else
6074
hip=()
6175
fi
@@ -80,12 +94,35 @@ echo
8094
# split TESTFLAGS into individual items
8195
set -- ${TESTFLAGS}
8296

83-
./configure \
84-
"${adios[@]}" \
85-
"${hdf[@]}" \
86-
"${hip[@]}" \
87-
"${flags[@]}" \
88-
FC=gfortran MPIFC=mpif90 CC=gcc "$@"
97+
###########################################################
98+
# configuration & compilation
99+
###########################################################
100+
# configuration
101+
102+
if [ "${TESTCOV}" == "true" ]; then
103+
echo "configuration: for coverage"
104+
./configure \
105+
"${adios[@]}" \
106+
"${hdf[@]}" \
107+
"${cuda[@]}" \
108+
"${hip[@]}" \
109+
"${flags[@]}" \
110+
FLAGS_CHECK="-fprofile-arcs -ftest-coverage -O0" CFLAGS="-coverage -O0" \
111+
FC=${FC} MPIFC=${MPIFC} CC=${CC} "$@"
112+
else
113+
if [ "${CUDA}" == "true" ]; then
114+
echo "configuration: for cuda"
115+
else
116+
echo "configuration: default"
117+
fi
118+
./configure \
119+
"${adios[@]}" \
120+
"${hdf[@]}" \
121+
"${cuda[@]}" \
122+
"${hip[@]}" \
123+
"${flags[@]}" \
124+
FC=${FC} MPIFC=${MPIFC} CC=${CC} "$@"
125+
fi
89126

90127
# checks
91128
if [[ $? -ne 0 ]]; then echo "configuration failed:"; cat config.log; echo ""; echo "exiting..."; exit 1; fi
@@ -98,6 +135,12 @@ fi
98135
# we output to console
99136
sed -i "s:IMAIN .*:IMAIN = ISTANDARD_OUTPUT:" setup/constants.h
100137

138+
# inversion example
139+
if [ "$TESTDIR" == "EXAMPLES/applications/inversion_examples/fwi_test_acoustic/" ]; then
140+
sed -i "s:IMAIN .*:IMAIN = 42:" setup/constants.h
141+
sed -i "s:INVERSE_LOG_FILE .*:INVERSE_LOG_FILE = 6:" src/inverse_problem_for_model/inverse_problem_par.f90
142+
fi
143+
101144
# compilation
102145
echo
103146
echo "clean"

.github/scripts/run_coverage.sh

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#!/bin/bash
2+
#
3+
# runs additional coverage examples
4+
#
5+
6+
set -euo pipefail
7+
8+
# getting updated environment (CUDA_HOME, PATH, ..)
9+
if [ -f $HOME/.tmprc ]; then source $HOME/.tmprc; fi
10+
11+
WORKDIR=$(pwd)
12+
TESTID=${TESTID:-}
13+
TESTCOV=${TESTCOV:-}
14+
15+
if [ "$TESTCOV" != "true" ]; then
16+
echo "TESTCOV=${TESTCOV} (not coverage), skipping run_coverage.sh"
17+
exit 0
18+
fi
19+
20+
run_simple() {
21+
local rel_dir="$1"
22+
local nstep="$2"
23+
local model="${3:-}"
24+
25+
echo "##################################################################"
26+
echo "${rel_dir}"
27+
echo
28+
29+
cd "${WORKDIR}/${rel_dir}"
30+
31+
# setup
32+
cp -v DATA/Par_file DATA/Par_file.org
33+
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file
34+
35+
# noise
36+
if [ "${rel_dir}" == "EXAMPLES/applications/noise_tomography/" ]; then
37+
sed -i '10,$ d' NOISE_TOMOGRAPHY/S_squared # truncates file, deletes all lines from line 10 till end
38+
fi
39+
# socal1D
40+
if [ "${rel_dir}" == "EXAMPLES/applications/meshfem3D_examples/socal1D/" ]; then
41+
if [ "$model" = "1d_socal" ]; then
42+
sed -i "s:^MODEL .*:MODEL = 1d_socal:" DATA/Par_file
43+
rm -f REF_SEIS
44+
ln -s REF_SEIS.1d_socal REF_SEIS
45+
elif [ "$model" = "1d_prem" ]; then
46+
sed -i "s:^MODEL .*:MODEL = 1d_prem:" DATA/Par_file
47+
rm -f REF_SEIS
48+
ln -s REF_SEIS.1d_prem REF_SEIS
49+
elif [ "$model" = "1d_cascadia" ]; then
50+
sed -i "s:^MODEL .*:MODEL = 1d_cascadia:" DATA/Par_file
51+
rm -f REF_SEIS
52+
ln -s REF_SEIS.1d_cascadia REF_SEIS
53+
fi
54+
fi
55+
56+
# run
57+
./run_this_example.sh
58+
if [[ $? -ne 0 ]]; then exit 1; fi
59+
mv -v DATA/Par_file.org DATA/Par_file
60+
cd "$WORKDIR"
61+
}
62+
63+
run_kernel() {
64+
local rel_dir="$1"
65+
local nstep="$2"
66+
67+
echo "##################################################################"
68+
echo "${rel_dir} (kernel coverage)"
69+
echo
70+
71+
cd "${WORKDIR}/${rel_dir}"
72+
73+
# setup
74+
cp -v DATA/Par_file DATA/Par_file.org
75+
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file
76+
77+
if [ "${rel_dir}" == "EXAMPLES/applications/homogeneous_acoustic/" ]; then
78+
sed -i "s:300:${nstep}:" run_this_example_kernel.sh
79+
sed -i "s:^t_start.*:t_start=-6.0:" create_adjoint_sources.sh
80+
sed -i "s:^t_end.*:t_end=-5.55:" create_adjoint_sources.sh
81+
fi
82+
83+
# run
84+
./run_this_example_kernel.sh
85+
if [[ $? -ne 0 ]]; then exit 1; fi
86+
mv -v DATA/Par_file.org DATA/Par_file
87+
cd "$WORKDIR"
88+
}
89+
90+
91+
run_serial() {
92+
local rel_dir="$1"
93+
local nstep="$2"
94+
95+
echo "##################################################################"
96+
echo "${rel_dir} (serial)"
97+
echo
98+
99+
cd "${WORKDIR}/${rel_dir}"
100+
101+
# setup
102+
cp -f DATA/Par_file DATA/Par_file.org
103+
sed -i "s:^NPROC .*:NPROC = 1:" DATA/Par_file
104+
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file
105+
106+
# meshfem setup
107+
if [ -e DATA/meshfem3D_files/Mesh_Par_file ]; then
108+
cp -f DATA/meshfem3D_files/Mesh_Par_file DATA/meshfem3D_files/Mesh_Par_file.org
109+
sed -i "s:^NPROC_XI .*:NPROC_XI = 1:" DATA/meshfem3D_files/Mesh_Par_file
110+
sed -i "s:^NPROC_ETA .*:NPROC_ETA = 1:" DATA/meshfem3D_files/Mesh_Par_file
111+
fi
112+
113+
# run
114+
./run_this_example.sh
115+
if [[ $? -ne 0 ]]; then exit 1; fi
116+
mv -v DATA/Par_file.org DATA/Par_file
117+
if [ -e DATA/meshfem3D_files/Mesh_Par_file.org ]; then mv -v DATA/meshfem3D_files/Mesh_Par_file.org DATA/meshfem3D_files/Mesh_Par_file; fi
118+
cd "$WORKDIR"
119+
}
120+
121+
echo
122+
echo "coverage run: TESTID=${TESTID}"
123+
echo "work directory: ${WORKDIR}"
124+
echo
125+
126+
# additional example tests (after base to avoid repeating code setup/configuration/compilation)
127+
case "$TESTID" in
128+
0) # serial bunch
129+
run_serial "EXAMPLES/applications/homogeneous_halfspace/" 5
130+
run_serial "EXAMPLES/applications/meshfem3D_examples/simple_model/" 5
131+
run_serial "EXAMPLES/applications/Gmsh_simple_box_hex27/" 5
132+
;;
133+
1) # parallel bunch 1
134+
run_simple "EXAMPLES/applications/homogeneous_halfspace_HEX27_elastic_no_absorbing/" 5
135+
run_simple "EXAMPLES/applications/homogeneous_poroelastic/" 5
136+
run_kernel "EXAMPLES/applications/homogeneous_acoustic/" 5
137+
;;
138+
2) # parallel bunch 2
139+
run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_acoustic_absorbing_CPML_5sides/" 5
140+
run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_elastic_absorbing_CPML_5sides/" 5
141+
run_simple "EXAMPLES/applications/noise_tomography/" 5
142+
run_simple "EXAMPLES/applications/tomographic_model/" 5
143+
run_simple "EXAMPLES/applications/layered_halfspace/" 5
144+
run_simple "EXAMPLES/applications/waterlayered_halfspace/" 5
145+
run_simple "EXAMPLES/applications/waterlayered_poroelastic/" 5
146+
;;
147+
3) # parallel bunch 3
148+
run_simple "EXAMPLES/applications/fault_examples/tpv5/" 5
149+
run_simple "EXAMPLES/applications/small_example_coupling_FK_specfem/" 5
150+
run_simple "EXAMPLES/applications/Gmsh_simple_lddrk/" 5
151+
run_simple "EXAMPLES/applications/decompose_mesh_MPI/" 5
152+
run_simple "EXAMPLES/applications/small_adjoint_multiple_sources/" 5
153+
run_simple "EXAMPLES/applications/LTS_homogeneous_halfspace_HEX8/" 50
154+
;;
155+
4) # parallel bunch 4
156+
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_socal"
157+
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_prem"
158+
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_cascadia"
159+
run_simple "EXAMPLES/applications/meshfem3D_examples/cavity/" 5
160+
run_simple "EXAMPLES/applications/meshfem3D_examples/sep_bathymetry/" 5
161+
run_simple "EXAMPLES/applications/meshfem3D_examples/regular_element_mesh/" 5
162+
;;
163+
5) # inversion
164+
echo "TESTID=4: no additional coverage examples (base inversion run already executed)"
165+
;;
166+
6) # NGLL 6
167+
echo "TESTID=5: no additional coverage examples (base run already executed)"
168+
;;
169+
*)
170+
echo "TESTID=${TESTID}: no additional coverage examples configured"
171+
;;
172+
esac
173+
174+
echo
175+
echo "coverage examples done"
176+
echo "$(date)"
177+
echo

.github/scripts/run_install.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,100 @@ if [ "${ADIOS2}" == "true" ]; then
115115
echo; echo "done ADIOS2"; echo
116116
fi
117117

118+
# installs the CUDA toolkit
119+
if [ "${CUDA}" == "true" ]; then
120+
# Linux environment
121+
## distribution from ubuntu 22.04
122+
UBUNTU_VERSION=ubuntu2204
123+
124+
# CUDA_VERSION - specifies CUDA toolkit version
125+
# http://developer.download.nvidia.com/compute/cuda/repos/
126+
CUDA_VERSION=13.1.1-1
127+
128+
# default architecture amd64
129+
CUDA_OS=x86_64
130+
CUDA_ARCH=amd64
131+
if [ "${RUNNER_ARCH}" == "arm64" ]; then
132+
CUDA_OS=sbsa
133+
CUDA_ARCH=arm64 # ARM
134+
fi
135+
136+
echo "Installing CUDA library"
137+
echo "CUDA version : ${CUDA_VERSION}"
138+
echo "UBUNTU version: ${UBUNTU_VERSION}"
139+
echo "CUDA OS : ${CUDA_OS}"
140+
echo "CUDA arch : ${CUDA_ARCH}"
141+
142+
# package needs key
143+
# see: https://developer.nvidia.com/blog/updating-the-cuda-linux-gpg-repository-key/
144+
# old:
145+
#sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/7fa2af80.pub
146+
# new:
147+
# manually add new key (not recommended):
148+
#sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/3bf863cc.pub
149+
#echo
150+
# gets packages
151+
#INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA_VERSION}_${CUDA_ARCH}.deb
152+
#wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/${INSTALLER}
153+
#sudo dpkg -i ${INSTALLER}
154+
#echo
155+
# (preferred) w/ new keyring package:
156+
# see https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772
157+
# if it doesn't work yet with error:
158+
# E:Conflicting values set for option Signed-By regarding source
159+
# remove outdated key:
160+
sudo apt-key del 7fa2af80
161+
sudo sed -i '/developer\.download\.nvidia\.com\/compute\/cuda\/repos/d' /etc/apt/sources.list
162+
sudo rm -f /etc/apt/sources.d/cuda*.list
163+
sudo rm -f /etc/apt/sources.list.d/cuda.list
164+
sudo rm -f /etc/apt/sources.list.d/nvidia-ml.list
165+
# for ubuntu1804/ppc64el ../$distro/$arch/.. becomes ../${UBUNTU_VERSION}/${CUDA_OS}/..
166+
wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/cuda-keyring_1.0-1_all.deb
167+
sudo dpkg -i cuda-keyring_1.0-1_all.deb
168+
echo
169+
170+
# update
171+
echo "Updating libraries"
172+
sudo apt-get update -qq
173+
dpkg -l | grep cuda
174+
export CUDA_APT=${CUDA_VERSION:0:4} # version 13.1
175+
export CUDA_APT=${CUDA_APT/./-}
176+
echo "CUDA: ${CUDA_APT}" # apt version 13-1 -> package name: cuda-compiler-13-1
177+
178+
# installs packages
179+
CUDA_PACKAGES="cuda-drivers cuda-compiler-${CUDA_APT} cuda-cudart-dev-${CUDA_APT}"
180+
echo "Installing ${CUDA_PACKAGES}"
181+
sudo apt-get install -y --no-install-recommends ${CUDA_PACKAGES}
182+
sudo apt-get clean
183+
export CUDA_HOME=/usr/local/cuda-${CUDA_VERSION:0:4} # version 13.1
184+
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
185+
export PATH=${CUDA_HOME}/bin:${PATH}
186+
echo ""
187+
nvcc --version
188+
echo ""
189+
190+
## OpenCL additionals
191+
if [ "${OPENCL}" == "true" ]; then
192+
echo "OpenCL installation"
193+
#echo "dpkg toolkit:"
194+
#dpkg -l | grep toolkit
195+
#echo ""
196+
#echo "dpkg opencl:"
197+
#dpkg -l | grep opencl
198+
#echo ""
199+
#echo "apt-cache opencl:"
200+
#apt-cache search opencl
201+
# possible packages for OpenCL:
202+
#sudo apt-get install -y --no-install-recommends cuda-toolkit-${CUDA_APT}
203+
#sudo apt-get install opencl-headers
204+
# for ppc64 architecture: to be able to compile/link OpenCL version
205+
sudo apt-get install nvidia-opencl-dev
206+
echo ""
207+
fi
208+
else
209+
export CUDA_HOME=""
210+
fi
211+
118212
# MPI
119213
# github actions uses for Linux virtual machines a 2-core CPU environment
120214
# see: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources

0 commit comments

Comments
 (0)