1 // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu 2 // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu 3 // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu 4 // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu 5 // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 7 #include <omp.h> 8 9 #include <cassert> 10 #include <iostream> 11 main(int argc,char * argv[])12int main(int argc, char *argv[]) { 13 #pragma omp parallel for 14 for (int i = 0; i < 16; ++i) { 15 for (int n = 1; n < (1 << 13); n <<= 1) { 16 void *p = omp_target_alloc(n * sizeof(int), 0); 17 omp_target_free(p, 0); 18 } 19 } 20 21 #pragma omp parallel for 22 for (int i = 0; i < 16; ++i) { 23 for (int n = 1; n < (1 << 13); n <<= 1) { 24 int *p = (int *)omp_target_alloc(n * sizeof(int), 0); 25 #pragma omp target teams distribute parallel for is_device_ptr(p) 26 for (int j = 0; j < n; ++j) { 27 p[j] = i; 28 } 29 int buffer[n]; 30 #pragma omp target teams distribute parallel for is_device_ptr(p) \ 31 map(from \ 32 : buffer) 33 for (int j = 0; j < n; ++j) { 34 buffer[j] = p[j]; 35 } 36 for (int j = 0; j < n; ++j) { 37 assert(buffer[j] == i); 38 } 39 omp_target_free(p, 0); 40 } 41 } 42 43 std::cout << "PASS\n"; 44 return 0; 45 } 46 47 // CHECK: PASS 48