Skip to content

Commit

Permalink
Fix compilation on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy committed Nov 14, 2024
1 parent 463fe57 commit a2de0e5
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 51 deletions.
24 changes: 17 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ function(add_deprecated_library target_name)
endfunction()


# Due to using the same file name for different headers in this library and in
# the Intel(R) oneAPI Math Kernel Library, the compiler may not include the
# expected header. Using `-iquote` lets us include this project's headers when
# double quotes are used and external headers when angle brackets are used.
function(target_add_onemath_include target_name)
target_compile_options(${target_name}
BEFORE PRIVATE -iquote $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
# Due to using the same directory structure and file name for different headers
# in this library and in the Intel(R) oneAPI Math Kernel Library, the compiler
# may not include the expected headers.
# Intel oneMKL include path is set as system include meaning it is always
# searched last no matter the order the order of the include flag in the command
# line argument.
# Using the -iquote flag is not supported on Windows.
# To avoid confusion the include paths are set up with a different "root" folder
# i.e.:
# * the oneMath include path is `${PROJECT_SOURCE_DIR}/include` and its
# deprecated headers can be included using `#include "oneapi/mkl/mkl.hpp"`
# for instance.
# * the Intel oneMKL include path is `${MKL_INCLUDE}/include/oneapi` and its
# headers can be included using `#include "mkl/mkl.hpp"` for instance.
function(target_add_intel_onemkl_include target_name)
target_include_directories(${target_name}
PRIVATE ${MKL_INCLUDE}/oneapi
)
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion src/blas/backends/mkl_common/mkl_blas_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Intel(R) oneMKL headers
#include <mkl_version.h>
#include <oneapi/mkl/blas.hpp>
#include <mkl/blas.hpp>

#include "common_onemkl_conversion.hpp"
#include "oneapi/math/types.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/blas/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})
endif()

target_add_onemath_include(${LIB_OBJ})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
Expand All @@ -47,6 +46,7 @@ if(TARGET MKL::MKL_SYCL::BLAS)
else()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_DPCPP)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
6 changes: 3 additions & 3 deletions src/blas/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ add_library(${LIB_OBJ} OBJECT
)
add_dependencies(onemath_backend_libs_blas ${LIB_NAME})

target_add_onemath_include(${LIB_OBJ})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
Expand All @@ -44,6 +43,7 @@ if(TARGET MKL::MKL_SYCL::BLAS)
else()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_DPCPP)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
6 changes: 3 additions & 3 deletions src/dft/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ target_include_directories(${LIB_NAME}
PUBLIC ${ONEMATH_INCLUDE_DIRS}
)

target_add_onemath_include(${LIB_OBJ})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
Expand All @@ -61,6 +60,7 @@ else()
PRIVATE onemath_warnings
)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
4 changes: 2 additions & 2 deletions src/dft/backends/mklgpu/backward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
// Intel(R) oneMKL headers
#include <mkl_version.h>
#if INTEL_MKL_VERSION < 20250000
#include <oneapi/mkl/dfti.hpp>
#include <mkl/dfti.hpp>
#else
#include <oneapi/mkl/dft.hpp>
#include <mkl/dft.hpp>
#endif

