brintos

brintos / llvm-project-archived public Read only

0
0
Text · 764 B · d2a6c42 Raw
42 lines · cpp
1// RUN: %libomptarget-compilexx-run-and-check-generic2 3// REQUIRES: gpu4 5#include <cassert>6#include <iostream>7 8int main(int argc, char *argv[]) {9  constexpr const int num_threads = 64, N = 128;10  int array[num_threads] = {0};11 12#pragma omp parallel for13  for (int i = 0; i < num_threads; ++i) {14    int tmp[N];15 16    for (int j = 0; j < N; ++j) {17      tmp[j] = i;18    }19 20#pragma omp target teams distribute parallel for map(tofrom : tmp)21    for (int j = 0; j < N; ++j) {22      tmp[j] += j;23    }24 25    for (int j = 0; j < N; ++j) {26      array[i] += tmp[j];27    }28  }29 30  // Verify31  for (int i = 0; i < num_threads; ++i) {32    const int ref = (0 + N - 1) * N / 2 + i * N;33    assert(array[i] == ref);34  }35 36  std::cout << "PASS\n";37 38  return 0;39}40 41// CHECK: PASS42