[Instrumentation] Fix a warning
[llvm-project.git] / offload / test / api / omp_device_managed_memory.c
blob2a9fe09a8334c92f196f865e58a17960b36d30ef
1 // RUN: %libomptarget-compile-run-and-check-generic
3 #include <omp.h>
4 #include <stdio.h>
6 void *llvm_omp_target_alloc_shared(size_t, int);
7 void llvm_omp_target_free_shared(void *, int);
9 int main() {
10 const int N = 64;
11 const int device = omp_get_default_device();
13 int *shared_ptr = llvm_omp_target_alloc_shared(N * sizeof(int), device);
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;
21 int sum = 0;
22 for (int i = 0; i < N; ++i)
23 sum += shared_ptr[i];
25 llvm_omp_target_free_shared(shared_ptr, device);
26 // CHECK: PASS
27 if (sum == N)
28 printf("PASS\n");