mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
core(ocl): options to control buffer access flags
- control using of clEnqueueMapBuffer or clEnqueueReadBuffer[Rect] - added benchmarks with OpenCL buffer access use cases
This commit is contained in:
@@ -4607,6 +4607,17 @@ public:
|
||||
return u;
|
||||
}
|
||||
|
||||
static bool isOpenCLMapForced() // force clEnqueueMapBuffer / clEnqueueUnmapMemObject OpenCL API
|
||||
{
|
||||
static bool value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_BUFFER_FORCE_MAPPING", false);
|
||||
return value;
|
||||
}
|
||||
static bool isOpenCLCopyingForced() // force clEnqueueReadBuffer[Rect] / clEnqueueWriteBuffer[Rect] OpenCL API
|
||||
{
|
||||
static bool value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_BUFFER_FORCE_COPYING", false);
|
||||
return value;
|
||||
}
|
||||
|
||||
void getBestFlags(const Context& ctx, int /*flags*/, UMatUsageFlags usageFlags, int& createFlags, int& flags0) const
|
||||
{
|
||||
const Device& dev = ctx.device(0);
|
||||
@@ -4614,7 +4625,15 @@ public:
|
||||
if ((usageFlags & USAGE_ALLOCATE_HOST_MEMORY) != 0)
|
||||
createFlags |= CL_MEM_ALLOC_HOST_PTR;
|
||||
|
||||
if( dev.hostUnifiedMemory() )
|
||||
if (!isOpenCLCopyingForced() &&
|
||||
(isOpenCLMapForced() ||
|
||||
(dev.hostUnifiedMemory()
|
||||
#ifndef __APPLE__
|
||||
|| dev.isIntel()
|
||||
#endif
|
||||
)
|
||||
)
|
||||
)
|
||||
flags0 = 0;
|
||||
else
|
||||
flags0 = UMatData::COPY_ON_MAP;
|
||||
|
||||
Reference in New Issue
Block a user