source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB014-outofbounds-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.4 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!The outmost loop is parallelized.
9!But the inner level loop has out of bound access for b[i][j] when i equals to 1.
10!This will case memory access of a previous columns's last element.
11!
12!For example, an array of 4x4:
13! j=1 2 3 4
14! i=1 x x x x
15! 2 x x x x
16! 3 x x x x
17! 4 x x x x
18! inner loop: i=1,
19! outer loop: j=3
20! array element accessed b[i-1][j] becomes b[0][3], which in turn is b[4][2]
21! due to linearized column-major storage of the 2-D array.
22! This causes loop-carried data dependence between j=2 and j=3.
23!
24!Data race pair: b[i][j]@41 vs. b[i-1][j]@41.
25
26program DRB014_outofbounds_orig_yes
27 use omp_lib
28 implicit none
29
30 integer :: i, j, n, m
31 real, dimension (:,:), allocatable :: b
32
33 n = 100
34 m = 100
35
36 allocate (b(n,m))
37
38 !$omp parallel do private(i)
39 do j = 2, n
40 do i = 1, m
41 b(i,j) = b(i-1,j)
42 end do
43 end do
44 !$omp end parallel do
45 print*,"b(50,50)=",b(50,50)
46
47 deallocate(b)
48end program
Note: See TracBrowser for help on using the repository browser.