Reputation: 437
I'm using OpenCL on OS X, I was wondering if someone could tell me the compiler which is used to generate the GPU binary from the OpenCL kernel source code? In OS X is the OpenCL kernel compiled to LLVM first then optimized and then finally compiled to GPU native code? Also I was wondering if the OpenCL kernel compiler does optimisations on the kernel such as loop invariant code motion?
Upvotes: 1
Views: 396
Reputation: 9886
Yes, on Mac OS X all OpenCL code is compiled to LLVM IR, which is then passed to device-specific optimizations and code generation.
You can generate LLVM bitcode files offline, and use the result in clCreateProgramWithBinary. The openclc compiler is inside the OpenCL framework (/System/Library/Framework/OpenCL.framework/Libraries/openclc). You need these options (arch can be i386, x86_64, gpu_32):
openclc -c -o foo.bc -arch gpu_32 -emit-llvm foo.cl
Upvotes: 3