| 1 | // RUN: %libomptarget-compile-run-and-check-generic |
| 2 | |
| 3 | // UNSUPPORTED: nvidiagpu |
| 4 | // UNSUPPORTED: amdgpu |
| 5 | |
| 6 | #include <assert.h> |
| 7 | #include <omp.h> |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | int main() { |
| 11 | #pragma omp target |
| 12 | { |
| 13 | int *ptr; |
| 14 | #pragma omp allocate(ptr) allocator(omp_default_mem_alloc) |
| 15 | ptr = omp_alloc(sizeof(int), omp_default_mem_alloc); |
| 16 | assert(ptr && "Ptr is (null)!" ); |
| 17 | *ptr = 0; |
| 18 | #pragma omp parallel num_threads(32) |
| 19 | { |
| 20 | #pragma omp atomic |
| 21 | *ptr += 1; |
| 22 | } |
| 23 | assert(*ptr == 32 && "Ptr is not 32" ); |
| 24 | omp_free(ptr, omp_default_mem_alloc); |
| 25 | } |
| 26 | |
| 27 | // CHECK: PASS |
| 28 | printf(format: "PASS\n" ); |
| 29 | } |
| 30 | |