[FFmpeg-devel] [PATCH]Exit configure if opencl is requested with w32threads

Michael Niedermayer michaelni at gmx.at
Thu Jun 27 13:01:27 CEST 2013


On Thu, Jun 27, 2013 at 06:10:55PM +0800, Wei Gao wrote:
> 2013/6/27 Carl Eugen Hoyos <cehoyos at ag.or.at>
> 
> > Carl Eugen Hoyos <cehoyos <at> ag.or.at> writes:
> >
> > > Attached patch should address the main issue of ticket #2422.
> >
> > Merged by Michael, thank you everybody for commenting!
> > Maybe OpenCL can be made to work with w32threads?
> >
> Hi
> 
> The attachment is the patch I want to modify, but it has bug that ffmpeg
> crush at start, I don't konw how to correct it. this is just my idea of fix
> the bug. Can anyone give some idea?
> 
> thanks
> 
> >
> > Carl Eugen
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >

>  configure          |    2 --
>  libavutil/opencl.c |   32 ++++++++++++++++++++++++++------
>  2 files changed, 26 insertions(+), 8 deletions(-)
> 645abce34312d47dd53935ff4f1b09ba06080a8b  0001-lavu-opencl-ticket-2422-opencl-with-win32-but-have-b.patch
> From ed31c2596f0a0344da5d022eb3cd3de1c184377f Mon Sep 17 00:00:00 2001
> From: highgod0401 <highgod0401 at gmail.com>
> Date: Thu, 27 Jun 2013 18:08:34 +0800
> Subject: [PATCH] lavu/opencl: ticket #2422 opencl with win32 but have bug
> 
> ---
>  configure          |  2 --
>  libavutil/opencl.c | 32 ++++++++++++++++++++++++++------
>  2 files changed, 26 insertions(+), 8 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..64de1e9 100644
> --- a/libavutil/opencl.c
> +++ b/libavutil/opencl.c
> @@ -25,18 +25,23 @@
>  #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;
> -
> -#define LOCK_OPENCL pthread_mutex_lock(&atomic_opencl_lock)
> -#define UNLOCK_OPENCL pthread_mutex_unlock(&atomic_opencl_lock)
> +#elif HAVE_W32THREADS
> +#include "compat/w32pthreads.h"
> +#elif HAVE_OS2THREADS
> +#include "compat/os2threads.h"
> +#endif
>  
> -#elif !HAVE_THREADS
> +#if !HAVE_THREADS
>  #define LOCK_OPENCL
>  #define UNLOCK_OPENCL
> +#else
> +static pthread_mutex_t atomic_opencl_lock = NULL;
> +#define LOCK_OPENCL pthread_mutex_lock(&atomic_opencl_lock)
> +#define UNLOCK_OPENCL pthread_mutex_unlock(&atomic_opencl_lock)
>  #endif
>  
>  
> @@ -588,6 +593,13 @@ static int compile_kernel_file(OpenclContext *opencl_ctx)
>  int av_opencl_init(AVOpenCLExternalEnv *ext_opencl_env)
>  {
>      int ret = 0;
> +#if HAVE_THREADS
> +    pthread_mutex_t opencl_mutex;
> +    pthread_mutex_init(&opencl_mutex, NULL);
> +    if (avpriv_atomic_ptr_cas((void * volatile *)&atomic_opencl_lock, NULL, &opencl_mutex)) {
> +        pthread_mutex_destroy(&opencl_mutex);
> +    }

that code makes no sense
pthread_t is not guramteed to be a pointer type, and you cannot
put a pointer to your local stack into a global variable. The stack
wont be there after the function, the pointer would point into
random memory


[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20130627/0be6b5a7/attachment.asc>


More information about the ffmpeg-devel mailing list