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