blob: 4026c167a4615c94628344ccaaf1c5037b02a62f [file] [edit]
// RUN: %libomptarget-compile-run-and-check-generic
// RUN: %libomptarget-compileopt-run-and-check-generic
// UNSUPPORTED: intelgpu
// Check private and firstprivate variables of a task in a target region.
// Pointers to them are passed to the task's privates mapping function, which
// takes them in the default address space; on AMDGPU, stack variables are in a
// different one.
#include <stdio.h>
#define N 8
struct S {
int a;
long b[3];
};
int main(void) {
int res[7] = {0};
#pragma omp target map(tofrom : res)
{
// The task's changes to its firstprivate copies are not seen by the
// originals.
long fp = 5;
int arr[N];
for (int i = 0; i < N; ++i)
arr[i] = i;
struct S s = {7, {1, 2, 3}};
long p;
#pragma omp task private(p) firstprivate(fp, arr, s) shared(res)
{
p = fp * 2;
fp += 1;
arr[0] = 100;
s.b[1] = 20;
res[0] = p;
res[1] = fp;
res[2] = arr[3] + arr[0];
res[3] = s.a + s.b[1];
}
#pragma omp taskwait
res[4] = fp;
res[5] = arr[0];
res[6] = s.b[1];
}
// CHECK: task: p=10 fp=6 arr=103 s=27
printf("task: p=%d fp=%d arr=%d s=%d\n", res[0], res[1], res[2], res[3]);
// CHECK: originals: fp=5 arr[0]=0 s.b[1]=2
printf("originals: fp=%d arr[0]=%d s.b[1]=%d\n", res[4], res[5], res[6]);
return 0;
}