Skip to content

[SYCL][CUDA] Build with cupti only when needed #7913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 24 additions & 22 deletions sycl/plugins/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ else()
)
endif()

if (SYCL_ENABLE_XPTI_TRACING)
set(XPTI_PROXY_SRC "${CMAKE_SOURCE_DIR}/../xpti/src/xpti_proxy.cpp")
endif()
if (SYCL_ENABLE_XPTI_TRACING)
# The following two if's can be removed when FindCUDA -> FindCUDAToolkit.
# CUDA_CUPTI_INCLUDE_DIR -> CUDAToolkit_CUPTI_INCLUDE_DIR
include(FindCUDACupti)
if(NOT CUDA_CUPTI_INCLUDE_DIR)
find_cuda_cupti_include_dir()
endif()
# CUDA_cupti_LIBRARY -> CUDAToolkit_cupti_LIBRARY
if(NOT CUDA_cupti_LIBRARY)
find_cuda_cupti_library()
endif()

# The following two if's can be removed when FindCUDA -> FindCUDAToolkit.
# CUDA_CUPTI_INCLUDE_DIR -> CUDAToolkit_CUPTI_INCLUDE_DIR
include(FindCUDACupti)
if(NOT CUDA_CUPTI_INCLUDE_DIR)
find_cuda_cupti_include_dir()
endif()
# CUDA_cupti_LIBRARY -> CUDAToolkit_cupti_LIBRARY
if(NOT CUDA_cupti_LIBRARY)
find_cuda_cupti_library()
set(XPTI_PROXY_SRC "${CMAKE_SOURCE_DIR}/../xpti/src/xpti_proxy.cpp")
set(XPTI_INCLUDE
"${CMAKE_SOURCE_DIR}/../xpti/include"
"${CUDA_CUPTI_INCLUDE_DIR}"
)
set(XPTI_LIBS
"${CMAKE_DL_LIBS}"
"${CUDA_cupti_LIBRARY}"
)
endif()

add_sycl_plugin(cuda
Expand All @@ -46,26 +54,20 @@ add_sycl_plugin(cuda
"pi_cuda.cpp"
"tracing.cpp"
${XPTI_PROXY_SRC}
INCLUDE_DIRS
${sycl_inc_dir}
${XPTI_INCLUDE}
LIBRARIES
cudadrv
${CUDA_cupti_LIBRARY}
${XPTI_LIBS}
)

if (SYCL_ENABLE_XPTI_TRACING)
target_compile_definitions(pi_cuda PRIVATE
XPTI_ENABLE_INSTRUMENTATION
XPTI_STATIC_LIBRARY
)
target_include_directories(pi_cuda PRIVATE "${CMAKE_SOURCE_DIR}/../xpti/include")
target_link_libraries(pi_cuda PRIVATE ${CMAKE_DL_LIBS})
endif()


target_include_directories(pi_cuda
PRIVATE
${sycl_inc_dir}
${CUDA_CUPTI_INCLUDE_DIR}
)

set_target_properties(pi_cuda PROPERTIES LINKER_LANGUAGE CXX)

2 changes: 2 additions & 0 deletions sycl/plugins/cuda/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#endif

#include <cuda.h>
#ifdef XPTI_ENABLE_INSTRUMENTATION
#include <cupti.h>
#endif // XPTI_ENABLE_INSTRUMENTATION

#include <exception>
#include <iostream>
Expand Down