Skip to content

Commit 4e766a0

Browse files
committed
cudaarithm: fix the compile faiure of CUDA 12.4.x .
A slight API change of NPP nppiMeanStdDevGetBufferHostSize_8u_C1R The type of bufSize is size_t instead of int in CUDA 12.4.x
1 parent ac994ed commit 4e766a0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

modules/cudaarithm/src/reductions.cpp

Lines changed: 14 additions & 2 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;
156+
#else
154157
int bufSize;
158+
#endif
159+
155160
#if (CUDA_VERSION <= 4020)
156161
nppSafeCall( nppiMeanStdDev8uC1RGetBufferHostSize(sz, &bufSize) );
157162
#else
@@ -162,7 +167,8 @@ void cv::cuda::meanStdDev(InputArray src, OutputArray dst, Stream& stream)
162167
#endif
163168

164169
BufferPool pool(stream);
165-
GpuMat buf = pool.getBuffer(1, bufSize, gsrc.type());
170+
CV_Assert(bufSize <= std::numeric_limits<int>::max());
171+
GpuMat buf = pool.getBuffer(1, static_cast<int>(bufSize), gsrc.type());
166172

167173
// detail: https://github.com/opencv/opencv/issues/11063
168174
//NppStreamHandler h(StreamAccessor::getStream(stream));
@@ -227,7 +233,12 @@ void cv::cuda::meanStdDev(InputArray src, OutputArray dst, InputArray mask, Stre
227233
sz.width = gsrc.cols;
228234
sz.height = gsrc.rows;
229235

236+
#if (CUDA_VERSION >= 12040)
237+
size_t bufSize;
238+
#else
230239
int bufSize;
240+
#endif
241+
231242
#if (CUDA_VERSION <= 4020)
232243
nppSafeCall( nppiMeanStdDev8uC1MRGetBufferHostSize(sz, &bufSize) );
233244
#else
@@ -238,7 +249,8 @@ void cv::cuda::meanStdDev(InputArray src, OutputArray dst, InputArray mask, Stre
238249
#endif
239250

240251
BufferPool pool(stream);
241-
GpuMat buf = pool.getBuffer(1, bufSize, gsrc.type());
252+
CV_Assert(bufSize <= std::numeric_limits<int>::max());
253+
GpuMat buf = pool.getBuffer(1, static_cast<int>(bufSize), gsrc.type());
242254

243255
if(gsrc.type() == CV_8UC1)
244256
nppSafeCall( nppiMean_StdDev_8u_C1MR(gsrc.ptr<Npp8u>(), static_cast<int>(gsrc.step), gmask.ptr<Npp8u>(), static_cast<int>(gmask.step),

0 commit comments

Comments
 (0)