[Mesa-dev] [PATCH 2/2] clover: Use threadsafe wrappers for pipe_screen and pipe_context

Tom Stellard thomas.stellard at amd.com
Tue May 12 11:07:44 PDT 2015


Events can be added to an OpenCL command queue concurrently from
multiple threads, but pipe_context and pipe_screen objects
are not threadsafe.  The threadsafe wrappers protect all pipe_screen
and pipe_context function calls with a mutex, so we can
safely use them with multiple threads.

CC: 10.5 <mesa-stable at lists.freedesktop.org
---
 src/gallium/state_trackers/clover/core/device.cpp | 2 ++
 src/gallium/targets/opencl/Makefile.am            | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index 42b45b7..d183e73 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -24,6 +24,7 @@
 #include "core/platform.hpp"
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
+#include "threadsafe/threadsafe.h"
 
 using namespace clover;
 
@@ -47,6 +48,7 @@ device::device(clover::platform &platform, pipe_loader_device *ldev) :
          pipe->destroy(pipe);
       throw error(CL_INVALID_DEVICE);
    }
+   pipe = pipe_threadsafe_screen(pipe);
 }
 
 device::~device() {
diff --git a/src/gallium/targets/opencl/Makefile.am b/src/gallium/targets/opencl/Makefile.am
index 5daf327..2144de1 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -18,6 +18,7 @@ endif
 
 lib at OPENCL_LIBNAME@_la_LIBADD = \
 	$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_client.la \
+	$(top_builddir)/src/gallium/drivers/threadsafe/libthreadsafe.la \
 	$(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
 	$(top_builddir)/src/gallium/auxiliary/libgallium.la \
 	$(top_builddir)/src/util/libmesautil.la \
@@ -38,7 +39,8 @@ lib at OPENCL_LIBNAME@_la_LIBADD = \
 	-lclangEdit \
 	-lclangLex \
 	-lclangBasic \
-	$(LLVM_LIBS)
+	$(LLVM_LIBS) \
+	$(PTHREAD_LIBS)
 
 nodist_EXTRA_lib at OPENCL_LIBNAME@_la_SOURCES = dummy.cpp
 lib at OPENCL_LIBNAME@_la_SOURCES =
-- 
2.0.4



More information about the mesa-dev mailing list