Skip to content

Commit

Permalink
[cmake] Add missing dependencies (oneapi-src#369)
Browse files Browse the repository at this point in the history
Add dependencies on libraries that will be dlopen'ed during runtime dispatch.
  • Loading branch information
Rbiessy authored Feb 7, 2024
1 parent 7d2044e commit 6aa5924
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
Expand Down
3 changes: 3 additions & 0 deletions src/blas/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/blas/backends/cublas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(SOURCES cublas_level1.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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
Expand Down
1 change: 1 addition & 0 deletions src/blas/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(SOURCES
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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()
Expand Down
1 change: 1 addition & 0 deletions src/blas/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT
mklgpu_level1.cpp mklgpu_level2.cpp mklgpu_level3.cpp mklgpu_batch.cpp mklgpu_extensions.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mklgpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_blas ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
3 changes: 2 additions & 1 deletion src/blas/backends/netlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/blas/backends/portblas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ set(SOURCES
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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})
Expand Down
1 change: 1 addition & 0 deletions src/blas/backends/rocblas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(SOURCES rocblas_level1.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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
Expand Down
3 changes: 3 additions & 0 deletions src/dft/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/dft/backends/cufft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library(${LIB_OBJ} OBJECT
backward.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_cufft_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/dft/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_library(${LIB_OBJ} OBJECT
backward.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_cpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/dft/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_library(${LIB_OBJ} OBJECT
backward.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_gpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/dft/backends/portfft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ add_library(${LIB_OBJ} OBJECT
commit.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_portfft_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

find_package(portfft QUIET)
if (NOT portfft_FOUND)
Expand Down
1 change: 1 addition & 0 deletions src/dft/backends/rocfft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library(${LIB_OBJ} OBJECT
backward.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_rocfft_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
3 changes: 3 additions & 0 deletions src/lapack/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/lapack/backends/cusolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(SOURCES cusolver_lapack.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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
Expand Down
1 change: 1 addition & 0 deletions src/lapack/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT
mkl_lapack.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: lapack_cpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/lapack/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_library(${LIB_OBJ} OBJECT
mkl_lapack.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: lapack_gpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_lapack ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/lapack/backends/rocsolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(SOURCES rocsolver_lapack.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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
Expand Down
3 changes: 3 additions & 0 deletions src/rng/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/rng/backends/curand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/rng/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/rng/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_library(${LIB_OBJ} OBJECT
mrg32k3a.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_rng_gpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_rng ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/rng/backends/rocrand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ set(SOURCES philox4x32x10.cpp mrg32k3a.cpp $<$<BOOL:${BUILD_SHARED_LIBS}>:

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
Expand Down
3 changes: 3 additions & 0 deletions src/sparse_blas/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/sparse_blas/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_library(${LIB_OBJ} OBJECT
mklcpu_operations.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mklcpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_sparse_blas ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
1 change: 1 addition & 0 deletions src/sparse_blas/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_library(${LIB_OBJ} OBJECT
mklgpu_operations.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mklgpu_wrappers.cpp>
)
add_dependencies(onemkl_backend_libs_sparse_blas ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down

0 comments on commit 6aa5924

Please sign in to comment.