brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 7b77d05 Raw
49 lines · c
1// The test supposes no offload, pure host execution.2// It checks that the bug in implementation of distribute construct is fixed.3 4// RUN: %libomp-compile-and-run5 6// gcc/icc target offloading is incompatible with libomp7// UNSUPPORTED: icc, gcc8 9#include <stdio.h>10#include <omp.h>11 12int main()13{14  const int size = 4;15  int wrong_counts = 0;16  omp_set_num_threads(2);17  #pragma omp parallel reduction(+:wrong_counts)18  {19    int i;20    int A[size];21    int th = omp_get_thread_num();22    for(i = 0; i < size; i++)23      A[i] = 0;24 25    #pragma omp target teams distribute map(tofrom: A[:size]) private(i)26    for(i = 0; i < size; i++)27    {28      A[i] = i;29      printf("th %d, team %d, i %d\n", th, omp_get_team_num(), i);30    }31    #pragma omp critical32    {33      printf("tid = %d\n", th);34      for(i = 0; i < size; i++)35      {36        if (A[i] != i) wrong_counts++;37        printf("  %d", A[i]);38      }39      printf("\n");40    }41  }42  if (wrong_counts) {43    printf("failed\n");44  } else {45    printf("passed\n");46  }47  return wrong_counts;48}49