Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 51 additions & 8 deletions .github/scripts/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
if [ -f $HOME/.tmprc ]; then source $HOME/.tmprc; fi

WORKDIR=`pwd`
TESTCOV=${TESTCOV:-}

# info
echo "work directory: $WORKDIR"
echo `date`
echo
echo "**********************************************************"
echo
echo "configuration test: TESTFLAGS=${TESTFLAGS} TESTNGLL=${TESTNGLL}"
echo "configuration test: TESTFLAGS=${TESTFLAGS} TESTNGLL=${TESTNGLL} TESTCOV=${TESTCOV}"
echo " CUDA=${CUDA} HIP=${HIP} ADIOS2=${ADIOS2} HDF5=${HDF5}"
echo
echo "**********************************************************"
echo
Expand Down Expand Up @@ -50,12 +52,24 @@ else
hdf=()
fi

## CUDA
if [ "${CUDA}" == "true" ]; then
echo
echo "enabling CUDA"
echo
cuda=(--with-cuda=cuda13 CUDA_LIB="${CUDA_HOME}/lib64" CUDA_INC="${CUDA_HOME}/include" \
CUDA_FLAGS="-Xcompiler -Wall,-Wno-unused-function,-Wno-unused-const-variable,-Wfatal-errors -g -G")
else
cuda=()
fi

## HIP
if [ "${HIP}" == "true" ]; then
echo
echo "enabling HIP"
echo
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++")
hip=(--with-hip HIPCC=g++ HIP_PLATFORM=cpu HIP_INC=./external_libs/ROCm-HIP-CPU/include HIP_LIBS="-ltbb -lpthread -lstdc++" \
HIP_FLAGS="-O2 -g -std=c++17")
else
hip=()
fi
Expand All @@ -80,12 +94,35 @@ echo
# split TESTFLAGS into individual items
set -- ${TESTFLAGS}

./configure \
"${adios[@]}" \
"${hdf[@]}" \
"${hip[@]}" \
"${flags[@]}" \
FC=gfortran MPIFC=mpif90 CC=gcc "$@"
###########################################################
# configuration & compilation
###########################################################
# configuration

if [ "${TESTCOV}" == "true" ]; then
echo "configuration: for coverage"
./configure \
"${adios[@]}" \
"${hdf[@]}" \
"${cuda[@]}" \
"${hip[@]}" \
"${flags[@]}" \
FLAGS_CHECK="-fprofile-arcs -ftest-coverage -O0" CFLAGS="-coverage -O0" \
FC=${FC} MPIFC=${MPIFC} CC=${CC} "$@"
else
if [ "${CUDA}" == "true" ]; then
echo "configuration: for cuda"
else
echo "configuration: default"
fi
./configure \
"${adios[@]}" \
"${hdf[@]}" \
"${cuda[@]}" \
"${hip[@]}" \
"${flags[@]}" \
FC=${FC} MPIFC=${MPIFC} CC=${CC} "$@"
fi

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

# inversion example
if [ "$TESTDIR" == "EXAMPLES/applications/inversion_examples/fwi_test_acoustic/" ]; then
sed -i "s:IMAIN .*:IMAIN = 42:" setup/constants.h
sed -i "s:INVERSE_LOG_FILE .*:INVERSE_LOG_FILE = 6:" src/inverse_problem_for_model/inverse_problem_par.f90
fi

# compilation
echo
echo "clean"
Expand Down
177 changes: 177 additions & 0 deletions .github/scripts/run_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/bin/bash
#
# runs additional coverage examples
#

set -euo pipefail

# getting updated environment (CUDA_HOME, PATH, ..)
if [ -f $HOME/.tmprc ]; then source $HOME/.tmprc; fi

WORKDIR=$(pwd)
TESTID=${TESTID:-}
TESTCOV=${TESTCOV:-}

if [ "$TESTCOV" != "true" ]; then
echo "TESTCOV=${TESTCOV} (not coverage), skipping run_coverage.sh"
exit 0
fi

