[Openmp-commits] [llvm] [openmp] [OpenMP] Change build of OpenMP device runtime to be a separate runtime (PR #136729)

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Wed Apr 23 08:34:25 PDT 2025


jdoerfert wrote:

To make one thing clear early on: **Standalone**, this only introduces cost. There is no tangible benefit from this PR, but a CMake change that will break people. If this is done after other reorganizations have happened, e.g., a generic device RTL is created, this might change, though I am not sure about tangible benefits then either.


Alternative Proposal:
```
offload/DeviceRTL/generic
offload/DeviceRTL/openmp
offload/DeviceRTL/openacc
offload/DeviceRTL/sycl
offload/DeviceRTL/cuda
...
```
Now `DeviceRTL.openmp.a` lives in .../openmp/ and we can guard building it with "OPENMP_IS_ENABLED".

Background:
`DeviceRTL.openmp.a` is dependent on offload and openmp.
It provides no functionality without both enabled (see the theoretical use case below).
Moving the code to openmp has no direct impact on anyone, except the cmake change.
W/ and w/o the PR we can use a CMake conditional to only build `DeviceRTL.openmp.a` if openmp is enabled, thus, we can "build what we need" either way.

Upsides of this PR (as I remember them):
- More OpenMP-dependent code lives inside of openmp.
- The other theoretical use case is that one could build openmp only, and then "send" the DeviceRTL to someone else. I doubt that it is practical.

Upsides of my proposal:
- The OpenMP deviceRTL code has no (and likely won't ever have any) connection to the OpenMP host runtime in openmp/ but, at least for now, there are clear connections to code in offload/ (e.g., the global debug flags). This might change once we have a generic part; we should put effort into that first.
- All device RTLs live together. They will share common code in generic, but also be similar in nature. Having them in one place helps people look around and see how it was solved in language "X", find and refactor common code, etc. One folder for all the GPU device code, one place to look, one place to put things. This is also more flexible: Let's say language X and Y want to share some code, and with this proposal, that is either in generic, or lives in top-level X or top-level Y. We could have it in `DeviceRTL/XY-common` instead.
- We have a clear place for the device RTLs for future languages. OpenMP is special since it has a top-level directory, but the others do not, and I don't assume all of them will. All DeviceRTLs will depend on offload, so putting them into offload satisfies one of their dependencies, even if there is a second one, e.g., to openmp.

Now, one could argue DeviceRTLs should not be in offload but maybe compilerRT. Even then, I'd argue you want `compiler-rt/DeviceRTL/{openmp,sycl,...}` not `compiler-rt/{openmp,sycl,...}/DeviceRTL`.




https://github.com/llvm/llvm-project/pull/136729


More information about the Openmp-commits mailing list