1 // RUN: %libomptarget-compile-nvptx64-nvidia-cuda -fopenmp-target-new-runtime
2 // RUN: env LIBOMPTARGET_SHARED_MEMORY_SIZE=256 \
3 // RUN:   %libomptarget-run-nvptx64-nvidia-cuda | %fcheck-nvptx64-nvidia-cuda
4 // REQUIRES: nvptx64-nvidia-cuda
5 
6 #include <omp.h>
7 #include <stdio.h>
8 
9 void *llvm_omp_get_dynamic_shared();
10 
11 int main() {
12   int x;
13 #pragma omp target parallel map(from : x)
14   {
15     int *buf = llvm_omp_get_dynamic_shared() + 252;
16 #pragma omp barrier
17     if (omp_get_thread_num() == 0)
18       *buf = 1;
19 #pragma omp barrier
20     if (omp_get_thread_num() == 1)
21       x = *buf;
22   }
23 
24   // CHECK: PASS
25   if (x == 1 && llvm_omp_get_dynamic_shared() == NULL)
26     printf("PASS\n");
27 }
28