source: CIVL/mods/dev.civl.com/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB140-reduction-barrier-orig-yes.c@ cb4d4f4

1.23 2.0 main test-branch
Last change on this file since cb4d4f4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

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

  • Property mode set to 100755
File size: 898 bytes
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/* The assignment to a@25:7 is not synchronized with the update of a@29:11 as a result of the
12 * reduction computation in the for loop.
13 * Data Race pair: a@25:5 and a@27:33
14 * */
15
16#include <stdio.h>
17#include <omp.h>
18
19int main(){
20 int a, i;
21
22 #pragma omp parallel shared(a) private(i)
23 {
24 #pragma omp master
25 a = 0;
26
27 #pragma omp for reduction(+:a)
28 for (i=0; i<10; i++){
29 a = a + i;
30 }
31
32 #pragma omp single
33 printf("Sum is %d\n", a);
34 }
35
36 return 0;
37}
Note: See TracBrowser for help on using the repository browser.