Hi Roel, Chris,
This is a summary on how you can add support for a a different offloading device on top of what we have in github for OpenMP:
a) Download and install lvm (https://github.com/clang-omp/llvm_trunk), and clang (https://github.com/clang-omp/clang_trunk) as usual
b) install the official llvm OpenMP runtime library openmp.llvm.org. Clang will expect that to be present in your library path in order to compile OpenMP code (even if you do not need any OpenMP feature other than offloading).
c) Install https://github.com/clang-omp/libomptarget (running ‘make’ should do it). This library implements the API to control offloading. It also contains a set of plugins to some targets we are testing this with - x86_64, powerpc64 and NVPTX - in ./RTLs. You will need to implement a plug in for your target as well. The interface used for these plugins is detailed in the document proposed in http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084986.html .You can look at the existing plugins for a hint. In a nutshell you would have to implement code that allocates and moves data to your device, returns a table of entry points and global variables given a device library and launches execution of a given entry point with the provided list of arguments.
d) The current implementation is expecting the device library to use ELF format. There is no reason for that other than the platforms we tested this with so far use ELF format. If your device does not use ELF __tgt_register_lib() (src/omptarget.cpp) would have to be extended to understand your desired format. Otherwise you may just update src/targets_info.cpp with your ELF ID and plugin name.
e) Offloading is driven by clang, so it has to be aware of the required by yourr device. If your device toolchain is not implemented in clang you would have to do that in lib/Driver/ToolChains.cpp.
f) Once everything is in place, you can compile your code by running something like “clang -fopenmp -omptargets=your-target-triple app.c”. If you do separate compilation you could see that two different files are generated for a given source file (the target file has the suffix tgt-your-target-triple).
I should say that in general OpenMP requires a runtime library for the device as well, however if you do not use any OpenMP pragmas inside your target code you won’t need that.
We started porting our code related with offloading currently in github to clang upstream. The driver support is currently under review in http://reviews.llvm.org/D9888. We are about to send our first offloading codegen patches as well.
I understand that what Chris is proposing is somewhat different that what we have in place, given that the transformations are intended to be in LLVM IR. However, the goal seems to be the same. Hope the summary above gives you some hints on whether your use cases can be accommodated.
Feel free to ask any questions you may have.
Thanks!
Samuel