This introduces the new `ARCHER_OPTIONS` flag `ignore_serial=0|1` to disable analysis and logging of memory accesses in the sequential part of the OpenMP application. In the sequential part of an OpenMP program no data race is possible, unless there is non-OpenMP concurrency (such as pthreads, MPI, ...). For the latter reason, this is not active by default. Besides reducing the runtime overhead for the sequential part of the program, this reduces the memory overhead for sequential initialization. In combination with `flush_shadow=1` this can allow analysis of applications, which run close to the limit of available memory, but only access smaller parts of shared memory during each OpenMP parallel region. A problem for this approach is that Archer only gets active, when the OpenMP runtime gets initialized, which might be after serial initialization of the application. In such case, it helps to call for example `omp_get_max_threads()` at the beginning of main. Differential Revision: https://reviews.llvm.org/D90473
59 lines
1.5 KiB
C
59 lines
1.5 KiB
C
/*
|
|
* task-taskwait-nested.c -- Archer testcase
|
|
*/
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int var = 0, a = 0;
|
|
|
|
#pragma omp parallel num_threads(2) shared(var, a)
|
|
#pragma omp master
|
|
{
|
|
#pragma omp task shared(var, a)
|
|
{
|
|
#pragma omp task shared(var, a)
|
|
{
|
|
// wait for master to pass the taskwait
|
|
OMPT_SIGNAL(a);
|
|
OMPT_WAIT(a, 2);
|
|
var++;
|
|
}
|
|
}
|
|
|
|
// Give other thread time to steal the task and execute its child.
|
|
OMPT_WAIT(a, 1);
|
|
|
|
// Only directly generated children are guaranteed to be executed.
|
|
#pragma omp taskwait
|
|
OMPT_SIGNAL(a);
|
|
var++;
|
|
}
|
|
|
|
int error = (var != 2);
|
|
fprintf(stderr, "DONE\n");
|
|
return error;
|
|
}
|
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|
|
// CHECK-NEXT: {{(Write|Read)}} of size 4
|
|
// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:34
|
|
// CHECK: Previous write of size 4
|
|
// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:44
|
|
// CHECK: DONE
|
|
// CHECK: ThreadSanitizer: reported 1 warnings
|