brintos

brintos / llvm-project-archived public Read only

0
0
Text · 562 B · fa3e245 Raw
27 lines · c
1// RUN: %libomptarget-compile-run-and-check-generic2 3#include <omp.h>4#include <stdio.h>5 6int main() {7  const int N = 64;8 9  int *hst_ptr = omp_alloc(N * sizeof(int), llvm_omp_target_host_mem_alloc);10 11  for (int i = 0; i < N; ++i)12    hst_ptr[i] = 2;13 14#pragma omp target teams distribute parallel for map(tofrom : hst_ptr[0 : N])15  for (int i = 0; i < N; ++i)16    hst_ptr[i] -= 1;17 18  int sum = 0;19  for (int i = 0; i < N; ++i)20    sum += hst_ptr[i];21 22  omp_free(hst_ptr, llvm_omp_target_host_mem_alloc);23  // CHECK: PASS24  if (sum == N)25    printf("PASS\n");26}27