brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · fad3697 Raw
45 lines · c
1/*2 * task-two.c -- Archer testcase3 */4//===----------------------------------------------------------------------===//5//6// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.7//8// See tools/archer/LICENSE.txt for details.9// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception10//11//===----------------------------------------------------------------------===//12 13// RUN: %libarcher-compile-and-run-race | FileCheck %s14// RUN: %libarcher-compile-and-run-race-noserial | FileCheck %s15// REQUIRES: tsan16#include <omp.h>17#include <stdio.h>18#include <unistd.h>19 20#define NUM_THREADS 821 22int main(int argc, char *argv[]) {23  int var = 0;24  int i;25 26#pragma omp parallel for num_threads(NUM_THREADS) shared(var)                  \27    schedule(static, 1)28  for (i = 0; i < NUM_THREADS; i++) {29#pragma omp task shared(var) if (0) // the task is inlined an executed locally30    { var++; }31  }32 33  int error = (var != 2);34  fprintf(stderr, "DONE\n");35  return error;36}37 38// CHECK: WARNING: ThreadSanitizer: data race39// CHECK-NEXT:   {{(Write|Read)}} of size 440// CHECK-NEXT: #0 {{.*}}task-two.c:3041// CHECK:   Previous write of size 442// CHECK-NEXT: #0 {{.*}}task-two.c:3043// CHECK: DONE44// CHECK: ThreadSanitizer: reported {{[0-9]+}} warnings45