forked from uxlfoundation/oneMath
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindcuBLAS.cmake
69 lines (64 loc) · 2.58 KB
/
FindcuBLAS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#==========================================================================
# Copyright (C) Codeplay Software Limited
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# For your convenience, a copy of the License has been included in this
# repository.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================
find_package(CUDA 10.0 REQUIRED)
get_filename_component(SYCL_BINARY_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
# the OpenCL include file from cuda is opencl 1.1 and it is not compatible with DPC++
# the OpenCL include headers 1.2 onward is required. This is used to bypass NVIDIA OpenCL headers
find_path(OPENCL_INCLUDE_DIR CL/cl.h OpenCL/cl.h
HINTS
${OPENCL_INCLUDE_DIR}
${SYCL_BINARY_DIR}/../include/sycl/
${SYCL_BINARY_DIR}/../../include/sycl/
)
# this is work around to avoid duplication half creation in both cuda and SYCL
add_compile_definitions(CUDA_NO_HALF)
find_package(Threads REQUIRED)
include(FindPackageHandleStandardArgs)
if(NOT TARGET ONEMKL::cuBLAS::cuBLAS)
add_library(ONEMKL::cuBLAS::cuBLAS SHARED IMPORTED)
if(USE_ADD_SYCL_TO_TARGET_INTEGRATION)
find_package_handle_standard_args(cuBLAS
REQUIRED_VARS
CUDA_TOOLKIT_INCLUDE
CUDA_cublas_LIBRARY
CUDA_LIBRARIES
CUDA_CUDART_LIBRARY
CUDA_CUDA_LIBRARY
)
set_target_properties(ONEMKL::cuBLAS::cuBLAS PROPERTIES
IMPORTED_LOCATION ${CUDA_cublas_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${CUDA_TOOLKIT_INCLUDE}"
INTERFACE_LINK_LIBRARIES "Threads::Threads;${CUDA_LIBRARIES};${CUDA_CUDART_LIBRARY};${CUDA_CUDA_LIBRARY}"
)
else()
find_package_handle_standard_args(cuBLAS
REQUIRED_VARS
CUDA_TOOLKIT_INCLUDE
CUDA_cublas_LIBRARY
CUDA_LIBRARIES
CUDA_CUDA_LIBRARY
OPENCL_INCLUDE_DIR
)
set_target_properties(ONEMKL::cuBLAS::cuBLAS PROPERTIES
IMPORTED_LOCATION ${CUDA_cublas_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${OPENCL_INCLUDE_DIR};${CUDA_TOOLKIT_INCLUDE}"
INTERFACE_LINK_LIBRARIES "Threads::Threads;${CUDA_CUDA_LIBRARY};${CUDA_LIBRARIES}"
)
endif()
endif()