61 lines · c
1/*2 * parallel-simple.c -- Archer testcase3 */4 5//===----------------------------------------------------------------------===//6//7// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.8//9// See tools/archer/LICENSE.txt for details.10// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception11//12//===----------------------------------------------------------------------===//13 14 15// RUN: %libarcher-compile && env OMP_TOOL_VERBOSE_INIT=stderr %libarcher-run 2>&1 | FileCheck %s --check-prefixes CHECK,TSAN_ON16// RUN: %clang-archer %openmp_flags %flags %s -o %t && env OMP_TOOL_VERBOSE_INIT=stderr %t 2>&1 | FileCheck %s --check-prefixes CHECK,TSAN_OFF17// REQUIRES: tsan18#include <omp.h>19#include <stdio.h>20 21// TSAN_ON: ----- START LOGGING OF TOOL REGISTRATION -----22// TSAN_ON-NEXT: Search for OMP tool in current address space... Failed.23// TSAN_ON-NEXT: No OMP_TOOL_LIBRARIES defined.24// TSAN_ON-NEXT: ...searching tool libraries failed. Using archer tool.25// TSAN_ON-NEXT: Opening libarcher.so... Success.26// TSAN_ON-NEXT: Searching for ompt_start_tool in libarcher.so... Success.27// TSAN_ON-NEXT: Tool was started and is using the OMPT interface.28// TSAN_ON-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----29 30// TSAN_OFF: ----- START LOGGING OF TOOL REGISTRATION -----31// TSAN_OFF-NEXT: Search for OMP tool in current address space... Failed.32// TSAN_OFF-NEXT: No OMP_TOOL_LIBRARIES defined.33// TSAN_OFF-NEXT: ...searching tool libraries failed. Using archer tool.34// TSAN_OFF-NEXT: Opening libarcher.so... Success.35// TSAN_OFF-NEXT: Searching for ompt_start_tool in libarcher.so... Found but not using the OMPT interface.36// TSAN_OFF-NEXT: No OMP tool loaded.37// TSAN_OFF-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----38 39 40int main(int argc, char *argv[]) {41 int var = 0;42 43#pragma omp parallel num_threads(2) shared(var)44 {45 if (omp_get_thread_num() == 1) {46 var++;47 }48 } // implicit barrier49 50 var++;51 52 fprintf(stderr, "DONE\n");53 int error = (var != 2);54 return error;55}56 57// CHECK-NOT: ThreadSanitizer: data race58// CHECK-NOT: ThreadSanitizer: reported59// CHECK-NOT: Warning: please export TSAN_OPTIONS60// CHECK: DONE61