Skip to content

Commit 39073a2

Browse files
committed
cudaarithm: fix the compile faiure of CUDA 12.
The slight API change of NPP nppiMeanStdDevGetBufferHostSize_8u_C1R The type of bufSize is size_t instead of int in CUDA 12
1 parent ac994ed commit 39073a2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

modules/cudaarithm/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
1515
if(NOT CUDA_VERSION VERSION_LESS 10.1)
1616
list(APPEND optional_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
1717
endif()
18+
if (CUDA_VERSION VERSION_GREATER_EQUAL 12.0)
19+
add_definitions(-DCUDA_12_OR_HIGHER)
20+
endif()
1821
endif()
1922
if(HAVE_CUFFT)
2023
# static version requires seperable compilation which is incompatible with opencv's current library structure

modules/cudaarithm/src/reductions.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ void cv::cuda::meanStdDev(InputArray src, OutputArray dst, Stream& stream)
151151
sz.width = gsrc.cols;
152152
sz.height = gsrc.rows;
153153

154+
#if (CUDA_VERSION >= 12040)
155+
size_t bufSize; // detail: CUDA>=12 NPP nppi_statistics_functions.h
156+
#else
154157
int bufSize;
158+
#endif
159+
155160
#if (CUDA_VERSION <= 4020)
156161
nppSafeCall( nppiMeanStdDev8uC1RGetBufferHostSize(sz, &bufSize) );
157162
#else
@@ -227,7 +232,12 @@ void cv::cuda::meanStdDev(InputArray src, OutputArray dst, InputArray mask, Stre
227232
sz.width = gsrc.cols;
228233
sz.height = gsrc.rows;
229234

235+
#if (CUDA_VERSION >= 12040)
236+
size_t bufSize; // detail: CUDA>=12.4.0 NPP nppi_statistics_functions.h
237+
#else
230238
int bufSize;
239+
#endif
240+
231241
#if (CUDA_VERSION <= 4020)
232242
nppSafeCall( nppiMeanStdDev8uC1MRGetBufferHostSize(sz, &bufSize) );
233243
#else

0 commit comments

Comments
 (0)