Question

When creating OpenCL Bitcode, Xcode 5 provides a way to control the version by using "-cl-std" flag defined by the OpenCL standard.

According to the standard, it seems that this flag can be omitted in order to create bitcode that is compatible with OpenCL C 1.0.

However, when I omit this flag in Xcode (by copying paste the command that it generates, remove this flag and run it manually), the result is identical to the result when the flag is "-cl-std=1.1".

Is it possible to create bitcode that is compatible with OpenCL C 1.0 (for Mac)?

Was it helpful?

Solution

Actually, the standard indicates that if you omit the -cl-std flag, the program will be compiled for the version of OpenCL C that the target device supports:

If the –cl-std build option is not specified, the CL_DEVICE_OPENCL_C_VERSION is used to select the version of OpenCL C to be used when compiling the program for each device.

If you are using an offline compiler, you are not necessarily targeting a specific device, and the default value is probably implementation defined. There is no OpenCL standard flag for compiling a program using OpenCL C 1.0.

Moreover, the -cl-std flag indicates which OpenCL C language version should be used when compiling your program. This is completely independent from the format of the bitcode used to store that compiled program. A program could be compiled for 1.0, 1.1 and 1.2 and still generate the same bitcode. Whether it's possible to have a single bitcode that is compatible with all OpenCL devices from 1.0 onwards is not clear from Apple's documentation; they seem to suggest that bitcode is the most portable way of shipping OpenCL binaries, but don't say anything about this kind of compatibility explicitly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top