run_simple() {
local rel_dir="$1"
local nstep="$2"
local model="${3:-}"

echo "##################################################################"
echo "${rel_dir}"
echo

cd "${WORKDIR}/${rel_dir}"

# setup
cp -v DATA/Par_file DATA/Par_file.org
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file

# noise
if [ "${rel_dir}" == "EXAMPLES/applications/noise_tomography/" ]; then
sed -i '10,$ d' NOISE_TOMOGRAPHY/S_squared # truncates file, deletes all lines from line 10 till end
fi
# socal1D
if [ "${rel_dir}" == "EXAMPLES/applications/meshfem3D_examples/socal1D/" ]; then
if [ "$model" = "1d_socal" ]; then
sed -i "s:^MODEL .*:MODEL = 1d_socal:" DATA/Par_file
rm -f REF_SEIS
ln -s REF_SEIS.1d_socal REF_SEIS
elif [ "$model" = "1d_prem" ]; then
sed -i "s:^MODEL .*:MODEL = 1d_prem:" DATA/Par_file
rm -f REF_SEIS
ln -s REF_SEIS.1d_prem REF_SEIS
elif [ "$model" = "1d_cascadia" ]; then
sed -i "s:^MODEL .*:MODEL = 1d_cascadia:" DATA/Par_file
rm -f REF_SEIS
ln -s REF_SEIS.1d_cascadia REF_SEIS
fi
fi

# run
./run_this_example.sh
if [[ $? -ne 0 ]]; then exit 1; fi
mv -v DATA/Par_file.org DATA/Par_file
cd "$WORKDIR"
}

run_kernel() {
local rel_dir="$1"
local nstep="$2"

echo "##################################################################"
echo "${rel_dir} (kernel coverage)"
echo

cd "${WORKDIR}/${rel_dir}"

# setup
cp -v DATA/Par_file DATA/Par_file.org
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file

if [ "${rel_dir}" == "EXAMPLES/applications/homogeneous_acoustic/" ]; then
sed -i "s:300:${nstep}:" run_this_example_kernel.sh
sed -i "s:^t_start.*:t_start=-6.0:" create_adjoint_sources.sh
sed -i "s:^t_end.*:t_end=-5.55:" create_adjoint_sources.sh
fi

# run
./run_this_example_kernel.sh
if [[ $? -ne 0 ]]; then exit 1; fi
mv -v DATA/Par_file.org DATA/Par_file
cd "$WORKDIR"
}


run_serial() {
local rel_dir="$1"
local nstep="$2"

echo "##################################################################"
echo "${rel_dir} (serial)"
echo

cd "${WORKDIR}/${rel_dir}"

# setup
cp -f DATA/Par_file DATA/Par_file.org
sed -i "s:^NPROC .*:NPROC = 1:" DATA/Par_file
sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file

# meshfem setup
if [ -e DATA/meshfem3D_files/Mesh_Par_file ]; then
cp -f DATA/meshfem3D_files/Mesh_Par_file DATA/meshfem3D_files/Mesh_Par_file.org
sed -i "s:^NPROC_XI .*:NPROC_XI = 1:" DATA/meshfem3D_files/Mesh_Par_file
sed -i "s:^NPROC_ETA .*:NPROC_ETA = 1:" DATA/meshfem3D_files/Mesh_Par_file
fi

# run
./run_this_example.sh
if [[ $? -ne 0 ]]; then exit 1; fi
mv -v DATA/Par_file.org DATA/Par_file
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
cd "$WORKDIR"
}

echo
echo "coverage run: TESTID=${TESTID}"
echo "work directory: ${WORKDIR}"
echo

# additional example tests (after base to avoid repeating code setup/configuration/compilation)
case "$TESTID" in
0) # serial bunch
run_serial "EXAMPLES/applications/homogeneous_halfspace/" 5
run_serial "EXAMPLES/applications/meshfem3D_examples/simple_model/" 5
run_serial "EXAMPLES/applications/Gmsh_simple_box_hex27/" 5
;;
1) # parallel bunch 1
run_simple "EXAMPLES/applications/homogeneous_halfspace_HEX27_elastic_no_absorbing/" 5
run_simple "EXAMPLES/applications/homogeneous_poroelastic/" 5
run_kernel "EXAMPLES/applications/homogeneous_acoustic/" 5
;;
2) # parallel bunch 2
run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_acoustic_absorbing_CPML_5sides/" 5
run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_elastic_absorbing_CPML_5sides/" 5
run_simple "EXAMPLES/applications/noise_tomography/" 5
run_simple "EXAMPLES/applications/tomographic_model/" 5
run_simple "EXAMPLES/applications/layered_halfspace/" 5
run_simple "EXAMPLES/applications/waterlayered_halfspace/" 5
run_simple "EXAMPLES/applications/waterlayered_poroelastic/" 5
;;
3) # parallel bunch 3
run_simple "EXAMPLES/applications/fault_examples/tpv5/" 5
run_simple "EXAMPLES/applications/small_example_coupling_FK_specfem/" 5
run_simple "EXAMPLES/applications/Gmsh_simple_lddrk/" 5
run_simple "EXAMPLES/applications/decompose_mesh_MPI/" 5
run_simple "EXAMPLES/applications/small_adjoint_multiple_sources/" 5
run_simple "EXAMPLES/applications/LTS_homogeneous_halfspace_HEX8/" 50
;;
4) # parallel bunch 4
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_socal"
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_prem"
run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_cascadia"
run_simple "EXAMPLES/applications/meshfem3D_examples/cavity/" 5
run_simple "EXAMPLES/applications/meshfem3D_examples/sep_bathymetry/" 5
run_simple "EXAMPLES/applications/meshfem3D_examples/regular_element_mesh/" 5
;;
5) # inversion
echo "TESTID=4: no additional coverage examples (base inversion run already executed)"
;;
6) # NGLL 6
echo "TESTID=5: no additional coverage examples (base run already executed)"
;;
*)
echo "TESTID=${TESTID}: no additional coverage examples configured"
;;
esac

