File tree Expand file tree Collapse file tree 2 files changed +47
-4
lines changed Expand file tree Collapse file tree 2 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (C) 2024 Intel Corporation
2+ # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+ message (STATUS "Checking for module 'cuda' using find_library()" )
6+
7+ find_library (CUDA_LIBRARY NAMES libcuda cuda)
8+ set (CUDA_LIBRARIES ${CUDA_LIBRARY} )
9+
10+ get_filename_component (CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY )
11+ set (CUDA_LIBRARY_DIRS ${CUDA_LIB_DIR} )
12+
13+ if (WINDOWS)
14+ find_file (CUDA_DLL NAMES "bin/cuda.dll" "cuda.dll" )
15+ get_filename_component (CUDA_DLL_DIR ${CUDA_DLL} DIRECTORY )
16+ set (CUDA_DLL_DIRS ${CUDA_DLL_DIR} )
17+ endif ()
18+
19+ if (CUDA_LIBRARY)
20+ message (STATUS " Found cuda using find_library()" )
21+ message (STATUS " CUDA_LIBRARIES = ${CUDA_LIBRARIES} " )
22+ message (STATUS " CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS} " )
23+ message (STATUS " CUDA_LIBRARY_DIRS = ${CUDA_LIBRARY_DIRS} " )
24+ if (WINDOWS)
25+ message (STATUS " CUDA_DLL_DIRS = ${CUDA_DLL_DIRS} " )
26+ endif ()
27+ else ()
28+ set (MSG_NOT_FOUND "cuda NOT found (set CMAKE_PREFIX_PATH to point the "
29+ "location)" )
30+ if (CUDA_FIND_REQUIRED)
31+ message (FATAL_ERROR ${MSG_NOT_FOUND} )
32+ else ()
33+ message (WARNING ${MSG_NOT_FOUND} )
34+ endif ()
35+ endif ()
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ if(NOT LIBHWLOC_FOUND)
2121 find_package (LIBHWLOC 2.3.0 REQUIRED hwloc)
2222endif ()
2323
24+ find_package (CUDA REQUIRED cuda)
25+
2426include (FetchContent)
2527
2628set (CUDA_REPO "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git" )
@@ -43,17 +45,23 @@ set(CUDA_INCLUDE_DIRS
4345 ${cuda-headers_SOURCE_DIR}
4446 CACHE PATH "Path to CUDA headers" )
4547message (STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS} " )
48+
4649# build the example
4750set (EXAMPLE_NAME umf_example_cuda_shared_memory)
4851add_executable (${EXAMPLE_NAME} cuda_shared_memory.c)
4952target_include_directories (
5053 ${EXAMPLE_NAME} PRIVATE ${CUDA_INCLUDE_DIRS} ${LIBUMF_INCLUDE_DIRS}
5154 ${UMF_EXAMPLE_DIR} /common)
52- target_link_directories (${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARY_DIRS}
53- ${LIBHWLOC_LIBRARY_DIRS} )
55+ target_link_directories (
56+ ${EXAMPLE_NAME}
57+ PRIVATE
58+ ${LIBUMF_LIBRARY_DIRS}
59+ ${LIBHWLOC_LIBRARY_DIRS}
60+ ${CUDA_LIBRARY_DIRS} )
5461target_link_options (${EXAMPLE_NAME} PRIVATE "-Wl,--start-group" )
55- target_link_libraries (${EXAMPLE_NAME} PRIVATE stdc++ libdisjoint_pool.a cuda
56- ${LIBUMF_LIBRARIES} )
62+ target_link_libraries (
63+ ${EXAMPLE_NAME} PRIVATE stdc++ libdisjoint_pool.a ${CUDA_LIBRARIES}
64+ ${LIBUMF_LIBRARIES} )
5765
5866# an optional part - adds a test of this example
5967add_test (
You can’t perform that action at this time.
0 commit comments