OpenCL support - using metadata

Anton Lokhmotov wrote:

Given that at least two companies have found metadata useful for

representing OpenCL C features in LLVM-IR, I think the community needs to

reconsider the use of metadata, perhaps introducing a ‘sticky’ variant of

it?

We at Intel are also using metadata for our implementation. This approach is very useful for a few reasons:

First, when compiling OpenCL C code to llvm, some important information about the kernel arguments is lost. i.e. typedefs are lost, structures are sometimes disassembled. We’re adding a string containing the interesting part original function signature. This can also be used for providing data about the kernel arguments, validating the arguments set by the user, etc…

Second, we use a global metadata node, which enumerates all the kernel functions. This can be used to quickly enumerate the kernels in a program, instead of passing the whole module.

Third, for each kernel we hold the kernel attributes in the same metadata: vector type hint, required workgroup size and workgroup size hint.

Last, we also hold in the metadata a list of the local variables defined in that kernel.

Thanks

Guy

image001.png