12b8115b1Sprotze@itc.rwth-aachen.de /* 22b8115b1Sprotze@itc.rwth-aachen.de * task-taskgroup.c -- Archer testcase 32b8115b1Sprotze@itc.rwth-aachen.de */ 42b8115b1Sprotze@itc.rwth-aachen.de 52b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===// 62b8115b1Sprotze@itc.rwth-aachen.de // 72b8115b1Sprotze@itc.rwth-aachen.de // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 82b8115b1Sprotze@itc.rwth-aachen.de // 92b8115b1Sprotze@itc.rwth-aachen.de // See tools/archer/LICENSE.txt for details. 102b8115b1Sprotze@itc.rwth-aachen.de // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 112b8115b1Sprotze@itc.rwth-aachen.de // 122b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===// 132b8115b1Sprotze@itc.rwth-aachen.de 142b8115b1Sprotze@itc.rwth-aachen.de 152b8115b1Sprotze@itc.rwth-aachen.de // RUN: %libarcher-compile-and-run | FileCheck %s 16*77ad98c8Sprotze@itc.rwth-aachen.de // REQUIRES: tsan 172b8115b1Sprotze@itc.rwth-aachen.de #include <omp.h> 182b8115b1Sprotze@itc.rwth-aachen.de #include <stdio.h> 192b8115b1Sprotze@itc.rwth-aachen.de #include <unistd.h> 202b8115b1Sprotze@itc.rwth-aachen.de #include "ompt/ompt-signal.h" 212b8115b1Sprotze@itc.rwth-aachen.de main(int argc,char * argv[])222b8115b1Sprotze@itc.rwth-aachen.deint main(int argc, char *argv[]) { 232b8115b1Sprotze@itc.rwth-aachen.de int var = 0, a = 0; 242b8115b1Sprotze@itc.rwth-aachen.de 252b8115b1Sprotze@itc.rwth-aachen.de #pragma omp parallel num_threads(2) shared(var, a) 262b8115b1Sprotze@itc.rwth-aachen.de #pragma omp master 272b8115b1Sprotze@itc.rwth-aachen.de { 282b8115b1Sprotze@itc.rwth-aachen.de #pragma omp taskgroup 292b8115b1Sprotze@itc.rwth-aachen.de { 302b8115b1Sprotze@itc.rwth-aachen.de #pragma omp task shared(var, a) 312b8115b1Sprotze@itc.rwth-aachen.de { 322b8115b1Sprotze@itc.rwth-aachen.de var++; 332b8115b1Sprotze@itc.rwth-aachen.de OMPT_SIGNAL(a); 342b8115b1Sprotze@itc.rwth-aachen.de } 352b8115b1Sprotze@itc.rwth-aachen.de 362b8115b1Sprotze@itc.rwth-aachen.de // Give other thread time to steal the task. 372b8115b1Sprotze@itc.rwth-aachen.de OMPT_WAIT(a, 1); 382b8115b1Sprotze@itc.rwth-aachen.de } 392b8115b1Sprotze@itc.rwth-aachen.de 402b8115b1Sprotze@itc.rwth-aachen.de var++; 412b8115b1Sprotze@itc.rwth-aachen.de } 422b8115b1Sprotze@itc.rwth-aachen.de 432b8115b1Sprotze@itc.rwth-aachen.de fprintf(stderr, "DONE\n"); 442b8115b1Sprotze@itc.rwth-aachen.de int error = (var != 2); 452b8115b1Sprotze@itc.rwth-aachen.de return error; 462b8115b1Sprotze@itc.rwth-aachen.de } 472b8115b1Sprotze@itc.rwth-aachen.de 482b8115b1Sprotze@itc.rwth-aachen.de // CHECK-NOT: ThreadSanitizer: data race 492b8115b1Sprotze@itc.rwth-aachen.de // CHECK-NOT: ThreadSanitizer: reported 502b8115b1Sprotze@itc.rwth-aachen.de // CHECK: DONE 51