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@33:19
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 | #include <stdio.h>
|
|---|
| 18 | #include <omp.h>
|
|---|
| 19 |
|
|---|
| 20 | void 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 taskwait depend(in: x) // 1st taskwait
|
|---|
| 31 |
|
|---|
| 32 | printf("x=%d\n",x);
|
|---|
| 33 | printf("y=%d\n",y);
|
|---|
| 34 | #pragma omp taskwait // 2nd taskwait
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | int main(){
|
|---|
| 39 | #pragma omp parallel
|
|---|
| 40 | #pragma omp single
|
|---|
| 41 | foo();
|
|---|
| 42 |
|
|---|
| 43 | return 0;
|
|---|
| 44 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.