diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 2cf1e35dc5..f864510de6 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -283,7 +283,6 @@ public: void* data, size_t* step, int flags) const = 0; virtual bool allocate(UMatData* data, int accessflags) const = 0; virtual void deallocate(UMatData* data) const = 0; - virtual void sync(UMatData* u) const; virtual void map(UMatData* data, int accessflags) const; virtual void unmap(UMatData* data) const; virtual void download(UMatData* data, void* dst, int dims, const size_t sz[], diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 07da4ad724..919452dc98 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -48,10 +48,6 @@ namespace cv { -void MatAllocator::sync(UMatData*) const -{ -} - void MatAllocator::map(UMatData*, int) const { } diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 1616267bee..64460efb0d 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -2268,8 +2268,8 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[], CV_Assert(_globalsize != 0); for (int i = 0; i < dims; i++) { - size_t val = _localsize ? _localsize[i] : 1; - //dims == 1 ? 64 : dims == 2 ? (16>>i) : dims == 3 ? (8>>(int)(i>0)) : 1; + size_t val = _localsize ? _localsize[i] : + dims == 1 ? 64 : dims == 2 ? (16>>i) : dims == 3 ? (8>>(int)(i>0)) : 1; CV_Assert( val > 0 ); total *= _globalsize[i]; globalsize[i] = ((_globalsize[i] + val - 1)/val)*val; @@ -2721,7 +2721,7 @@ public: return true; } - void sync(UMatData* u) const + /*void sync(UMatData* u) const { cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); UMatDataAutoLock lock(u); @@ -2749,19 +2749,19 @@ public: clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, u->data, 0, 0, 0); } - } + }*/ void deallocate(UMatData* u) const { if(!u) return; - UMatDataAutoLock lock(u); // TODO: !!! when we add Shared Virtual Memory Support, // this function (as well as the others) should be corrected CV_Assert(u->handle != 0 && u->urefcount == 0); if(u->tempUMat()) { + UMatDataAutoLock lock(u); if( u->hostCopyObsolete() && u->refcount > 0 ) { cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); @@ -2792,6 +2792,7 @@ public: } else { + CV_Assert(u->refcount == 0); if(u->data && u->copyOnMap() && !(u->flags & UMatData::USER_ALLOCATED)) { fastFree(u->data); diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index de8cd07be0..e8144cd646 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -286,8 +286,6 @@ void UMat::copySize(const UMat& m) UMat::~UMat() { - //if( u && u->refcount > 0 ) - // u->currAllocator->sync(u); release(); if( step.p != step.buf ) fastFree(step.p); diff --git a/modules/ocl/test/test_api.cpp b/modules/ocl/test/test_api.cpp index 68888a7c08..a54ebb7cdf 100644 --- a/modules/ocl/test/test_api.cpp +++ b/modules/ocl/test/test_api.cpp @@ -83,12 +83,8 @@ TEST(TestAPI, openCLExecuteKernelInterop) TEST(OCL_TestTAPI, performance) { cv::RNG rng; -#if 1 cv::Mat src(1280,768,CV_8UC4), dst; rng.fill(src, RNG::UNIFORM, 0, 255); -#else - cv::Mat src = cv::imread("/Users/vp/work/opencv/samples/c/lena.jpg", 1), dst; -#endif cv::UMat usrc, udst; src.copyTo(usrc); @@ -130,9 +126,4 @@ TEST(OCL_TestTAPI, performance) } t = (double)cv::getTickCount() - t; printf("cpu exec time = %gms per iter\n", t*1000./niters/cv::getTickFrequency()); - /*cv::imshow("result0", dst); - cv::imshow("result1", udst); - cv::waitKey(); - cv::destroyWindow("result0"); - cv::destroyWindow("result1");*/ }