mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 13:27:09 +00:00
OpenMP::OpenMP_<lang> carries no device flags, and for GCC and Clang links the OpenMP runtime without the OpenMP flag, so target regions built through it fail to link or silently run on the host. Once OpenMP_<lang>_OFFLOAD or OpenMP_<lang>_OFFLOAD_FLAGS is set, the new targets add the device flags, plus the OpenMP flag at link time; otherwise they match the host targets. FindOpenMP.Offload runs a target kernel on a GPU and is enabled in the nvhpc job. Fixes: #21784, #26701
21 lines
308 B
C
21 lines
308 B
C
#include <omp.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
#endif
|
|
int
|
|
offload_check(void)
|
|
{
|
|
int i;
|
|
int on_host = 1;
|
|
int sum = 0;
|
|
#pragma omp target map(tofrom : on_host, sum)
|
|
{
|
|
on_host = omp_is_initial_device();
|
|
for (i = 1; i <= 10; ++i) {
|
|
sum += i;
|
|
}
|
|
}
|
|
return on_host || sum != 55;
|
|
}
|