source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB131-taskdep4-orig-omp45-yes.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 1.2 KB
Line 
1/*
2!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
3!!! Copyright (c) 2017-20, Lawrence Livermore National Security, LLC
4!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details.
5!!!
6!!! SPDX-License-Identifier: (BSD-3-Clause)
7!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
8 */
9
10/*
11 * There is no completion restraint on the second child task. Hence, immediately after the first
12 * taskwait it is unsafe to access the y variable since the second child task may still be
13 * executing.
14 * Data Race at y@28:2 and y@34:19
15*/
16
17#include <stdio.h>
18#include <omp.h>
19
20void foo(){
21
22 int x = 0, y = 2;
23
24 #pragma omp task depend(inout: x) shared(x)
25 x++; //1st Child Task
26
27 #pragma omp task shared(y)
28 y--; // 2nd child task
29
30 #pragma omp task depend(in: x) if(0) // 1st taskwait
31 {}
32
33 printf("x=%d\n",x);
34 printf("y=%d\n",y);
35 #pragma omp taskwait // 2nd taskwait
36}
37
38
39int main(){
40 #pragma omp parallel
41 #pragma omp single
42 foo();
43
44 return 0;
45}
Note: See TracBrowser for help on using the repository browser.