source: CIVL/mods/dev.civl.com/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB025-simdtruedep-var-yes.f95@ cb4d4f4

1.23 2.0 main test-branch
Last change on this file since cb4d4f4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 1.7 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 one has race condition due to true dependence.
9!But data races happen at instruction level, not thread level.
10!Data race pair: a[i+1]@55:18 vs. a[i]@55:9
11
12program DRB025_simdtruedep_var_yes
13 use omp_lib
14 implicit none
15
16 integer :: i, len, argCount, allocStatus, rdErr, ix
17 character(len=80), dimension(:), allocatable :: args
18 integer, dimension(:), allocatable :: a
19 integer, dimension(:), allocatable :: b
20
21 len = 100
22
23 argCount = command_argument_count()
24 if (argCount == 0) then
25 write (*,'(a)') "No command line arguments provided."
26 end if
27
28 allocate(args(argCount), stat=allocStatus)
29 if (allocStatus > 0) then
30 write (*,'(a)') "Allocation error, program terminated."
31 stop
32 end if
33
34 do ix = 1, argCount
35 call get_command_argument(ix,args(ix))
36 end do
37
38 if (argCount >= 1) then
39 read (args(1), '(i10)', iostat=rdErr) len
40 if (rdErr /= 0 ) then
41 write (*,'(a)') "Error, invalid integer value."
42 end if
43 end if
44
45 allocate (a(len))
46 allocate (b(len))
47
48 do i = 1, len
49 a(i) = i
50 b(i) = i+1
51 end do
52
53 !$omp simd
54 do i = 1, len-1
55 a(i+1) = a(i) + b(i)
56 end do
57
58 do i = 1, len
59 write(6,*) 'Values for i and a(i) are:', i, a(i)
60 end do
61
62 deallocate(args,a,b)
63
64end program
Note: See TracBrowser for help on using the repository browser.