1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
|
|---|
| 3 | !!! Copyright (c) 2017-20, Lawrence Livermore National Security, LLC
|
|---|
| 4 | !!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details.
|
|---|
| 5 | !!!
|
|---|
| 6 | !!! SPDX-License-Identifier: (BSD-3-Clause)
|
|---|
| 7 | !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | /* The assignment to a@25:7 is not synchronized with the update of a@29:11 as a result of the
|
|---|
| 12 | * reduction computation in the for loop.
|
|---|
| 13 | * Data Race pair: a@25:5 and a@27:33
|
|---|
| 14 | * */
|
|---|
| 15 |
|
|---|
| 16 | #include <stdio.h>
|
|---|
| 17 | #include <omp.h>
|
|---|
| 18 |
|
|---|
| 19 | int main(){
|
|---|
| 20 | int a, i;
|
|---|
| 21 |
|
|---|
| 22 | #pragma omp parallel shared(a) private(i)
|
|---|
| 23 | {
|
|---|
| 24 | #pragma omp master
|
|---|
| 25 | a = 0;
|
|---|
| 26 |
|
|---|
| 27 | #pragma omp for reduction(+:a)
|
|---|
| 28 | for (i=0; i<10; i++){
|
|---|
| 29 | a = a + i;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | #pragma omp single
|
|---|
| 33 | printf("Sum is %d\n", a);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | return 0;
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.