-
Notifications
You must be signed in to change notification settings - Fork 103
Description
I am trying to port RapidCFD to AMD GPUs:
ROCm is installed under /opt/rocm-6.0.0: Relevant sections are:
/opt/rocm-6.0.0/bin
/opt/rocm-6.0.0/lib
/opt/rocm-6.0.0/include
/opt/rocm-6.0.0/include/thrust
/opt/rocm-6.0.0/include/rocprim
the compiler is called "hipcc"
Using rocThrust in a project, here RapidCFD:
We recommended including rocThrust into a CMake project by using its package configuration files.
On ROCm rocThrust requires rocPRIM
find_package(rocprim REQUIRED CONFIG PATHS "/opt/rocm-6.0.0/include/rocprim")
"/opt/rocm" - default install prefix
find_package(rocthrust REQUIRED CONFIG PATHS "/opt/rocm-6.0.0/include/thrust")
...
includes rocThrust headers and roc::rocprim_hip target
target_link_libraries(<your_target> roc::rocthrust)
Where your_target refers to the GPU architecture e.g. gfx1030 for a RX6800
The problem is, that the porting tools don't port the make and configuration files. How to change the setup to use hipcc instead of nvcc and to find thrust and rocprim, a dependency for thrust?
I think the following section in "settings.sh" needs to be changed to make it happen, maybe .bashrc, too?: Can someone tell me how to specify the compiler(s) to be used and set the path to thrust'
# Location of compiler installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -z "$foamCompiler" ]
then
foamCompiler=system
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " foamCompiler not set, using '$foamCompiler'" 1>&2
fi
case "${foamCompiler}" in
OpenFOAM | ThirdParty)
case "$WM_COMPILER" in
Gcc | Gcc++0x | Gcc48 | Gcc48++0x)
gcc_version=gcc-11.4.1
gmp_version=gmp-5.1.2
mpfr_version=mpfr-3.1.2
mpc_version=mpc-1.0.1
;;
Gcc49 | Gcc49++0x)
gcc_version=gcc-4.9.0
gmp_version=gmp-5.1.2
mpfr_version=mpfr-3.1.2
mpc_version=mpc-1.0.1
;;
Clang)
# using clang - not gcc
export WM_CC='clang'
export WM_CXX='clang++'
clang_version=llvm-3.4.2
;;
*)
echo 1>&2
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " Unknown OpenFOAM compiler type '$WM_COMPILER'" 1>&2
echo " Please check your settings" 1>&2
echo 1>&2
;;
esac
# optional configuration tweaks:
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/compiler.sh`
if [ -n "$gcc_version" ]
then
gccDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version
gmpDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version
mpfrDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version
mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpc_version
# Check that the compiler directory can be found
[ -d "$gccDir" ] || {
echo 1>&2
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " Cannot find $gccDir installation." 1>&2
echo " Please install this compiler version or if you wish to use the system compiler," 1>&2
echo " change the 'foamCompiler' setting to 'system'" 1>&2
echo
}
_foamAddMan $gccDir/man
_foamAddPath $gccDir/bin
# add compiler libraries to run-time environment
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH
# add gmp/mpfr libraries to run-time environment
_foamAddLib $gmpDir/lib
_foamAddLib $mpfrDir/lib
# add mpc libraries (not need for older gcc) to run-time environment
if [ -n "$mpc_version" ]
then
_foamAddLib $mpcDir/lib
fi
# used by boost/CGAL:
export MPFR_ARCH_PATH=$mpfrDir
export GMP_ARCH_PATH=$gmpDir
fi
unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
if [ -n "$clang_version" ]
then
clangDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$clang_version
# Check that the compiler directory can be found
[ -d "$clangDir" ] || {
echo 1>&2
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " Cannot find $clangDir installation." 1>&2
echo " Please install this compiler version or if you wish to use the system compiler," 1>&2
echo " change the 'foamCompiler' setting to 'system'" 1>&2
echo 1>&2
}
_foamAddMan $clangDir/share/man
_foamAddPath $clangDir/bin
fi
unset clang_version clangDir
;;
system)
case "$WM_COMPILER" in
Clang)
export WM_CC='clang'
export WM_CXX='clang++'
clang_version=llvm-9.0.0
cudaHome="$(dirname $(dirname $(which nvcc)))"
[ -d "$cudaHome" ] || {
echo 1>&2
echo "Error in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " Cannot find CUDA installation." 1>&2
echo " Found only $cudaHome." 1>&2
echo 1>&2
exit 1
}
export CUDA_HOME=$cudaHome
#an option to override thrust
if [ -d "$THRUST_HOME" ]
then
export THRUST_INCLUDE=-I$THRUST_HOME
else
export THRUST_INCLUDE=/opt/rocm-6.0.0/include/thrust
fi
unset cudaHome
;;
esac
# okay, use system compiler
;;
*)
echo "Warn: foamCompiler='$foamCompiler' is unsupported" 1>&2
echo " treating as 'system' instead" 1>&2
;;
esac
#
# add c++0x flags for external programs
#
if [ -n "$WM_CXXFLAGS" ]
then
case "$WM_COMPILER" in
Gcc*++0x)
WM_CXXFLAGS="$WM_CXXFLAGS -std=c++0x"
;;
esac
fi