From 28e7aa975f23699cd3e9ec6cc2abaed8682068a6 Mon Sep 17 00:00:00 2001 From: Ekaterina Grabovskaya Date: Thu, 18 Jul 2024 14:38:32 +0200 Subject: [PATCH] [RNG] Added -fsycl -fsycl-device-code-split=per_kernel at the linking stage to have device code because of failures on windows (#533) --- cmake/CMakeLists.txt | 1 - cmake/FindCompiler.cmake | 2 -- examples/rng/device/CMakeLists.txt | 4 ++++ tests/unit_tests/rng/device/moments/CMakeLists.txt | 10 +++++++--- tests/unit_tests/rng/device/service/CMakeLists.txt | 10 +++++++--- 5 files changed, 18 insertions(+), 9 deletions(-) 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}" 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) 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()