Skip to content

Commit 2ef427d

Browse files
committed
Fix API compatibility error
This patch fixes a OCV API compatibility error. The error was reported due to the interface changes of Kernel::run. To resolve the issue, An overloaded function of Kernel::run is added. It take a flag indicating whether there are more work to be done with the kernel object without releasing resources related to it. Signed-off-by: Woo, Insoo <insoo.woo@intel.com>
1 parent 8f5b66f commit 2ef427d

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

modules/core/include/opencv2/core/ocl.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,20 @@ class CV_EXPORTS Kernel
580580
@param localsize work-group size for each dimension.
581581
@param sync specify whether to wait for OpenCL computation to finish before return.
582582
@param q command queue
583+
*/
584+
bool run(int dims, size_t globalsize[],
585+
size_t localsize[], bool sync, const Queue& q=Queue());
586+
/**
587+
Run the OpenCL kernel.
588+
@param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3.
589+
@param globalsize work items for each dimension.
590+
It is not the final globalsize passed to OpenCL.
591+
Each dimension will be adjusted to the nearest integer divisible by the corresponding value in localsize.
592+
If localsize is NULL, it will still be adjusted depending on dims.
593+
The adjusted values are greater than or equal to the original values.
594+
@param localsize work-group size for each dimension.
595+
@param sync specify whether to wait for OpenCL computation to finish before return.
596+
@param q command queue
583597
@param moreWorkDone specify whether there will the remaining work to be computed (more Kernel::run calls).
584598
When a computation requires multiple kernel execution by changing input and output buffer offset to get
585599
the final computation results.
@@ -590,7 +604,8 @@ class CV_EXPORTS Kernel
590604
kernel.run(..., q, false);
591605
*/
592606
bool run(int dims, size_t globalsize[],
593-
size_t localsize[], bool sync, const Queue& q=Queue(), bool moreWorkDone = false);
607+
size_t localsize[], bool sync, bool moreWorkDone, const Queue& q);
608+
594609
bool runTask(bool sync, const Queue& q=Queue());
595610

596611
size_t workGroupSize() const;

modules/core/src/intel_gpu_gemm.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
namespace cv
3434
{
3535

36+
bool intel_gpu_gemm( UMat A, Size sizeA, UMat B, Size sizeB, UMat D, Size sizeD, double alpha, double beta, bool atrans, bool btrans);
37+
3638
bool intel_gpu_gemm(
3739
UMat A, Size sizeA,
3840
UMat B, Size sizeB,
3941
UMat D, Size sizeD,
4042
double alpha, double beta,
4143
bool atrans, bool btrans)
4244
{
43-
sizeA; sizeB;
45+
CV_UNUSED(sizeA); CV_UNUSED(sizeB);
4446

4547
int M = sizeD.height, N = sizeD.width, K = ((atrans)? sizeA.height : sizeA.width);
4648

@@ -105,7 +107,7 @@ bool intel_gpu_gemm(
105107
ocl::Queue q;
106108
if(!atrans && btrans)
107109
{
108-
ret = k.run(2, global, local, false, q, false);
110+
ret = k.run(2, global, local, false, false, q);
109111
}
110112
else
111113
{
@@ -114,12 +116,12 @@ bool intel_gpu_gemm(
114116
k.set(14, &start_index, sizeof(start_index));
115117
if ((start_index + stride) < K)
116118
{
117-
ret = k.run(2, global, local, false, q, true);
119+
ret = k.run(2, global, local, false, true, q);
118120
if (!ret) return ret;
119121
}
120122
else
121123
{
122-
ret = k.run(2, global, local, false, q, false);
124+
ret = k.run(2, global, local, false, false, q);
123125
}
124126
}
125127
}

modules/core/src/ocl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ int Kernel::set(int i, const KernelArg& arg)
34653465
}
34663466

34673467
bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
3468-
bool sync, const Queue& q, bool moreWorkDone)
3468+
bool sync, bool moreWorkDone, const Queue& q)
34693469
{
34703470
CV_INSTRUMENT_REGION_OPENCL_RUN(p->name.c_str());
34713471

@@ -3511,6 +3511,12 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
35113511
return retval == CL_SUCCESS;
35123512
}
35133513

3514+
bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
3515+
bool sync, const Queue& q)
3516+
{
3517+
return run(dims, _globalsize, _localsize, sync, false, q);
3518+
}
3519+
35143520
bool Kernel::runTask(bool sync, const Queue& q)
35153521
{
35163522
if(!p || !p->handle || p->e != 0)

0 commit comments

Comments
 (0)