From c551365fe7dfcfbf452f06f0ae89c12c250d4b38 Mon Sep 17 00:00:00 2001 From: Wayne Mitchell Date: Tue, 16 Aug 2022 17:43:08 -0700 Subject: [PATCH] Add config options for target backends for sycl instead of hard coding (#701) Adds config options for specifying a target backend with sycl (both cmake and autoconf) --- src/CMakeLists.txt | 16 ++++++++++++ src/config/configure.in | 45 +++++++++++++++++++++++++++++++-- src/configure | 55 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a97c9c8b..78b4544db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,6 +119,8 @@ set(HYPRE_CUDA_SM "70" CACHE STRING "Target CUDA architecture.") option(HYPRE_ENABLE_ONEMKLSPARSE "Use oneMKL sparse" ON) option(HYPRE_ENABLE_ONEMKLBLAS "Use oneMKL blas" ON) option(HYPRE_ENABLE_ONEMKLRAND "Use oneMKL rand" ON) +set(HYPRE_SYCL_TARGET "" CACHE STRING "Target SYCL architecture, e.g. 'spir64_gen'.") +set(HYPRE_SYCL_TARGET_BACKEND "" CACHE STRING "Additional SYCL backend options, e.g. '-device 12.1.0,12.4.0'.") option(TPL_DSUPERLU_LIBRARIES "List of absolute paths to SuperLU_Dist link libraries [].") option(TPL_DSUPERLU_INCLUDE_DIRS "List of absolute paths to SuperLU_Dist include directories [].") @@ -309,6 +311,12 @@ if (HYPRE_WITH_SYCL) # Set CXX compiler to dpcpp set(CMAKE_CXX_COMPILER "dpcpp") + # Set linker to dpcpp + set(CMAKE_LINKER "dpcpp") + set(CMAKE_CXX_LINK_EXECUTABLE " -o ") + set(CMAKE_CXX_LINKER_WRAPPER_FLAG " ") + set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP " ") + # Add any extra CXX compiler flags HYPRE_WITH_EXTRA_CXXFLAGS if (NOT HYPRE_WITH_EXTRA_CXXFLAGS STREQUAL "") string(REPLACE " " ";" HYPRE_WITH_EXTRA_CXXFLAGS "${HYPRE_WITH_EXTRA_CXXFLAGS}") @@ -335,6 +343,13 @@ if (HYPRE_WITH_SYCL) add_compile_options("$<$:-fsycl-unnamed-lambda>") add_compile_options("$<$:-fsycl-device-code-split=per_kernel>") + if (HYPRE_SYCL_TARGET) + add_link_options("SHELL:-fsycl-targets=${HYPRE_SYCL_TARGET}") + endif () + if (HYPRE_SYCL_TARGET_BACKEND) + add_link_options("SHELL:-Xsycl-target-backend '${HYPRE_SYCL_TARGET_BACKEND}'") + endif () + set(HYPRE_USING_HOST_MEMORY OFF CACHE BOOL "" FORCE) if (HYPRE_ENABLE_CUDA_STREAMS) @@ -437,6 +452,7 @@ if (HYPRE_USING_CUDA) endif () if (HYPRE_USING_SYCL) + target_include_directories(${PROJECT_NAME} PUBLIC $ENV{DPLROOT}/include) if (HYPRE_ENABLE_ONEMKLSPARSE) set(HYPRE_USING_ONEMKLSPARSE ON CACHE BOOL "" FORCE) endif() diff --git a/src/config/configure.in b/src/config/configure.in index 0ae8214e9..0d6d8578b 100644 --- a/src/config/configure.in +++ b/src/config/configure.in @@ -1235,7 +1235,6 @@ AS_HELP_STRING([--with-cuda], [hypre_using_cuda=no] ) - dnl ***** HIP AC_ARG_WITH(hip, AS_HELP_STRING([--with-hip], @@ -1260,6 +1259,7 @@ esac], [hypre_using_sycl=no] ) +dnl ***** CUDA options AC_ARG_WITH(cuda-home, AS_HELP_STRING([--with-cuda-home=DIR], @@ -1285,6 +1285,39 @@ AS_HELP_STRING([--with-gpu-arch=ARG], ] ) +dnl ***** SYCL options + +AC_ARG_WITH(sycl-target, +AS_HELP_STRING([--with-sycl-target=ARG], + [User specifies sycl targets for AOT compilation in ARG, where ARG is a comma-separated + list (enclosed in quotes), e.g. "spir64_gen".]), +[ + if test "x${withval}" != "x" + then + if test "x${HYPRE_SYCL_TARGET}" = "x" + then + HYPRE_SYCL_TARGET="${withval}" + fi + fi +] +) + +AC_ARG_WITH(sycl-target-backend, +AS_HELP_STRING([--with-sycl-target-backend=ARG], + [User specifies additional options for the sycl target backend for AOT compilation in ARG, + where ARG contains the desired options (enclosed in double+single quotes), + e.g. --with-sycl-target-backend="'-device 12.1.0,12.4.0'".]), +[ + if test "x${withval}" != "x" + then + if test "x${HYPRE_SYCL_TARGET_BACKEND}" = "x" + then + HYPRE_SYCL_TARGET_BACKEND="${withval}" + fi + fi +] +) + dnl ***** RAJA AC_ARG_WITH(raja, @@ -2425,7 +2458,15 @@ AS_IF([test x"$hypre_using_sycl" == x"yes"], SYCLFLAGS="-g -O3 ${SYCLFLAGS}" fi - LDFLAGS+="-fsycl-targets=spir64_gen -Xsycl-target-backend '-device 12.1.0,12.4.0'" + dnl AOT compilation for specific devices + if test "x${HYPRE_SYCL_TARGET}" != "x" + then + LDFLAGS+=" -fsycl-targets=${HYPRE_SYCL_TARGET}" + fi + if test "x${HYPRE_SYCL_TARGET_BACKEND}" != "x" + then + LDFLAGS+=" -Xsycl-target-backend ${HYPRE_SYCL_TARGET_BACKEND}" + fi dnl (Ab)Use CUFLAGS to capture SYCL compilation flags if test "$hypre_user_chose_cuflags" = "no" diff --git a/src/configure b/src/configure index 573eb8c0d..e5242bb38 100755 --- a/src/configure +++ b/src/configure @@ -842,6 +842,8 @@ with_hip with_sycl with_cuda_home with_gpu_arch +with_sycl_target +with_sycl_target_backend with_raja with_raja_include with_raja_lib @@ -1662,6 +1664,16 @@ Optional Packages: files will be compiled for in ARG, where ARG is a space-separated list (enclosed in quotes) of numbers. + --with-sycl-target=ARG User specifies sycl targets for AOT compilation in + ARG, where ARG is a comma-separated list (enclosed + in quotes), e.g. "spir64_gen". + --with-sycl-target-backend=ARG + User specifies additional options for the sycl + target backend for AOT compilation in ARG, where ARG + contains the desired options (enclosed in + double+single quotes), e.g. + --with-sycl-target-backend="'-device + 12.1.0,12.4.0'". --with-raja Use RAJA. Require RAJA package to be compiled properly (default is NO). --with-raja-include=DIR User specifies that RAJA/*.h is in DIR. The options @@ -4099,7 +4111,6 @@ fi - # Check whether --with-hip was given. if test "${with_hip+set}" = set; then : withval=$with_hip; case "$withval" in @@ -4157,6 +4168,39 @@ fi +# Check whether --with-sycl-target was given. +if test "${with_sycl_target+set}" = set; then : + withval=$with_sycl_target; + if test "x${withval}" != "x" + then + if test "x${HYPRE_SYCL_TARGET}" = "x" + then + HYPRE_SYCL_TARGET="${withval}" + fi + fi + + +fi + + + +# Check whether --with-sycl-target-backend was given. +if test "${with_sycl_target_backend+set}" = set; then : + withval=$with_sycl_target_backend; + if test "x${withval}" != "x" + then + if test "x${HYPRE_SYCL_TARGET_BACKEND}" = "x" + then + HYPRE_SYCL_TARGET_BACKEND="${withval}" + fi + fi + + +fi + + + + # Check whether --with-raja was given. if test "${with_raja+set}" = set; then : withval=$with_raja; case "$withval" in @@ -9347,7 +9391,14 @@ $as_echo "#define HYPRE_USING_SYCL 1" >>confdefs.h SYCLFLAGS="-g -O3 ${SYCLFLAGS}" fi - LDFLAGS+="-fsycl-targets=spir64_gen -Xsycl-target-backend '-device 12.1.0,12.4.0'" + if test "x${HYPRE_SYCL_TARGET}" != "x" + then + LDFLAGS+=" -fsycl-targets=${HYPRE_SYCL_TARGET}" + fi + if test "x${HYPRE_SYCL_TARGET_BACKEND}" != "x" + then + LDFLAGS+=" -Xsycl-target-backend ${HYPRE_SYCL_TARGET_BACKEND}" + fi if test "$hypre_user_chose_cuflags" = "no" then