12b8115b1Sprotze@itc.rwth-aachen.de /* 22b8115b1Sprotze@itc.rwth-aachen.de * task-taskgroup-unrelated.c -- Archer testcase 32b8115b1Sprotze@itc.rwth-aachen.de */ 42b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===// 52b8115b1Sprotze@itc.rwth-aachen.de // 62b8115b1Sprotze@itc.rwth-aachen.de // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 72b8115b1Sprotze@itc.rwth-aachen.de // 82b8115b1Sprotze@itc.rwth-aachen.de // See tools/archer/LICENSE.txt for details. 92b8115b1Sprotze@itc.rwth-aachen.de // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 102b8115b1Sprotze@itc.rwth-aachen.de // 112b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===// 122b8115b1Sprotze@itc.rwth-aachen.de 132b8115b1Sprotze@itc.rwth-aachen.de // RUN: %libarcher-compile-and-run-race | FileCheck %s 14fdc9dfc8SJoachim Protze // RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s 1577ad98c8Sprotze@itc.rwth-aachen.de // REQUIRES: tsan 1684637408SJoachim Protze #include "ompt/ompt-signal.h" 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 main(int argc,char * argv[])212b8115b1Sprotze@itc.rwth-aachen.deint main(int argc, char *argv[]) { 222b8115b1Sprotze@itc.rwth-aachen.de int var = 0, a = 0; 232b8115b1Sprotze@itc.rwth-aachen.de 24*4acc2f29SJoachim Protze #pragma omp parallel num_threads(8) shared(var, a) 252b8115b1Sprotze@itc.rwth-aachen.de #pragma omp master 262b8115b1Sprotze@itc.rwth-aachen.de { 272b8115b1Sprotze@itc.rwth-aachen.de #pragma omp task shared(var, a) 282b8115b1Sprotze@itc.rwth-aachen.de { 292b8115b1Sprotze@itc.rwth-aachen.de var++; 302b8115b1Sprotze@itc.rwth-aachen.de OMPT_SIGNAL(a); 312b8115b1Sprotze@itc.rwth-aachen.de // Give master thread time to execute the task in the taskgroup. 322b8115b1Sprotze@itc.rwth-aachen.de OMPT_WAIT(a, 2); 332b8115b1Sprotze@itc.rwth-aachen.de } 342b8115b1Sprotze@itc.rwth-aachen.de 352b8115b1Sprotze@itc.rwth-aachen.de #pragma omp taskgroup 362b8115b1Sprotze@itc.rwth-aachen.de { 372b8115b1Sprotze@itc.rwth-aachen.de #pragma omp task if (0) 382b8115b1Sprotze@itc.rwth-aachen.de { 392b8115b1Sprotze@itc.rwth-aachen.de // Dummy task. 402b8115b1Sprotze@itc.rwth-aachen.de } 412b8115b1Sprotze@itc.rwth-aachen.de 422b8115b1Sprotze@itc.rwth-aachen.de // Give other threads time to steal the tasks. 432b8115b1Sprotze@itc.rwth-aachen.de OMPT_WAIT(a, 1); 442b8115b1Sprotze@itc.rwth-aachen.de OMPT_SIGNAL(a); 452b8115b1Sprotze@itc.rwth-aachen.de } 462b8115b1Sprotze@itc.rwth-aachen.de 472b8115b1Sprotze@itc.rwth-aachen.de var++; 482b8115b1Sprotze@itc.rwth-aachen.de } 492b8115b1Sprotze@itc.rwth-aachen.de 502b8115b1Sprotze@itc.rwth-aachen.de int error = (var != 2); 512b8115b1Sprotze@itc.rwth-aachen.de fprintf(stderr, "DONE\n"); 522b8115b1Sprotze@itc.rwth-aachen.de return error; 532b8115b1Sprotze@itc.rwth-aachen.de } 542b8115b1Sprotze@itc.rwth-aachen.de 552b8115b1Sprotze@itc.rwth-aachen.de // CHECK: WARNING: ThreadSanitizer: data race 562b8115b1Sprotze@itc.rwth-aachen.de // CHECK-NEXT: {{(Write|Read)}} of size 4 5784637408SJoachim Protze // CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:47 582b8115b1Sprotze@itc.rwth-aachen.de // CHECK: Previous write of size 4 5984637408SJoachim Protze // CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:29 602b8115b1Sprotze@itc.rwth-aachen.de // CHECK: DONE 612b8115b1Sprotze@itc.rwth-aachen.de // CHECK: ThreadSanitizer: reported 1 warnings 62