Where are the ICV and runtime functions defined?

Hello together,

now, that I'm making progress with my OpenCL/SPIR-V implementation (I got a running subset with proper parallelisation), I seem to get blind on both eyes when it comes to finding things.

I would be very thankful, if someone could tell me, where to implement the ICVs and runtime functions (I mean the ones defined in the specification). Or are they implemented once and not per target platform?

Also, I'm not sure, if the runtime functions should be callable from target region, but it seems so. This would mean that I have to write some SPIR-V functions for each declared function in omp.h. Where do I put these?

Thanks in advance,
Daniel

Hi,

I assume you are talking about using OpenCL to implement the target constructs aka offloading?

There are two things:
1) You need a plugin for libomptarget that handles the mapping from the target agnostic runtime entry points to the OpenCL runtime. There are already some committed to SVN (generic ELF one for x86 and ppc and one for CUDA)
2) You need an OpenMP runtime that can be linked to implement device side functions. For x86, the same runtime is used as on the host (libomp). The NVPTX implementation is currently under review: https://reviews.llvm.org/D14254

Does that answer your questions?
Jonas

Thank you! That is exactly what I was looking for.
The plugin rtl is already done, but I was missing the device runtime.

So far, I implemented stuff like for_static_init() directly in clang. Is this undesirable?
In a later step, I wanted to get rid of the ub, lb, etc. references which is not possible if this has to implemented as runtime functions instead of codegen. Any advice?

I am using OpenCL 2.1 and generate SPIR-V kernels. Thus, I would like to have the device runtime functions as SPIR-V functions (compiled offline from OpenCL). How do I handle this to be upstreamable?

Daniel