@@ -25,9 +25,10 @@ option(DPCTL_GENERATE_COVERAGE_FOR_PYBIND11_EXTENSIONS
25
25
"Build dpctl pybind11 offloading extensions with coverage instrumentation"
26
26
OFF
27
27
)
28
- option (DPCTL_TARGET_CUDA
29
- "Build DPCTL to target CUDA devices"
30
- OFF
28
+ set (DPCTL_TARGET_CUDA
29
+ ""
30
+ CACHE STRING
31
+ "Build DPCTL to target CUDA devices. Set to ON to use default architecture (sm_50), or to a specific architecture like sm_80."
31
32
)
32
33
set (DPCTL_TARGET_HIP
33
34
""
@@ -51,9 +52,20 @@ set(_dpctl_sycl_target_compile_options)
51
52
set (_dpctl_sycl_target_link_options )
52
53
53
54
set (_dpctl_sycl_targets )
55
+ set (_dpctl_cuda_arch )
54
56
set (_dpctl_amd_targets )
55
57
if ("x${DPCTL_SYCL_TARGETS} " STREQUAL "x" )
56
- if (DPCTL_TARGET_CUDA )
58
+ if (NOT "x${DPCTL_TARGET_CUDA} " STREQUAL "x" )
59
+ if (DPCTL_TARGET_CUDA STREQUAL "ON" )
60
+ set (_dpctl_cuda_arch "sm_50" )
61
+ elseif (DPCTL_TARGET_CUDA MATCHES "^sm_" )
62
+ set (_dpctl_cuda_arch ${DPCTL_TARGET_CUDA} )
63
+ else ()
64
+ message (FATAL_ERROR
65
+ "Invalid value for DPCTL_TARGET_CUDA: \" ${DPCTL_TARGET_CUDA} \" . "
66
+ "Expected 'ON' or an architecture like 'sm_80'."
67
+ )
68
+ endif ()
57
69
set (_dpctl_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown" )
58
70
endif ()
59
71
if (NOT "x${DPCTL_TARGET_HIP} " STREQUAL "x" )
@@ -88,6 +100,10 @@ if (_dpctl_sycl_targets)
88
100
message (STATUS "Compiling for -fsycl-targets=${_dpctl_sycl_targets} " )
89
101
list (APPEND _dpctl_sycl_target_compile_options -fsycl-targets=${_dpctl_sycl_targets} )
90
102
list (APPEND _dpctl_sycl_target_link_options -fsycl-targets=${_dpctl_sycl_targets} )
103
+ if (_dpctl_cuda_arch )
104
+ list (APPEND _dpctl_sycl_target_compile_options -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${_dpctl_cuda_arch} )
105
+ list (APPEND _dpctl_sycl_target_link_options -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${_dpctl_cuda_arch} )
106
+ endif ()
91
107
if (_dpctl_amd_targets )
92
108
list (APPEND _dpctl_sycl_target_compile_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets} )
93
109
list (APPEND _dpctl_sycl_target_link_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets} )
0 commit comments