Closed colleeneb closed 9 months ago
To compile the hip_sycl_interop and hip_sycl_interop_no_buffer examples, I needed to tweak the CMake for linking in MKL a bit. In particular, it looks like find_package(MKL) needs CMAKE_CXX_COMPILER to be set to icpx otherwise the MKL::MKL_SYCL target will not be found (See https://github.com/oneapi-src/oneMKL/blob/dd082b649166027c7adf0c1139561b5e65ad4c5c/cmake/mkl/MKLConfig.cmake#L207 and https://github.com/oneapi-src/oneMKL/blob/dd082b649166027c7adf0c1139561b5e65ad4c5c/cmake/mkl/MKLConfig.cmake#L275 (although it's a bit outdated with DPCPP instead of SYCL, but the more recent MKL cmake is the same)).
To get around this I set(CMAKE_CXX_COMPILER ${ICPX_EXECUTABLE}) and reset to whatever it was set to before the find_package(MKL) after it. I put the git diff of what I did to let it build below. I can make a PR if this is an acceptable solution.
set(CMAKE_CXX_COMPILER ${ICPX_EXECUTABLE})
There are still other interop issues like in https://github.com/CHIP-SPV/chipStar/issues/694 but this is another issue for interop. :)
diff --git a/cmake/mkl_and_icpx.cmake b/cmake/mkl_and_icpx.cmake index 4e4ae142..74bbe2cf 100644 --- a/cmake/mkl_and_icpx.cmake +++ b/cmake/mkl_and_icpx.cmake @@ -12,6 +12,8 @@ endif() set(ENABLE_OMP_OFFLOAD ON) set(MKL_THREADING sequential) +set(CMAKE_CXX_COMPILER_CORRECT ${CMAKE_CXX_COMPILER}) +set(CMAKE_CXX_COMPILER ${ICPX_EXECUTABLE}) find_package(MKL CONFIG HINTS $ENV{MKLROOT}/lib/cmake/mkl $ENV{ONEAPI_ROOT}/mkl/latest/lib/cmake/mkl PATHS /opt/intel/oneapi/mkl/latest/lib/cmake/mkl) @@ -21,10 +23,11 @@ if(MKL_FOUND) include_directories(${MKL_INCLUDE}) add_link_options(-L${MKL_ROOT}/lib/${MKL_ARCH}) endif() - # message(STATUS "ICPX : ${ICPX_EXECUTABLE} MKL: ${MKL_FOUND} ") set(INTEL_LIBS -L${ICPX_SYCL_LIBDIR} -L${ICPX_CORE_LIBDIR} -lsvml -lintlc -lirng -limf -lsycl) +set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_CORRECT}) + if(ICPX_EXECUTABLE AND MKL_FOUND) message(STATUS "Found both MLK and ICPX") set(SYCL_AVAILABLE ON) diff --git a/samples/hip_sycl_interop/onemkl_gemm_wrapper/CMakeLists.txt b/samples/hip_sycl_interop/onemkl_gemm_wrapper/CMakeLists.txt index 4c63ad15..8fda3904 100644 --- a/samples/hip_sycl_interop/onemkl_gemm_wrapper/CMakeLists.txt +++ b/samples/hip_sycl_interop/onemkl_gemm_wrapper/CMakeLists.txt @@ -5,7 +5,7 @@ set(POSITION_INDEPENDENT_CODE ON) add_library(onemkl_gemm_wrapper SHARED ./onemkl_gemm_wrapper.cpp) -target_link_libraries(onemkl_gemm_wrapper PUBLIC MKL::mkl_sycl MKL::mkl_intel_ilp64 MKL::mkl_sequential MKL::mkl_core) +target_link_libraries(onemkl_gemm_wrapper PUBLIC MKL::MKL_SYCL MKL::mkl_intel_ilp64 MKL::mkl_sequential MKL::mkl_core) target_include_directories(onemkl_gemm_wrapper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. "$<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>") #target_link_options(onemkl_gemm_wrapper PRIVATE "$<LINK_ONLY:MKL::MKL>") target_compile_options(onemkl_gemm_wrapper PRIVATE "$<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>") diff --git a/samples/hip_sycl_interop_no_buffers/onemkl_gemm_wrapper_no_buffers/CMakeLists.txt b/samples/hip_sycl_interop_no_buffers/onemkl_gemm_wrapper_no_buffers/CMakeLists.txt index 81de3784..15b25c02 100644 --- a/samples/hip_sycl_interop_no_buffers/onemkl_gemm_wrapper_no_buffers/CMakeLists.txt +++ b/samples/hip_sycl_interop_no_buffers/onemkl_gemm_wrapper_no_buffers/CMakeLists.txt @@ -5,7 +5,7 @@ set(POSITION_INDEPENDENT_CODE ON) add_library(onemkl_gemm_wrapper_no_buffers SHARED ./onemkl_gemm_wrapper.cpp) -target_link_libraries(onemkl_gemm_wrapper_no_buffers PUBLIC MKL::mkl_sycl MKL::mkl_intel_ilp64 MKL::mkl_sequential MKL::mkl_core) +target_link_libraries(onemkl_gemm_wrapper_no_buffers PUBLIC MKL::MKL_SYCL MKL::mkl_intel_ilp64 MKL::mkl_sequential MKL::mkl_core) target_include_directories(onemkl_gemm_wrapper_no_buffers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. "$<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>") #target_link_options(onemkl_gemm_wrapper_no_buffers PRIVATE "$<LINK_ONLY:MKL::MKL>") target_compile_options(onemkl_gemm_wrapper_no_buffers PRIVATE "$<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>")
PR #731 should fix the compilation issue.
@colleeneb can you confirm that this was fixed?
I'll try today and let you know!
It did build fine for me with the latest!
To compile the hip_sycl_interop and hip_sycl_interop_no_buffer examples, I needed to tweak the CMake for linking in MKL a bit. In particular, it looks like find_package(MKL) needs CMAKE_CXX_COMPILER to be set to icpx otherwise the MKL::MKL_SYCL target will not be found (See https://github.com/oneapi-src/oneMKL/blob/dd082b649166027c7adf0c1139561b5e65ad4c5c/cmake/mkl/MKLConfig.cmake#L207 and https://github.com/oneapi-src/oneMKL/blob/dd082b649166027c7adf0c1139561b5e65ad4c5c/cmake/mkl/MKLConfig.cmake#L275 (although it's a bit outdated with DPCPP instead of SYCL, but the more recent MKL cmake is the same)).
To get around this I
set(CMAKE_CXX_COMPILER ${ICPX_EXECUTABLE})
and reset to whatever it was set to before the find_package(MKL) after it. I put the git diff of what I did to let it build below. I can make a PR if this is an acceptable solution.There are still other interop issues like in https://github.com/CHIP-SPV/chipStar/issues/694 but this is another issue for interop. :)