1.23
2.0
acw/focus-triggers
main
test-branch
| 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 | !To avoid data race, the initialization of the original list item "a" should complete before any
|
|---|
| 9 | !update of a as a result of the reduction clause. This can be achieved by adding an explicit
|
|---|
| 10 | !barrier after the assignment a=0@22:9, or by enclosing the assignment a=0@22:9 in a single directive
|
|---|
| 11 | !or by initializing a@21:7 before the start of the parallel region. No data race pair
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | program DRB141_reduction_barrier_orig_no
|
|---|
| 15 | use omp_lib
|
|---|
| 16 | implicit none
|
|---|
| 17 |
|
|---|
| 18 | integer :: a, i
|
|---|
| 19 |
|
|---|
| 20 | !$omp parallel shared(a) private(i)
|
|---|
| 21 | !$omp master
|
|---|
| 22 | a = 0
|
|---|
| 23 | !$omp end master
|
|---|
| 24 |
|
|---|
| 25 | !$omp barrier
|
|---|
| 26 |
|
|---|
| 27 | !$omp do reduction(+:a)
|
|---|
| 28 | do i = 1, 10
|
|---|
| 29 | a = a+i
|
|---|
| 30 | end do
|
|---|
| 31 | !$omp end do
|
|---|
| 32 |
|
|---|
| 33 | !$omp single
|
|---|
| 34 | print*, "Sum is ", A
|
|---|
| 35 | !$omp end single
|
|---|
| 36 |
|
|---|
| 37 | !$omp end parallel
|
|---|
| 38 | end program
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.