Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ endif()
option(ENABLE_CUBLAS_BACKEND "" OFF)
option(ENABLE_CURAND_BACKEND "" OFF)
option(ENABLE_NETLIB_BACKEND "" OFF)
option(DISABLE_HALF_RUTINES "" OFF)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah here it is... an alternative naming could be ENABLE_HALF_DATA_TYPE or similar (inspired by SYCL-BLAS..)

option(ONEMKL_SYCL_IMPLEMENTATION "" "dpc++")



## Domains
set(DOMAINS_LIST "")
Expand Down Expand Up @@ -124,7 +128,20 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if(WIN32)
add_library(ONEMKL::SYCL::SYCL INTERFACE IMPORTED)
else()
find_package(Compiler REQUIRED)
# Find necessary packages
if (${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipSYCL")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to use hipsycl to be in-line with using lowercase dpc++..
you could also use string( TOLOWER "${ONEMKL_SYCL_IMPLEMENTATION}" ONEMKL_SYCL_IMPLEMENTATION) beforehand, so the case of the input actually doesn't matter.
Also, if I understand it correctly, it is better to use if(ONEMKL_SYCL_IMPLEMENTATION .. without the dereferencing source

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm inclined to disagree about hipSYCL being lowercase. SYCL is a term that is inherently and strictly defined as all capital. DPC++ does not have such strong capitalization definitions. We also pretty consistently use the hipSYCL capitalization in all our stuff - the only exception being C++ source code inside hipSYCL.

In any case, actively turning everything lower case and hence accepting any capitalization seems like the best way to go.

message(STATUS "Looking for hipSYCL")
find_package(hipSYCL CONFIG REQUIRED)
set(USE_ADD_SYCL_TO_TARGET_INTEGRATION true)
set(DISABLE_HALF_RUTINES ON)
add_library(ONEMKL::SYCL::SYCL INTERFACE IMPORTED)
elseif(${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "dpc++")
message(STATUS "Looking for dpc++")
set(USE_ADD_SYCL_TO_TARGET_INTEGRATION false)
find_package(Compiler REQUIRED)
else()
message(FATAL_ERROR "SYCL implementation ${ONEMKL_SYCL_IMPLEMENTATION} is not known")
endif()
endif()

# Add source directory and output to bin/
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ if(is_dpcpp)
if(UNIX)
set(UNIX_INTERFACE_COMPILE_OPTIONS -fsycl)
set(UNIX_INTERFACE_LINK_OPTIONS -fsycl)
if(ENABLE_CURAND_BACKEND)
if(ENABLE_CURAND_BACKEND OR ENABLE_CUBLAS_BACKEND)
list(APPEND UNIX_INTERFACE_COMPILE_OPTIONS
-fsycl-targets=nvptx64-nvidia-cuda-sycldevice -fsycl-unnamed-lambda)
list(APPEND UNIX_INTERFACE_LINK_OPTIONS
-fsycl-targets=nvptx64-nvidia-cuda-sycldevice)
endif()
if(ENABLE_CURAND_BACKEND)
if(ENABLE_CURAND_BACKEND OR ENABLE_CUBLAS_BACKEND)
set_target_properties(ONEMKL::SYCL::SYCL PROPERTIES
INTERFACE_COMPILE_OPTIONS "${UNIX_INTERFACE_COMPILE_OPTIONS}"
INTERFACE_LINK_OPTIONS "${UNIX_INTERFACE_LINK_OPTIONS}"
Expand Down
8 changes: 6 additions & 2 deletions src/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ target_include_directories(onemkl_blas
${CMAKE_BINARY_DIR}/bin
$<TARGET_FILE_DIR:onemkl>
)

target_compile_options(onemkl_blas PRIVATE ${ONEMKL_BUILD_COPT})

set_target_properties(onemkl_blas PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(onemkl_blas PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET onemkl_blas SOURCES blas_loader.cpp)
else()
target_link_libraries(onemkl_blas PUBLIC ONEMKL::SYCL::SYCL)
endif()

endif()

23 changes: 12 additions & 11 deletions src/blas/backends/cublas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
set(LIB_NAME onemkl_blas_cublas)
set(LIB_OBJ ${LIB_NAME}_obj)
find_package(cuBLAS REQUIRED)

set(SOURCES cublas_level1.cpp
cublas_level2.cpp
cublas_level3.cpp
cublas_batch.cpp
cublas_extensions.cpp
cublas_scope_handle.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_blas_cublas_wrappers.cpp>)
add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT
cublas_level1.cpp
cublas_level2.cpp
cublas_level3.cpp
cublas_batch.cpp
cublas_extensions.cpp
cublas_scope_handle.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_blas_cublas_wrappers.cpp>
)
add_library(${LIB_OBJ} OBJECT ${SOURCES})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
Expand All @@ -42,7 +41,9 @@ set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON)

target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ})

if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even have to specify the SOURCES here..? (not sure about the semantics with or without :D)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hipSYCL doesn't need it, but it's the correct interface for portability, as e.g. ComputeCpp needs it AFAIK.

endif()
# Add major version to the library
set_target_properties(${LIB_NAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
Expand Down
13 changes: 7 additions & 6 deletions src/blas/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ set(LIB_NAME onemkl_blas_mklcpu)
set(LIB_OBJ ${LIB_NAME}_obj)

find_package(MKL REQUIRED)

add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT
fp16.hpp mklcpu_common.hpp
set(SOURCES fp16.hpp mklcpu_common.hpp
mklcpu_level1.cpp mklcpu_level2.cpp mklcpu_level3.cpp mklcpu_batch.cpp mklcpu_extensions.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mklcpu_wrappers.cpp>
)
$<$<BOOL:${BUILD_SHARED_LIBS}>: mklcpu_wrappers.cpp>)
add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT ${SOURCES})
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} ${SOURCES})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you specify the sources here, don't you need the SOURCES keyword, as you used above?

