Skip to content

Commit

Permalink
update HIP configuration; adds HIP GPU kernel test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeter committed Nov 13, 2024
1 parent fd5e287 commit dd9e694
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 89 deletions.
8 changes: 8 additions & 0 deletions .github/scripts/run_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ if [[ "${TEST}" == *"with-hdf5"* ]]; then
#echo
fi

## HIP
if [ "${HIP}" == "true" ]; then
echo
echo "HIP additionals installation:"
echo
sudo apt-get install -yq --no-install-recommends libtbb-dev
fi

# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
echo
Expand Down
52 changes: 49 additions & 3 deletions .github/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,20 @@ if [ "${ADIOS2}" == "true" ]; then
sed -i "s:^ADIOS_ENABLED .*:ADIOS_ENABLED = .true.:" DATA/Par_file
fi

# default script
./run_this_example.sh
# GPU
if [ "${GPU}" == "true" ]; then
# turns on GPU
sed -i "s:^GPU_ENABLED .*:GPU_ENABLED = .true.:" DATA/Par_file
fi

# use kernel script
if [ "${RUN_KERNEL}" == "true" ]; then
# use kernel script
./run_this_example.kernel.sh
else
# default script
./run_this_example.sh
fi
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi

Expand All @@ -136,13 +147,48 @@ echo `date`
echo

# seismogram comparison
if [ "${DEBUG}" == "true" ]; then
if [ "${DEBUG}" == "true" ] || [ "${RUN_KERNEL}" == "true" ]; then
# no comparisons
continue
else
my_test
fi

# kernel test
if [ "${RUN_KERNEL}" == "true" ]; then
# homogeneous halfspace
if [ "$TESTDIR" == "EXAMPLES/applications/homogeneous_halfspace/" ]; then
PASSED=0
# checks rho kernel value
RHO=3.18576676E-09
VAL=`fgrep 'maximum value of rho kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '`
echo "kernel rho : $VAL"
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.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$RHO val=$VAL
if [[ $? -ne 0 ]]; then PASSED=1; fi

# checks kappa kernel value
KAPPA=9.48281809E-09
VAL=`fgrep 'maximum value of kappa kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '`
echo "kernel kappa : $VAL"
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.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$KAPPA val=$VAL
if [[ $? -ne 0 ]]; then PASSED=1; fi

# checks mu kernel value
MU=3.89545782E-08
VAL=`fgrep 'maximum value of mu kernel' OUTPUT_FILES/output_solver.txt | cut -d = -f 2 | tr -d ' '`
echo "kernel mu : $VAL"
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.0001){print "failed"; exit 1;}else{print "good"; exit 0;} }' ex=$MU val=$VAL
if [[ $? -ne 0 ]]; then PASSED=1; fi

# overall pass
if [[ $PASSED -ne 0 ]]; then
echo "kernel tests: failed"; exit 1;
else
echo "kernel tests: good"
fi
fi
fi

# cleanup
rm -rf OUTPUT_FILES/ DATABASES_MPI/

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -787,3 +787,30 @@ jobs:
run: ./.github/scripts/run_tests.sh
shell: bash

linuxTest_20:
name: Test run example 20 - HIP GPU homogeneous halfspace
runs-on: ubuntu-latest
needs: [linuxCheck]

steps:
- uses: actions/checkout@v4

- name: Install packages
env:
HIP: true
run: ./.github/scripts/run_install.sh
shell: bash

- name: Run build
env:
TESTFLAGS: --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++"
run: ./.github/scripts/run_build.sh
shell: bash

- name: Run test kernel
env:
TESTDIR: EXAMPLES/applications/homogeneous_halfspace/
GPU: true
RUN_KERNEL: true
run: ./.github/scripts/run_tests.sh
shell: bash
5 changes: 4 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ GENCODE_AMD_MI250 = --amdgpu-target=gfx90a
# NVIDIA default Tesla
@COND_HIP_TRUE@@COND_HIP_PLATFORM_NVIDIA_TRUE@GENCODE_HIP = $(GENCODE_30)
@COND_HIP_TRUE@@COND_HIP_PLATFORM_NVIDIA_TRUE@HIP_CFLAG_ENDING = # no need for ending
# CPU
@COND_HIP_TRUE@@COND_HIP_PLATFORM_CPU_TRUE@GENCODE_HIP = # no card specifics
@COND_HIP_TRUE@@COND_HIP_PLATFORM_CPU_TRUE@HIP_CFLAG_ENDING = -x c++

# specific targets
@COND_HIP_TRUE@@COND_HIP_MI8_TRUE@GENCODE_HIP = $(GENCODE_AMD_MI8) # --with-hip=MI8 ..
Expand All @@ -297,7 +300,7 @@ HIP_INC = @HIP_CPPFLAGS@ $(MPI_INCLUDES)
@COND_HIP_FALSE@HIPCC = @CC@

@COND_HIP_TRUE@HIP_CFLAGS = $(HIP_FLAGS) $(HIP_INC) $(GENCODE_HIP)
@COND_HIP_TRUE@HIP_LINK = @HIP_LDFLAGS@ @HIP_LIBS@
@COND_HIP_TRUE@HIP_LINK = @HIP_LIBS@

@COND_HIP_FALSE@HIP_CFLAGS =
@COND_HIP_FALSE@HIP_LINK =
Expand Down
Loading

0 comments on commit dd9e694

Please sign in to comment.