-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][Archer] Add support for taskwait depend
At the moment Archer segfaults due to a null-pointer access, if an application uses taskwait with depend clause as used in the two new tests. This patch cleans up the task_schedule function, moves semantic blocks into functions and replaces the if blocks by a single switch statement. The switch statement will warn, when new enum values are added in OMPT and makes clear what code is executed for the different cases. With free-agent tasks coming up in OpenMP 6.0, we should expect more null-pointer task_data, so additional null-pointer checks were added. We also cannot rely on having an implicit task on the stack, so the BarrierIndex is stored during task creation. Differential Revision: https://reviews.llvm.org/D158072
- Loading branch information
Showing
3 changed files
with
245 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* taskwait-depend.c -- Archer testcase | ||
* derived from DRB165-taskdep4-orig-omp50-yes.c in DataRaceBench | ||
*/ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// | ||
// See tools/archer/LICENSE.txt for details. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// RUN: %libarcher-compile-and-run-race | FileCheck %s | ||
// RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s | ||
// REQUIRES: tsan | ||
|
||
#include "ompt/ompt-signal.h" | ||
#include <omp.h> | ||
#include <stdio.h> | ||
|
||
void foo() { | ||
|
||
int x = 0, y = 2, sem = 0; | ||
|
||
#pragma omp task depend(inout : x) shared(x, sem) | ||
{ | ||
OMPT_SIGNAL(sem); | ||
x++; // 1st Child Task | ||
} | ||
|
||
#pragma omp task shared(y, sem) | ||
{ | ||
OMPT_SIGNAL(sem); | ||
y--; // 2nd child task | ||
} | ||
|
||
OMPT_WAIT(sem, 2); | ||
#pragma omp taskwait depend(in : x) // 1st taskwait | ||
|
||
printf("x=%d\n", x); | ||
printf("y=%d\n", y); | ||
#pragma omp taskwait // 2nd taskwait | ||
} | ||
|
||
int main() { | ||
#pragma omp parallel num_threads(2) | ||
#pragma omp single | ||
foo(); | ||
|
||
return 0; | ||
} | ||
|
||
// CHECK: WARNING: ThreadSanitizer: data race | ||
// CHECK-NEXT: {{(Write|Read)}} of size 4 | ||
// CHECK-NEXT: #0 {{.*}}taskwait-depend.c:42:20 | ||
// CHECK: Previous write of size 4 | ||
// CHECK-NEXT: #0 {{.*}}taskwait-depend.c:35:6 | ||
// CHECK: ThreadSanitizer: reported {{[0-9]+}} warnings |
Oops, something went wrong.