| 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 example is to mimic a memory access pattern extracted from an LLNL proxy app.
|
|---|
| 9 | !Two pointers have distance of 12.
|
|---|
| 10 | !They are used as base addresses of two arrays, indexed through an index set.
|
|---|
| 11 | !The index set has no two indices with distance of 12.
|
|---|
| 12 | !So there is no loop carried dependence. No data race pairs.
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | program DRB052_indirectaccesssharebase_orig_no
|
|---|
| 16 | use omp_lib
|
|---|
| 17 | implicit none
|
|---|
| 18 |
|
|---|
| 19 | integer, dimension(:), allocatable :: indexSet
|
|---|
| 20 | integer, parameter :: dp = kind(1.0d0)
|
|---|
| 21 | real(dp), dimension(:), pointer :: xa1, xa2
|
|---|
| 22 | real(dp), dimension(:), allocatable, target :: base
|
|---|
| 23 | integer :: N = 180
|
|---|
| 24 | integer:: i, idx1,idx2
|
|---|
| 25 |
|
|---|
| 26 | allocate (xa1(2025))
|
|---|
| 27 | allocate (xa2(2025))
|
|---|
| 28 | allocate (base(2025))
|
|---|
| 29 | allocate (indexSet(180))
|
|---|
| 30 | xa1 => base(1:2025)
|
|---|
| 31 | xa2 => base(1:2025)
|
|---|
| 32 |
|
|---|
| 33 | indexSet = (/ 521, 523, 525, 527, 529, 531, 547, 549, &
|
|---|
| 34 | 551, 553, 555, 557, 573, 575, 577, 579, 581, 583, 599, &
|
|---|
| 35 | 601, 603, 605, 607, 609, 625, 627, 629, 631, 633, 635, &
|
|---|
| 36 | 651, 653, 655, 657, 659, 661, 859, 861, 863, 865, 867, &
|
|---|
| 37 | 869, 885, 887, 889, 891, 893, 895, 911, 913, 915, 917, &
|
|---|
| 38 | 919, 921, 937, 939, 941, 943, 945, 947, 963, 965, 967, &
|
|---|
| 39 | 969, 971, 973, 989, 991, 993, 995, 997, 999, 1197, 1199, &
|
|---|
| 40 | 1201, 1203, 1205, 1207, 1223, 1225, 1227, 1229, 1231, &
|
|---|
| 41 | 1233, 1249, 1251, 1253, 1255, 1257, 1259, 1275, 1277, &
|
|---|
| 42 | 1279, 1281, 1283, 1285, 1301, 1303, 1305, 1307, 1309, &
|
|---|
| 43 | 1311, 1327, 1329, 1331, 1333, 1335, 1337, 1535, 1537, &
|
|---|
| 44 | 1539, 1541, 1543, 1545, 1561, 1563, 1565, 1567, 1569, &
|
|---|
| 45 | 1571, 1587, 1589, 1591, 1593, 1595, 1597, 1613, 1615, &
|
|---|
| 46 | 1617, 1619, 1621, 1623, 1639, 1641, 1643, 1645, 1647, &
|
|---|
| 47 | 1649, 1665, 1667, 1669, 1671, 1673, 1675, 1873, 1875, &
|
|---|
| 48 | 1877, 1879, 1881, 1883, 1899, 1901, 1903, 1905, 1907, &
|
|---|
| 49 | 1909, 1925, 1927, 1929, 1931, 1933, 1935, 1951, 1953, &
|
|---|
| 50 | 1955, 1957, 1959, 1961, 1977, 1979, 1981, 1983, 1985, &
|
|---|
| 51 | 1987, 2003, 2005, 2007, 2009, 2011, 2013 /)
|
|---|
| 52 |
|
|---|
| 53 | do i = 521, 2025
|
|---|
| 54 | base(i) = 0.0
|
|---|
| 55 | end do
|
|---|
| 56 |
|
|---|
| 57 | !$omp parallel do private(idx1,idx2)
|
|---|
| 58 | do i = 1, N
|
|---|
| 59 | idx1 = indexSet(i)
|
|---|
| 60 | idx2 = indexSet(i)+12
|
|---|
| 61 | base(idx1) = base(idx1)+1.0
|
|---|
| 62 | base(idx2) = base(idx2)+3.0
|
|---|
| 63 | end do
|
|---|
| 64 | !$omp end parallel do
|
|---|
| 65 |
|
|---|
| 66 | do i = 521, 2025
|
|---|
| 67 | if (base(i) == 4.0) then
|
|---|
| 68 | print*,'i= ',i,' base =',base(i)
|
|---|
| 69 | end if
|
|---|
| 70 | end do
|
|---|
| 71 |
|
|---|
| 72 | deallocate(base,indexSet)
|
|---|
| 73 | nullify(xa1,xa2)
|
|---|
| 74 | end program
|
|---|