1// RUN: %libomptarget-compile-generic
2// RUN: env LIBOMPTARGET_SHARED_MEMORY_SIZE=256 \
3// RUN: %libomptarget-run-generic | %fcheck-generic
4
5// RUN: %libomptarget-compileopt-generic
6// RUN: env LIBOMPTARGET_SHARED_MEMORY_SIZE=256 \
7// RUN: %libomptarget-run-generic | %fcheck-generic
8
9// UNSUPPORTED: x86_64-pc-linux-gnu
10// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
11// UNSUPPORTED: aarch64-unknown-linux-gnu
12// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
13// UNSUPPORTED: s390x-ibm-linux-gnu
14// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
15
16#include <omp.h>
17#include <stdio.h>
18
19int main() {
20 int x;
21#pragma omp target parallel map(from : x)
22 {
23 int *buf = llvm_omp_target_dynamic_shared_alloc() + 252;
24#pragma omp barrier
25 if (omp_get_thread_num() == 0)
26 *buf = 1;
27#pragma omp barrier
28 if (omp_get_thread_num() == 1)
29 x = *buf;
30 }
31
32 // CHECK: PASS
33 if (x == 1 && llvm_omp_target_dynamic_shared_alloc() == NULL)
34 printf(format: "PASS\n");
35}
36

source code of offload/test/api/omp_dynamic_shared_memory.c