| 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 nested loops with loop-carried anti-dependence on the outer level.
|
|---|
| 9 | !This is a variable-length array version in F95.
|
|---|
| 10 | !Data race pair: a[i][j]@55:13 vs. a[i+1][j]@55:31
|
|---|
| 11 |
|
|---|
| 12 | program DRB004_antidep2_var_yes
|
|---|
| 13 | use omp_lib
|
|---|
| 14 | implicit none
|
|---|
| 15 |
|
|---|
| 16 | integer :: i, j, len, argCount, allocStatus, rdErr, ix
|
|---|
| 17 | character(len=80), dimension(:), allocatable :: args
|
|---|
| 18 | real, dimension (:,:), allocatable :: a
|
|---|
| 19 | len = 1000
|
|---|
| 20 |
|
|---|
| 21 | argCount = command_argument_count()
|
|---|
| 22 | if (argCount == 0) then
|
|---|
| 23 | write (*,'(a)') "No command line arguments provided."
|
|---|
| 24 | end if
|
|---|
| 25 |
|
|---|
| 26 | allocate(args(argCount), stat=allocStatus)
|
|---|
| 27 | if (allocStatus > 0) then
|
|---|
| 28 | write (*,'(a)') "Allocation error, program terminated."
|
|---|
| 29 | stop
|
|---|
| 30 | end if
|
|---|
| 31 |
|
|---|
| 32 | do ix = 1, argCount
|
|---|
| 33 | call get_command_argument(ix,args(ix))
|
|---|
| 34 | end do
|
|---|
| 35 |
|
|---|
| 36 | if (argCount >= 1) then
|
|---|
| 37 | read (args(1), '(i10)', iostat=rdErr) len
|
|---|
| 38 | if (rdErr /= 0 ) then
|
|---|
| 39 | write (*,'(a)') "Error, invalid integer value."
|
|---|
| 40 | end if
|
|---|
| 41 | end if
|
|---|
| 42 |
|
|---|
| 43 | allocate (a(len,len))
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | do i = 1, len
|
|---|
| 47 | do j = 1, len
|
|---|
| 48 | a(i,j) = 0.5
|
|---|
| 49 | end do
|
|---|
| 50 | end do
|
|---|
| 51 |
|
|---|
| 52 | !$omp parallel do private(j)
|
|---|
| 53 | do i = 1, len-1
|
|---|
| 54 | do j = 1, len
|
|---|
| 55 | a(i,j) = a(i,j) + a(i+1,j)
|
|---|
| 56 | end do
|
|---|
| 57 | end do
|
|---|
| 58 | !$omp end parallel do
|
|---|
| 59 |
|
|---|
| 60 | write(*,*) 'a(10,10) =', a(10,10)
|
|---|
| 61 |
|
|---|
| 62 | deallocate(a)
|
|---|
| 63 | deallocate(args)
|
|---|
| 64 |
|
|---|
| 65 | end program
|
|---|