[FFmpeg-devel] configure needs to check for OpenCL version 1.2 and look elsewhere as well
Hanspeter Niederstrasser
niederstrasser at gmail.com
Sat Apr 20 16:31:58 CEST 2013
On Fri, Apr 19, 2013 at 10:52 PM, Wei Gao <highgod0401 at gmail.com> wrote:
> Hi, sorry for replying late, and also I am not familiar with configure
> things, I do some works and test as your patch, some comments as follows:
No problem. I'm also trying to figure this out as I go.
> 2013/4/13 Hanspeter Niederstrasser <niederstrasser at gmail.com>
>
>> The OpenCL test just checks for CL/cl.h which doesn't exist on OS X
>> (it's at OpenCL/cl.h). In trying to fix that, I also noticed that
>> ffmpeg needs OpenCL >= 1.2, so I tried to add a version check to
>> configure as well. Here's my current patch, but it is not setting
>> HAVE_OPENCL_CL_H, even though config.log says that the header and
>> library were found.
>>
>> diff --git a/configure b/configure
>> index fe976fd..83bb71f 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1471,6 +1471,7 @@ HAVE_LIST="
>> mprotect
>> msvcrt
>> nanosleep
>> + opencl_cl_h
>> openjpeg_1_5_openjpeg_h
>> PeekNamedPipe
>> perl
>>
> it should add a check header line:check_header opencl/cl.h to set the
> opencl_cl_h
Both check_lib() and require() already call check_header(), but even
when I just use
enabled opencl && check_header OpenCL/cl.h
HAVE_OPENCL_CL_H is not set in config.log. To make sure my syntax is
right, when I search for the completely unrelated header
"exiv2/exv_conf.h", HAVE_EXIV2_EXV_CONF_H is set to 1 in config.log.
>> @@ -4034,7 +4035,12 @@ enabled openal && { { for al_libs in
>> "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32
>> die "ERROR: openal not found"; } &&
>> { check_cpp_condition "AL/al.h"
>> "defined(AL_VERSION_1_1)" ||
>> die "ERROR: openal must be installed and
>> version must be 1.1 or compatible"; }
>> -enabled opencl && require2 opencl CL/cl.h clEnqueueNDRangeKernel
>> -lOpenCL
>> +enabled opencl && { check_lib OpenCL/cl.h clEnqueueNDRangeKernel
>> -Wl,-framework,OpenCL ||
>> + check_lib CL/cl.h clEnqueueNDRangeKernel -lOpenCL
>> ||
>> + die "ERROR: opencl not found"; } &&
>> + { 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"; }
>>
> I tried this on my computer, it does not pass the configure, I think it
> should be written like this:
> enabled opencl && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel
> -Wl,-framework,OpenCL ||
> check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL
> ||
> die "ERROR: opencl not found"; } &&
> { 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"; }
> use check_lib2 to check, and this can pass on my computer.
I've tried that too and configure accepts it, but config.log doesn't
provide any indication that the header or the library were not found.
If I give it a non-existing header, configure errors out, so the
syntax seems right.
> And I want to
> ask a question: -Wl,-framework,OpenCL, what does these mean? Isn't
> -lOpenCL OK?
On OS X, the system OpenCL is found inside a Framework, rather than in
the usual $(PREFIX)/{include,lib} layout found in most other systems,
so -lOpenCL will not work. The actual file path is complicated, but
OS X compilers and linkers know where to search for Frameworks if
provided with a header of the form "OpenCL/cl.h" and a library of
"-framework OpenCL". The "-Wl,-framework,OpenCL" string is just an
alternative syntax so that the compiler passes "-framework OpenCL" to
the linker.
https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html
> enabled openssl && { check_lib openssl/ssl.h SSL_library_init
>> -lssl -lcrypto ||
>> check_lib openssl/ssl.h SSL_library_init
>> -lssl32 -leay32 ||
>> check_lib openssl/ssl.h SSL_library_init
>> -lssl -lcrypto -lws2_32 -lgdi32 ||
>> diff --git a/libavutil/opencl.h b/libavutil/opencl.h
>> index acafe36..5450537 100644
>> --- a/libavutil/opencl.h
>> +++ b/libavutil/opencl.h
>> @@ -31,7 +31,11 @@
>> #ifndef LIBAVUTIL_OPENCL_H
>> #define LIBAVUTIL_OPENCL_H
>>
>> +#if HAVE_OPENCL_CL_H
>> +#include <OpenCL/cl.h>
>> +#else
>> #include <CL/cl.h>
>> +#endif
>> #include "config.h"
>> #include "dict.h"
>>
> I think the #include "config.h" should above the #if HAVE_OPENCL_CL_H
> line. It should be written as follows:
>
> #include "config.h"
> +#if HAVE_OPENCL_CL_H
> +#include <OpenCL/cl.h>
> +#else
> #include <CL/cl.h>
> +#endif
> #include "dict.h"
You're right. I had kept the original order, but config.h is needed
to find HAVE_OPENCL_CL_H.
An alternative would be to conditional the header choice in opencl.h
on __APPLE__ instead of HAVE_OPENCL_CL_H. The configure check does
seem to work (it sets EXTRALIBS correctly, for example), but it would
be nice to find out why HAVE_OPENCL_CL_H is not being set. Thanks
again for your help.
Hanspeter
--
Disclaimer:
By sending an email to ANY of my addresses you are agreeing that:
1. I am by definition, "the intended recipient"
2. All information in the email is mine to do with as I see fit and
make such financial profit, political mileage, or good joke as it
lends itself to.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that
may be included with your message.
More information about the ffmpeg-devel
mailing list