Files
clang-p2996/openmp/tools/archer/tests/task/taskwait-depend.c
Joachim Jenke 1880d8f5c1 [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
2023-08-28 09:43:24 +02:00

58 lines
1.2 KiB
C

/*
* taskwait-depend.c -- Archer testcase
* derived from DRB166-taskdep4-orig-omp50-no.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 | 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);
#pragma omp taskwait // 2nd taskwait
printf("y=%d\n", y);
}
int main() {
#pragma omp parallel num_threads(2)
#pragma omp single
foo();
return 0;
}
// CHECK-NOT: ThreadSanitizer: data race
// CHECK-NOT: ThreadSanitizer: reported
// CHECK: y=1