llvm-project
35 строк · 618.0 Байт
1// RUN: %libomptarget-compile-run-and-check-generic
2
3#include <cstdio>4#include <cstdlib>5
6#define NUM 10247
8class C {9public:10int *a;11};12
13#pragma omp declare mapper(id : C s) map(s.a[0 : NUM])14
15int main() {16C c;17c.a = (int *)malloc(sizeof(int) * NUM);18for (int i = 0; i < NUM; i++) {19c.a[i] = 1;20}21#pragma omp target data map(mapper(id), tofrom : c)22{23#pragma omp target teams distribute parallel for24for (int i = 0; i < NUM; i++) {25++c.a[i];26}27}28int sum = 0;29for (int i = 0; i < NUM; i++) {30sum += c.a[i];31}32// CHECK: Sum = 204833printf("Sum = %d\n", sum);34return 0;35}
36