source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB005-indirectaccess1-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: 3.0 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!This program is extracted from a real application at LLNL.
9!Two pointers (xa1 and xa2) have a pair of values with a distance of 12.
10!They are used as start base addresses for two 1-D arrays.
11!Their index set has two indices with distance of 12: 999 +12 = 1011.
12!So there is loop carried dependence.
13!
14!However, having loop carried dependence does not mean data races will always happen.
15!The iterations with loop carried dependence must be scheduled to
16!different threads in order for data races to happen.
17!
18!In this example, we use schedule(static,1) to increase the chance that
19!the dependent loop iterations will be scheduled to different threads.
20!Data race pair: base[idx1]@78:5 vs. base[idx2]@79:5
21
22
23module DRB005
24 implicit none
25
26 integer, dimension(180) :: indexSet
27 integer :: n
28
29end module
30
31
32program DRB005_indirectaccess1_orig_yes
33 use omp_lib
34 use DRB005
35 implicit none
36
37 integer :: i, idx1, idx2
38 integer, parameter :: dp = kind(1.0d0)
39 real(dp), dimension(:), pointer :: xa1=>NULL(), xa2=>NULL()
40 real(dp), dimension(2025), target :: base
41
42 allocate (xa1(2025))
43 allocate (xa2(2025))
44
45 xa1 => base(1:2025)
46 xa2 => base(1:2025)
47
48 n=180
49
50 indexSet = (/ 521, 523, 525, 527, 529, 531, 547, 549, &
51 551, 553, 555, 557, 573, 575, 577, 579, 581, 583, 599, &
52 601, 603, 605, 607, 609, 625, 627, 629, 631, 633, 635, &
53 651, 653, 655, 657, 659, 661, 859, 861, 863, 865, 867, &
54 869, 885, 887, 889, 891, 893, 895, 911, 913, 915, 917, &
55 919, 921, 937, 939, 941, 943, 945, 947, 963, 965, 967, &
56 969, 971, 973, 989, 991, 993, 995, 997, 999, 1197, 1199, &
57 1201, 1203, 1205, 1207, 1223, 1225, 1227, 1229, 1231, &
58 1233, 1249, 1251, 1253, 1255, 1257, 1259, 1275, 1277, &
59 1279, 1281, 1283, 1285, 1301, 1303, 1305, 1307, 1309, &
60 1311, 1327, 1329, 1331, 1333, 1335, 1337, 1535, 1537, &
61 1539, 1541, 1543, 1545, 1561, 1563, 1565, 1567, 1569, &
62 1571, 1587, 1589, 1591, 1593, 1595, 1597, 1613, 1615, &
63 1617, 1619, 1621, 1623, 1639, 1641, 1643, 1645, 1647, &
64 1649, 1665, 1667, 1669, 1671, 1673, 1675, 1873, 1875, &
65 1877, 1879, 1881, 1883, 1899, 1901, 1903, 1905, 1907, &
66 1909, 1925, 1927, 1929, 1931, 1933, 1935, 1951, 1953, &
67 1955, 1957, 1959, 1961, 1977, 1979, 1981, 1983, 1985, &
68 1987, 2003, 2005, 2007, 2009, 2011, 2013 /)
69
70 do i = 521, 2025
71 base(i) = 0.5*i
72 end do
73
74 !$omp parallel do schedule(static,1)
75 do i = 1, n
76 idx1 = indexSet(i)
77 idx2 = indexSet(i)+12
78 base(idx1) = base(idx1)+1.0
79 base(idx2) = base(idx2)+3.0
80 end do
81 !$omp end parallel do
82
83 print*,'xa1(999) =',base(999),' xa2(1285) =',base(1285)
84
85 nullify(xa1,xa2)
86end program
Note: See TracBrowser for help on using the repository browser.