| // RUN: %libomptarget-compile-run-and-check-generic | |
| // RUN: %libomptarget-compileopt-run-and-check-generic | |
| // FIXME: For SPIR-V devices, clang emits the call to __kmpc_taskloop with a | |
| // mismatched signature and asserts. | |
| // UNSUPPORTED: intelgpu | |
| // Check lastprivate, firstprivate and private variables of a taskloop in a | |
| // target region. | |
| #include <stdio.h> | |
| #define N 8 | |
| int main(void) { | |
| int res = 0; | |
| #pragma omp target map(tofrom : res) | |
| { | |
| // FIXME: The device runtime runs a taskloop as a single task without | |
| // setting its last iteration flag, so the value of a lastprivate variable | |
| // is not copied out. Check the task's copy instead. | |
| int last = -1; | |
| int base = 10; | |
| int tmp; | |
| #pragma omp taskloop lastprivate(last) firstprivate(base) private(tmp) \ | |
| shared(res) | |
| for (int i = 0; i < N; ++i) { | |
| tmp = base + i; | |
| last = tmp; | |
| if (i == N - 1) | |
| res = last; | |
| } | |
| } | |
| // CHECK: taskloop: last=17 | |
| printf("taskloop: last=%d\n", res); | |
| return 0; | |
| } |