You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenMP uses the #pragma omp declare target directive to control which variables are present on the device. Currently this cannot be used to mark any variable on the device unless it is applied to the first time that variable is seen. This can be seen in this godbolt example https://godbolt.org/z/aT9171xn6. In the first case, because the #pragma omp declare target to(x) clause is applied to an extern declaration of the variable x, OpenMP does not place it on the device. This can be seen due to the visibility begin extern and x being passed in as an argument to the GPU. However, if we instead apply it to the extern variable before the actual declaration, it will work fine.
This is currently preventing us from providing adequately wrapped headers when implementing system utilities on the GPU. I.e. we cannot do the following so there is no way to indicate that stderr is on the GPU without including everything from the host's stdio.h on the GPU as well.
This patch changes the handling of OpenMP to add the device attributes
to the canonical definitions when we encounter a non-canonical
definition. Previously, the following code would not work because it
would find the non-canonical definition first which would then not be
used anywhere else.
```
int x;
extern int x;
```
This patch now adds the attribute to both of them. This allows us to
perform the following operation if, for example, there were an
implementation of `stderr` on the device.
```
#include <stdio.h>
// List of libc symbols supported on the device.
extern FILE *stderr;
```
Unfortunately I cannot think of an equivalent solution to HIP / CUDA
device declarations as those are done with simple attributes. Attributes
themselves cannot be used to affect a definition once its canonical
definition has already been seen. Some help on that front would be
appreciated.
Fixesllvm/llvm-project#63355
Reviewed By: ABataev
Differential Revision: https://reviews.llvm.org/D153369
OpenMP uses the
#pragma omp declare target
directive to control which variables are present on the device. Currently this cannot be used to mark any variable on the device unless it is applied to the first time that variable is seen. This can be seen in this godbolt example https://godbolt.org/z/aT9171xn6. In the first case, because the#pragma omp declare target to(x)
clause is applied to an extern declaration of the variablex
, OpenMP does not place it on the device. This can be seen due to the visibility beginextern
andx
being passed in as an argument to the GPU. However, if we instead apply it to the extern variable before the actual declaration, it will work fine.This is currently preventing us from providing adequately wrapped headers when implementing system utilities on the GPU. I.e. we cannot do the following so there is no way to indicate that
stderr
is on the GPU without including everything from the host'sstdio.h
on the GPU as well.The text was updated successfully, but these errors were encountered: