Skip to content

Commit

Permalink
Move cmake instruction to keep configuration clean
Browse files Browse the repository at this point in the history
Moved variables setting for headers to a more appropriate section of
the configuration.
  • Loading branch information
s-Nick committed Sep 19, 2024
1 parent c1f8414 commit 3e73ce3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 65 deletions.
63 changes: 4 additions & 59 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ endif()
# Build options
option(BUILD_SHARED_LIBS "Build dynamic libraries" ON)

if(BUILD_SHARED_LIBS)
set(ONEAPI_ONEMKL_BUILD_SHARED_LIBS True)
endif()

## Backends
option(ENABLE_MKLCPU_BACKEND "Enable the Intel oneMKL CPU backend for supported interfaces" ON)
option(ENABLE_MKLGPU_BACKEND "Enable the Intel oneMKL GPU backend for supported interfaces" ON)

if(ENABLE_MKLCPU_BACKEND)
option(ENABLE_MKLCPU_THREAD_TBB "Enable the use of Intel TBB with the oneMKL CPU backend" ON)
endif()

# blas
option(ENABLE_CUBLAS_BACKEND "Enable the cuBLAS backend for the BLAS interface" OFF)
option(ENABLE_ROCBLAS_BACKEND "Enable the rocBLAS backend for the BLAS interface" OFF)
Expand All @@ -61,61 +61,6 @@ option(ENABLE_CUFFT_BACKEND "Enable the cuFFT backend for the DFT interface" OFF
option(ENABLE_ROCFFT_BACKEND "Enable the rocFFT backend for the DFT interface" OFF)
option(ENABLE_PORTFFT_BACKEND "Enable the portFFT DFT backend for the DFT interface. Cannot be used with other DFT backends." OFF)

# Following if-conditions allow to decouple cmake configuration variables with
# the corresponding generated macro. This is done to be conformant with ES.33
# C++ Core Guidelines
if(ENABLE_MKLCPU_BACKEND)
option(ENABLE_MKLCPU_THREAD_TBB "Enable the use of Intel TBB with the oneMKL CPU backend" ON)
set(ONEAPI_ONEMKL_ENABLE_MKLCPU_BACKEND True)
endif()

if(ENABLE_MKLGPU_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_MKLGPU_BACKEND True)
endif()

if(ENABLE_CUBLAS_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_CUBLAS_BACKEND True)
endif()

if(ENABLE_ROCBLAS_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_ROCBLAS_BACKEND True)
endif()

if(ENABLE_NETLIB_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_NETLIB_BACKEND True)
endif()

if(ENABLE_PORTBLAS_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_PORTBLAS_BACKEND True)
endif()

if(ENABLE_CURAND_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_CURAND_BACKEND True)
endif()

if(ENABLE_ROCRAND_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_ROCRAND_BACKEND True)
endif()

if(ENABLE_CUSOLVER_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_CUSOLVER_BACKEND True)
endif()

if(ENABLE_ROCSOLVER_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_ROCSOLVER_BACKEND True)
endif()

if(ENABLE_CUFFT_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_CUFFT_BACKEND True)
endif()

if(ENABLE_ROCFFT_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_ROCFFT_BACKEND True)
endif()

if(ENABLE_PORTFFT_BACKEND)
set(ONEAPI_ONEMKL_ENABLE_PORTFFT_BACKEND True)
endif()

set(ONEMKL_SYCL_IMPLEMENTATION "dpc++" CACHE STRING "Name of the SYCL compiler")
set(HIP_TARGETS "" CACHE STRING "Target HIP architectures")
Expand Down
25 changes: 19 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ if(WIN32 AND BUILD_SHARED_LIBS)
list(APPEND ONEMKL_BUILD_COPT "-Donemkl_EXPORTS")
endif()

# portBLAS backend variables must be accessible here to correctly
# generate the config file.
set(ENABLE_PORTBLAS_BACKEND_INTEL_CPU OFF CACHE INTERNAL "")
set(ENABLE_PORTBLAS_BACKEND_INTEL_GPU OFF CACHE INTERNAL "")
set(ENABLE_PORTBLAS_BACKEND_AMD_GPU OFF CACHE INTERNAL "")
set(ENABLE_PORTBLAS_BACKEND_NVIDIA_GPU OFF CACHE INTERNAL "")
# store path to CMAKE_CURRENT_BINARY_DIR to use it later (makes FetchContent_Declare workable)
set(ONEMKL_GENERATED_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR})

Expand All @@ -46,6 +40,25 @@ foreach(domain ${TARGET_DOMAINS})
endforeach()

# Generate header with enabled backends for testing

# Following if-conditions allow to decouple cmake configuration variables with
# the corresponding generated macro. This is done to be conformant with ES.33
# C++ Core Guidelines
set(ONEAPI_ONEMKL_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(ONEAPI_ONEMKL_ENABLE_MKLCPU_BACKEND ${ENABLE_MKLCPU_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_MKLGPU_BACKEND ${ENABLE_MKLGPU_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_CUBLAS_BACKEND ${ENABLE_CUBLAS_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_ROCBLAS_BACKEND ${ENABLE_ROCBLAS_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_NETLIB_BACKEND ${ENABLE_NETLIB_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_PORTBLAS_BACKEND ${ENABLE_PORTBLAS_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_CURAND_BACKEND ${ENABLE_CURAND_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_ROCRAND_BACKEND ${ENABLE_ROCRAND_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_CUSOLVER_BACKEND ${ENABLE_CUSOLVER_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_ROCSOLVER_BACKEND ${ENABLE_ROCSOLVER_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_CUFFT_BACKEND ${ENABLE_CUFFT_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_ROCFFT_BACKEND ${ENABLE_ROCFFT_BACKEND})
set(ONEAPI_ONEMKL_ENABLE_PORTFFT_BACKEND ${ENABLE_PORTFFT_BACKEND})

configure_file(config.hpp.in "${CMAKE_CURRENT_BINARY_DIR}/oneapi/mkl/config.hpp.configured")
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/oneapi/mkl/detail/config.hpp"
Expand Down

0 comments on commit 3e73ce3

Please sign in to comment.