brintos

brintos / llvm-project-archived public Read only

0
0
Text · 945 B · 310942f Raw
41 lines · c
1// RUN: %libomptarget-compile-generic2// RUN: %libomptarget-compileopt-generic3 4#include <stdio.h>5#define N 106 7int main(void) {8  long int aa = 0;9  int res = 0;10 11  int ng = 12;12  int cmom = 14;13  int nxyz = 5000;14 15#pragma omp target teams distribute num_teams(nxyz)                            \16    thread_limit(ng *(cmom - 1)) map(tofrom : aa)17  for (int gid = 0; gid < nxyz; gid++) {18#pragma omp parallel for collapse(2)19    for (unsigned int g = 0; g < ng; g++) {20      for (unsigned int l = 0; l < cmom - 1; l++) {21        int a = 0;22#pragma omp parallel for reduction(+ : a)23        for (int i = 0; i < N; i++) {24          a += i;25        }26#pragma omp atomic27        aa += a;28      }29    }30  }31  long exp = (long)ng * (cmom - 1) * nxyz * (N * (N - 1) / 2);32  printf("The result is = %ld exp:%ld!\n", aa, exp);33  if (aa != exp) {34    printf("Failed %ld\n", aa);35    return 1;36  }37  // CHECK: Success38  printf("Success\n");39  return 0;40}41