Offloading API

Hi all,

Some of my colleagues and I are currently developing the infrastructure for adding a new device, the cloud, to the list of available targets. Considering the cloud as a device requires few changes to the API of the offloading library (libomptarget). Indeed, our cloud device handles offloading data thanks to files instead of values within an address space. To do so, we had to associate each offloaded variables with a unique identifier. Those identifiers are assigned by Clang to each variable, then transmitted to libomptarget as an additional argument of the offloading function “__tgt_target”. In case of pointer addresses that are not generated by Clang, the special identifier “-1” is attributed. This allows us to easily skip the offloading of these addresses that our device doesn’t use.

You can find attached the patches including the needed modifications both for Clang and libomptarget (based on the repositories of If needed, I can make a push request directly in github.

Let’s us precise that we plan to open source all this work and to submit patches to the upstream Clang/OpenMP repositories when it will be mature enough. Additionally to simplify future integrations, those API changes can be helpful for any exotic offloading target. That’s why we propose to integrate them directly.


libomptarget-identifiers.patch (20.2 KB)

clang-identifiers.patch (11.9 KB)

Hi Herve,

Sounds like an interesting project the one you are working on!

From your description I didn’t understand well how you are dealing with the map of pointers. When you say that you have a pointer not generated by clang, what else is generating it? Can you elaborate on that. I think it will also help if you post a small example of what you are trying to accomplish.

I think it will be good to create a pull request in github so we can more easily comment on the code you have.


Ok, the following of the discussion takes place there:



I can’t get the idea to associate an identifier with a variable. Consider you have multiple threads running on host and each thread has its own private copy of a variable. How would you name it in Clang then? How would you change naming in case number of threads is defined dynamicly?
I bet that this should be an offload library duty to associate the host address of a variable with the (file?) identifier. Then you will reuse the same identifier while mapping is alive and will replace it with the new one as soon as mapping will be re-created anew.


Hi Sergey,

Thank you for the comment, I think you are right :slight_smile:
Indeed, the example with threads is quite convincing… I still need to figure out some technical details during the code generation specific to my target but I will try to make a new pull request next week.