source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB117-taskwait-waitonlychild-orig-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/*
11The thread encountering the taskwait directive at line 46 only waits for
12its child task (line 37-44) to complete. It does not wait for its
13descendant tasks (line 39-42).
14Data Race Pairs, sum@47:7 and sum@47:7.
15*/
16
17#include <stdio.h>
18#include <stdlib.h>
19
20int main(){
21
22 int a[4];
23 int psum[2];
24 int sum;
25
26 #pragma omp parallel num_threads(2)
27 {
28 #pragma omp for schedule(dynamic, 1)
29 for (int i=0; i < 4; ++i){
30 a[i] = i;
31 int s;
32 s = (- 3 - 3) / - 3;
33 }
34
35 #pragma omp single
36 {
37 #pragma omp task
38 {
39 #pragma omp task
40 {
41 psum[1] = a[2] + a[3];
42 }
43 psum[0] = a[0] + a[1];
44 }
45
46 #pragma omp taskwait
47 sum = psum[1] + psum[0];
48 }
49 }
50
51 printf("sum = %d\n", sum);
52 return 0;
53 }
Note: See TracBrowser for help on using the repository browser.