source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB013-nowait-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: 1.4 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 example is extracted from a paper:
9!Ma etc. Symbolic Analysis of Concurrency Errors in OpenMP Programs, ICPP 2013
10!
11!Some threads may finish the for loop early and execute errors = dt[10]+1
12!while another thread may still be simultaneously executing
13!the for worksharing region by writing to d[9], causing data races.
14!
15!Data race pair: a[i]@41:21 vs. a[10]@37:!7
16
17program DRB013_nowait_orig_yes
18 use omp_lib
19 implicit none
20
21 integer i, error, len, b
22 integer, dimension (:), allocatable :: a
23
24 b = 5
25 len = 1000
26
27 allocate (a(len))
28
29 do i = 1, len
30 a(i) = i
31 end do
32
33 !$omp parallel shared(b, error)
34 !$omp parallel
35 !$omp do
36 do i = 1, len
37 a(i) = b + a(i)*5
38 end do
39 !$omp end do nowait
40 !$omp single
41 error = a(10) + 1;
42 !$omp end single
43 !$omp end parallel
44 !$omp end parallel
45
46 print*,"error =",error
47
48 deallocate(a)
49end program
Note: See TracBrowser for help on using the repository browser.