[Mesa-stable] [PATCH 2/2] clover: Use threadsafe wrappers for pipe_context v2

Francisco Jerez currojerez at riseup.net
Sat Jul 11 03:47:26 PDT 2015


Tom Stellard <thomas.stellard at amd.com> writes:

> Events can be added to an OpenCL command queue concurrently from multiple
> threads, but pipe_context bjects are not threadsafe.  The threadsafe
> wrappers protect all pipe_context function calls with a mutex, so we
> can safely use them with multiple threads.
>
> v2:
>   - Don't use wrapper for pipe_screen.
>
> CC: 10.6 <mesa-stable at lists.freedesktop.org>

Thanks, this patch is:
Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/gallium/state_trackers/clover/core/queue.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/queue.cpp b/src/gallium/state_trackers/clover/core/queue.cpp
> index 87f9dcc..16b089c 100644
> --- a/src/gallium/state_trackers/clover/core/queue.cpp
> +++ b/src/gallium/state_trackers/clover/core/queue.cpp
> @@ -24,6 +24,7 @@
>  #include "core/event.hpp"
>  #include "pipe/p_screen.h"
>  #include "pipe/p_context.h"
> +#include "threadsafe/threadsafe.h"
>  
>  using namespace clover;
>  
> @@ -33,6 +34,7 @@ command_queue::command_queue(clover::context &ctx, clover::device &dev,
>     pipe = dev.pipe->context_create(dev.pipe, NULL);
>     if (!pipe)
>        throw error(CL_INVALID_DEVICE);
> +   pipe = pipe_threadsafe_context(pipe);
>  }
>  
>  command_queue::~command_queue() {
> diff --git a/src/gallium/targets/opencl/Makefile.am b/src/gallium/targets/opencl/Makefile.am
> index 70e60e2..be5a59d 100644
> --- a/src/gallium/targets/opencl/Makefile.am
> +++ b/src/gallium/targets/opencl/Makefile.am
> @@ -16,6 +16,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 \
> @@ -36,7 +37,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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-stable/attachments/20150711/095e8737/attachment-0001.sig>


More information about the mesa-stable mailing list