Merge pull request #736 from bitwangyaoyao:2.4_clflush
This commit is contained in:
commit
656594ad4f
@ -126,6 +126,9 @@ namespace cv
|
|||||||
|
|
||||||
CV_EXPORTS void* getoclCommandQueue();
|
CV_EXPORTS void* getoclCommandQueue();
|
||||||
|
|
||||||
|
//explicit call clFinish. The global command queue will be used.
|
||||||
|
CV_EXPORTS void finish();
|
||||||
|
|
||||||
//this function enable ocl module to use customized cl_context and cl_command_queue
|
//this function enable ocl module to use customized cl_context and cl_command_queue
|
||||||
//getDevice also need to be called before this function
|
//getDevice also need to be called before this function
|
||||||
CV_EXPORTS void setDeviceEx(Info &oclinfo, void *ctx, void *qu, int devnum = 0);
|
CV_EXPORTS void setDeviceEx(Info &oclinfo, void *ctx, void *qu, int devnum = 0);
|
||||||
|
@ -375,6 +375,7 @@ struct name##_test: Runnable { \
|
|||||||
while (!TestSystem::instance().stop()) { \
|
while (!TestSystem::instance().stop()) { \
|
||||||
TestSystem::instance().gpuOn()
|
TestSystem::instance().gpuOn()
|
||||||
#define GPU_OFF \
|
#define GPU_OFF \
|
||||||
|
ocl::finish(); \
|
||||||
TestSystem::instance().gpuOff(); \
|
TestSystem::instance().gpuOff(); \
|
||||||
} TestSystem::instance().gpuComplete()
|
} TestSystem::instance().gpuComplete()
|
||||||
|
|
||||||
@ -388,4 +389,5 @@ struct name##_test: Runnable { \
|
|||||||
#define WARMUP_ON \
|
#define WARMUP_ON \
|
||||||
while (!TestSystem::instance().warmupStop()) {
|
while (!TestSystem::instance().warmupStop()) {
|
||||||
#define WARMUP_OFF \
|
#define WARMUP_OFF \
|
||||||
|
ocl::finish(); \
|
||||||
} TestSystem::instance().warmupComplete()
|
} TestSystem::instance().warmupComplete()
|
||||||
|
@ -354,6 +354,11 @@ namespace cv
|
|||||||
return &(Context::getContext()->impl->clCmdQueue);
|
return &(Context::getContext()->impl->clCmdQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void finish()
|
||||||
|
{
|
||||||
|
clFinish(Context::getContext()->impl->clCmdQueue);
|
||||||
|
}
|
||||||
|
|
||||||
void queryDeviceInfo(DEVICE_INFO info_type, void* info)
|
void queryDeviceInfo(DEVICE_INFO info_type, void* info)
|
||||||
{
|
{
|
||||||
static Info::Impl* impl = Context::getContext()->impl;
|
static Info::Impl* impl = Context::getContext()->impl;
|
||||||
@ -712,7 +717,7 @@ namespace cv
|
|||||||
clReleaseEvent(event);
|
clReleaseEvent(event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clFinish(clCxt->impl->clCmdQueue);
|
clFlush(clCxt->impl->clCmdQueue);
|
||||||
openCLSafeCall(clReleaseKernel(kernel));
|
openCLSafeCall(clReleaseKernel(kernel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ namespace cv
|
|||||||
format.image_channel_data_type = CL_FLOAT;
|
format.image_channel_data_type = CL_FLOAT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::exception();
|
CV_Error(-1, "Image forma is not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch(channels)
|
switch(channels)
|
||||||
@ -159,7 +159,7 @@ namespace cv
|
|||||||
format.image_channel_order = CL_RGBA;
|
format.image_channel_order = CL_RGBA;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::exception();
|
CV_Error(-1, "Image forma is not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if CL_VERSION_1_2
|
#if CL_VERSION_1_2
|
||||||
@ -197,7 +197,8 @@ namespace cv
|
|||||||
const size_t regin[3] = {mat.cols * mat.elemSize(), mat.rows, 1};
|
const size_t regin[3] = {mat.cols * mat.elemSize(), mat.rows, 1};
|
||||||
clEnqueueCopyBufferRect((cl_command_queue)mat.clCxt->oclCommandQueue(), (cl_mem)mat.data, devData, origin, origin,
|
clEnqueueCopyBufferRect((cl_command_queue)mat.clCxt->oclCommandQueue(), (cl_mem)mat.data, devData, origin, origin,
|
||||||
regin, mat.step, 0, mat.cols * mat.elemSize(), 0, 0, NULL, NULL);
|
regin, mat.step, 0, mat.cols * mat.elemSize(), 0, 0, NULL, NULL);
|
||||||
}
|
clFlush((cl_command_queue)mat.clCxt->oclCommandQueue());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
devData = (cl_mem)mat.data;
|
devData = (cl_mem)mat.data;
|
||||||
@ -206,7 +207,7 @@ namespace cv
|
|||||||
clEnqueueCopyBufferToImage((cl_command_queue)mat.clCxt->oclCommandQueue(), devData, texture, 0, origin, region, 0, NULL, 0);
|
clEnqueueCopyBufferToImage((cl_command_queue)mat.clCxt->oclCommandQueue(), devData, texture, 0, origin, region, 0, NULL, 0);
|
||||||
if ((mat.cols * mat.elemSize() != mat.step))
|
if ((mat.cols * mat.elemSize() != mat.step))
|
||||||
{
|
{
|
||||||
clFinish((cl_command_queue)mat.clCxt->oclCommandQueue());
|
clFlush((cl_command_queue)mat.clCxt->oclCommandQueue());
|
||||||
clReleaseMemObject(devData);
|
clReleaseMemObject(devData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +232,8 @@ namespace cv
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
cv::ocl::openCLGetKernelFromSource(clCxt, &_kernel_string, "test_func");
|
cv::ocl::openCLGetKernelFromSource(clCxt, &_kernel_string, "test_func");
|
||||||
//_support = true;
|
finish();
|
||||||
|
_support = true;
|
||||||
}
|
}
|
||||||
catch (const cv::Exception& e)
|
catch (const cv::Exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user