1 // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda
2 // REQUIRES: nvptx64-nvidia-cuda
3 
4 #include <omp.h>
5 #include <stdio.h>
6 
7 void *llvm_omp_target_alloc_shared(size_t, int);
8 
9 int main() {
10   const int N = 64;
11   const int device = omp_get_default_device();
12 
13   int *shared_ptr = llvm_omp_target_alloc_shared(N * sizeof(int), device);
14 
15 #pragma omp target teams distribute parallel for device(device) \
16             is_device_ptr(shared_ptr)
17   for (int i = 0; i < N; ++i) {
18     shared_ptr[i] = 1;
19   }
getInstance()20 
21   int sum = 0;
22   for (int i = 0; i < N; ++i)
23     sum += shared_ptr[i];
24 
25   omp_target_free(shared_ptr, device);
26   // CHECK: PASS
__construct()27   if (sum == N)
28     printf ("PASS\n");
29 }
30