xref: /llvm-project/openmp/tools/archer/tests/parallel/parallel-firstprivate.c (revision 77ad98c80881ba90bf18ec2780169c60e02c159b)
12b8115b1Sprotze@itc.rwth-aachen.de /*
22b8115b1Sprotze@itc.rwth-aachen.de  * parallel-firstprivate.c -- Archer testcase
32b8115b1Sprotze@itc.rwth-aachen.de  */
42b8115b1Sprotze@itc.rwth-aachen.de 
52b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===//
62b8115b1Sprotze@itc.rwth-aachen.de //
72b8115b1Sprotze@itc.rwth-aachen.de // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
82b8115b1Sprotze@itc.rwth-aachen.de //
92b8115b1Sprotze@itc.rwth-aachen.de // See tools/archer/LICENSE.txt for details.
102b8115b1Sprotze@itc.rwth-aachen.de // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
112b8115b1Sprotze@itc.rwth-aachen.de //
122b8115b1Sprotze@itc.rwth-aachen.de //===----------------------------------------------------------------------===//
132b8115b1Sprotze@itc.rwth-aachen.de 
142b8115b1Sprotze@itc.rwth-aachen.de 
152b8115b1Sprotze@itc.rwth-aachen.de // RUN: %libarcher-compile-and-run | FileCheck %s
16*77ad98c8Sprotze@itc.rwth-aachen.de // REQUIRES: tsan
172b8115b1Sprotze@itc.rwth-aachen.de #include <omp.h>
182b8115b1Sprotze@itc.rwth-aachen.de #include <stdio.h>
192b8115b1Sprotze@itc.rwth-aachen.de 
main(int argc,char * argv[])202b8115b1Sprotze@itc.rwth-aachen.de int main(int argc, char *argv[]) {
212b8115b1Sprotze@itc.rwth-aachen.de   int var = 0;
222b8115b1Sprotze@itc.rwth-aachen.de 
232b8115b1Sprotze@itc.rwth-aachen.de #pragma omp parallel num_threads(2) firstprivate(var)
242b8115b1Sprotze@itc.rwth-aachen.de   { var = 1; }
252b8115b1Sprotze@itc.rwth-aachen.de 
262b8115b1Sprotze@itc.rwth-aachen.de   fprintf(stderr, "DONE\n");
272b8115b1Sprotze@itc.rwth-aachen.de   // var should still be 0!
282b8115b1Sprotze@itc.rwth-aachen.de   return var;
292b8115b1Sprotze@itc.rwth-aachen.de }
302b8115b1Sprotze@itc.rwth-aachen.de 
312b8115b1Sprotze@itc.rwth-aachen.de // CHECK-NOT: ThreadSanitizer: data race
322b8115b1Sprotze@itc.rwth-aachen.de // CHECK-NOT: ThreadSanitizer: reported
332b8115b1Sprotze@itc.rwth-aachen.de // CHECK: DONE
34