echo
echo "coverage examples done"
echo "$(date)"
echo
94 changes: 94 additions & 0 deletions .github/scripts/run_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,100 @@ if [ "${ADIOS2}" == "true" ]; then
echo; echo "done ADIOS2"; echo
fi

# installs the CUDA toolkit
if [ "${CUDA}" == "true" ]; then
# Linux environment
## distribution from ubuntu 22.04
UBUNTU_VERSION=ubuntu2204

# CUDA_VERSION - specifies CUDA toolkit version
# http://developer.download.nvidia.com/compute/cuda/repos/
CUDA_VERSION=13.1.1-1

# default architecture amd64
CUDA_OS=x86_64
CUDA_ARCH=amd64
if [ "${RUNNER_ARCH}" == "arm64" ]; then
CUDA_OS=sbsa
CUDA_ARCH=arm64 # ARM
fi

echo "Installing CUDA library"
echo "CUDA version : ${CUDA_VERSION}"
echo "UBUNTU version: ${UBUNTU_VERSION}"
echo "CUDA OS : ${CUDA_OS}"
echo "CUDA arch : ${CUDA_ARCH}"

# package needs key
# see: https://developer.nvidia.com/blog/updating-the-cuda-linux-gpg-repository-key/
# old:
#sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/7fa2af80.pub
# new:
# manually add new key (not recommended):
#sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/3bf863cc.pub
#echo
# gets packages
#INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA_VERSION}_${CUDA_ARCH}.deb
#wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/${INSTALLER}
#sudo dpkg -i ${INSTALLER}
#echo
# (preferred) w/ new keyring package:
# see https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772
# if it doesn't work yet with error:
# E:Conflicting values set for option Signed-By regarding source
# remove outdated key:
sudo apt-key del 7fa2af80
sudo sed -i '/developer\.download\.nvidia\.com\/compute\/cuda\/repos/d' /etc/apt/sources.list
sudo rm -f /etc/apt/sources.d/cuda*.list
sudo rm -f /etc/apt/sources.list.d/cuda.list
sudo rm -f /etc/apt/sources.list.d/nvidia-ml.list
# for ubuntu1804/ppc64el ../$distro/$arch/.. becomes ../${UBUNTU_VERSION}/${CUDA_OS}/..
wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/${CUDA_OS}/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
echo

# update
echo "Updating libraries"
sudo apt-get update -qq
dpkg -l | grep cuda
export CUDA_APT=${CUDA_VERSION:0:4} # version 13.1
export CUDA_APT=${CUDA_APT/./-}
echo "CUDA: ${CUDA_APT}" # apt version 13-1 -> package name: cuda-compiler-13-1

# installs packages
CUDA_PACKAGES="cuda-drivers cuda-compiler-${CUDA_APT} cuda-cudart-dev-${CUDA_APT}"
echo "Installing ${CUDA_PACKAGES}"
sudo apt-get install -y --no-install-recommends ${CUDA_PACKAGES}
sudo apt-get clean
export CUDA_HOME=/usr/local/cuda-${CUDA_VERSION:0:4} # version 13.1
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
echo ""
nvcc --version
echo ""

## OpenCL additionals
if [ "${OPENCL}" == "true" ]; then
echo "OpenCL installation"
#echo "dpkg toolkit:"
#dpkg -l | grep toolkit
#echo ""
#echo "dpkg opencl:"
#dpkg -l | grep opencl
#echo ""
#echo "apt-cache opencl:"
#apt-cache search opencl
# possible packages for OpenCL:
#sudo apt-get install -y --no-install-recommends cuda-toolkit-${CUDA_APT}
#sudo apt-get install opencl-headers
# for ppc64 architecture: to be able to compile/link OpenCL version
sudo apt-get install nvidia-opencl-dev
echo ""
fi
else
export CUDA_HOME=""
fi

# MPI
# github actions uses for Linux virtual machines a 2-core CPU environment
# see: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
Expand Down
Loading