From 6bd7a444bc7e5ed3fcfe7bb452f7f5d536ad1215 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 20 Mar 2014 19:53:38 +0400 Subject: [PATCH] UMat map-unmap synchronization test --- modules/core/test/test_umat.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/core/test/test_umat.cpp b/modules/core/test/test_umat.cpp index 60f9ee66a3..e2d1b33d99 100644 --- a/modules/core/test/test_umat.cpp +++ b/modules/core/test/test_umat.cpp @@ -795,4 +795,42 @@ TEST(UMat, ReadBufferRect) EXPECT_MAT_NEAR(t, t2, 0); } +// Use iGPU or OPENCV_OPENCL_DEVICE=:CPU: to catch problem +TEST(UMat, DISABLED_synchronization_map_unmap) +{ + class TestParallelLoopBody : public cv::ParallelLoopBody + { + UMat u_; + public: + TestParallelLoopBody(const UMat& u) : u_(u) { } + void operator() (const cv::Range& range) const + { + printf("range: %d, %d -- begin\n", range.start, range.end); + for (int i = 0; i < 10; i++) + { + printf("%d: %d map...\n", range.start, i); + Mat m = u_.getMat(cv::ACCESS_READ); + + printf("%d: %d unmap...\n", range.start, i); + m.release(); + } + printf("range: %d, %d -- end\n", range.start, range.end); + } + }; + try + { + UMat u(1000, 1000, CV_32FC1); + parallel_for_(cv::Range(0, 2), TestParallelLoopBody(u)); + } + catch (const cv::Exception& e) + { + FAIL() << "Exception: " << e.what(); + ADD_FAILURE(); + } + catch (...) + { + FAIL() << "Exception!"; + } +} + } } // namespace cvtest::ocl