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:
898 bytes
|
| 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.