Question

I'm using Xcode (version 5.3) to compile OpenCL kernels to bitcode, as explained in WWDC 2013 session 508.

Xcode generates 4 different files, each with a different extension according to the architecture for which it has been targeted for.

The extensions are: cl.gpu_32.bc , cl.gpu_64.bc , cl.x84_64.bc, cl.i386.bc

In session 508, they only load a single file (The one with the cl.gpu_32.bc extension and use it).

Is it possible to generate a single cl_program that support all devices associated with the context?

How do I know which architecture to use for each of the available devices?

A sample code that reads all files and generate a single cl_program would be very helpful.

Was it helpful?

Solution

Apple provides sample code that covers loading platform-specific bitcode: https://developer.apple.com/library/mac/samplecode/OpenCLOfflineCompilation/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011196

From the description:

This sample demonstrates how developers can utilize the OpenCL offline compiler to transform their human-readable OpenCL source files into shippable bitcode. It includes an example Makefile that demonstrates how to invoke the compiler, and a self-contained OpenCL program that shows how to build a program from the generated bitcode. The sample covers the case of using bitcode on 64 and 32 bit CPU devices, as well as 32 bit GPU devices.

The readme covers the CLI arguments and the single-file C program contains lots of explanations.

OTHER TIPS

Seems from Apple Sample Code (referenced by weichsel), that all is needed is to get CL_DEVICE_ADDRESS_BITS and CL_DEVICE_TYPE_GPU using clGetDeviceInfo to distinguish between all possible different architectures.

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