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 | !This example is based on fpriv_sections.1.c OpenMP Examples 5.0.0
|
|---|
| 9 | !The section construct modifies the value of section_count which breaks the independence of the
|
|---|
| 10 | !section constructs. If the same thread executes both the section one will print 1 and the other
|
|---|
| 11 | !will print 2. For a same thread execution, there is no data race.
|
|---|
| 12 |
|
|---|
| 13 | program DRB126_firstprivatesections_orig_no
|
|---|
| 14 | use omp_lib
|
|---|
| 15 | implicit none
|
|---|
| 16 |
|
|---|
| 17 | integer :: section_count
|
|---|
| 18 |
|
|---|
| 19 | section_count = 0
|
|---|
| 20 |
|
|---|
| 21 | call omp_set_dynamic(.FALSE.)
|
|---|
| 22 | call omp_set_num_threads(1)
|
|---|
| 23 |
|
|---|
| 24 | !$omp parallel
|
|---|
| 25 | !$omp sections firstprivate( section_count )
|
|---|
| 26 | !$omp section
|
|---|
| 27 | section_count = section_count+1
|
|---|
| 28 | print 100, section_count
|
|---|
| 29 | 100 format ('section_count =',3i8)
|
|---|
| 30 |
|
|---|
| 31 | !$omp section
|
|---|
| 32 | section_count = section_count+1
|
|---|
| 33 | print 101, section_count
|
|---|
| 34 | 101 format ('section_count =',3i8)
|
|---|
| 35 | !$omp end sections
|
|---|
| 36 | !$omp end parallel
|
|---|
| 37 | end program
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.