endif()

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
Expand Down
7 changes: 6 additions & 1 deletion src/rng/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ target_compile_options(onemkl_rng PRIVATE ${ONEMKL_BUILD_COPT})
set_target_properties(onemkl_rng PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(onemkl_rng PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET onemkl_rng SOURCES rng_loader.cpp)
else()
target_link_libraries(onemkl_rng PUBLIC ONEMKL::SYCL::SYCL)
endif()

endif()
13 changes: 8 additions & 5 deletions src/rng/backends/curand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ set(LIB_NAME onemkl_rng_curand)
set(LIB_OBJ ${LIB_NAME}_obj)
find_package(cuRAND REQUIRED)

add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT
philox4x32x10.cpp
set(SOURCES philox4x32x10.cpp
mrg32k3a.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_rng_curand_wrappers.cpp>
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_rng_curand_wrappers.cpp>)
)

add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT ${SOURCES})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
Expand All @@ -81,7 +82,9 @@ set_target_properties(${LIB_OBJ} PROPERTIES
)

target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ})

if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})
endif()
# Add major version to the library
set_target_properties(${LIB_NAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
Expand Down
12 changes: 8 additions & 4 deletions src/rng/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ set(LIB_OBJ ${LIB_NAME}_obj)

find_package(MKL REQUIRED)

add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT
cpu_common.hpp
set(SOURCES cpu_common.hpp
philox4x32x10.cpp
mrg32k3a.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_rng_cpu_wrappers.cpp>
)

add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT ${SOURCES})


target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
Expand All @@ -38,7 +40,9 @@ target_include_directories(${LIB_OBJ}
)

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMKL_BUILD_COPT} ${MKL_COPT})

if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})
endif()
target_link_libraries(${LIB_OBJ} PUBLIC ONEMKL::SYCL::SYCL ${MKL_LINK_C})

set_target_properties(${LIB_OBJ} PROPERTIES
Expand Down
10 changes: 9 additions & 1 deletion tests/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ foreach(domain ${TARGET_DOMAINS})
add_executable(test_main_${domain}_ct main_test.cpp)
target_include_directories(test_main_${domain}_ct PUBLIC ${GTEST_INCLUDE_DIR})
target_compile_options(test_main_${domain}_ct PRIVATE -fsycl)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET test_main_${domain}_ct SOURCES t main_test.cpp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t seems like a good source file name..? :D

also, shouldn't the setting of the -fsycl flag be moved to the else branch (potentially even only if the implementation option is set to dpc++)?

endif()

if(BUILD_SHARED_LIBS)
add_executable(test_main_${domain}_rt main_test.cpp)
Expand All @@ -73,6 +76,9 @@ foreach(domain ${TARGET_DOMAINS})
onemkl
${${domain}_TEST_LIST_RT}
)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET test_main_${domain}_rt SOURCES main_test.cpp)
endif()
endif()

