brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 99c3aeb Raw
58 lines · c
1/*2 * taskwait-depend.c -- Archer testcase3 * derived from DRB166-taskdep4-orig-omp50-no.c in DataRaceBench4 */5//===----------------------------------------------------------------------===//6//7// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.8//9// See tools/archer/LICENSE.txt for details.10// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception11//12//===----------------------------------------------------------------------===//13 14// RUN: %libarcher-compile-and-run | FileCheck %s15// REQUIRES: tsan16 17#include "ompt/ompt-signal.h"18#include <omp.h>19#include <stdio.h>20 21void foo() {22 23  int x = 0, y = 2, sem = 0;24 25#pragma omp task depend(inout : x) shared(x, sem)26  {27    OMPT_SIGNAL(sem);28    x++; // 1st Child Task29  }30 31#pragma omp task shared(y, sem)32  {33    OMPT_SIGNAL(sem);34    y--; // 2nd child task35  }36 37  OMPT_WAIT(sem, 2);38#pragma omp taskwait depend(in : x) // 1st taskwait39 40  printf("x=%d\n", x);41 42#pragma omp taskwait // 2nd taskwait43 44  printf("y=%d\n", y);45}46 47int main() {48#pragma omp parallel num_threads(2)49#pragma omp single50  foo();51 52  return 0;53}54 55// CHECK-NOT: ThreadSanitizer: data race56// CHECK-NOT: ThreadSanitizer: reported57// CHECK: y=158