brintos

brintos / llvm-project-archived public Read only

0
0
Text · 907 B · b71eba4 Raw
43 lines · c
1// RUN: %libomptarget-compile-run-and-check-generic2 3#include <omp.h>4#include <ompx.h>5#include <stdio.h>6 7void foo(int device) {8  int X;9  // clang-format off10#pragma omp target teams map(from: X) device(device) thread_limit(2) num_teams(1)11#pragma omp parallel12  // clang-format on13  {14    int tid = ompx_thread_id_x();15    int bid = ompx_block_id_x();16    if (tid == 1 && bid == 0) {17      X = 42;18      ompx_sync_block_divergent(3);19    } else {20      ompx_sync_block_divergent(1);21    }22    if (tid == 0 && bid == 0)23      X++;24    ompx_sync_block(ompx_seq_cst);25    if (tid == 1 && bid == 0)26      X++;27    ompx_sync_block_acq_rel();28    if (tid == 0 && bid == 0)29      X++;30    ompx_sync_block(ompx_release);31    if (tid == 0 && bid == 0)32      X++;33  }34  // CHECK: X: 4635  // CHECK: X: 4636  printf("X: %i\n", X);37}38 39int main() {40  foo(omp_get_default_device());41  foo(omp_get_initial_device());42}43