1
votes

I'm interested in using an optional extension to OpenCL which adds certain functions to the OpenCL language (in particular, cl_khr_gl_msaa_sharing). I'm using Apple's openclc to compile my OpenCL sources at build-time, however, openclc fails to compile my source (see below) because of calls to these new functions. The machine I'm running on does, indeed, support the extensions, and if I use clCreateProgramWithSource() and clBuildProgram() at runtime, everything works great.

Obviously, any build-time tool can't know which extensions are supported at run-time. However, I'd like to be able to compile my source at build-time assuming the extension exists, then at run-time query for the presence for the extension and degrade gracefully if the extension isn't present. Is there a mechanism for doing anything like this?

The top answer to OpenCL half4 type Apple OS X suggests using preprocessor defines inside the OpenCL program to detect extensions, but that won't help me as those defines are evaluated at build-time.

The particular build-time compiler error is this: error: target does not support depth and MSAA textures

1
I haven't used Apple's openclc (Windows user here) but the error message suggests to me that openclc expects some target specification, perhaps in the form of a CPU or GPU model number, or simply you forgot to tell openclc whether it should target the CPU or GPU on your computer and its default device is not the right one.chippies

1 Answers

1
votes

I had a similar problem; I wanted the compiler to assume that the extension cl_khr_fp64 existed so I could use the boilerplate code

#ifdef cl_khr_fp64
    #pragma OPENCL EXTENSION cl_khr_fp64 : enable
#elif defined(cl_amd_fp64)
    #pragma OPENCL EXTENSION cl_amd_fp64 : enable
#else
    #error "Double precision floating point not supported by OpenCL implementation."
#endif

and have it compile as if double precision was available.

The solution (as of XCode 6.3.1) was to select Target > Build Settings > OpenCL - Preprocessing, and add cl_khr_fp64 to the OPENCL_PREPROCESSOR_DEFINITIONS section.

The code then compiled without complaining within XCode, assuming there were no syntax errors in my source code (which is what I wanted to check).