if(ENABLE_MKLCPU_BACKEND)
Expand Down Expand Up @@ -109,7 +115,6 @@ foreach(domain ${TARGET_DOMAINS})
ONEMKL::SYCL::SYCL
${${domain}_TEST_LIST_CT}
)

string(TOUPPER ${domain} DOMAIN_PREFIX)

if(BUILD_SHARED_LIBS)
Expand All @@ -130,5 +135,8 @@ foreach(domain ${TARGET_DOMAINS})
PROPERTIES TEST_PREFIX ${DOMAIN_PREFIX}/CT/
DISCOVERY_TIMEOUT 30
)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET test_main_${domain}_rt)
endif()

endforeach()
10 changes: 10 additions & 0 deletions tests/unit_tests/blas/batch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_batch_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_batch_rt SOURCES ${BATCH_SOURCES})
else()
target_link_libraries(blas_batch_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()

add_library(blas_batch_ct OBJECT ${BATCH_SOURCES})
Expand All @@ -45,3 +50,8 @@ target_include_directories(blas_batch_ct
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_batch_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_batch_ct SOURCES ${BATCH_SOURCES})
else()
target_link_libraries(blas_batch_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line at end of file

10 changes: 10 additions & 0 deletions tests/unit_tests/blas/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_extensions_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_extensions_rt SOURCES ${EXTENSIONS_SOURCES})
else()
target_link_libraries(blas_extensions_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()

add_library(blas_extensions_ct OBJECT ${EXTENSIONS_SOURCES})
Expand All @@ -45,3 +50,8 @@ target_include_directories(blas_extensions_ct
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_extensions_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_extensions_ct SOURCES ${EXTENSIONS_SOURCES})
else()
target_link_libraries(blas_extensions_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()
13 changes: 11 additions & 2 deletions tests/unit_tests/blas/level1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level1_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level1_rt SOURCES ${L1_SOURCES})
else()
target_link_libraries(blas_level1_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()


add_library(blas_level1_ct OBJECT ${L1_SOURCES})
target_compile_options(blas_level1_ct PRIVATE -DNOMINMAX)
target_include_directories(blas_level1_ct
Expand All @@ -44,4 +49,8 @@ target_include_directories(blas_level1_ct
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level1_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level1_ct SOURCES ${L1_SOURCES})
else()
target_link_libraries(blas_level1_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()
12 changes: 10 additions & 2 deletions tests/unit_tests/blas/level2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level2_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level2_rt SOURCES ${L2_SOURCES})
else()
target_link_libraries(blas_level2_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()

add_library(blas_level2_ct OBJECT ${L2_SOURCES})
Expand All @@ -44,5 +48,9 @@ target_include_directories(blas_level2_ct
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level2_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level2_ct SOURCES ${L2_SOURCES})
else()
target_link_libraries(blas_level2_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()

12 changes: 10 additions & 2 deletions tests/unit_tests/blas/level3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level3_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level3_rt SOURCES ${L3_SOURCES})
else()
target_link_libraries(blas_level3_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()

add_library(blas_level3_ct OBJECT ${L3_SOURCES})
Expand All @@ -44,6 +48,10 @@ target_include_directories(blas_level3_ct
PUBLIC ${CMAKE_BINARY_DIR}/bin
PUBLIC ${CBLAS_INCLUDE}
)
target_link_libraries(blas_level3_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET blas_level3_ct SOURCES ${L3_SOURCES})
else()
target_link_libraries(blas_level3_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()


11 changes: 10 additions & 1 deletion tests/unit_tests/rng/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${PROJECT_SOURCE_DIR}/deps/googletest/include
PUBLIC ${CMAKE_BINARY_DIR}/bin
)
target_link_libraries(rng_service_rt PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET rng_service_rt SOURCES ${SERVICE_TESTS_SOURCES})
else()
target_link_libraries(rng_service_rt PUBLIC ONEMKL::SYCL::SYCL)
endif()
endif()

add_library(rng_service_ct OBJECT ${SERVICE_TESTS_SOURCES})
Expand All @@ -43,3 +47,8 @@ target_include_directories(rng_service_ct
PUBLIC ${CMAKE_BINARY_DIR}/bin
)
target_link_libraries(rng_service_ct PUBLIC ONEMKL::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET rng_service_ct SOURCES ${SERVICE_TESTS_SOURCES})
else()
target_link_libraries(rng_service_ct PUBLIC ONEMKL::SYCL::SYCL)
endif()
Loading