[FFmpeg-devel] [PATCH] lavu/opencl: ticket #2422 opencl using dynamic mutex

Michael Niedermayer michaelni at gmx.at
Sat Jun 29 01:11:24 CEST 2013


On Fri, Jun 28, 2013 at 06:17:36PM +0800, Wei Gao wrote:
> Hi
> 
> The attachment is about the opencl using dynamic mutex, I have tested on my
> comoputer in pthread, I can't compile a win32 version, can anyone help to
> test?
> 
> Thanks
> Best regards

>  configure          |    2 -
>  libavutil/opencl.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++-----
>  2 files changed, 54 insertions(+), 7 deletions(-)
> 072c7c1358f4002dcfe9b71987e775d3de6ec9a5  0001-lavu-opencl-ticket-2422-opencl-using-dynamic-mutex.patch
> From cd6ef1a9bae0081364799a49988d678afe805338 Mon Sep 17 00:00:00 2001
> From: highgod0401 <highgod0401 at gmail.com>
> Date: Fri, 28 Jun 2013 18:13:10 +0800
> Subject: [PATCH] lavu/opencl: ticket #2422 opencl using dynamic mutex
> 
> ---
>  configure          |  2 --
>  libavutil/opencl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++-----
>  2 files changed, 54 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index a179036..d3d5580 100755
> --- a/configure
> +++ b/configure
> @@ -4185,8 +4185,6 @@ enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lO
>  enabled opencl            && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
>                                 check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
>                                 die "ERROR: opencl not found"; } &&
> -                             { enabled_any w32threads os2threads &&
> -                               die "opencl currently needs --enable-pthreads or --disable-w32threads"; } &&
>                               { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
>                                 check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
>                                 die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
> diff --git a/libavutil/opencl.c b/libavutil/opencl.c
> index 5887b50..e5de2a7 100644
> --- a/libavutil/opencl.c
> +++ b/libavutil/opencl.c
> @@ -25,18 +25,24 @@
>  #include "log.h"
>  #include "avassert.h"
>  #include "opt.h"
> +#include "atomic.h"
>  
>  #if HAVE_PTHREADS
> -
>  #include <pthread.h>
> -static pthread_mutex_t atomic_opencl_lock = PTHREAD_MUTEX_INITIALIZER;
> +#elif HAVE_W32THREADS
> +#include "compat/w32pthreads.h"
> +#elif HAVE_OS2THREADS
> +#include "compat/os2threads.h"
> +#endif
>  
> -#define LOCK_OPENCL pthread_mutex_lock(&atomic_opencl_lock)
> -#define UNLOCK_OPENCL pthread_mutex_unlock(&atomic_opencl_lock)
>  
> -#elif !HAVE_THREADS
> +#if !HAVE_THREADS
>  #define LOCK_OPENCL
>  #define UNLOCK_OPENCL
> +#else

> +static pthread_mutex_t atomic_opencl_lock = NULL;


> +    if (avpriv_atomic_ptr_cas((void * volatile *)&atomic_opencl_lock, NULL, opencl_mutex)) {

atomic_opencl_lock must be a pointer you cannot cast a opaque type
to a pointer and treat it like one

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130629/73ef0b6b/attachment.asc>


More information about the ffmpeg-devel mailing list