diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c1427aa0..f69e0682a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,7 @@ set(ENABLE_PORTBLAS_BACKEND_NVIDIA_GPU OFF CACHE INTERNAL "") set(ONEMKL_GENERATED_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}) # Build loader and backends for each domain +add_custom_target(onemkl_backend_libs) foreach(domain ${TARGET_DOMAINS}) add_subdirectory(${domain}) endforeach() @@ -52,6 +53,12 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/oneapi/mkl/detail/config.hpp" if(BUILD_SHARED_LIBS) add_library(onemkl SHARED) + # The loader library depends on all the backend libraries as it uses + # dlopen to load them at runtime. + # Use add_dependencies to ensure that all the backend libraries are + # (re-)built when compiling the loader or runtime binaries. + add_dependencies(onemkl onemkl_backend_libs) + target_include_directories(onemkl PUBLIC $ $ diff --git a/src/blas/backends/CMakeLists.txt b/src/blas/backends/CMakeLists.txt index 1f0273a61..351f4b0e5 100644 --- a/src/blas/backends/CMakeLists.txt +++ b/src/blas/backends/CMakeLists.txt @@ -17,6 +17,9 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +add_custom_target(onemkl_backend_libs_blas) +add_dependencies(onemkl_backend_libs onemkl_backend_libs_blas) + if(ENABLE_MKLCPU_BACKEND) add_subdirectory(mklcpu) endif() diff --git a/src/blas/backends/cublas/CMakeLists.txt b/src/blas/backends/cublas/CMakeLists.txt index 3cdf4a9d0..b64e7c37d 100644 --- a/src/blas/backends/cublas/CMakeLists.txt +++ b/src/blas/backends/cublas/CMakeLists.txt @@ -30,6 +30,7 @@ set(SOURCES cublas_level1.cpp $<$: cublas_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/blas/backends/mklcpu/CMakeLists.txt b/src/blas/backends/mklcpu/CMakeLists.txt index 10201a3ac..322741d26 100644 --- a/src/blas/backends/mklcpu/CMakeLists.txt +++ b/src/blas/backends/mklcpu/CMakeLists.txt @@ -25,6 +25,7 @@ set(SOURCES $<$: mklcpu_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() diff --git a/src/blas/backends/mklgpu/CMakeLists.txt b/src/blas/backends/mklgpu/CMakeLists.txt index 32d2f0428..c971d1afd 100644 --- a/src/blas/backends/mklgpu/CMakeLists.txt +++ b/src/blas/backends/mklgpu/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT mklgpu_level1.cpp mklgpu_level2.cpp mklgpu_level3.cpp mklgpu_batch.cpp mklgpu_extensions.cpp $<$: mklgpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/blas/backends/netlib/CMakeLists.txt b/src/blas/backends/netlib/CMakeLists.txt index 195cb9cd9..fd5275fc0 100644 --- a/src/blas/backends/netlib/CMakeLists.txt +++ b/src/blas/backends/netlib/CMakeLists.txt @@ -29,7 +29,8 @@ set(SOURCES netlib_common.hpp ) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) - +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) + if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) endif() diff --git a/src/blas/backends/portblas/CMakeLists.txt b/src/blas/backends/portblas/CMakeLists.txt index f4356eed1..e1ad6862c 100644 --- a/src/blas/backends/portblas/CMakeLists.txt +++ b/src/blas/backends/portblas/CMakeLists.txt @@ -175,6 +175,7 @@ set(SOURCES $<$: portblas_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) diff --git a/src/blas/backends/rocblas/CMakeLists.txt b/src/blas/backends/rocblas/CMakeLists.txt index 4d2cdf3bc..0d5559155 100644 --- a/src/blas/backends/rocblas/CMakeLists.txt +++ b/src/blas/backends/rocblas/CMakeLists.txt @@ -32,6 +32,7 @@ set(SOURCES rocblas_level1.cpp $<$: rocblas_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/dft/backends/CMakeLists.txt b/src/dft/backends/CMakeLists.txt index 8f9b9939f..b03a63e8a 100644 --- a/src/dft/backends/CMakeLists.txt +++ b/src/dft/backends/CMakeLists.txt @@ -17,6 +17,9 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +add_custom_target(onemkl_backend_libs_dft) +add_dependencies(onemkl_backend_libs onemkl_backend_libs_dft) + if(ENABLE_MKLGPU_BACKEND) add_subdirectory(mklgpu) endif() diff --git a/src/dft/backends/cufft/CMakeLists.txt b/src/dft/backends/cufft/CMakeLists.txt index 7586b1d5d..186b91aef 100644 --- a/src/dft/backends/cufft/CMakeLists.txt +++ b/src/dft/backends/cufft/CMakeLists.txt @@ -29,6 +29,7 @@ add_library(${LIB_OBJ} OBJECT backward.cpp $<$: mkl_dft_cufft_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/dft/backends/mklcpu/CMakeLists.txt b/src/dft/backends/mklcpu/CMakeLists.txt index ff21148a5..28fbdacfa 100644 --- a/src/dft/backends/mklcpu/CMakeLists.txt +++ b/src/dft/backends/mklcpu/CMakeLists.txt @@ -30,6 +30,7 @@ add_library(${LIB_OBJ} OBJECT backward.cpp $<$: mkl_dft_cpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/dft/backends/mklgpu/CMakeLists.txt b/src/dft/backends/mklgpu/CMakeLists.txt index 75e840683..e7b863ad3 100644 --- a/src/dft/backends/mklgpu/CMakeLists.txt +++ b/src/dft/backends/mklgpu/CMakeLists.txt @@ -30,6 +30,7 @@ add_library(${LIB_OBJ} OBJECT backward.cpp $<$: mkl_dft_gpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/dft/backends/portfft/CMakeLists.txt b/src/dft/backends/portfft/CMakeLists.txt index 3a0f7c237..6741875f2 100644 --- a/src/dft/backends/portfft/CMakeLists.txt +++ b/src/dft/backends/portfft/CMakeLists.txt @@ -62,6 +62,7 @@ add_library(${LIB_OBJ} OBJECT commit.cpp $<$: mkl_dft_portfft_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_dft ${LIB_NAME}) find_package(portfft QUIET) if (NOT portfft_FOUND) diff --git a/src/dft/backends/rocfft/CMakeLists.txt b/src/dft/backends/rocfft/CMakeLists.txt index 935db69c7..51c0ca177 100644 --- a/src/dft/backends/rocfft/CMakeLists.txt +++ b/src/dft/backends/rocfft/CMakeLists.txt @@ -29,6 +29,7 @@ add_library(${LIB_OBJ} OBJECT backward.cpp $<$: mkl_dft_rocfft_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_dft ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/lapack/backends/CMakeLists.txt b/src/lapack/backends/CMakeLists.txt index 8085ba125..636f6728f 100644 --- a/src/lapack/backends/CMakeLists.txt +++ b/src/lapack/backends/CMakeLists.txt @@ -17,6 +17,9 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +add_custom_target(onemkl_backend_libs_lapack) +add_dependencies(onemkl_backend_libs onemkl_backend_libs_lapack) + if(ENABLE_MKLCPU_BACKEND) add_subdirectory(mklcpu) endif() diff --git a/src/lapack/backends/cusolver/CMakeLists.txt b/src/lapack/backends/cusolver/CMakeLists.txt index 171380e59..dfd1267d7 100644 --- a/src/lapack/backends/cusolver/CMakeLists.txt +++ b/src/lapack/backends/cusolver/CMakeLists.txt @@ -27,6 +27,7 @@ set(SOURCES cusolver_lapack.cpp $<$: cusolver_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/lapack/backends/mklcpu/CMakeLists.txt b/src/lapack/backends/mklcpu/CMakeLists.txt index 6eb22c4f5..fcc60a8e7 100644 --- a/src/lapack/backends/mklcpu/CMakeLists.txt +++ b/src/lapack/backends/mklcpu/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT mkl_lapack.cpp $<$: lapack_cpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/lapack/backends/mklgpu/CMakeLists.txt b/src/lapack/backends/mklgpu/CMakeLists.txt index e5b52dc50..e11592f82 100644 --- a/src/lapack/backends/mklgpu/CMakeLists.txt +++ b/src/lapack/backends/mklgpu/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT mkl_lapack.cpp $<$: lapack_gpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/lapack/backends/rocsolver/CMakeLists.txt b/src/lapack/backends/rocsolver/CMakeLists.txt index 34702a842..1162cca5b 100644 --- a/src/lapack/backends/rocsolver/CMakeLists.txt +++ b/src/lapack/backends/rocsolver/CMakeLists.txt @@ -28,6 +28,7 @@ set(SOURCES rocsolver_lapack.cpp $<$: rocsolver_wrappers.cpp>) add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/rng/backends/CMakeLists.txt b/src/rng/backends/CMakeLists.txt index 7324a6103..9045f7e75 100644 --- a/src/rng/backends/CMakeLists.txt +++ b/src/rng/backends/CMakeLists.txt @@ -17,6 +17,9 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +add_custom_target(onemkl_backend_libs_rng) +add_dependencies(onemkl_backend_libs onemkl_backend_libs_rng) + if(ENABLE_MKLCPU_BACKEND) add_subdirectory(mklcpu) endif() diff --git a/src/rng/backends/curand/CMakeLists.txt b/src/rng/backends/curand/CMakeLists.txt index 57f42bd0c..f37a34f1d 100644 --- a/src/rng/backends/curand/CMakeLists.txt +++ b/src/rng/backends/curand/CMakeLists.txt @@ -66,6 +66,7 @@ set(SOURCES philox4x32x10.cpp add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/rng/backends/mklcpu/CMakeLists.txt b/src/rng/backends/mklcpu/CMakeLists.txt index 2c6d1ef01..e72ce048f 100644 --- a/src/rng/backends/mklcpu/CMakeLists.txt +++ b/src/rng/backends/mklcpu/CMakeLists.txt @@ -28,6 +28,7 @@ set(SOURCES cpu_common.hpp add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src diff --git a/src/rng/backends/mklgpu/CMakeLists.txt b/src/rng/backends/mklgpu/CMakeLists.txt index 1d268f9cb..150f90136 100644 --- a/src/rng/backends/mklgpu/CMakeLists.txt +++ b/src/rng/backends/mklgpu/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(${LIB_OBJ} OBJECT mrg32k3a.cpp $<$: mkl_rng_gpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_rng ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/rng/backends/rocrand/CMakeLists.txt b/src/rng/backends/rocrand/CMakeLists.txt index 13ffc5e82..b3c1d04bd 100644 --- a/src/rng/backends/rocrand/CMakeLists.txt +++ b/src/rng/backends/rocrand/CMakeLists.txt @@ -61,6 +61,7 @@ set(SOURCES philox4x32x10.cpp mrg32k3a.cpp $<$: add_library(${LIB_NAME}) add_library(${LIB_OBJ} OBJECT ${SOURCES}) +add_dependencies(onemkl_backend_libs_rng ${LIB_NAME}) target_include_directories( ${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src diff --git a/src/sparse_blas/backends/CMakeLists.txt b/src/sparse_blas/backends/CMakeLists.txt index aafb48851..ef606c6e1 100644 --- a/src/sparse_blas/backends/CMakeLists.txt +++ b/src/sparse_blas/backends/CMakeLists.txt @@ -17,6 +17,9 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== +add_custom_target(onemkl_backend_libs_sparse_blas) +add_dependencies(onemkl_backend_libs onemkl_backend_libs_sparse_blas) + if(ENABLE_MKLCPU_BACKEND) add_subdirectory(mklcpu) endif() diff --git a/src/sparse_blas/backends/mklcpu/CMakeLists.txt b/src/sparse_blas/backends/mklcpu/CMakeLists.txt index fb243c2f8..cfcf9cf3d 100644 --- a/src/sparse_blas/backends/mklcpu/CMakeLists.txt +++ b/src/sparse_blas/backends/mklcpu/CMakeLists.txt @@ -28,6 +28,7 @@ add_library(${LIB_OBJ} OBJECT mklcpu_operations.cpp $<$: mklcpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include diff --git a/src/sparse_blas/backends/mklgpu/CMakeLists.txt b/src/sparse_blas/backends/mklgpu/CMakeLists.txt index 67c129c15..a31794547 100644 --- a/src/sparse_blas/backends/mklgpu/CMakeLists.txt +++ b/src/sparse_blas/backends/mklgpu/CMakeLists.txt @@ -28,6 +28,7 @@ add_library(${LIB_OBJ} OBJECT mklgpu_operations.cpp $<$: mklgpu_wrappers.cpp> ) +add_dependencies(onemkl_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include