Skip to content

Commit 5e44128

Browse files
riegl-iaNeroBurner
authored andcommitted
Enable multicore CUDA compilation
Specify the number of threads to be used for compilation to the CUDA compiler NVCC. Option introduced in NVCC 11.2.
1 parent 052179d commit 5e44128

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmake/OpenCVDetectCUDA.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ if(CUDA_FOUND)
354354
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xptxas;-dlcm=ca")
355355
endif()
356356

357+
# Tell NVCC the maximum number of threads to be used to execute the compilation steps in parallel
358+
# (option --threads was introduced in version 11.2)
359+
if(NOT CUDA_VERSION VERSION_LESS "11.2")
360+
if(NOT $ENV{CMAKE_BUILD_PARALLEL_LEVEL} STREQUAL "")
361+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--threads=$ENV{CMAKE_BUILD_PARALLEL_LEVEL}")
362+
endif()
363+
endif()
364+
357365
message(STATUS "CUDA NVCC target flags: ${CUDA_NVCC_FLAGS}")
358366

359367
OCV_OPTION(CUDA_FAST_MATH "Enable --use_fast_math for CUDA compiler " OFF)

0 commit comments

Comments
 (0)