source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB084-threadprivatemissing-orig-yes.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!A file-scope variable used within a function called by a parallel region.
9!No threadprivate is used to avoid data races.
10!
11!Data race pairs sum0@39:13 vs. sum0@39:19
12! sum0@39:13 vs. sum0@39:13
13
14module DRB084
15 implicit none
16 integer (kind=8) :: sum0, sum1
17contains
18 subroutine foo(i)
19 integer (kind=8) :: i
20 sum0=sum0+i
21 end subroutine
22end module
23
24program DRB084_threadprivatemissing_orig_yes
25 use omp_lib
26 use DRB084
27 implicit none
28
29 integer (kind=8) :: i, sum
30 sum = 0
31
32 !$omp parallel
33 !$omp do
34 do i = 1, 1001
35 call foo(i)
36 end do
37 !$omp end do
38 !$omp critical
39 sum = sum + sum0
40 !$omp end critical
41 !$omp end parallel
42
43 do i = 1, 1001
44 sum1 = sum1+i
45 end do
46
47 print*,'sum = ',sum,'sum1 =',sum1
48end program
Note: See TracBrowser for help on using the repository browser.