source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB141-reduction-barrier-orig-no.f95

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!!! Copyright (c) 2017-20, Lawrence Livermore National Security, LLC
3!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details.
4!!!
5!!! SPDX-License-Identifier: (BSD-3-Clause)
6!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
7
8!To avoid data race, the initialization of the original list item "a" should complete before any
9!update of a as a result of the reduction clause. This can be achieved by adding an explicit
10!barrier after the assignment a=0@22:9, or by enclosing the assignment a=0@22:9 in a single directive
11!or by initializing a@21:7 before the start of the parallel region. No data race pair
12
13
14program DRB141_reduction_barrier_orig_no
15 use omp_lib
16 implicit none
17
18 integer :: a, i
19
20 !$omp parallel shared(a) private(i)
21 !$omp master
22 a = 0
23 !$omp end master
24
25 !$omp barrier
26
27 !$omp do reduction(+:a)
28 do i = 1, 10
29 a = a+i
30 end do
31 !$omp end do
32
33 !$omp single
34 print*, "Sum is ", A
35 !$omp end single
36
37 !$omp end parallel
38end program
Note: See TracBrowser for help on using the repository browser.