brintos

brintos / llvm-project-archived public Read only

0
0
Text · 584 B · 6cb2264 Raw
31 lines · c
1// RUN: %libomp-compile-and-run2#include <stdio.h>3#include <omp.h>4int main()5{6  enum {ITERS = 500};7  enum {SIZE = 5};8  int err = 0;9  #pragma omp parallel num_threads(2) reduction(+:err)10  {11    int r = 0;12    int i;13    #pragma omp taskloop grainsize(SIZE) shared(r) nogroup14    for(i=0; i<ITERS; i++) {15      #pragma omp atomic16        ++r;17    }18    #pragma omp taskwait19    printf("%d\n", r);20    if (r != ITERS)21      err++;22  } // end of parallel23  if (err != 0) {24    printf("failed, err = %d\n", err);25    return 1;26  } else {27    printf("passed\n");28    return 0;29  }30}31