From 164617ea4534ee2db9895d642b910669c6fe3392 Mon Sep 17 00:00:00 2001 From: "Yu-Hsiang M. Tsai" Date: Wed, 14 Jun 2023 16:19:54 +0200 Subject: [PATCH 1/5] add icpx support --- .github/workflows/intel.yml | 6 ++++-- CMakeLists.txt | 4 +++- README.md | 2 +- benchmark/CMakeLists.txt | 2 ++ cmake/autodetect_executors.cmake | 4 ++++ cmake/build_helpers.cmake | 7 ++++++- cmake/create_test.cmake | 2 ++ dpcpp/CMakeLists.txt | 2 ++ test/solver/CMakeLists.txt | 3 +++ third_party/gtest/CMakeLists.txt | 2 +- 10 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index 9fd85708737..4652b3996e1 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -6,6 +6,7 @@ on: - 'master' - 'develop' - 'release/**' + - 'icpx_compilation' tags: - '**' pull_request: @@ -21,7 +22,8 @@ jobs: fail-fast: false matrix: config: - - {build_type: "Release", name: "intel/release/shared", "mixed": "ON"} + - {compiler: "dpcpp", build_type: "Release", name: "intel/dpcpp/release/shared", mixed: "ON"} + - {compiler: "icpx", build_type: "Release", name: "intel/icpx/release/shared", mixed: "OFF"} name: ${{ matrix.config.name }} runs-on: [gpu_intel] @@ -35,7 +37,7 @@ jobs: spack find --loaded mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=install_ginkgo -DGINKGO_COMPILER_FLAGS="-ffp-model=precise" -DCMAKE_CXX_COMPILER=dpcpp -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_DPCPP_SINGLE_MODE=ON + cmake .. -DCMAKE_INSTALL_PREFIX=install_ginkgo -DGINKGO_COMPILER_FLAGS="-ffp-model=precise" -DCMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_DPCPP_SINGLE_MODE=ON make -j8 ONEAPI_DEVICE_SELECTOR=level_zero:gpu ctest -j10 --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fd7c658c0b..4608b010720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ set(GINKGO_VERBOSE_LEVEL "1" CACHE STRING if(MSVC) set(GINKGO_COMPILER_FLAGS "" CACHE STRING "Set the required CXX compiler flags, mainly used for warnings. Current default is ``") -elseif(GINKGO_BUILD_DPCPP OR CMAKE_CXX_COMPILER MATCHES "dpcpp") +elseif(GINKGO_BUILD_DPCPP OR CMAKE_CXX_COMPILER MATCHES "dpcpp|icpx") # For now always use `-ffp-model=precise` with DPC++. This can be removed when # the floating point issues are fixed. set(GINKGO_COMPILER_FLAGS "-Wpedantic;-ffp-model=precise" CACHE STRING @@ -298,6 +298,8 @@ endif() if(GINKGO_BUILD_DPCPP) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_MAJOR_VERSION __LIBSYCL_MAJOR_VERSION) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_VERSION __SYCL_COMPILER_VERSION) + get_filename_component(GINKGO_SYCL_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) + set(SYCL_INCLUDE_PATH "${GINKGO_SYCL_DIR}/../include;${GINKGO_SYCL_DIR}/../include/sycl") else() set(GINKGO_DPCPP_MAJOR_VERSION "0") endif() diff --git a/README.md b/README.md index 929300fede0..b39765ca71f 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The Ginkgo HIP module has the following __additional__ requirements: The Ginkgo DPC++ module has the following __additional__ requirements: * _OneAPI 2021.3+_ -* Set `dpcpp` as the `CMAKE_CXX_COMPILER` +* Set `dpcpp` or `icpx` as the `CMAKE_CXX_COMPILER` * `c++17` is used to compile Ginkgo * The following oneAPI packages should be available: * oneMKL diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index fd04620f595..7a4f5b1ca43 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -140,6 +140,8 @@ if (GINKGO_BUILD_DPCPP) ginkgo_benchmark_onemkl_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION) ginkgo_benchmark_onemkl_linops(c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION) add_library(dpcpp_timer utils/dpcpp_timer.dp.cpp) + target_compile_options(dpcpp_timer PRIVATE ${GINKGO_DPCPP_FLAGS}) + target_link_options(dpcpp_timer PRIVATE ${GINKGO_DPCPP_FLAGS}) target_link_libraries(dpcpp_timer ginkgo) endif() diff --git a/cmake/autodetect_executors.cmake b/cmake/autodetect_executors.cmake index 315e0eb3e38..86949cecda9 100644 --- a/cmake/autodetect_executors.cmake +++ b/cmake/autodetect_executors.cmake @@ -40,6 +40,10 @@ endif() if (NOT DEFINED GINKGO_BUILD_DPCPP) try_compile(GKO_CAN_COMPILE_DPCPP ${PROJECT_BINARY_DIR}/dpcpp SOURCES ${PROJECT_SOURCE_DIR}/dpcpp/test_dpcpp.dp.cpp + # try_compile will pass the project CMAKE_CXX_FLAGS so passing -DCMAKE_CXX_FLAGS does not affect it. + # They append COMPILE_DEFINITIONS into CMAKE_CXX_FLAGS. + # Note. it is different from try_compile COMPILE_DEFINITIONS affect + CMAKE_FLAGS -DCOMPILE_DEFINITIONS=-fsycl CXX_STANDARD 17) if (GKO_CAN_COMPILE_DPCPP) message(STATUS "Enabling DPCPP executor") diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index a7b8c48acf3..25add05c60f 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -9,6 +9,10 @@ function(ginkgo_default_includes name) $ $ ) + if(DEFINED SYCL_INCLUDE_PATH) + # avoid -fsycl in all place + target_include_directories("${name}" PUBLIC ${SYCL_INCLUDE_PATH}) + endif() if(GINKGO_HAVE_HWLOC) target_include_directories("${name}" PUBLIC @@ -139,7 +143,8 @@ function(ginkgo_extract_dpcpp_version DPCPP_COMPILER GINKGO_DPCPP_VERSION MACRO_ "int main() {std::cout << ${MACRO_VAR} << '\\n'\;" "return 0\;}") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/extract_dpcpp_ver.cpp" ${DPCPP_VERSION_PROG}) - execute_process(COMMAND ${DPCPP_COMPILER} ${CMAKE_CURRENT_BINARY_DIR}/extract_dpcpp_ver.cpp + # we always add -fsycl + execute_process(COMMAND ${DPCPP_COMPILER} -fsycl ${CMAKE_CURRENT_BINARY_DIR}/extract_dpcpp_ver.cpp -o ${CMAKE_CURRENT_BINARY_DIR}/extract_dpcpp_ver ERROR_VARIABLE DPCPP_EXTRACT_VER_ERROR) execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/extract_dpcpp_ver diff --git a/cmake/create_test.cmake b/cmake/create_test.cmake index cec47fced74..55b70bbaeaa 100644 --- a/cmake/create_test.cmake +++ b/cmake/create_test.cmake @@ -124,6 +124,7 @@ function(ginkgo_create_dpcpp_test test_name) add_executable(${test_target_name} ${test_name}.dp.cpp) target_compile_features(${test_target_name} PUBLIC cxx_std_17) target_compile_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS}) + target_link_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS}) target_link_options(${test_target_name} PRIVATE -fsycl-device-code-split=per_kernel) ginkgo_set_test_target_properties(${test_target_name} "_dpcpp" ${ARGN}) ginkgo_add_test(${test_name} ${test_target_name} ${ARGN} RESOURCE_TYPE sycl) @@ -298,6 +299,7 @@ function(ginkgo_create_common_device_test test_name) ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN}) target_compile_features(${test_target_name}_dpcpp PRIVATE cxx_std_17) target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) + target_link_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) target_link_options(${test_target_name}_dpcpp PRIVATE -fsycl-device-lib=all -fsycl-device-code-split=per_kernel) endif() if(GINKGO_BUILD_OMP) diff --git a/dpcpp/CMakeLists.txt b/dpcpp/CMakeLists.txt index 4099bb603a3..9d0952480be 100644 --- a/dpcpp/CMakeLists.txt +++ b/dpcpp/CMakeLists.txt @@ -88,8 +88,10 @@ configure_file(preconditioner/jacobi_common.hpp.in preconditioner/jacobi_common. ginkgo_compile_features(ginkgo_dpcpp) target_compile_definitions(ginkgo_dpcpp PRIVATE GKO_COMPILING_DPCPP _ONEDPL_COMPILE_KERNEL=0) +set(GINKGO_DPCPP_FLAGS "-fsycl") set(GINKGO_DPCPP_FLAGS ${GINKGO_DPCPP_FLAGS} PARENT_SCOPE) target_compile_options(ginkgo_dpcpp PRIVATE "${GINKGO_DPCPP_FLAGS}") +target_link_options(ginkgo_dpcpp PRIVATE "${GINKGO_DPCPP_FLAGS}") target_compile_options(ginkgo_dpcpp PRIVATE "${GINKGO_COMPILER_FLAGS}") # Note: add MKL as PRIVATE not PUBLIC (MKL example shows) to avoid propagating # find_package(MKL) everywhere when linking ginkgo (see the MKL example diff --git a/test/solver/CMakeLists.txt b/test/solver/CMakeLists.txt index 4cec6b05d22..3231956beb7 100644 --- a/test/solver/CMakeLists.txt +++ b/test/solver/CMakeLists.txt @@ -13,3 +13,6 @@ ginkgo_create_common_test(lower_trs_kernels DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(multigrid_kernels DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(solver DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(upper_trs_kernels DISABLE_EXECUTORS dpcpp) +if(GINKGO_BUILD_DPCPP) + target_link_options(test_solver_idr_kernels_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) +endif() diff --git a/third_party/gtest/CMakeLists.txt b/third_party/gtest/CMakeLists.txt index 45b564dbfbf..378a7cdc705 100644 --- a/third_party/gtest/CMakeLists.txt +++ b/third_party/gtest/CMakeLists.txt @@ -22,7 +22,7 @@ set_target_properties(gtest gtest_main PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") # If CXX compiler is dpcpp, use -ffp-model=precise # Otherwise, it will throw src/gtest.cc:1583:8: error: comparison with NaN always evaluates to false in fast floating point modes -if(CMAKE_CXX_COMPILER MATCHES "dpcpp") +if(CMAKE_CXX_COMPILER MATCHES "dpcpp|icpx") target_compile_options(gtest PRIVATE "-ffp-model=precise") target_compile_options(gtest_main PRIVATE "-ffp-model=precise") endif() From c00d20ed1bfdab62c44a93449990f1e0b4bc0eef Mon Sep 17 00:00:00 2001 From: "Yu-Hsiang M. Tsai" Date: Mon, 21 Aug 2023 09:41:42 +0200 Subject: [PATCH 2/5] add gko_add_sycl_to_target --- .github/workflows/intel.yml | 1 - .gitlab-ci.yml | 17 ++++++++++++++++- CMakeLists.txt | 5 +++-- benchmark/CMakeLists.txt | 2 +- cmake/build_helpers.cmake | 4 ---- cmake/create_test.cmake | 6 ++++-- cmake/sycl.cmake | 33 +++++++++++++++++++++++++++++++++ dpcpp/CMakeLists.txt | 6 ++++-- test/solver/CMakeLists.txt | 2 +- 9 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 cmake/sycl.cmake diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index 4652b3996e1..db18b510e21 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -6,7 +6,6 @@ on: - 'master' - 'develop' - 'release/**' - - 'icpx_compilation' tags: - '**' pull_request: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6185608864f..e1f1eb8be3d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -581,7 +581,7 @@ build/nocuda-nomixed/nompi/clang/omp/debug/static: BUILD_SHARED_LIBS: "OFF" MIXED_PRECISION: "OFF" -build/dpcpp/2022-1/cpu/release/static: +build/dpcpp/2022-1/cpu/release/shared: extends: - .build_and_test_template - .default_variables @@ -665,6 +665,21 @@ build/dpcpp/level_zero_dgpu/release/shared: DPCPP_SINGLE_MODE: "ON" ONEAPI_DEVICE_SELECTOR: "level_zero:gpu" +build/icpx/level_zero_dgpu/release/shared: + extends: + - .build_and_test_template + - .default_variables + - .quick_test_condition + - .use_gko-oneapi-dgpu + variables: + C_COMPILER: "icx" + CXX_COMPILER: "icpx" + BUILD_DPCPP: "ON" + GKO_COMPILER_FLAGS: "-ffp-model=precise" + BUILD_TYPE: "Release" + DPCPP_SINGLE_MODE: "ON" + ONEAPI_DEVICE_SELECTOR: "level_zero:gpu" + # Job with important warnings as error warnings: stage: code_quality diff --git a/CMakeLists.txt b/CMakeLists.txt index 4608b010720..507ef561f64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,9 @@ endif() if(GINKGO_BUILD_HIP) include(cmake/hip.cmake) endif() +if(GINKGO_BUILD_DPCPP) + include(cmake/sycl.cmake) +endif() if(GINKGO_BUILD_OMP) find_package(OpenMP 3.0 REQUIRED) endif() @@ -298,8 +301,6 @@ endif() if(GINKGO_BUILD_DPCPP) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_MAJOR_VERSION __LIBSYCL_MAJOR_VERSION) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_VERSION __SYCL_COMPILER_VERSION) - get_filename_component(GINKGO_SYCL_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) - set(SYCL_INCLUDE_PATH "${GINKGO_SYCL_DIR}/../include;${GINKGO_SYCL_DIR}/../include/sycl") else() set(GINKGO_DPCPP_MAJOR_VERSION "0") endif() diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 7a4f5b1ca43..5cffddd51aa 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -141,7 +141,7 @@ if (GINKGO_BUILD_DPCPP) ginkgo_benchmark_onemkl_linops(c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION) add_library(dpcpp_timer utils/dpcpp_timer.dp.cpp) target_compile_options(dpcpp_timer PRIVATE ${GINKGO_DPCPP_FLAGS}) - target_link_options(dpcpp_timer PRIVATE ${GINKGO_DPCPP_FLAGS}) + gko_add_sycl_to_target(TARGET dpcpp_timer SOURCES utils/dpcpp_timer.dp.cpp) target_link_libraries(dpcpp_timer ginkgo) endif() diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 25add05c60f..34189a09450 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -9,10 +9,6 @@ function(ginkgo_default_includes name) $ $ ) - if(DEFINED SYCL_INCLUDE_PATH) - # avoid -fsycl in all place - target_include_directories("${name}" PUBLIC ${SYCL_INCLUDE_PATH}) - endif() if(GINKGO_HAVE_HWLOC) target_include_directories("${name}" PUBLIC diff --git a/cmake/create_test.cmake b/cmake/create_test.cmake index 55b70bbaeaa..3794a8026e1 100644 --- a/cmake/create_test.cmake +++ b/cmake/create_test.cmake @@ -124,7 +124,7 @@ function(ginkgo_create_dpcpp_test test_name) add_executable(${test_target_name} ${test_name}.dp.cpp) target_compile_features(${test_target_name} PUBLIC cxx_std_17) target_compile_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS}) - target_link_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS}) + gko_add_sycl_to_target(TARGET ${test_target_name} SOURCES ${test_name}.dp.cpp) target_link_options(${test_target_name} PRIVATE -fsycl-device-code-split=per_kernel) ginkgo_set_test_target_properties(${test_target_name} "_dpcpp" ${ARGN}) ginkgo_add_test(${test_name} ${test_target_name} ${ARGN} RESOURCE_TYPE sycl) @@ -299,7 +299,9 @@ function(ginkgo_create_common_device_test test_name) ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN}) target_compile_features(${test_target_name}_dpcpp PRIVATE cxx_std_17) target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) - target_link_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) + # We need to use a new file to avoid sycl setting in other backends because add_sycl_to_target will change the source property. + configure_file(${test_name}.cpp ${test_name}.dp.cpp COPYONLY) + gko_add_sycl_to_target(TARGET ${test_target_name}_dpcpp SOURCES ${test_name}.dp.cpp) target_link_options(${test_target_name}_dpcpp PRIVATE -fsycl-device-lib=all -fsycl-device-code-split=per_kernel) endif() if(GINKGO_BUILD_OMP) diff --git a/cmake/sycl.cmake b/cmake/sycl.cmake new file mode 100644 index 00000000000..b0f4eab91f1 --- /dev/null +++ b/cmake/sycl.cmake @@ -0,0 +1,33 @@ +# IntelSYCL for dpcpp and icpx if the config is existed and cmake reaches the requirement +if(CMAKE_CXX_COMPILER MATCHES "dpcpp|icpx") + if(CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.25) + find_package(IntelSYCL QUIET) + elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20.5) + find_package(IntelSYCL QUIET) + endif() +endif() +# If we do not have the config from compiler, try to set components to make it work. +if(NOT COMMAND add_sycl_to_target) + if(NOT DEFINED SYCL_FLAGS) + set(SYCL_FLAGS "-fsycl" CACHE STRING "SYCL flags for compiler") + endif() +endif() + +# Provide a uniform way for those package without add_sycl_to_target +function(gko_add_sycl_to_target) + if(COMMAND add_sycl_to_target) + add_sycl_to_target(${ARGN}) + return() + endif() + # We handle them by adding SYCL_FLAGS to compile and link to the target + set(one_value_args TARGET) + set(multi_value_args SOURCES) + cmake_parse_arguments(SYCL + "" + "${one_value_args}" + "${multi_value_args}" + ${ARGN}) + target_compile_options(${SYCL_TARGET} PRIVATE "${SYCL_FLAGS}") + target_link_options(${SYCL_TARGET} PRIVATE "${SYCL_FLAGS}") +endfunction() + diff --git a/dpcpp/CMakeLists.txt b/dpcpp/CMakeLists.txt index 9d0952480be..0041b7cbd18 100644 --- a/dpcpp/CMakeLists.txt +++ b/dpcpp/CMakeLists.txt @@ -88,10 +88,12 @@ configure_file(preconditioner/jacobi_common.hpp.in preconditioner/jacobi_common. ginkgo_compile_features(ginkgo_dpcpp) target_compile_definitions(ginkgo_dpcpp PRIVATE GKO_COMPILING_DPCPP _ONEDPL_COMPILE_KERNEL=0) -set(GINKGO_DPCPP_FLAGS "-fsycl") set(GINKGO_DPCPP_FLAGS ${GINKGO_DPCPP_FLAGS} PARENT_SCOPE) target_compile_options(ginkgo_dpcpp PRIVATE "${GINKGO_DPCPP_FLAGS}") -target_link_options(ginkgo_dpcpp PRIVATE "${GINKGO_DPCPP_FLAGS}") +# all file in target ginkgo_dpcpp are necessarily compiled with sycl, so we can ignore the warning. +# If we would like to use SOURCES, please use the new files copied from GKO_UNIFIED_COMMON_SOURCES. +# Otherwise, the source's properties will be changed by add_sycl_to_target +gko_add_sycl_to_target(TARGET ginkgo_dpcpp) target_compile_options(ginkgo_dpcpp PRIVATE "${GINKGO_COMPILER_FLAGS}") # Note: add MKL as PRIVATE not PUBLIC (MKL example shows) to avoid propagating # find_package(MKL) everywhere when linking ginkgo (see the MKL example diff --git a/test/solver/CMakeLists.txt b/test/solver/CMakeLists.txt index 3231956beb7..f870ecfbf19 100644 --- a/test/solver/CMakeLists.txt +++ b/test/solver/CMakeLists.txt @@ -14,5 +14,5 @@ ginkgo_create_common_test(multigrid_kernels DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(solver DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(upper_trs_kernels DISABLE_EXECUTORS dpcpp) if(GINKGO_BUILD_DPCPP) - target_link_options(test_solver_idr_kernels_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) + gko_add_sycl_to_target(TARGET test_solver_idr_kernels_dpcpp SOURCES idr_kernels.cpp) endif() From bde2a8a41e237441343d58dddc45aaef929e9662 Mon Sep 17 00:00:00 2001 From: "Yuhsiang M. Tsai" Date: Mon, 21 Aug 2023 22:55:52 +0200 Subject: [PATCH 3/5] rename GINKGO_BUILD_DPCPP to GINKGO_BUILD_SYCL Co-authored-by: Terry Cojean Co-authored-by: Tobias Ribizel --- .github/workflows/bot-pr-updated.yml | 2 +- .gitlab-ci.yml | 14 +++++++------- .gitlab/scripts.yml | 4 ++-- .gitlab/variables.yml | 1 + CMakeLists.txt | 16 ++++++++++------ INSTALL.md | 7 ++++--- README.md | 6 +++--- benchmark/CMakeLists.txt | 6 +++--- cmake/GinkgoConfig.cmake.in | 4 ++-- cmake/autodetect_executors.cmake | 6 +++--- cmake/create_test.cmake | 4 ++-- cmake/get_info.cmake | 4 ++-- cmake/rename.cmake | 25 +++++++++++++++++++++++++ core/device_hooks/CMakeLists.txt | 2 +- core/test/gtest/CMakeLists.txt | 2 +- doc/examples/examples.hpp.in | 2 +- test/solver/CMakeLists.txt | 2 +- 17 files changed, 69 insertions(+), 38 deletions(-) create mode 100644 cmake/rename.cmake diff --git a/.github/workflows/bot-pr-updated.yml b/.github/workflows/bot-pr-updated.yml index ae357c9db96..8554ca3b1e9 100644 --- a/.github/workflows/bot-pr-updated.yml +++ b/.github/workflows/bot-pr-updated.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest if: github.event.pull_request.author_association == 'COLLABORATOR' || github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'OWNER' env: - CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=DEBUG -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -DGINKGO_BUILD_HWLOC=OFF -DGINKGO_BUILD_REFERENCE=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_DPCPP=OFF + CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=DEBUG -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_BENCHMARKS=OFF -DGINKGO_BUILD_HWLOC=OFF -DGINKGO_BUILD_REFERENCE=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_SYCL=OFF steps: - name: Checkout the new code (shallow clone) uses: actions/checkout@v3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e1f1eb8be3d..ffd037e45ff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -590,7 +590,7 @@ build/dpcpp/2022-1/cpu/release/shared: variables: C_COMPILER: "gcc" CXX_COMPILER: "dpcpp" - BUILD_DPCPP: "ON" + BUILD_SYCL: "ON" GKO_COMPILER_FLAGS: "-ffp-model=precise" BUILD_TYPE: "Release" BUILD_SHARED_LIBS: "ON" @@ -609,7 +609,7 @@ build/dpcpp/igpu/release/shared: variables: C_COMPILER: "gcc" CXX_COMPILER: "dpcpp" - BUILD_DPCPP: "ON" + BUILD_SYCL: "ON" GKO_COMPILER_FLAGS: "-ffp-model=precise" BUILD_TYPE: "Release" BUILD_SHARED_LIBS: "ON" @@ -626,7 +626,7 @@ build/dpcpp/igpu/release/shared: # variables: # C_COMPILER: "gcc" # CXX_COMPILER: "dpcpp" -# BUILD_DPCPP: "ON" +# BUILD_SYCL: "ON" # GKO_COMPILER_FLAGS: "-ffp-model=precise" # BUILD_TYPE: "Debug" # BUILD_SHARED_LIBS: "ON" @@ -643,7 +643,7 @@ build/dpcpp/dgpu/release/static: variables: C_COMPILER: "gcc" CXX_COMPILER: "dpcpp" - BUILD_DPCPP: "ON" + BUILD_SYCL: "ON" GKO_COMPILER_FLAGS: "-ffp-model=precise" BUILD_TYPE: "Release" BUILD_SHARED_LIBS: "OF" @@ -659,7 +659,7 @@ build/dpcpp/level_zero_dgpu/release/shared: variables: C_COMPILER: "gcc" CXX_COMPILER: "dpcpp" - BUILD_DPCPP: "ON" + BUILD_SYCL: "ON" GKO_COMPILER_FLAGS: "-ffp-model=precise" BUILD_TYPE: "Release" DPCPP_SINGLE_MODE: "ON" @@ -674,7 +674,7 @@ build/icpx/level_zero_dgpu/release/shared: variables: C_COMPILER: "icx" CXX_COMPILER: "icpx" - BUILD_DPCPP: "ON" + BUILD_SYCL: "ON" GKO_COMPILER_FLAGS: "-ffp-model=precise" BUILD_TYPE: "Release" DPCPP_SINGLE_MODE: "ON" @@ -834,7 +834,7 @@ gh-pages: -DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=ON ${EXTRA_CMAKE_FLAGS} -DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_BUILD_REFERENCE=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_BUILD_CUDA=OFF - -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_DPCPP=OFF -DGINKGO_BUILD_MPI=OFF + -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_SYCL=OFF -DGINKGO_BUILD_MPI=OFF -DGINKGO_BUILD_TESTS=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_DOC=ON -DGINKGO_DOC_GENERATE_PDF=ON - make usr diff --git a/.gitlab/scripts.yml b/.gitlab/scripts.yml index 15a2004bde6..504aa7dad40 100644 --- a/.gitlab/scripts.yml +++ b/.gitlab/scripts.yml @@ -40,7 +40,7 @@ -DGINKGO_COMPILER_FLAGS=${GKO_COMPILER_FLAGS} -DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_BUILD_REFERENCE=${BUILD_REFERENCE} -DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA} - -DGINKGO_BUILD_HIP=${BUILD_HIP} + -DGINKGO_BUILD_HIP=${BUILD_HIP} -DGINKGO_BUILD_SYCL=${BUILD_SYCL} -DGINKGO_BUILD_MPI=${BUILD_MPI} ${MPI_STR} -DGINKGO_BUILD_HWLOC=${BUILD_HWLOC} -DGINKGO_BUILD_PAPI_SDE=${BUILD_PAPI_SDE} @@ -85,7 +85,7 @@ -DGINKGO_COMPILER_FLAGS=${GKO_COMPILER_FLAGS} -DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_BUILD_REFERENCE=${BUILD_REFERENCE} -DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA} - -DGINKGO_BUILD_HIP=${BUILD_HIP} + -DGINKGO_BUILD_HIP=${BUILD_HIP} -DGINKGO_BUILD_SYCL=${BUILD_SYCL} -DGINKGO_BUILD_MPI=${BUILD_MPI} ${MPI_STR} -DGINKGO_BUILD_HWLOC=${BUILD_HWLOC} -DGINKGO_BUILD_PAPI_SDE=${BUILD_PAPI_SDE} diff --git a/.gitlab/variables.yml b/.gitlab/variables.yml index 2316b5abc71..6c75d60d069 100644 --- a/.gitlab/variables.yml +++ b/.gitlab/variables.yml @@ -11,6 +11,7 @@ BUILD_OMP: "OFF" BUILD_CUDA: "OFF" BUILD_HIP: "OFF" + BUILD_SYCL: "OFF" BUILD_HWLOC: "ON" BUILD_PAPI_SDE: "OFF" BUILD_MPI: "OFF" diff --git a/CMakeLists.txt b/CMakeLists.txt index 507ef561f64..a458714ba82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ include(cmake/autodetect_executors.cmake) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/") include(cmake/autodetect_system_libs.cmake) +# rename helper +include(cmake/rename.cmake) + # Ginkgo configuration options option(GINKGO_DEVEL_TOOLS "Add development tools to the build system" OFF) option(GINKGO_BUILD_TESTS "Generate build files for unit tests" ON) @@ -21,8 +24,9 @@ option(GINKGO_BUILD_BENCHMARKS "Build Ginkgo's benchmarks" ON) option(GINKGO_BUILD_REFERENCE "Compile reference CPU kernels" ON) option(GINKGO_BUILD_OMP "Compile OpenMP kernels for CPU" ${GINKGO_HAS_OMP}) option(GINKGO_BUILD_MPI "Compile the MPI module" ${GINKGO_HAS_MPI}) -option(GINKGO_BUILD_DPCPP - "Compile DPC++ kernels for Intel GPUs or other DPC++ enabled hardware" ${GINKGO_HAS_DPCPP}) +gko_rename_cache(GINKGO_BUILD_DPCPP GINKGO_BUILD_SYCL BOOL) +option(GINKGO_BUILD_SYCL + "Compile SYCL kernels for Intel GPUs or other SYCL enabled hardware" ${GINKGO_HAS_SYCL}) option(GINKGO_BUILD_CUDA "Compile kernels for NVIDIA GPUs" ${GINKGO_HAS_CUDA}) option(GINKGO_BUILD_HIP "Compile kernels for AMD or NVIDIA GPUs" ${GINKGO_HAS_HIP}) option(GINKGO_BUILD_DOC "Generate documentation" OFF) @@ -50,7 +54,7 @@ set(GINKGO_VERBOSE_LEVEL "1" CACHE STRING if(MSVC) set(GINKGO_COMPILER_FLAGS "" CACHE STRING "Set the required CXX compiler flags, mainly used for warnings. Current default is ``") -elseif(GINKGO_BUILD_DPCPP OR CMAKE_CXX_COMPILER MATCHES "dpcpp|icpx") +elseif(GINKGO_BUILD_SYCL OR CMAKE_CXX_COMPILER MATCHES "dpcpp|icpx") # For now always use `-ffp-model=precise` with DPC++. This can be removed when # the floating point issues are fixed. set(GINKGO_COMPILER_FLAGS "-Wpedantic;-ffp-model=precise" CACHE STRING @@ -99,7 +103,7 @@ endif() if(GINKGO_BUILD_HIP) include(cmake/hip.cmake) endif() -if(GINKGO_BUILD_DPCPP) +if(GINKGO_BUILD_SYCL) include(cmake/sycl.cmake) endif() if(GINKGO_BUILD_OMP) @@ -298,7 +302,7 @@ if(MSVC) endif() endif() -if(GINKGO_BUILD_DPCPP) +if(GINKGO_BUILD_SYCL) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_MAJOR_VERSION __LIBSYCL_MAJOR_VERSION) ginkgo_extract_dpcpp_version(${CMAKE_CXX_COMPILER} GINKGO_DPCPP_VERSION __SYCL_COMPILER_VERSION) else() @@ -321,7 +325,7 @@ endif() if(GINKGO_BUILD_HIP) add_subdirectory(hip) # High-performance kernels for AMD or NVIDIA GPUs endif() -if(GINKGO_BUILD_DPCPP) +if(GINKGO_BUILD_SYCL) add_subdirectory(dpcpp) # High-performance DPC++ kernels endif() if(GINKGO_BUILD_OMP) diff --git a/INSTALL.md b/INSTALL.md index b29358d4eb6..4da58010ba8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,9 +42,10 @@ Ginkgo adds the following additional switches to control what is being built: * `-DGINKGO_BUILD_CUDA={ON, OFF}` builds optimized cuda versions of the kernels (requires CUDA), default is `ON` if a CUDA compiler could be detected, `OFF` otherwise. -* `-DGINKGO_BUILD_DPCPP={ON, OFF}` builds optimized DPC++ versions of the - kernels (requires `CMAKE_CXX_COMPILER` to be set to the `dpcpp` compiler). - The default is `ON` if `CMAKE_CXX_COMPILER` is a DPC++ compiler, `OFF` +* `-DGINKGO_BUILD_DPCPP={ON, OFF}` is deprecated. Please use `GINKGO_BUILD_SYCL` instead. +* `-DGINKGO_BUILD_SYCL={ON, OFF}` builds optimized SYCL versions of the + kernels (requires `CMAKE_CXX_COMPILER` to be set to the `dpcpp` or `icpx` compiler). + The default is `ON` if `CMAKE_CXX_COMPILER` is a SYCL compiler, `OFF` otherwise. * `-DGINKGO_BUILD_HIP={ON, OFF}` builds optimized HIP versions of the kernels (requires HIP), default is `ON` if an installation of HIP could be detected, diff --git a/README.md b/README.md index b39765ca71f..48c7db0715f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Ginkgo is a high-performance linear algebra library for manycore systems, with a focus on the solution of sparse linear systems. It is implemented using modern C++ (you will need an at least C++14 compliant compiler to build it), with GPU kernels -implemented in CUDA, HIP, and DPC++. +implemented in CUDA, HIP, and DPC++(SYCL). Performance @@ -62,7 +62,7 @@ The Ginkgo HIP module has the following __additional__ requirements: * _10.1 <= CUDA < 11_ backend * if the hipFFT package is available, it is used to implement the FFT LinOps. -The Ginkgo DPC++ module has the following __additional__ requirements: +The Ginkgo DPC++(SYCL) module has the following __additional__ requirements: * _OneAPI 2021.3+_ * Set `dpcpp` or `icpx` as the `CMAKE_CXX_COMPILER` @@ -123,7 +123,7 @@ cmake -G "Unix Makefiles" .. && make By default, `GINKGO_BUILD_REFERENCE` is enabled. You should be able to run examples with this executor. By default, Ginkgo tries to enable the relevant modules depending on your machine environment (present of CUDA, ...). You can -also explicitly compile with the OpenMP, CUDA, HIP or DPC++ modules enabled to +also explicitly compile with the OpenMP, CUDA, HIP or DPC++(SYCL) modules enabled to run the examples with these executors. Please refer to the [Installation page](./INSTALL.md) for more details. diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 5cffddd51aa..347ecec7699 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -67,7 +67,7 @@ function(ginkgo_add_single_benchmark_executable name use_lib_linops macro_def ty target_compile_definitions("${name}" PRIVATE HAS_HIP_TIMER=1) target_link_libraries("${name}" hip_timer) endif() - if (GINKGO_BUILD_DPCPP) + if (GINKGO_BUILD_SYCL) target_compile_definitions("${name}" PRIVATE HAS_DPCPP_TIMER=1) target_link_libraries("${name}" dpcpp_timer) endif() @@ -87,7 +87,7 @@ function(ginkgo_add_single_benchmark_executable name use_lib_linops macro_def ty target_compile_definitions("${name}" PRIVATE HAS_HIP=1) target_link_libraries("${name}" hipsparse_linops_${type}) endif() - if (GINKGO_BUILD_DPCPP) + if (GINKGO_BUILD_SYCL) target_compile_definitions("${name}" PRIVATE HAS_DPCPP=1) target_link_libraries("${name}" onemkl_linops_${type}) endif() @@ -134,7 +134,7 @@ if (GINKGO_BUILD_HIP) target_link_libraries(hip_timer ginkgo) endif() -if (GINKGO_BUILD_DPCPP) +if (GINKGO_BUILD_SYCL) ginkgo_benchmark_onemkl_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION) ginkgo_benchmark_onemkl_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION) ginkgo_benchmark_onemkl_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION) diff --git a/cmake/GinkgoConfig.cmake.in b/cmake/GinkgoConfig.cmake.in index 352cf1dde8d..41f3b8f2879 100644 --- a/cmake/GinkgoConfig.cmake.in +++ b/cmake/GinkgoConfig.cmake.in @@ -37,7 +37,7 @@ set(GINKGO_BUILD_OMP @GINKGO_BUILD_OMP@) set(GINKGO_BUILD_CUDA @GINKGO_BUILD_CUDA@) set(GINKGO_BUILD_HIP @GINKGO_BUILD_HIP@) set(GINKGO_BUILD_MPI @GINKGO_BUILD_MPI@) -set(GINKGO_BUILD_DPCPP @GINKGO_BUILD_DPCPP@) +set(GINKGO_BUILD_SYCL @GINKGO_BUILD_SYCL@) set(GINKGO_DEVEL_TOOLS @GINKGO_DEVEL_TOOLS@) set(GINKGO_BUILD_TESTS @GINKGO_BUILD_TESTS@) @@ -184,7 +184,7 @@ if((NOT GINKGO_BUILD_SHARED_LIBS) AND GINKGO_BUILD_HIP) endif() endif() -if((NOT GINKGO_BUILD_SHARED_LIBS) AND GINKGO_BUILD_DPCPP) +if((NOT GINKGO_BUILD_SHARED_LIBS) AND GINKGO_BUILD_SYCL) find_package(MKL CONFIG REQUIRED HINTS "${GINKGO_MKL_ROOT}") find_package(oneDPL REQUIRED HINTS "${GINKGO_DPL_ROOT}") endif() diff --git a/cmake/autodetect_executors.cmake b/cmake/autodetect_executors.cmake index 86949cecda9..757262f1ea1 100644 --- a/cmake/autodetect_executors.cmake +++ b/cmake/autodetect_executors.cmake @@ -1,7 +1,7 @@ set(GINKGO_HAS_OMP OFF) set(GINKGO_HAS_MPI OFF) set(GINKGO_HAS_CUDA OFF) -set(GINKGO_HAS_DPCPP OFF) +set(GINKGO_HAS_SYCL OFF) set(GINKGO_HAS_HIP OFF) include(CheckLanguage) @@ -37,7 +37,7 @@ if (NOT DEFINED GINKGO_BUILD_HIP) endif() endif() -if (NOT DEFINED GINKGO_BUILD_DPCPP) +if (NOT DEFINED GINKGO_BUILD_DPCPP AND NOT DEFINED GINKGO_BUILD_SYCL) try_compile(GKO_CAN_COMPILE_DPCPP ${PROJECT_BINARY_DIR}/dpcpp SOURCES ${PROJECT_SOURCE_DIR}/dpcpp/test_dpcpp.dp.cpp # try_compile will pass the project CMAKE_CXX_FLAGS so passing -DCMAKE_CXX_FLAGS does not affect it. @@ -47,6 +47,6 @@ if (NOT DEFINED GINKGO_BUILD_DPCPP) CXX_STANDARD 17) if (GKO_CAN_COMPILE_DPCPP) message(STATUS "Enabling DPCPP executor") - set(GINKGO_HAS_DPCPP ON) + set(GINKGO_HAS_SYCL ON) endif() endif() diff --git a/cmake/create_test.cmake b/cmake/create_test.cmake index 3794a8026e1..522ad5f2ba7 100644 --- a/cmake/create_test.cmake +++ b/cmake/create_test.cmake @@ -247,7 +247,7 @@ function(ginkgo_create_common_test test_name) if(GINKGO_BUILD_CUDA) ginkgo_create_common_test_internal(${test_name} CudaExecutor cuda ${ARGN}) endif() - if(GINKGO_BUILD_DPCPP) + if(GINKGO_BUILD_SYCL) ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN}) endif() endfunction(ginkgo_create_common_test) @@ -295,7 +295,7 @@ endfunction(ginkgo_create_common_test_internal) function(ginkgo_create_common_device_test test_name) cmake_parse_arguments(PARSE_ARGV 1 common_device_test "" "${gko_test_single_args}" "${gko_test_multi_args}") ginkgo_build_test_name(${test_name} test_target_name) - if(GINKGO_BUILD_DPCPP) + if(GINKGO_BUILD_SYCL) ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN}) target_compile_features(${test_target_name}_dpcpp PRIVATE cxx_std_17) target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) diff --git a/cmake/get_info.cmake b/cmake/get_info.cmake index 2dd068abb50..6b904189151 100644 --- a/cmake/get_info.cmake +++ b/cmake/get_info.cmake @@ -127,7 +127,7 @@ foreach(log_type ${log_types}) ginkgo_print_module_footer(${${log_type}} "User configuration:") ginkgo_print_module_footer(${${log_type}} " Enabled modules:") ginkgo_print_foreach_variable(${${log_type}} - "GINKGO_BUILD_OMP;GINKGO_BUILD_MPI;GINKGO_BUILD_REFERENCE;GINKGO_BUILD_CUDA;GINKGO_BUILD_HIP;GINKGO_BUILD_DPCPP") + "GINKGO_BUILD_OMP;GINKGO_BUILD_MPI;GINKGO_BUILD_REFERENCE;GINKGO_BUILD_CUDA;GINKGO_BUILD_HIP;GINKGO_BUILD_SYCL") ginkgo_print_module_footer(${${log_type}} " Enabled features:") ginkgo_print_foreach_variable(${${log_type}} "GINKGO_MIXED_PRECISION;GINKGO_HAVE_GPU_AWARE_MPI") @@ -167,7 +167,7 @@ IF(GINKGO_BUILD_HIP) include(hip/get_info.cmake) ENDIF() -IF(GINKGO_BUILD_DPCPP) +IF(GINKGO_BUILD_SYCL) include(dpcpp/get_info.cmake) ENDIF() diff --git a/cmake/rename.cmake b/cmake/rename.cmake new file mode 100644 index 00000000000..d9837b84a1b --- /dev/null +++ b/cmake/rename.cmake @@ -0,0 +1,25 @@ +# Only for CACHE variable (option) +macro(gko_rename_cache deprecated actual type) + if(DEFINED ${deprecated}) + if(DEFINED ${actual}) + message("actual ${actual} and deprecated ${deprecated}") + if("${${actual}}" STREQUAL "${${deprecated}}") + # They are the same, so only throw warning + message(WARNING "${deprecated} was deprecated, please only use ${actual} instead.") + else() + # They are different + set(${deprecated}_copy ${${deprecated}}) + unset(${deprecated} CACHE) + message(FATAL_ERROR "Both ${deprecated} and ${actual} were specified, please use ${actual} instead. " + "We remove ${deprecated}:${${deprecated}_copy} and keep ${actual}:${${actual}}") + endif() + else() + # Only set `deprecated`, move it to `actual`. + message(WARNING "${deprecated} was deprecated, please use ${actual} instead. " + "We copy ${${deprecated}} to ${actual} and unset ${deprecated}.") + set(${actual} ${${deprecated}} CACHE ${type} "") + endif() + # We always unset the deprecated for easier next setup + unset(${deprecated} CACHE) + endif() +endmacro() \ No newline at end of file diff --git a/core/device_hooks/CMakeLists.txt b/core/device_hooks/CMakeLists.txt index 901acef7797..573f87fad93 100644 --- a/core/device_hooks/CMakeLists.txt +++ b/core/device_hooks/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT GINKGO_BUILD_CUDA) ginkgo_install_library(ginkgo_cuda) endif() -if (NOT GINKGO_BUILD_DPCPP) +if (NOT GINKGO_BUILD_SYCL) add_library(ginkgo_dpcpp $ dpcpp_hooks.cpp) diff --git a/core/test/gtest/CMakeLists.txt b/core/test/gtest/CMakeLists.txt index 6d77b663e84..cdfc67fafdf 100644 --- a/core/test/gtest/CMakeLists.txt +++ b/core/test/gtest/CMakeLists.txt @@ -27,6 +27,6 @@ endif() if (GINKGO_BUILD_HIP) add_gtest_main("_hip" "GKO_COMPILING_HIP") endif() -if (GINKGO_BUILD_DPCPP) +if (GINKGO_BUILD_SYCL) add_gtest_main("_dpcpp" "GKO_COMPILING_DPCPP") endif() diff --git a/doc/examples/examples.hpp.in b/doc/examples/examples.hpp.in index a75ac59f186..7234a3ca8aa 100644 --- a/doc/examples/examples.hpp.in +++ b/doc/examples/examples.hpp.in @@ -64,7 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
    *
  1. -DGINKGO_BUILD_CUDA=ON option for NVIDIA GPUs. *
  2. -DGINKGO_BUILD_HIP=ON option for AMD or NVIDIA GPUs. - *
  3. -DGINKGO_BUILD_DPCPP=ON option for Intel GPUs (and + *
  4. -DGINKGO_BUILD_SYCL=ON option for Intel GPUs (and * possibly any other platform). *
* diff --git a/test/solver/CMakeLists.txt b/test/solver/CMakeLists.txt index f870ecfbf19..3cfe2db8ac3 100644 --- a/test/solver/CMakeLists.txt +++ b/test/solver/CMakeLists.txt @@ -13,6 +13,6 @@ ginkgo_create_common_test(lower_trs_kernels DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(multigrid_kernels DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(solver DISABLE_EXECUTORS dpcpp) ginkgo_create_common_test(upper_trs_kernels DISABLE_EXECUTORS dpcpp) -if(GINKGO_BUILD_DPCPP) +if(GINKGO_BUILD_SYCL) gko_add_sycl_to_target(TARGET test_solver_idr_kernels_dpcpp SOURCES idr_kernels.cpp) endif() From c7bfeb44f9392604d756d1dc9ceb8325a46a9d78 Mon Sep 17 00:00:00 2001 From: "Yuhsiang M. Tsai" Date: Fri, 13 Oct 2023 10:09:53 +0200 Subject: [PATCH 4/5] do not delete deprecated var from CMake, keep doc Co-authored-by: Tobias Ribizel --- CMakeLists.txt | 2 +- cmake/rename.cmake | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a458714ba82..d4f6fa5376d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ option(GINKGO_BUILD_BENCHMARKS "Build Ginkgo's benchmarks" ON) option(GINKGO_BUILD_REFERENCE "Compile reference CPU kernels" ON) option(GINKGO_BUILD_OMP "Compile OpenMP kernels for CPU" ${GINKGO_HAS_OMP}) option(GINKGO_BUILD_MPI "Compile the MPI module" ${GINKGO_HAS_MPI}) -gko_rename_cache(GINKGO_BUILD_DPCPP GINKGO_BUILD_SYCL BOOL) +gko_rename_cache(GINKGO_BUILD_DPCPP GINKGO_BUILD_SYCL BOOL "Compile SYCL kernels for Intel GPUs or other SYCL enabled hardware") option(GINKGO_BUILD_SYCL "Compile SYCL kernels for Intel GPUs or other SYCL enabled hardware" ${GINKGO_HAS_SYCL}) option(GINKGO_BUILD_CUDA "Compile kernels for NVIDIA GPUs" ${GINKGO_HAS_CUDA}) diff --git a/cmake/rename.cmake b/cmake/rename.cmake index d9837b84a1b..6c386bc24c6 100644 --- a/cmake/rename.cmake +++ b/cmake/rename.cmake @@ -1,5 +1,5 @@ # Only for CACHE variable (option) -macro(gko_rename_cache deprecated actual type) +macro(gko_rename_cache deprecated actual type doc_string) if(DEFINED ${deprecated}) if(DEFINED ${actual}) message("actual ${actual} and deprecated ${deprecated}") @@ -8,18 +8,13 @@ macro(gko_rename_cache deprecated actual type) message(WARNING "${deprecated} was deprecated, please only use ${actual} instead.") else() # They are different - set(${deprecated}_copy ${${deprecated}}) - unset(${deprecated} CACHE) - message(FATAL_ERROR "Both ${deprecated} and ${actual} were specified, please use ${actual} instead. " - "We remove ${deprecated}:${${deprecated}_copy} and keep ${actual}:${${actual}}") + message(FATAL_ERROR "Both ${deprecated} and ${actual} were specified differently, please only use ${actual} instead.") endif() else() # Only set `deprecated`, move it to `actual`. message(WARNING "${deprecated} was deprecated, please use ${actual} instead. " - "We copy ${${deprecated}} to ${actual} and unset ${deprecated}.") - set(${actual} ${${deprecated}} CACHE ${type} "") + "We copy ${${deprecated}} to ${actual}") + set(${actual} ${${deprecated}} CACHE ${type} "${doc_string}") endif() - # We always unset the deprecated for easier next setup - unset(${deprecated} CACHE) endif() endmacro() \ No newline at end of file From acf7a825760a731368fb85a730a5631a36f71702 Mon Sep 17 00:00:00 2001 From: "Yuhsiang M. Tsai" Date: Fri, 13 Oct 2023 10:47:20 +0200 Subject: [PATCH 5/5] adapt MKL and oneDPL env --- dpcpp/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dpcpp/CMakeLists.txt b/dpcpp/CMakeLists.txt index 0041b7cbd18..9990496c98f 100644 --- a/dpcpp/CMakeLists.txt +++ b/dpcpp/CMakeLists.txt @@ -1,7 +1,8 @@ -find_package(MKL CONFIG REQUIRED HINTS "$ENV{MKLROOT}") -set(GINKGO_MKL_ROOT "${MKL_ROOT}" PARENT_SCOPE) -find_package(oneDPL REQUIRED HINTS "$ENV{DPL_ROOT}") -set(GINKGO_DPL_ROOT "${DPL_ROOT}" PARENT_SCOPE) +find_package(MKL CONFIG REQUIRED HINTS "$ENV{MKLROOT}" "$ENV{MKL_ROOT}") +find_package(oneDPL REQUIRED HINTS "$ENV{DPL_ROOT}" "$ENV{DPLROOT}") +# use the parameter from cmake +set(GINKGO_MKL_ROOT "${MKL_DIR}" PARENT_SCOPE) +set(GINKGO_DPL_ROOT "${oneDPL_DIR}" PARENT_SCOPE) include(${PROJECT_SOURCE_DIR}/cmake/template_instantiation.cmake) add_instantiation_files(${PROJECT_SOURCE_DIR}/common/unified matrix/dense_kernels.instantiate.cpp DENSE_INSTANTIATE)