llvm-project/offload/test/offloading/target_nowait_target.cpp
fineg74 1611a23a5b
[OFFLOAD] Add spirv implementation for named barrier (#180393)
This change adds implementation for named barriers for SPIRV backend.
Since there is no built in API/intrinsics for named barrier in SPIRV,
the implementation loosely follows implementation for AMD
2026-03-27 20:14:09 +01:00

32 lines
601 B
C++

// RUN: %libomptarget-compilexx-and-run-generic
// RUN: %libomptarget-compileoptxx-and-run-generic
#include <cassert>
int main(int argc, char *argv[]) {
int data[1024];
int sum = 0;
for (int i = 0; i < 1024; ++i)
data[i] = i;
#pragma omp target map(tofrom : sum) map(to : data) depend(inout : data[0]) \
nowait
{
for (int i = 0; i < 1024; ++i) {
sum += data[i];
}
}
#pragma omp target map(tofrom : sum) map(to : data) depend(inout : data[0])
{
for (int i = 0; i < 1024; ++i) {
sum += data[i];
}
}
assert(sum == 1023 * 1024);
return 0;
}