ocl: workaround for synchronization issue in ::map()
authorAlexander Alekhin <alexander.alekhin@itseez.com>
Thu, 13 Mar 2014 12:39:54 +0000 (16:39 +0400)
committerAndrey Pavlenko <andrey.pavlenko@itseez.com>
Fri, 11 Apr 2014 09:09:18 +0000 (13:09 +0400)
modules/core/src/ocl.cpp

index 2017300..9b4cf72 100644 (file)
@@ -3798,11 +3798,16 @@ public:
 
         cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
 
-        if( u->refcount == 0 )
+        // FIXIT Workaround for UMat synchronization issue
+        // if( u->refcount == 0 )
         {
             if( !u->copyOnMap() )
             {
-                CV_Assert(u->data == 0);
+                if (u->data) // FIXIT Workaround for UMat synchronization issue
+                {
+                    //CV_Assert(u->hostCopyObsolete() == false);
+                    return;
+                }
                 // because there can be other map requests for the same UMat with different access flags,
                 // we use the universal (read-write) access mode.
                 cl_int retval = 0;
@@ -3844,6 +3849,10 @@ public:
 
         UMatDataAutoLock autolock(u);
 
+        // FIXIT Workaround for UMat synchronization issue
+        if(u->refcount > 0)
+            return;
+
         cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
         cl_int retval = 0;
         if( !u->copyOnMap() && u->data )