namespace oneapi::math::dft::mklgpu {
Expand Down
4 changes: 2 additions & 2 deletions src/dft/backends/mklgpu/commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
// Intel(R) oneMKL headers
#include <mkl_version.h>
#if INTEL_MKL_VERSION < 20250000
#include <oneapi/mkl/dfti.hpp>
#include <mkl/dfti.hpp>
#else
#include <oneapi/mkl/dft.hpp>
#include <mkl/dft.hpp>
#endif

// Intel oneMKL 2024.1 deprecates input/output strides.
Expand Down
4 changes: 2 additions & 2 deletions src/dft/backends/mklgpu/forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
// Intel(R) oneMKL headers
#include <mkl_version.h>
#if INTEL_MKL_VERSION < 20250000
#include <oneapi/mkl/dfti.hpp>
#include <mkl/dfti.hpp>
#else
#include <oneapi/mkl/dft.hpp>
#include <mkl/dft.hpp>
#endif

/**
Expand Down
4 changes: 2 additions & 2 deletions src/dft/backends/mklgpu/mklgpu_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
// Intel(R) oneMKL headers
#include <mkl_version.h>
#if INTEL_MKL_VERSION < 20250000
#include <oneapi/mkl/dfti.hpp>
#include <mkl/dfti.hpp>
#else
#include <oneapi/mkl/dft.hpp>
#include <mkl/dft.hpp>
#endif

namespace oneapi {
Expand Down
4 changes: 2 additions & 2 deletions src/include/common_onemkl_conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// The file is used to convert oneMath types to Intel(R) oneMKL types for all the common types shared across domains.
// The file assumes that the common types are identical between the 2 libraries, except for their namespace.

#include <oneapi/mkl/exceptions.hpp>
#include <oneapi/mkl/types.hpp>
#include <mkl/exceptions.hpp>
#include <mkl/types.hpp>

#include "oneapi/math/types.hpp"
#include "oneapi/math/exceptions.hpp"
Expand Down
12 changes: 3 additions & 9 deletions src/lapack/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,21 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemath_backend_libs_lapack ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
)

# Due to using the same file name for different headers in this library and in
# the Intel(R) oneAPI Math Kernel Library, we force the compiler to follow C++
# Core Guideline SF.12 using the flag "-iquote" to avoid conflicts and find the
# correct header.
target_compile_options(${LIB_OBJ}
BEFORE PRIVATE -iquote $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT})

if(TARGET MKL::MKL_SYCL::LAPACK)
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_SYCL::LAPACK)
else()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_DPCPP)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
2 changes: 1 addition & 1 deletion src/lapack/backends/mklcpu/mkl_lapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#endif

// Intel(R) oneMKL header
#include <oneapi/mkl/lapack.hpp>
#include <mkl/lapack.hpp>

#include "oneapi/math/types.hpp"
#include "oneapi/math/lapack/types.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/lapack/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemath_backend_libs_lapack ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
)

target_add_onemath_include(${LIB_OBJ})

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT})

if(TARGET MKL::MKL_SYCL::LAPACK)
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_SYCL::LAPACK)
else()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_DPCPP)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
2 changes: 1 addition & 1 deletion src/lapack/backends/mklgpu/mkl_lapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#endif

// Intel(R) oneMKL header
#include <oneapi/mkl/lapack.hpp>
#include <mkl/lapack.hpp>

#include "oneapi/math/types.hpp"
#include "oneapi/math/lapack/types.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/rng/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ 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}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
)

target_add_onemath_include(${LIB_OBJ})

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT})
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})
endif()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL)
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
6 changes: 3 additions & 3 deletions src/rng/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemath_backend_libs_rng ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${CMAKE_BINARY_DIR}/bin
${ONEMATH_GENERATED_INCLUDE_PATH}
)

target_add_onemath_include(${LIB_OBJ})

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT})

if(TARGET MKL::MKL_SYCL::RNG)
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_SYCL::RNG)
else()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMATH::SYCL::SYCL MKL::MKL_DPCPP)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down
2 changes: 1 addition & 1 deletion src/rng/backends/mklgpu/mrg32k3a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Intel(R) oneMKL headers
#include <mkl_version.h>
#include <oneapi/mkl/rng.hpp>
#include <mkl/rng.hpp>

#include "oneapi/math/rng/detail/engine_impl.hpp"
#include "oneapi/math/rng/engines.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/rng/backends/mklgpu/onemkl_distribution_conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// Convert oneMath RNG distribution types to Intel(R) oneMKL equivalents

#include <oneapi/mkl/rng.hpp>
#include <mkl/rng.hpp>

#include "common_onemkl_conversion.hpp"
#include "oneapi/math/rng/distributions.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/rng/backends/mklgpu/philox4x32x10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Intel(R) oneMKL headers
#include <mkl_version.h>
#include <oneapi/mkl/rng.hpp>
#include <mkl/rng.hpp>

#include "oneapi/math/rng/detail/engine_impl.hpp"
#include "oneapi/math/rng/engines.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/sparse_blas/backends/mkl_common/mkl_handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define _ONEMATH_SRC_SPARSE_BLAS_BACKENDS_MKL_COMMON_MKL_HANDLES_HPP_

// Intel(R) oneMKL header
#include <oneapi/mkl/spblas.hpp>
#include <mkl/spblas.hpp>

#include "sparse_blas/generic_container.hpp"
#include "sparse_blas/macros.hpp"
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 @@ -54,6 +54,7 @@ else()
PRIVATE onemath_warnings
)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
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 @@ -54,6 +54,7 @@ else()
PRIVATE onemath_warnings
)
endif()
target_add_intel_onemkl_include(${LIB_OBJ})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
Expand Down

0 comments on commit a2de0e5

Please sign in to comment.