source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB135-taskdep-mutexinoutset-orig-no.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.1 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/* Addition of mutexinoutset dependence type on c, will ensure that line d@37:7 assignment will depend
12 * on task at Line 32 and line 34. They might execute in any order but not at the same time.
13 * There is no data race.
14 * */
15
16
17#include <stdio.h>
18#include <omp.h>
19
20int main(){
21 int a, b, c, d;
22
23 #pragma omp parallel
24 #pragma omp single
25 {
26 #pragma omp task depend(out: c)
27 c = 1;
28 #pragma omp task depend(out: a)
29 a = 2;
30 #pragma omp task depend(out: b)
31 b = 3;
32 #pragma omp task depend(in: a) depend(mutexinoutset: c)
33 c += a;
34 #pragma omp task depend(in: b) depend(mutexinoutset: c)
35 c += b;
36 #pragma omp task depend(in: c)
37 d = c;
38 }
39
40 printf("%d\n",d);
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.