From 58908830db36a5a361597a159add93523b5624e5 Mon Sep 17 00:00:00 2001 From: "Grabovskaya, Ekaterina" Date: Thu, 11 Jul 2024 02:57:22 -0700 Subject: [PATCH 1/7] added -fsycl -fsycl-device-code-split=per_kernel at the linking stage to have device code --- examples/rng/device/CMakeLists.txt | 4 ++++ tests/unit_tests/rng/device/moments/CMakeLists.txt | 10 +++++++--- tests/unit_tests/rng/device/service/CMakeLists.txt | 10 +++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/rng/device/CMakeLists.txt b/examples/rng/device/CMakeLists.txt index b72f51085..1b6ecf2dd 100644 --- a/examples/rng/device/CMakeLists.txt +++ b/examples/rng/device/CMakeLists.txt @@ -59,6 +59,10 @@ foreach(rng_device_source ${RNG_DEVICE_SOURCES}) ONEMKL::SYCL::SYCL ) + if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") + target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) + endif() + # Register example as ctest foreach(device_filter ${DEVICE_FILTERS}) add_test(NAME ${domain}/EXAMPLE/DEVICE/${rng_device_source}/${device_filter} COMMAND example_${domain}_${rng_device_source}) diff --git a/tests/unit_tests/rng/device/moments/CMakeLists.txt b/tests/unit_tests/rng/device/moments/CMakeLists.txt index 11f796fef..2da8033bf 100644 --- a/tests/unit_tests/rng/device/moments/CMakeLists.txt +++ b/tests/unit_tests/rng/device/moments/CMakeLists.txt @@ -18,9 +18,9 @@ #=============================================================================== # Build object from all test sources -set(SERVICE_TESTS_SOURCES "moments.cpp") +set(MOMENTS_DEVICE_TESTS_SOURCES "moments.cpp") -add_library(rng_device_moments_ct OBJECT ${SERVICE_TESTS_SOURCES}) +add_library(rng_device_moments_ct OBJECT ${MOMENTS_DEVICE_TESTS_SOURCES}) target_compile_options(rng_device_moments_ct PRIVATE -DNOMINMAX) target_include_directories(rng_device_moments_ct PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include @@ -30,7 +30,11 @@ target_include_directories(rng_device_moments_ct PUBLIC ${CMAKE_BINARY_DIR}/bin ) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET rng_device_moments_ct SOURCES ${SERVICE_TESTS_SOURCES}) + add_sycl_to_target(TARGET rng_device_moments_ct SOURCES ${MOMENTS_DEVICE_TESTS_SOURCES}) else() target_link_libraries(rng_device_moments_ct PUBLIC ONEMKL::SYCL::SYCL) endif() + +if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") + target_link_options(rng_device_moments_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) +endif() diff --git a/tests/unit_tests/rng/device/service/CMakeLists.txt b/tests/unit_tests/rng/device/service/CMakeLists.txt index a481f2559..03d960e1a 100644 --- a/tests/unit_tests/rng/device/service/CMakeLists.txt +++ b/tests/unit_tests/rng/device/service/CMakeLists.txt @@ -18,9 +18,9 @@ #=============================================================================== # Build object from all test sources -set(SERVICE_TESTS_SOURCES "skip_ahead.cpp") +set(SERVICE_DEVICE_TESTS_SOURCES "skip_ahead.cpp") -add_library(rng_device_service_ct OBJECT ${SERVICE_TESTS_SOURCES}) +add_library(rng_device_service_ct OBJECT ${SERVICE_DEVICE_TESTS_SOURCES}) target_compile_options(rng_device_service_ct PRIVATE -DNOMINMAX) target_include_directories(rng_device_service_ct PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include @@ -30,7 +30,11 @@ target_include_directories(rng_device_service_ct PUBLIC ${CMAKE_BINARY_DIR}/bin ) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET rng_device_service_ct SOURCES ${SERVICE_TESTS_SOURCES}) + add_sycl_to_target(TARGET rng_device_service_ct SOURCES ${SERVICE_DEVICE_TESTS_SOURCES}) else() target_link_libraries(rng_device_service_ct PUBLIC ONEMKL::SYCL::SYCL) endif() + +if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") + target_link_options(rng_device_service_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) +endif() From ff92b2527e546e29381abfbf1ba2e3c67d81d3db Mon Sep 17 00:00:00 2001 From: "Grabovskaya, Ekaterina" Date: Mon, 15 Jul 2024 06:14:20 -0700 Subject: [PATCH 2/7] using is_dpcpp instead of (NOT STREQUAL hipsycl) --- examples/rng/device/CMakeLists.txt | 2 +- tests/unit_tests/rng/device/moments/CMakeLists.txt | 2 +- tests/unit_tests/rng/device/service/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/rng/device/CMakeLists.txt b/examples/rng/device/CMakeLists.txt index 1b6ecf2dd..cb80c03cd 100644 --- a/examples/rng/device/CMakeLists.txt +++ b/examples/rng/device/CMakeLists.txt @@ -59,7 +59,7 @@ foreach(rng_device_source ${RNG_DEVICE_SOURCES}) ONEMKL::SYCL::SYCL ) - if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") + if(is_dpcpp) target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/moments/CMakeLists.txt b/tests/unit_tests/rng/device/moments/CMakeLists.txt index 2da8033bf..d5f7cc095 100644 --- a/tests/unit_tests/rng/device/moments/CMakeLists.txt +++ b/tests/unit_tests/rng/device/moments/CMakeLists.txt @@ -35,6 +35,6 @@ else() target_link_libraries(rng_device_moments_ct PUBLIC ONEMKL::SYCL::SYCL) endif() -if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") +if(is_dpcpp) target_link_options(rng_device_moments_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/service/CMakeLists.txt b/tests/unit_tests/rng/device/service/CMakeLists.txt index 03d960e1a..8107e697f 100644 --- a/tests/unit_tests/rng/device/service/CMakeLists.txt +++ b/tests/unit_tests/rng/device/service/CMakeLists.txt @@ -35,6 +35,6 @@ else() target_link_libraries(rng_device_service_ct PUBLIC ONEMKL::SYCL::SYCL) endif() -if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") +if(is_dpcpp) target_link_options(rng_device_service_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() From 8a1186073f0013b36ea49a6c56527fa8cc1fcebd Mon Sep 17 00:00:00 2001 From: "Grabovskaya, Ekaterina" Date: Mon, 15 Jul 2024 08:39:24 -0700 Subject: [PATCH 3/7] debugging --- CMakeLists.txt | 2 ++ cmake/CMakeLists.txt | 4 +++- cmake/FindCompiler.cmake | 6 ++++-- examples/rng/device/CMakeLists.txt | 1 + tests/unit_tests/rng/device/moments/CMakeLists.txt | 1 + tests/unit_tests/rng/device/service/CMakeLists.txt | 1 + 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79af06f6a..414c12dde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,8 @@ cmake_minimum_required (VERSION 3.13) # Define build type set(DEFAULT_BUILD_TYPE "Release") +message("==> CMakeLists.txt") + if("${CMAKE_BUILD_TYPE}" STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE: None, set to ${DEFAULT_BUILD_TYPE} by default") set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c440dd2bf..972bfb9b9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -17,10 +17,12 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +message("1. cmake/CMakeLists.txt") + install(FILES FindCompiler.cmake DESTINATION "lib/cmake/${PROJECT_NAME}" ) - +message("2. cmake/CMakeLists.txt") if(ENABLE_MKLGPU_BACKEND OR ENABLE_MKLCPU_BACKEND) install(FILES mkl/MKLConfig.cmake DESTINATION "lib/cmake/${PROJECT_NAME}" diff --git a/cmake/FindCompiler.cmake b/cmake/FindCompiler.cmake index aeb7ad43d..2d0a3871f 100644 --- a/cmake/FindCompiler.cmake +++ b/cmake/FindCompiler.cmake @@ -17,12 +17,14 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +message("1. FindCompiler.cmake") include_guard() - +message("2. FindCompiler.cmake") include(CheckCXXCompilerFlag) include(FindPackageHandleStandardArgs) - +message("3. FindCompiler.cmake") check_cxx_compiler_flag("-fsycl" is_dpcpp) +message("is_dpcpp = ${is_dpcpp}") if(is_dpcpp) # Workaround for internal compiler error during linking if -fsycl is used diff --git a/examples/rng/device/CMakeLists.txt b/examples/rng/device/CMakeLists.txt index cb80c03cd..1a19d4447 100644 --- a/examples/rng/device/CMakeLists.txt +++ b/examples/rng/device/CMakeLists.txt @@ -60,6 +60,7 @@ foreach(rng_device_source ${RNG_DEVICE_SOURCES}) ) if(is_dpcpp) + message("is_dpcpp in examples/rng/device") target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/moments/CMakeLists.txt b/tests/unit_tests/rng/device/moments/CMakeLists.txt index d5f7cc095..5dfcfb8ba 100644 --- a/tests/unit_tests/rng/device/moments/CMakeLists.txt +++ b/tests/unit_tests/rng/device/moments/CMakeLists.txt @@ -36,5 +36,6 @@ else() endif() if(is_dpcpp) + message("is_dpcpp in unit_tests/moments") target_link_options(rng_device_moments_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/service/CMakeLists.txt b/tests/unit_tests/rng/device/service/CMakeLists.txt index 8107e697f..e4580100b 100644 --- a/tests/unit_tests/rng/device/service/CMakeLists.txt +++ b/tests/unit_tests/rng/device/service/CMakeLists.txt @@ -36,5 +36,6 @@ else() endif() if(is_dpcpp) + message("is_dpcpp in unit_tests/service") target_link_options(rng_device_service_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() From 13eec505d2f0f031a42e6a014a2559bb3ccd1d45 Mon Sep 17 00:00:00 2001 From: "Grabovskaya, Ekaterina" Date: Wed, 17 Jul 2024 02:44:58 -0700 Subject: [PATCH 4/7] Revert "using is_dpcpp instead of (NOT STREQUAL hipsycl)" This reverts commit ff92b2527e546e29381abfbf1ba2e3c67d81d3db. --- examples/rng/device/CMakeLists.txt | 3 +-- tests/unit_tests/rng/device/moments/CMakeLists.txt | 3 +-- tests/unit_tests/rng/device/service/CMakeLists.txt | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/rng/device/CMakeLists.txt b/examples/rng/device/CMakeLists.txt index 1a19d4447..1b6ecf2dd 100644 --- a/examples/rng/device/CMakeLists.txt +++ b/examples/rng/device/CMakeLists.txt @@ -59,8 +59,7 @@ foreach(rng_device_source ${RNG_DEVICE_SOURCES}) ONEMKL::SYCL::SYCL ) - if(is_dpcpp) - message("is_dpcpp in examples/rng/device") + if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/moments/CMakeLists.txt b/tests/unit_tests/rng/device/moments/CMakeLists.txt index 5dfcfb8ba..2da8033bf 100644 --- a/tests/unit_tests/rng/device/moments/CMakeLists.txt +++ b/tests/unit_tests/rng/device/moments/CMakeLists.txt @@ -35,7 +35,6 @@ else() target_link_libraries(rng_device_moments_ct PUBLIC ONEMKL::SYCL::SYCL) endif() -if(is_dpcpp) - message("is_dpcpp in unit_tests/moments") +if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") target_link_options(rng_device_moments_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() diff --git a/tests/unit_tests/rng/device/service/CMakeLists.txt b/tests/unit_tests/rng/device/service/CMakeLists.txt index e4580100b..03d960e1a 100644 --- a/tests/unit_tests/rng/device/service/CMakeLists.txt +++ b/tests/unit_tests/rng/device/service/CMakeLists.txt @@ -35,7 +35,6 @@ else() target_link_libraries(rng_device_service_ct PUBLIC ONEMKL::SYCL::SYCL) endif() -if(is_dpcpp) - message("is_dpcpp in unit_tests/service") +if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") target_link_options(rng_device_service_ct PUBLIC -fsycl -fsycl-device-code-split=per_kernel) endif() From 3c8b42d05fbeae9a2199607861b99b630b9d2f19 Mon Sep 17 00:00:00 2001 From: "Grabovskaya, Ekaterina" Date: Wed, 17 Jul 2024 02:52:52 -0700 Subject: [PATCH 5/7] Debugging revert --- CMakeLists.txt | 2 -- cmake/CMakeLists.txt | 4 +--- cmake/FindCompiler.cmake | 6 ++---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 414c12dde..79af06f6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,6 @@ cmake_minimum_required (VERSION 3.13) # Define build type set(DEFAULT_BUILD_TYPE "Release") -message("==> CMakeLists.txt") - if("${CMAKE_BUILD_TYPE}" STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE: None, set to ${DEFAULT_BUILD_TYPE} by default") set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 972bfb9b9..c440dd2bf 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -17,12 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -message("1. cmake/CMakeLists.txt") - install(FILES FindCompiler.cmake DESTINATION "lib/cmake/${PROJECT_NAME}" ) -message("2. cmake/CMakeLists.txt") + if(ENABLE_MKLGPU_BACKEND OR ENABLE_MKLCPU_BACKEND) install(FILES mkl/MKLConfig.cmake DESTINATION "lib/cmake/${PROJECT_NAME}" diff --git a/cmake/FindCompiler.cmake b/cmake/FindCompiler.cmake index 2d0a3871f..aeb7ad43d 100644 --- a/cmake/FindCompiler.cmake +++ b/cmake/FindCompiler.cmake @@ -17,14 +17,12 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -message("1. FindCompiler.cmake") include_guard() -message("2. FindCompiler.cmake") + include(CheckCXXCompilerFlag) include(FindPackageHandleStandardArgs) -message("3. FindCompiler.cmake") + check_cxx_compiler_flag("-fsycl" is_dpcpp) -message("is_dpcpp = ${is_dpcpp}") if(is_dpcpp) # Workaround for internal compiler error during linking if -fsycl is used From 6e9cbfc13ca24acceb09e9fa519e8171972a4984 Mon Sep 17 00:00:00 2001 From: Ekaterina Grabovskaya Date: Wed, 17 Jul 2024 11:54:06 +0200 Subject: [PATCH 6/7] Removed added spaces in FindCompiler.cmake --- cmake/FindCompiler.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/FindCompiler.cmake b/cmake/FindCompiler.cmake index aeb7ad43d..265719bf0 100644 --- a/cmake/FindCompiler.cmake +++ b/cmake/FindCompiler.cmake @@ -18,10 +18,8 @@ #=============================================================================== include_guard() - include(CheckCXXCompilerFlag) include(FindPackageHandleStandardArgs) - check_cxx_compiler_flag("-fsycl" is_dpcpp) if(is_dpcpp) From bfbd99a57a70622fb4a80a612aecbc4b4ae9d4a1 Mon Sep 17 00:00:00 2001 From: Ekaterina Grabovskaya Date: Wed, 17 Jul 2024 11:55:23 +0200 Subject: [PATCH 7/7] Removed space in CMakeLists.txt --- cmake/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c440dd2bf..df7d2fc4c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -20,7 +20,6 @@ install(FILES FindCompiler.cmake DESTINATION "lib/cmake/${PROJECT_NAME}" ) - if(ENABLE_MKLGPU_BACKEND OR ENABLE_MKLCPU_BACKEND) install(FILES mkl/MKLConfig.cmake DESTINATION "lib/cmake/${PROJECT_NAME}"