31 lines · c
1// RUN: %libomptarget-compile-generic2// RUN: env LIBOMPTARGET_SHARED_MEMORY_SIZE=256 \3// RUN: %libomptarget-run-generic | %fcheck-generic4 5// RUN: %libomptarget-compileopt-generic6// RUN: env LIBOMPTARGET_SHARED_MEMORY_SIZE=256 \7// RUN: %libomptarget-run-generic | %fcheck-generic8 9// REQUIRES: gpu10 11#include <omp.h>12#include <stdio.h>13 14int main() {15 int x;16#pragma omp target parallel map(from : x)17 {18 int *buf = llvm_omp_target_dynamic_shared_alloc() + 252;19#pragma omp barrier20 if (omp_get_thread_num() == 0)21 *buf = 1;22#pragma omp barrier23 if (omp_get_thread_num() == 1)24 x = *buf;25 }26 27 // CHECK: PASS28 if (x == 1 && llvm_omp_target_dynamic_shared_alloc() == NULL)29 printf("PASS\n");30}31