Skip to content

Commit 9f90497

Browse files
committed
Improved support for HIP and other tweaks.
1 parent 8ff7274 commit 9f90497

File tree

7 files changed

+57
-12
lines changed

7 files changed

+57
-12
lines changed

machine-configs/corona.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,39 @@ function setup_hip()
4141
hip_lib=${hip_home}/lib64
4242
}
4343

44+
function setup_gcc8()
45+
{
46+
# Load additional modules from 'opt'; needed for the 'rocm' module
47+
module load opt
48+
# ROCm 3.8.0 is using /opt/rh/devtoolset-8 for linking with libstdc++, so
49+
# we use the module gcc/8.3.1 which seems to be the same as the version in
50+
# /opt/rh/devtoolset-8
51+
module load gcc/8.3.1
52+
module load mvapich2/2.3
53+
54+
# ROCm and HIP
55+
module load rocm/3.8.0
56+
57+
MPICC=mpicc
58+
MPICXX=mpicxx
59+
CFLAGS="-O3"
60+
# CXX11FLAG="--std=c++11 -fno-gpu-rdc"
61+
# Used e.g. by libCEED:
62+
NATIVE_CFLAG="-march=native"
63+
64+
hip_path=$(dirname $(which hipcc))
65+
hip_home=$(dirname ${hip_path})
66+
hip_lib=${hip_home}/lib64
67+
}
68+
4469
function set_mpi_options()
4570
{
4671
echo "${cyan}MPI setup${none}"
4772
num_proc_node=${num_proc_run}
4873
compose_mpi_run_command
4974
}
5075

51-
valid_compilers="hip"
76+
valid_compilers="hip gcc8"
5277

5378
num_proc_detect="$(getconf _NPROCESSORS_ONLN)"
5479
num_proc_build=${num_proc_build:-$num_proc_detect}

package-builders/cuda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pkg="CUDA"
3939
function build_package()
4040
{
4141
if [[ -n "$CUDA_ENABLED" ]]; then
42-
echo "CUDA is enabled."
42+
echo "CUDA is enabled. [ cuda_home = $cuda_home ]"
4343
else
4444
echo "Error: cannot enable CUDA: 'cuda_home' is not configured. Stop."
4545
return 1

package-builders/hip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function build_package()
4040
{
4141
echo "${cyan}HIP build_package${none}"
4242
if [[ -n "$HIP_ENABLED" ]]; then
43-
echo "HIP is enabled."
43+
echo "HIP is enabled. [ hip_home = $hip_home ]"
4444
else
4545
echo "Error: cannot enable HIP: 'hip_home' is not configured. Stop."
4646
return 1

package-builders/libceed.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,19 @@ function libceed_build()
8181
OPT_FLAGS+=" $NATIVE_CFLAG"
8282
fi
8383
# Check for optional packages used by backends
84-
# Note: If OCCA already is built in OUT_DIR, libCEED will find it in ../occa
85-
# and use it; in particular, the next INFO message will be incorrect in
86-
# this case.
87-
local OCCA_MAKE_OPTS=()
84+
local CUDA_MAKE_OPTS=("CUDA_DIR=/disable-cuda")
85+
if [[ -n "$CUDA_ENABLED" ]]; then
86+
CUDA_MAKE_OPTS=("CUDA_DIR=${cuda_home}")
87+
else
88+
echo "${magenta}INFO: Building $pkg without CUDA ...${none}"
89+
fi
90+
local HIP_MAKE_OPTS=("HIP_DIR=/disable-hip")
91+
if [[ -n "$HIP_ENABLED" ]]; then
92+
HIP_MAKE_OPTS=("HIP_DIR=${hip_home}")
93+
else
94+
echo "${magenta}INFO: Building $pkg without HIP ...${none}"
95+
fi
96+
local OCCA_MAKE_OPTS=("OCCA_DIR=/disable-occa")
8897
if [[ -n "$OCCA_DIR" ]]; then
8998
OCCA_MAKE_OPTS=("OCCA_DIR=${OCCA_DIR}")
9099
else
@@ -100,14 +109,16 @@ function libceed_build()
100109
CXX="$MPICXX" \
101110
FC="$MPIF77" \
102111
OPT="$OPT_FLAGS" \
112+
"${CUDA_MAKE_OPTS[@]}" \
113+
"${HIP_MAKE_OPTS[@]}" \
103114
"${OCCA_MAKE_OPTS[@]}"
104115
} &> "${pkg_bld_dir}_build.log" || {
105116
echo " ... building $pkg FAILED, see log for details."
106117
return 1
107118
}
108119
echo "Build successful."
109120
print_variables "$pkg_var_prefix" \
110-
LIBCEED_BRANCH OCCA_DIR \
121+
LIBCEED_BRANCH CUDA_ENABLED cuda_home HIP_ENABLED hip_home OCCA_DIR \
111122
> "${pkg_bld_dir}_build_successful"
112123
}
113124

package-builders/mfem.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ function mfem_build()
171171
echo "Build successful."
172172
print_variables "$pkg_var_prefix" \
173173
MFEM_BRANCH MFEM_DEBUG \
174-
HYPRE_DIR METIS_DIR METIS_VERSION CUDA_ENABLED cuda_home OCCA_DIR \
175-
RAJA_DIR OMP_ENABLED omp_flag LIBCEED_DIR SUNDIALS_DIR \
174+
HYPRE_DIR METIS_DIR METIS_VERSION CUDA_ENABLED cuda_home \
175+
HIP_ENABLED hip_home OCCA_DIR RAJA_DIR OMP_ENABLED omp_flag \
176+
LIBCEED_DIR SUNDIALS_DIR \
176177
> "${pkg_bld_dir}_build_successful"
177178
}
178179

package-builders/occa.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ function occa_build()
8080
export OCCA_CUDA_ENABLED=0
8181
echo "${magenta}INFO: Building $pkg without CUDA ...${none}"
8282
fi
83+
if [[ -n "$HIP_ENABLED" ]]; then
84+
add_to_path after OCCA_INCLUDE_PATH "${hip_home}/hip/include"
85+
add_to_path after OCCA_INCLUDE_PATH "${hip_home}/opencl/include"
86+
export OCCA_INCLUDE_PATH
87+
else
88+
export OCCA_HIP_ENABLED=0
89+
echo "${magenta}INFO: Building $pkg without HIP ...${none}"
90+
fi
8391
echo "Building $pkg, sending output to ${pkg_bld_dir}_build.log ..." && {
8492
cd "$pkg_bld_dir" && \
8593
make \
@@ -93,7 +101,7 @@ function occa_build()
93101
}
94102
echo "Build successful."
95103
print_variables "$pkg_var_prefix" \
96-
OCCA_BRANCH CUDA_ENABLED cuda_home \
104+
OCCA_BRANCH CUDA_ENABLED cuda_home HIP_ENABLED hip_home \
97105
> "${pkg_bld_dir}_build_successful"
98106
}
99107

package-builders/openmp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pkg="OpenMP"
3939
function build_package()
4040
{
4141
if [[ -n "$OMP_ENABLED" ]]; then
42-
echo "OpenMP is enabled."
42+
echo "OpenMP is enabled. [ omp_flag = $omp_flag ]"
4343
else
4444
echo "Error: cannot enable OpenMP: 'omp_flag' is not configured. Stop."
4545
return 1

0 commit comments

Comments
 (0)