[clang] [OpenMP] Allow GPUs to be targeted directly via `-fopenmp`. (PR #122149)

Krzysztof Parzyszek via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 9 09:08:21 PST 2025


kparzysz wrote:

> All that said, there are two cases to consider wrt. the standard:
> 
> 1. The initial device is the CPU and the code compiled here is just part of a GPU library, or
> 2. the initial device is the GPU and the code compiled here is just part of the "host code".
> 
> For 1), omp target, w/o ancestor, is disallowed, IIRC. For 2), it should work as if it is a task, basically we do not implement "offloading" from this host, which is totally fine.

Option (2) summarizes my point of view.

The use case that I have in mind for this is
```
cc -fopenmp -target=cpu -offload-target=gpu -c foo.c
cc -fopenmp -target=gpu -c bar.c
link device-part-of-foo.o bar.o -o works-on-gpu
```

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


More information about the cfe-commits mailing list