OpenMP check fails during HIP device compile
- Dominant language
- C++
- Stars
- 598
- Forks
- 118
- Avg merge
- 21h 29m
- Merged PRs (30d)
- 1
Description
Clang HIP (and probably CUDA) compilation have two different preprocessing passes, one for the device code and one for the host code. During the device preprocessing path `_OPENMP` isn't defined, which causes this check to fail:
https://github.com/LLNL/RAJA/blob/08cbbafd2d21589ebf341f7275c229412d0fe903/include/RAJA/config.hpp.in#L157-L165
As a consequence, the HIP and CPU OpenMP backends can't be built at the same time. If that check is sentineled somehow, possibly with a `defined(__HIP_DEVICE_COMPILE__) || defined(__CUDA_ARCH__)` the CPU OpenMP and HIP/CUDA-clang backends could both be built.
This smaller code showcases it a little more compactly:
``` omp_test.cpp
#include
#ifndef _OPENMP
#define _OPENMP 0
#warning "OpenMP Not Defined"
#endif
#ifndef __HIP_DEVICE_COMPILE__
#warning "Device compile not defined"
#endif
int main()
{
printf("OpenMP version %d\n", _OPENMP);
}
```
And at compilation (note the target for each warning)
```
$ hipcc -fopenmp -x hip omp_test.cpp
omp_test.cpp:5:2: warning: "OpenMP Not Defined" [-W#warnings]
#warning "OpenMP Not Defined"
^
1 warning generated when compiling for gfx803.
omp_test.cpp:9:2: warning: "Device compile not defined" [-W#warnings]
#warning "Device compile not defined"
^
1 warning generated when compiling for host.
```
Contributor guide
Research direction
Start at include/RAJA/config.hpp.in lines 157-165 and reproduce the issue with the omp_test.cpp example and the hipcc -fopenmp -x hip command. Check that the OpenMP configuration check handles the device and host preprocessing passes so the CPU OpenMP and HIP/CUDA-clang backends can build together.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100