From 2ed4d5ebad0f54dd0f0b953f3f3eeb8ae5508870 Mon Sep 17 00:00:00 2001 From: "romain.biessy" Date: Fri, 17 Jan 2025 14:16:54 +0000 Subject: [PATCH] [cmake] Allow users to link against onemath__ targets --- docs/using_onemath_with_cmake.rst | 19 +++--- .../level3/CMakeLists.txt | 44 ++++++------- .../level3/CMakeLists.txt | 47 ++++++-------- .../compile_time_dispatching/CMakeLists.txt | 47 +++++++------- .../dft/run_time_dispatching/CMakeLists.txt | 56 +++++++---------- .../compile_time_dispatching/CMakeLists.txt | 52 ++++++++-------- .../run_time_dispatching/CMakeLists.txt | 46 ++++++-------- .../compile_time_dispatching/CMakeLists.txt | 49 +++++++-------- examples/rng/device/CMakeLists.txt | 61 ++++++++++--------- .../rng/run_time_dispatching/CMakeLists.txt | 46 ++++++-------- .../compile_time_dispatching/CMakeLists.txt | 42 ++++++++----- ...parse.cpp => spmv_usm_mklcpu_cusparse.cpp} | 0 .../run_time_dispatching/CMakeLists.txt | 52 +++++++--------- ...{sparse_blas_spmv_usm.cpp => spmv_usm.cpp} | 0 src/CMakeLists.txt | 2 +- src/blas/backends/cublas/CMakeLists.txt | 18 +++--- src/blas/backends/generic/CMakeLists.txt | 10 +-- src/blas/backends/mklcpu/CMakeLists.txt | 8 +-- src/blas/backends/mklgpu/CMakeLists.txt | 8 +-- src/blas/backends/netlib/CMakeLists.txt | 10 +-- src/blas/backends/rocblas/CMakeLists.txt | 18 +++--- src/dft/backends/cufft/CMakeLists.txt | 14 ++--- src/dft/backends/mklcpu/CMakeLists.txt | 16 ++--- src/dft/backends/mklgpu/CMakeLists.txt | 12 ++-- src/dft/backends/portfft/CMakeLists.txt | 17 +++--- src/dft/backends/rocfft/CMakeLists.txt | 14 ++--- src/lapack/backends/cusolver/CMakeLists.txt | 12 ++-- src/lapack/backends/mklcpu/CMakeLists.txt | 8 +-- src/lapack/backends/mklgpu/CMakeLists.txt | 8 +-- src/lapack/backends/rocsolver/CMakeLists.txt | 8 +-- src/rng/backends/curand/CMakeLists.txt | 7 ++- src/rng/backends/mklcpu/CMakeLists.txt | 7 ++- src/rng/backends/mklgpu/CMakeLists.txt | 8 +-- src/rng/backends/rocrand/CMakeLists.txt | 7 ++- .../backends/cusparse/CMakeLists.txt | 7 ++- .../backends/mklcpu/CMakeLists.txt | 8 +-- .../backends/mklgpu/CMakeLists.txt | 8 +-- .../backends/rocsparse/CMakeLists.txt | 9 +-- 38 files changed, 377 insertions(+), 428 deletions(-) rename examples/sparse_blas/compile_time_dispatching/{sparse_blas_spmv_usm_mklcpu_cusparse.cpp => spmv_usm_mklcpu_cusparse.cpp} (100%) rename examples/sparse_blas/run_time_dispatching/{sparse_blas_spmv_usm.cpp => spmv_usm.cpp} (100%) diff --git a/docs/using_onemath_with_cmake.rst b/docs/using_onemath_with_cmake.rst index 8dac6e092..c9c7e7a1c 100644 --- a/docs/using_onemath_with_cmake.rst +++ b/docs/using_onemath_with_cmake.rst @@ -6,7 +6,7 @@ Using oneMath in your project with CMake The CMake build tool can help you use oneMath in your own project. Instead of manually linking and including directories, you can use the CMake targets exported by the oneMath project. You can use oneMath in one of two forms, with -the target names depending on the approach taken: +the target names depending on the approach taken: * you can use a previously installed copy, either from a binary distribution or built from source. This can be imported using CMake's ``find_package`` @@ -33,10 +33,11 @@ For example: find_package(oneMath REQUIRED) target_link_libraries(myTarget PRIVATE ONEMATH::onemath) -Different targets can be used depending on the requirements of oneMath. -To link against the entire library, the ``ONEMATH::onemath`` target should be used. -For specific domains, ``ONEMATH::onemath_`` should be used. -And for specific backends, ``ONEMATH::onemath__`` should be used. +Different targets can be used depending on the requirements of oneMath. +To link against the entire library with run-time dispatching, the +``ONEMATH::onemath`` target should be used. +For specific backends with compile-time dispatching, +``ONEMATH::onemath__`` should be used. When using a binary, it may be useful to know the backends that were enabled during the build. To check for the existence of backends, CMake's ``if(TARGET @@ -81,10 +82,8 @@ The build parameters should be appropriately set before :ref:`building_the_project_with_adaptivecpp`. To link against the main library with run-time dispatching, use the target -``onemath``. To link against particular domains, use the target -``onemath_``. For example, ``onemath_blas`` or ``onemath_dft``. To link -against particular backends (as required for static dispatch of oneAPI calls to -a particular backend), use the target ``onemath__``. For -example, ``onemath_dft_cufft``. +``onemath``. To link against particular backends with compile-time dispatching, +use the target ``onemath__``. For example, +``onemath_dft_cufft``. .. _FetchContent: https://cmake.org/cmake/help/latest/module/FetchContent.html diff --git a/examples/blas/compile_time_dispatching/level3/CMakeLists.txt b/examples/blas/compile_time_dispatching/level3/CMakeLists.txt index eb33a7497..e5e558f8c 100644 --- a/examples/blas/compile_time_dispatching/level3/CMakeLists.txt +++ b/examples/blas/compile_time_dispatching/level3/CMakeLists.txt @@ -17,31 +17,31 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -#Build object from all sources -set(BLAS_CT_SOURCES "") -if(ENABLE_MKLCPU_BACKEND AND ENABLE_CUBLAS_BACKEND) - list(APPEND BLAS_CT_SOURCES "gemm_usm_mklcpu_cublas") +# The example is written for the MKLCPU and CUBLAS backends +if(NOT (ENABLE_MKLCPU_BACKEND AND ENABLE_CUBLAS_BACKEND)) + return() endif() -foreach(blas_ct_source ${BLAS_CT_SOURCES}) - add_executable(example_${domain}_${blas_ct_source} ${blas_ct_source}.cpp) - target_include_directories(example_${domain}_${blas_ct_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_blas_gemm_usm_mklcpu_cublas) - if(domain STREQUAL "blas" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CUBLAS_BACKEND) - add_dependencies(example_${domain}_${blas_ct_source} onemath_${domain}_mklcpu onemath_${domain}_cublas) - list(APPEND ONEMATH_LIBRARIES_${domain} onemath_${domain}_mklcpu onemath_${domain}_cublas) - endif() +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - target_link_libraries(example_${domain}_${blas_ct_source} PUBLIC - ${ONEMATH_LIBRARIES_${domain}} - ONEMATH::SYCL::SYCL - ) +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} gemm_usm_mklcpu_cublas.cpp) - # Register example as ctest - add_test(NAME ${domain}/EXAMPLE/CT/${blas_ct_source} COMMAND example_${domain}_${blas_ct_source}) +# Linking against onemath_blas_mklcpu and onemath_blas_cublas in CMake will add the required include directories and dependencies. +# One can also link against `onemath_blas` to link against all the blas backends built. +# These targets should only be used for compile-time dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC + onemath_blas_mklcpu + onemath_blas_cublas +) -endforeach(blas_ct_source) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) + +# Register example as ctest +add_test(NAME blas/EXAMPLE/CT/gemm_usm_mklcpu_cublas COMMAND ${EXAMPLE_TARGET}) diff --git a/examples/blas/run_time_dispatching/level3/CMakeLists.txt b/examples/blas/run_time_dispatching/level3/CMakeLists.txt index b7accf474..56fbda093 100644 --- a/examples/blas/run_time_dispatching/level3/CMakeLists.txt +++ b/examples/blas/run_time_dispatching/level3/CMakeLists.txt @@ -20,10 +20,6 @@ # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example without specifying backend in CMake # $ENV{ONEAPI_DEVICE_SELECTOR} - -# Build object from all example sources -set(BLAS_RT_SOURCES "gemm_usm") - # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend @@ -56,32 +52,27 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(blas_rt_source ${BLAS_RT_SOURCES}) - add_executable(example_${domain}_${blas_rt_source} ${blas_rt_source}.cpp) - target_include_directories(example_${domain}_${blas_rt_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_blas_gemm_usm) - add_dependencies(example_${domain}_${blas_rt_source} onemath) +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${domain}_${blas_rt_source} SOURCES ${BLAS_RT_SOURCES}) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} gemm_usm.cpp) - target_link_libraries(example_${domain}_${blas_rt_source} PUBLIC - onemath - ONEMATH::SYCL::SYCL - ${CMAKE_DL_LIBS} - ) +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - # Register example as ctest - foreach(device_filter ${DEVICE_FILTERS}) - add_test(NAME ${domain}/EXAMPLE/RT/${blas_rt_source}/${device_filter} COMMAND example_${domain}_${blas_rt_source}) - set_property(TEST ${domain}/EXAMPLE/RT/${blas_rt_source}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) -endforeach(blas_rt_source) +# Register example as ctest for each device +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME blas/EXAMPLE/RT/gemm_usm/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST blas/EXAMPLE/RT/gemm_usm/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/dft/compile_time_dispatching/CMakeLists.txt b/examples/dft/compile_time_dispatching/CMakeLists.txt index 8c7665cb2..a3db503ba 100644 --- a/examples/dft/compile_time_dispatching/CMakeLists.txt +++ b/examples/dft/compile_time_dispatching/CMakeLists.txt @@ -17,34 +17,35 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -#Build object from all sources -set(DFT_CT_SOURCES "") -if (ENABLE_MKLCPU_BACKEND AND ENABLE_CUFFT_BACKEND) - list(APPEND DFT_CT_SOURCES "complex_fwd_usm_mklcpu_cufft") +# The example is written for the MKLCPU and CUFFT backends +if(NOT (ENABLE_MKLCPU_BACKEND AND ENABLE_CUFFT_BACKEND)) + return() endif() -include(WarningsUtils) +set(EXAMPLE_TARGET example_dft_complex_fwd_usm_mklcpu_cufft) -foreach(dft_ct_source ${DFT_CT_SOURCES}) - set(EXAMPLE_NAME example_${domain}_${dft_ct_source}) - add_executable(${EXAMPLE_NAME} ${dft_ct_source}.cpp) - target_include_directories(${EXAMPLE_NAME} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if(domain STREQUAL "dft" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CUFFT_BACKEND) - add_dependencies(${EXAMPLE_NAME} onemath_${domain}_mklcpu onemath_${domain}_cufft) - list(APPEND ONEMATH_LIBRARIES_${domain} onemath_${domain}_mklcpu onemath_${domain}_cufft) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} complex_fwd_usm_mklcpu_cufft.cpp) - target_link_libraries(${EXAMPLE_NAME} PUBLIC - ${ONEMATH_LIBRARIES_${domain}} - onemath_warnings - ) +# Linking against onemath_dft_mklcpu and onemath_dft_cufft in CMake will add the required include directories and dependencies. +# One can also link against `onemath_dft` to link against all the dft backends built. +# These targets should only be used for compile-time dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC + onemath_dft_mklcpu + onemath_dft_cufft +) - # Register example as ctest - add_test(NAME dft/EXAMPLE/CT/${dft_ct_source} COMMAND ${EXAMPLE_NAME}) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) -endforeach(dft_ct_source) +# Enable warnings +include(WarningsUtils) +target_link_libraries(${EXAMPLE_TARGET} PRIVATE onemath_warnings) +# Register example as ctest +add_test(NAME dft/EXAMPLE/CT/complex_fwd_usm_mklcpu_cufft COMMAND ${EXAMPLE_TARGET}) diff --git a/examples/dft/run_time_dispatching/CMakeLists.txt b/examples/dft/run_time_dispatching/CMakeLists.txt index 5d9f201cc..97ecf37f1 100644 --- a/examples/dft/run_time_dispatching/CMakeLists.txt +++ b/examples/dft/run_time_dispatching/CMakeLists.txt @@ -18,19 +18,11 @@ #=============================================================================== # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example (no need to specify backend when building with CMake) -include(WarningsUtils) - -# Build object from all example sources -set(DFT_RT_SOURCES "") # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend set(DEVICE_FILTERS "") -if(ENABLE_MKLGPU_BACKEND OR ENABLE_MKLCPU_BACKEND OR ENABLE_CUFFT_BACKEND OR ENABLE_ROCFFT_BACKEND OR ENABLE_PORTFFT_BACKEND) - list(APPEND DFT_RT_SOURCES "real_fwd_usm") -endif() - if(ENABLE_MKLGPU_BACKEND) list(APPEND DEVICE_FILTERS "level_zero:gpu") endif() @@ -49,33 +41,31 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(dft_rt_sources ${DFT_RT_SOURCES}) - add_executable(example_${domain}_${dft_rt_sources} ${dft_rt_sources}.cpp) - target_include_directories(example_${domain}_${dft_rt_sources} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_dft_real_fwd_usm) + +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - add_dependencies(example_${domain}_${dft_rt_sources} onemath) +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} real_fwd_usm.cpp) - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${domain}_${dft_rt_sources} SOURCES ${DFT_RT_SOURCES}) - endif() +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - target_link_libraries(example_${domain}_${dft_rt_sources} - PUBLIC onemath - PUBLIC ONEMATH::SYCL::SYCL - PUBLIC ${CMAKE_DL_LIBS} - PRIVATE onemath_warnings - ) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) - # Register example as ctest - foreach(device_filter ${DEVICE_FILTERS}) - add_test(NAME ${domain}/EXAMPLE/RT/${dft_rt_sources}/${device_filter} COMMAND example_${domain}_${dft_rt_sources}) - set_property(TEST ${domain}/EXAMPLE/RT/${dft_rt_sources}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# Enable warnings +include(WarningsUtils) +target_link_libraries(${EXAMPLE_TARGET} PRIVATE onemath_warnings) -endforeach() +# Register example as ctest +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME dft/EXAMPLE/RT/real_fwd_usm/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST dft/EXAMPLE/RT/real_fwd_usm/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/lapack/compile_time_dispatching/CMakeLists.txt b/examples/lapack/compile_time_dispatching/CMakeLists.txt index f72ea3c7b..f3b45f40c 100644 --- a/examples/lapack/compile_time_dispatching/CMakeLists.txt +++ b/examples/lapack/compile_time_dispatching/CMakeLists.txt @@ -17,33 +17,31 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -#Build object from all sources -set(LAPACK_CT_SOURCES "") -if(ENABLE_MKLCPU_BACKEND AND ENABLE_CUSOLVER_BACKEND) - list(APPEND LAPACK_CT_SOURCES "getrs_usm_mklcpu_cusolver") +# The example is written for the MKLCPU and CUSOLVER backends +if(NOT (ENABLE_MKLCPU_BACKEND AND ENABLE_CUSOLVER_BACKEND)) + return() endif() -if(domain STREQUAL "lapack" AND ENABLE_MKLCPU_BACKEND) - find_library(OPENCL_LIBRARY NAMES OpenCL) - message(STATUS "Found OpenCL: ${OPENCL_LIBRARY}") -endif() +set(EXAMPLE_TARGET example_lapack_getrs_usm_mklcpu_cusolver) + +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst + +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} getrs_usm_mklcpu_cusolver.cpp) + +# Linking against onemath_lapack_mklcpu and onemath_lapack_cusolver in CMake will add the required include directories and dependencies. +# One can also link against `onemath_lapack` to link against all the lapack backends built. +# These targets should only be used for compile-time dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC + onemath_lapack_mklcpu + onemath_lapack_cusolver +) + +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) -foreach(lapack_ct_source ${LAPACK_CT_SOURCES}) - add_executable(example_${domain}_${lapack_ct_source} ${lapack_ct_source}.cpp) - target_include_directories(example_${domain}_${lapack_ct_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) - if(domain STREQUAL "lapack" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CUSOLVER_BACKEND) - add_dependencies(example_${domain}_${lapack_ct_source} onemath_${domain}_mklcpu onemath_${domain}_cusolver) - list(APPEND ONEMATH_LIBRARIES_${domain} onemath_${domain}_mklcpu onemath_${domain}_cusolver) - target_link_libraries(example_${domain}_${lapack_ct_source} PUBLIC ${OPENCL_LIBRARY}) - endif() - target_link_libraries(example_${domain}_${lapack_ct_source} PUBLIC - ${ONEMATH_LIBRARIES_${domain}} - ONEMATH::SYCL::SYCL - ) - # Register example as ctest - add_test(NAME ${domain}/EXAMPLE/CT/${lapack_ct_source} COMMAND example_${domain}_${lapack_ct_source}) -endforeach(lapack_ct_source) +# Register example as ctest +add_test(NAME lapack/EXAMPLE/CT/getrs_usm_mklcpu_cusolver COMMAND ${EXAMPLE_TARGET}) \ No newline at end of file diff --git a/examples/lapack/run_time_dispatching/CMakeLists.txt b/examples/lapack/run_time_dispatching/CMakeLists.txt index 5026a6b49..a8f4f3ebb 100644 --- a/examples/lapack/run_time_dispatching/CMakeLists.txt +++ b/examples/lapack/run_time_dispatching/CMakeLists.txt @@ -19,9 +19,6 @@ # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example without specifying backend in CMake -# Build object from all example sources -set(LAPACK_RT_SOURCES "getrs_usm") - # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend @@ -41,32 +38,27 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(lapack_rt_source ${LAPACK_RT_SOURCES}) - add_executable(example_${domain}_${lapack_rt_source} ${lapack_rt_source}.cpp) - target_include_directories(example_${domain}_${lapack_rt_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_lapack_getrs_usm) - add_dependencies(example_${domain}_${lapack_rt_source} onemath) +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${domain}_${lapack_rt_source} SOURCES ${LAPACK_RT_SOURCES}) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} getrs_usm.cpp) - target_link_libraries(example_${domain}_${lapack_rt_source} PUBLIC - onemath - ONEMATH::SYCL::SYCL - ${CMAKE_DL_LIBS} - ) +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - foreach(device_filter ${DEVICE_FILTERS}) - # Register example as ctest - add_test(NAME ${domain}/EXAMPLE/RT/${lapack_rt_source}/${device_filter} COMMAND example_${domain}_${lapack_rt_source}) - set_property(TEST ${domain}/EXAMPLE/RT/${lapack_rt_source}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) -endforeach(lapack_rt_source) +# Register example as ctest +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME lapack/EXAMPLE/RT/getrs_usm/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST lapack/EXAMPLE/RT/getrs_usm/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/rng/compile_time_dispatching/CMakeLists.txt b/examples/rng/compile_time_dispatching/CMakeLists.txt index bfd37eead..8697a9fbc 100644 --- a/examples/rng/compile_time_dispatching/CMakeLists.txt +++ b/examples/rng/compile_time_dispatching/CMakeLists.txt @@ -17,34 +17,31 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -#Build object from all sources -set(RNG_CT_SOURCES "") -if(ENABLE_MKLCPU_BACKEND AND ENABLE_CURAND_BACKEND) - list(APPEND RNG_CT_SOURCES "uniform_usm_mklcpu_curand") +# The example is written for the MKLCPU and CURAND backends +if(NOT (ENABLE_MKLCPU_BACKEND AND ENABLE_CURAND_BACKEND)) + return() endif() -foreach(rng_ct_source ${RNG_CT_SOURCES}) - add_executable(example_${domain}_${rng_ct_source} ${rng_ct_source}.cpp) - target_include_directories(example_${domain}_${rng_ct_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_rng_uniform_usm_mklcpu_curand) - if(domain STREQUAL "rng" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CURAND_BACKEND) - add_dependencies(example_${domain}_${rng_ct_source} - onemath_${domain}_mklcpu - onemath_${domain}_curand) - list(APPEND ONEMATH_LIBRARIES_${domain} - onemath_${domain}_mklcpu - onemath_${domain}_curand) - endif() +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - target_link_libraries(example_${domain}_${rng_ct_source} PUBLIC - ${ONEMATH_LIBRARIES_${domain}} - ONEMATH::SYCL::SYCL - ) +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} uniform_usm_mklcpu_curand.cpp) - # Register example as ctest - add_test(NAME ${domain}/EXAMPLE/CT/${rng_ct_source} COMMAND example_${domain}_${rng_ct_source}) -endforeach(rng_ct_source) +# Linking against onemath_rng_mklcpu and onemath_rng_curand in CMake will add the required include directories and dependencies. +# One can also link against `onemath_rng` to link against all the rng backends built. +# These targets should only be used for compile-time dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC + onemath_rng_mklcpu + onemath_rng_curand +) + +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) + +# Register example as ctest +add_test(NAME rng/EXAMPLE/CT/uniform_usm_mklcpu_curand COMMAND ${EXAMPLE_TARGET}) diff --git a/examples/rng/device/CMakeLists.txt b/examples/rng/device/CMakeLists.txt index b7282798c..aa41db3a8 100644 --- a/examples/rng/device/CMakeLists.txt +++ b/examples/rng/device/CMakeLists.txt @@ -19,9 +19,6 @@ # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example (no need to specify backend when building with CMake) -# Build object from all example sources -set(RNG_DEVICE_SOURCES "uniform") - # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend @@ -42,35 +39,39 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(rng_device_source ${RNG_DEVICE_SOURCES}) - add_executable(example_${domain}_${rng_device_source} ${rng_device_source}.cpp) - target_include_directories(example_${domain}_${rng_device_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/rng/device/include - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_rng_uniform) + +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${domain}_${rng_device_source} SOURCES ${RNG_DEVICE_SOURCES}) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} uniform.cpp) - target_link_libraries(example_${domain}_${rng_device_source} PUBLIC - ONEMATH::SYCL::SYCL - ) +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - if(NOT ${ONEMATH_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") - # set strict warning flags for rng device API examples - target_compile_options(example_${domain}_${rng_device_source} PUBLIC -Wall -Werror -Wextra -Wpedantic -Wunreachable-code -Wfloat-conversion -Wextra-semi -Wshadow) - target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) - endif() +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/rng/device/include + ${PROJECT_SOURCE_DIR}/examples/include +) - # 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}) - set_property(TEST ${domain}/EXAMPLE/DEVICE/${rng_device_source}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# May be needed to compile source files with SYCL kernels +if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) + add_sycl_to_target(TARGET ${EXAMPLE_TARGET} SOURCES uniform.cpp) +endif() + +if(NOT ${ONEMATH_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") + # set strict warning flags for rng device API examples + target_compile_options(${EXAMPLE_TARGET} PUBLIC -Wall -Werror -Wextra -Wpedantic -Wunreachable-code -Wfloat-conversion -Wextra-semi -Wshadow) + target_link_options(${EXAMPLE_TARGET} PUBLIC -fsycl -fsycl-device-code-split=per_kernel) +endif() -endforeach() +# Register example as ctest +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME rng/EXAMPLE/DEVICE/uniform/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST rng/EXAMPLE/DEVICE/uniform/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/rng/run_time_dispatching/CMakeLists.txt b/examples/rng/run_time_dispatching/CMakeLists.txt index 8de795c02..f1de7074e 100644 --- a/examples/rng/run_time_dispatching/CMakeLists.txt +++ b/examples/rng/run_time_dispatching/CMakeLists.txt @@ -19,9 +19,6 @@ # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example (no need to specify backend when building with CMake) -# Build object from all example sources -set(RNG_RT_SOURCES "uniform_usm") - # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend @@ -42,32 +39,27 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(rng_rt_source ${RNG_RT_SOURCES}) - add_executable(example_${domain}_${rng_rt_source} ${rng_rt_source}.cpp) - target_include_directories(example_${domain}_${rng_rt_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_rng_uniform_usm) - add_dependencies(example_${domain}_${rng_rt_source} onemath) +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${domain}_${rng_rt_source} SOURCES ${RNG_RT_SOURCES}) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} uniform_usm.cpp) - target_link_libraries(example_${domain}_${rng_rt_source} PUBLIC - onemath - ONEMATH::SYCL::SYCL - ${CMAKE_DL_LIBS} - ) +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - # Register example as ctest - foreach(device_filter ${DEVICE_FILTERS}) - add_test(NAME ${domain}/EXAMPLE/RT/${rng_rt_source}/${device_filter} COMMAND example_${domain}_${rng_rt_source}) - set_property(TEST ${domain}/EXAMPLE/RT/${rng_rt_source}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) -endforeach() +# Register example as ctest +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME rng/EXAMPLE/DEVICE/uniform_usm/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST rng/EXAMPLE/DEVICE/uniform_usm/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/sparse_blas/compile_time_dispatching/CMakeLists.txt b/examples/sparse_blas/compile_time_dispatching/CMakeLists.txt index 8c586056d..68f24c563 100644 --- a/examples/sparse_blas/compile_time_dispatching/CMakeLists.txt +++ b/examples/sparse_blas/compile_time_dispatching/CMakeLists.txt @@ -17,25 +17,35 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -#Build object from all sources -set(SPARSE_CT_SOURCES "") -if(ENABLE_MKLCPU_BACKEND AND ENABLE_CUSPARSE_BACKEND) - list(APPEND SPARSE_CT_SOURCES "sparse_blas_spmv_usm_mklcpu_cusparse") +# The example is written for the MKLCPU and CUSPARSE backends +if(NOT (ENABLE_MKLCPU_BACKEND AND ENABLE_CUSPARSE_BACKEND)) + return() endif() -include(WarningsUtils) +set(EXAMPLE_TARGET example_sparse_blas_spmv_usm_mklcpu_cusparse) + +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst -foreach(sparse_ct_source ${SPARSE_CT_SOURCES}) - add_executable(${sparse_ct_source} ${sparse_ct_source}.cpp) - target_include_directories(${sparse_ct_source} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} spmv_usm_mklcpu_cusparse.cpp) - target_link_libraries(${sparse_ct_source} PRIVATE ONEMATH::SYCL::SYCL onemath_sparse_blas_mklcpu onemath_sparse_blas_cusparse) +# Linking against onemath_sparse_blas_mklcpu and onemath_sparse_blas_cusparse in CMake will add the required include directories and dependencies. +# One can also link against `onemath_sparse_blas` to link against all the sparse_blas backends built. +# These targets should only be used for compile-time dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC + onemath_sparse_blas_mklcpu + onemath_sparse_blas_cusparse +) - # Register example as ctest - add_test(NAME sparse_blas/EXAMPLE/CT/${sparse_ct_source} COMMAND ${sparse_ct_source}) -endforeach(sparse_ct_source) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) + +# Enable warnings +include(WarningsUtils) +target_link_libraries(${EXAMPLE_TARGET} PRIVATE onemath_warnings) +# Register example as ctest +add_test(NAME sparse_blas/EXAMPLE/CT/spmv_usm_mklcpu_cusparse COMMAND ${EXAMPLE_TARGET}) diff --git a/examples/sparse_blas/compile_time_dispatching/sparse_blas_spmv_usm_mklcpu_cusparse.cpp b/examples/sparse_blas/compile_time_dispatching/spmv_usm_mklcpu_cusparse.cpp similarity index 100% rename from examples/sparse_blas/compile_time_dispatching/sparse_blas_spmv_usm_mklcpu_cusparse.cpp rename to examples/sparse_blas/compile_time_dispatching/spmv_usm_mklcpu_cusparse.cpp diff --git a/examples/sparse_blas/run_time_dispatching/CMakeLists.txt b/examples/sparse_blas/run_time_dispatching/CMakeLists.txt index 1274b8c6b..5e9f6d712 100644 --- a/examples/sparse_blas/run_time_dispatching/CMakeLists.txt +++ b/examples/sparse_blas/run_time_dispatching/CMakeLists.txt @@ -19,10 +19,6 @@ # NOTE: user needs to set env var ONEAPI_DEVICE_SELECTOR to use runtime example (no need to specify backend when building with CMake) -include(WarningsUtils) - -# Build object from all example sources -set(SPARSE_BLAS_RT_SOURCES "sparse_blas_spmv_usm") # Set up for the right backend for run-time dispatching examples # If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to # overwrite ONEAPI_DEVICE_SELECTOR in their environment to run on the desired backend @@ -42,33 +38,31 @@ endif() message(STATUS "ONEAPI_DEVICE_SELECTOR will be set to the following value(s): [${DEVICE_FILTERS}] for run-time dispatching examples") -foreach(sparse_blas_rt_sources ${SPARSE_BLAS_RT_SOURCES}) - add_executable(example_${sparse_blas_rt_sources} ${sparse_blas_rt_sources}.cpp) - target_include_directories(example_${sparse_blas_rt_sources} - PUBLIC ${PROJECT_SOURCE_DIR}/examples/include - PUBLIC ${PROJECT_SOURCE_DIR}/include - PUBLIC ${CMAKE_BINARY_DIR}/bin - ) +set(EXAMPLE_TARGET example_sparse_blas_spmv_usm) - add_dependencies(example_${sparse_blas_rt_sources} onemath) +# External applications should use find_package or FetchContent to include oneMath first. +# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst - if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) - add_sycl_to_target(TARGET example_${sparse_blas_rt_sources} SOURCES ${SPARSE_BLAS_RT_SOURCES}) - endif() +# Create a CMake target with one source file +add_executable(${EXAMPLE_TARGET} spmv_usm.cpp) - target_link_libraries(example_${sparse_blas_rt_sources} - PUBLIC onemath - PUBLIC ONEMATH::SYCL::SYCL - PUBLIC ${CMAKE_DL_LIBS} - PRIVATE onemath_warnings - ) +# Linking against onemath in CMake will add the required include directories and dependencies. +# This target should only be used for runtime dispatching. +target_link_libraries(${EXAMPLE_TARGET} PUBLIC onemath) - # Register example as ctest - foreach(device_filter ${DEVICE_FILTERS}) - add_test(NAME ${domain}/EXAMPLE/RT/${sparse_blas_rt_sources}/${device_filter} COMMAND example_${sparse_blas_rt_sources}) - set_property(TEST ${domain}/EXAMPLE/RT/${sparse_blas_rt_sources}/${device_filter} PROPERTY - ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH} - ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) - endforeach(device_filter) +# Include directories specific to the examples +target_include_directories(${EXAMPLE_TARGET} PUBLIC + ${PROJECT_SOURCE_DIR}/examples/include +) + +# Enable warnings +include(WarningsUtils) +target_link_libraries(${EXAMPLE_TARGET} PRIVATE onemath_warnings) -endforeach() +# Register example as ctest for each device +foreach(device_filter ${DEVICE_FILTERS}) + add_test(NAME sparse_blas/EXAMPLE/RT/spmv_usm/${device_filter} COMMAND ${EXAMPLE_TARGET}) + # Set ONEAPI_DEVICE_SELECTOR environment variable to select a device at runtime + set_property(TEST sparse_blas/EXAMPLE/RT/spmv_usm/${device_filter} PROPERTY + ENVIRONMENT ONEAPI_DEVICE_SELECTOR=${device_filter}) +endforeach(device_filter) diff --git a/examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp b/examples/sparse_blas/run_time_dispatching/spmv_usm.cpp similarity index 100% rename from examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp rename to examples/sparse_blas/run_time_dispatching/spmv_usm.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3e21c97a..19de7c5f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,7 +136,7 @@ if(BUILD_SHARED_LIBS) # Build dispatcher library set (ONEMATH_LIBS ${TARGET_DOMAINS}) list(TRANSFORM ONEMATH_LIBS PREPEND onemath_) - target_link_libraries(onemath PUBLIC ${ONEMATH_LIBS}) + target_link_libraries(onemath PUBLIC ${ONEMATH_LIBS} ${CMAKE_DL_LIBS}) set_target_properties(onemath PROPERTIES INSTALL_RPATH "\$ORIGIN" BUILD_WITH_INSTALL_RPATH TRUE diff --git a/src/blas/backends/cublas/CMakeLists.txt b/src/blas/backends/cublas/CMakeLists.txt index 1cda3352f..4d3f8d0f9 100644 --- a/src/blas/backends/cublas/CMakeLists.txt +++ b/src/blas/backends/cublas/CMakeLists.txt @@ -20,11 +20,11 @@ set(LIB_NAME onemath_blas_cublas) set(LIB_OBJ ${LIB_NAME}_obj) find_package(cuBLAS REQUIRED) -set(SOURCES cublas_level1.cpp - cublas_level2.cpp - cublas_level3.cpp - cublas_batch.cpp - cublas_extensions.cpp +set(SOURCES cublas_level1.cpp + cublas_level2.cpp + cublas_level3.cpp + cublas_batch.cpp + cublas_extensions.cpp $<$:cublas_scope_handle.cpp > $<$:cublas_scope_handle_hipsycl.cpp > $<$: cublas_wrappers.cpp>) @@ -34,8 +34,8 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -52,7 +52,8 @@ target_compile_features(${LIB_OBJ} PUBLIC cxx_std_11) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -65,7 +66,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/blas/backends/generic/CMakeLists.txt b/src/blas/backends/generic/CMakeLists.txt index 4c998d79c..c4f1a2105 100644 --- a/src/blas/backends/generic/CMakeLists.txt +++ b/src/blas/backends/generic/CMakeLists.txt @@ -51,7 +51,7 @@ if(NUM_TARGETS EQUAL 0) endif() if(GENERIC_BLAS_TUNING_TARGET) - # Allow the user to manually enable a specific device type + # Allow the user to manually enable a specific device type # for tuned generic backend configurations and sets sycl-target. if(GENERIC_BLAS_TUNING_TARGET STREQUAL "INTEL_CPU") set(ONEMATH_ENABLE_GENERIC_BLAS_BACKEND_INTEL_CPU "ON" CACHE INTERNAL "") @@ -185,8 +185,8 @@ if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) endif() target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -198,7 +198,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL onemath_sycl_blas) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if(BUILD_SHARED_LIBS) set_target_properties(${LIB_NAME} PROPERTIES @@ -215,7 +216,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/blas/backends/mklcpu/CMakeLists.txt b/src/blas/backends/mklcpu/CMakeLists.txt index 592546ee8..c6e6724ab 100644 --- a/src/blas/backends/mklcpu/CMakeLists.txt +++ b/src/blas/backends/mklcpu/CMakeLists.txt @@ -32,9 +32,9 @@ if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) endif() target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -51,7 +51,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -69,7 +70,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/blas/backends/mklgpu/CMakeLists.txt b/src/blas/backends/mklgpu/CMakeLists.txt index d15da3519..31a2cabd9 100644 --- a/src/blas/backends/mklgpu/CMakeLists.txt +++ b/src/blas/backends/mklgpu/CMakeLists.txt @@ -29,9 +29,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -48,7 +48,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -66,7 +67,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/blas/backends/netlib/CMakeLists.txt b/src/blas/backends/netlib/CMakeLists.txt index 73b7f6ce5..1f09410f8 100644 --- a/src/blas/backends/netlib/CMakeLists.txt +++ b/src/blas/backends/netlib/CMakeLists.txt @@ -20,7 +20,7 @@ set(LIB_NAME onemath_blas_netlib) set(LIB_OBJ ${LIB_NAME}_obj) -# Add third-party library +# Add third-party library find_package(NETLIB REQUIRED) set(SOURCES netlib_common.hpp @@ -37,9 +37,9 @@ if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) endif() target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${NETLIB_INCLUDE} ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -52,7 +52,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL ${NETLIB_LINK}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if(BUILD_SHARED_LIBS) set_target_properties(${LIB_NAME} PROPERTIES @@ -69,7 +70,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/blas/backends/rocblas/CMakeLists.txt b/src/blas/backends/rocblas/CMakeLists.txt index c50e5349c..0bcee8502 100644 --- a/src/blas/backends/rocblas/CMakeLists.txt +++ b/src/blas/backends/rocblas/CMakeLists.txt @@ -25,10 +25,10 @@ find_package(hip REQUIRED) find_package(rocblas REQUIRED) find_package(Threads REQUIRED) -set(SOURCES rocblas_level1.cpp - rocblas_level2.cpp - rocblas_level3.cpp - rocblas_batch.cpp +set(SOURCES rocblas_level1.cpp + rocblas_level2.cpp + rocblas_level3.cpp + rocblas_batch.cpp rocblas_extensions.cpp $<$:rocblas_scope_handle.cpp > $<$:rocblas_scope_handle_hipsycl.cpp > @@ -39,8 +39,8 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -52,7 +52,7 @@ if(NOT ${ONEMATH_SYCL_IMPLEMENTATION} STREQUAL "hipsycl") -fsycl-targets=amdgcn-amd-amdhsa -fsycl-unnamed-lambda -Xsycl-target-backend --offload-arch=${HIP_TARGETS}) target_link_options(ONEMATH::SYCL::SYCL INTERFACE - -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend + -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${HIP_TARGETS}) else() target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT}) @@ -66,7 +66,8 @@ target_compile_features(${LIB_OBJ} PUBLIC cxx_std_17) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -79,7 +80,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/dft/backends/cufft/CMakeLists.txt b/src/dft/backends/cufft/CMakeLists.txt index dfb28099f..028bb1740 100644 --- a/src/dft/backends/cufft/CMakeLists.txt +++ b/src/dft/backends/cufft/CMakeLists.txt @@ -33,13 +33,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_NAME} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/src + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include + ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -60,7 +56,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -78,7 +75,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/dft/backends/mklcpu/CMakeLists.txt b/src/dft/backends/mklcpu/CMakeLists.txt index d79327087..a0152337b 100644 --- a/src/dft/backends/mklcpu/CMakeLists.txt +++ b/src/dft/backends/mklcpu/CMakeLists.txt @@ -34,15 +34,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_NAME} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) - -target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include + ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -69,7 +63,8 @@ endif() set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -87,7 +82,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/dft/backends/mklgpu/CMakeLists.txt b/src/dft/backends/mklgpu/CMakeLists.txt index dfa9d5097..938cfee9d 100644 --- a/src/dft/backends/mklgpu/CMakeLists.txt +++ b/src/dft/backends/mklgpu/CMakeLists.txt @@ -33,14 +33,10 @@ add_library(${LIB_OBJ} OBJECT ) add_dependencies(onemath_backend_libs_dft ${LIB_NAME}) -target_include_directories(${LIB_NAME} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) - target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -65,7 +61,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -83,7 +80,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/dft/backends/portfft/CMakeLists.txt b/src/dft/backends/portfft/CMakeLists.txt index 72ec70e24..fd9e5af9f 100644 --- a/src/dft/backends/portfft/CMakeLists.txt +++ b/src/dft/backends/portfft/CMakeLists.txt @@ -48,7 +48,7 @@ if (IS_DPCPP AND UNIX AND NOT FOUND_TARGETS) else() message(WARNING "Can't enable hip backend, HIP_TARGETS has not been set.") endif() - + message(STATUS "portFFT target triple set to ${TARGETS_TRIPLES}") list(APPEND TARGETS_COMPILE_OPTIONS -fsycl-targets=${TARGETS_TRIPLES}) @@ -92,14 +92,11 @@ endif() target_link_libraries(${LIB_OBJ} PRIVATE onemath_warnings) target_include_directories(${LIB_OBJ} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_NAME} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/src + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include + ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin + ${ONEMATH_GENERATED_INCLUDE_PATH} ) target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT}) @@ -109,7 +106,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -127,7 +125,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/dft/backends/rocfft/CMakeLists.txt b/src/dft/backends/rocfft/CMakeLists.txt index b234f70e3..0c48a62ee 100644 --- a/src/dft/backends/rocfft/CMakeLists.txt +++ b/src/dft/backends/rocfft/CMakeLists.txt @@ -33,13 +33,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_NAME} - PUBLIC ${ONEMATH_INCLUDE_DIRS} -) -target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/src + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include + ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -70,7 +66,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) # Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -88,7 +85,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/lapack/backends/cusolver/CMakeLists.txt b/src/lapack/backends/cusolver/CMakeLists.txt index b49e9e1ff..2a77d68e3 100644 --- a/src/lapack/backends/cusolver/CMakeLists.txt +++ b/src/lapack/backends/cusolver/CMakeLists.txt @@ -31,23 +31,24 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/blas/backends/cublas ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT}) -target_link_libraries(${LIB_OBJ} - PUBLIC ONEMATH::SYCL::SYCL +target_link_libraries(${LIB_OBJ} + PUBLIC ONEMATH::SYCL::SYCL ONEMATH::cuSOLVER::cuSOLVER ONEMATH::cuBLAS::cuBLAS) target_compile_features(${LIB_OBJ} PUBLIC cxx_std_11) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -60,7 +61,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/lapack/backends/mklcpu/CMakeLists.txt b/src/lapack/backends/mklcpu/CMakeLists.txt index 62a04f323..c2f64e2d4 100644 --- a/src/lapack/backends/mklcpu/CMakeLists.txt +++ b/src/lapack/backends/mklcpu/CMakeLists.txt @@ -29,9 +29,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -48,7 +48,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -66,7 +67,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/lapack/backends/mklgpu/CMakeLists.txt b/src/lapack/backends/mklgpu/CMakeLists.txt index 2786e462c..ac75599b7 100644 --- a/src/lapack/backends/mklgpu/CMakeLists.txt +++ b/src/lapack/backends/mklgpu/CMakeLists.txt @@ -29,9 +29,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -48,7 +48,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -66,7 +67,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/lapack/backends/rocsolver/CMakeLists.txt b/src/lapack/backends/rocsolver/CMakeLists.txt index fe63454c1..7da996c5b 100644 --- a/src/lapack/backends/rocsolver/CMakeLists.txt +++ b/src/lapack/backends/rocsolver/CMakeLists.txt @@ -35,8 +35,8 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -48,7 +48,8 @@ target_compile_features(${LIB_OBJ} PUBLIC cxx_std_17) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -61,7 +62,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/rng/backends/curand/CMakeLists.txt b/src/rng/backends/curand/CMakeLists.txt index 566db6422..71b760cdf 100644 --- a/src/rng/backends/curand/CMakeLists.txt +++ b/src/rng/backends/curand/CMakeLists.txt @@ -70,7 +70,8 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -82,7 +83,8 @@ set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -95,7 +97,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/rng/backends/mklcpu/CMakeLists.txt b/src/rng/backends/mklcpu/CMakeLists.txt index edc122a6e..8a4d3e512 100644 --- a/src/rng/backends/mklcpu/CMakeLists.txt +++ b/src/rng/backends/mklcpu/CMakeLists.txt @@ -31,7 +31,8 @@ add_deprecated_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -47,7 +48,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) # Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -65,7 +67,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/rng/backends/mklgpu/CMakeLists.txt b/src/rng/backends/mklgpu/CMakeLists.txt index 3e628b8e0..b72e478ae 100644 --- a/src/rng/backends/mklgpu/CMakeLists.txt +++ b/src/rng/backends/mklgpu/CMakeLists.txt @@ -30,9 +30,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -49,7 +49,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) # Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -67,7 +68,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/rng/backends/rocrand/CMakeLists.txt b/src/rng/backends/rocrand/CMakeLists.txt index 44dc98a51..26555f737 100644 --- a/src/rng/backends/rocrand/CMakeLists.txt +++ b/src/rng/backends/rocrand/CMakeLists.txt @@ -67,7 +67,8 @@ add_library(${LIB_OBJ} OBJECT ${SOURCES}) add_dependencies(onemath_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -78,7 +79,8 @@ target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL) target_compile_features(${LIB_OBJ} PUBLIC cxx_std_11) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) if(USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() @@ -89,7 +91,6 @@ set_target_properties(${LIB_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install( TARGETS ${LIB_NAME} EXPORT oneMathTargets diff --git a/src/sparse_blas/backends/cusparse/CMakeLists.txt b/src/sparse_blas/backends/cusparse/CMakeLists.txt index 636202868..c28f40385 100644 --- a/src/sparse_blas/backends/cusparse/CMakeLists.txt +++ b/src/sparse_blas/backends/cusparse/CMakeLists.txt @@ -34,7 +34,8 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -59,7 +60,8 @@ target_link_libraries(${LIB_OBJ} set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -77,7 +79,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/sparse_blas/backends/mklcpu/CMakeLists.txt b/src/sparse_blas/backends/mklcpu/CMakeLists.txt index 973fdae20..502baa1c2 100644 --- a/src/sparse_blas/backends/mklcpu/CMakeLists.txt +++ b/src/sparse_blas/backends/mklcpu/CMakeLists.txt @@ -32,9 +32,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -59,7 +59,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -77,7 +78,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/sparse_blas/backends/mklgpu/CMakeLists.txt b/src/sparse_blas/backends/mklgpu/CMakeLists.txt index 84e6e097c..9547e1611 100644 --- a/src/sparse_blas/backends/mklgpu/CMakeLists.txt +++ b/src/sparse_blas/backends/mklgpu/CMakeLists.txt @@ -32,9 +32,9 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/src/include ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} ) @@ -59,7 +59,8 @@ target_add_intel_onemkl_include(${LIB_OBJ}) set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMath libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -77,7 +78,6 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/src/sparse_blas/backends/rocsparse/CMakeLists.txt b/src/sparse_blas/backends/rocsparse/CMakeLists.txt index c6b78aa47..2f33a9857 100644 --- a/src/sparse_blas/backends/rocsparse/CMakeLists.txt +++ b/src/sparse_blas/backends/rocsparse/CMakeLists.txt @@ -34,7 +34,8 @@ add_library(${LIB_OBJ} OBJECT add_dependencies(onemath_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} - PRIVATE ${PROJECT_SOURCE_DIR}/include + PUBLIC ${ONEMATH_INCLUDE_DIRS} + PRIVATE ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin ${ONEMATH_GENERATED_INCLUDE_PATH} @@ -55,7 +56,8 @@ target_link_libraries(${LIB_OBJ} set_target_properties(${LIB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON ) -target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) #Set oneMATH libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) @@ -73,8 +75,7 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMATHTargets) -install(TARGETS ${LIB_NAME} EXPORT oneMATHTargets +install(TARGETS ${LIB_NAME} EXPORT oneMathTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib