1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

instrumentation: minor refactoring, wrap OpenCL

- calculate ticksTotal instead of ticksMean
- local / global width is based on ticksTotal value
- added instrumentation for OpenCL program compilation
- added instrumentation for OpenCL kernel execution
This commit is contained in:
Alexander Alekhin
2016-08-25 17:26:46 +03:00
parent 4013ce570f
commit 10d18a315c
6 changed files with 86 additions and 54 deletions
+10
View File
@@ -45,6 +45,7 @@
#include <string>
#include <sstream>
#include <iostream> // std::cerr
#include <inttypes.h>
#define CV_OPENCL_ALWAYS_SHOW_BUILD_LOG 0
#define CV_OPENCL_SHOW_RUN_ERRORS 0
@@ -3169,6 +3170,9 @@ struct Kernel::Impl
{
cl_program ph = (cl_program)prog.ptr();
cl_int retval = 0;
#ifdef ENABLE_INSTRUMENTATION
name = kname;
#endif
handle = ph != 0 ?
clCreateKernel(ph, kname, &retval) : 0;
CV_OclDbgAssert(retval == CL_SUCCESS);
@@ -3221,6 +3225,9 @@ struct Kernel::Impl
IMPLEMENT_REFCOUNTABLE();
#ifdef ENABLE_INSTRUMENTATION
cv::String name;
#endif
cl_kernel handle;
cl_event e;
enum { MAX_ARRS = 16 };
@@ -3441,6 +3448,8 @@ int Kernel::set(int i, const KernelArg& arg)
bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
bool sync, const Queue& q)
{
CV_INSTRUMENT_REGION_META(p->name.c_str(), instr::TYPE_FUN, instr::IMPL_OPENCL);
if(!p || !p->handle || p->e != 0)
return false;
@@ -3552,6 +3561,7 @@ struct Program::Impl
Impl(const ProgramSource& _src,
const String& _buildflags, String& errmsg)
{
CV_INSTRUMENT_REGION_OPENCL_(cv::format("Compile: %" PRIx64 " options: %s", _src.hash(), _buildflags.c_str()).c_str());
refcount = 1;
const Context& ctx = Context::getDefault();
src = _src;