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.1 KB
|
| 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 | /* This kernel imitates the nature of a program from the NAS Parallel Benchmarks 3.0 MG suit.
|
|---|
| 11 | * The private(i) inline 27 and explicit barrier inline 35 will ensure synchronized behavior.
|
|---|
| 12 | * No Data Race Pairs.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #include <omp.h>
|
|---|
| 16 | #include <stdio.h>
|
|---|
| 17 |
|
|---|
| 18 | int main(){
|
|---|
| 19 | int i;
|
|---|
| 20 | double q[10], qq[10];
|
|---|
| 21 |
|
|---|
| 22 | for (i = 0; i < 10; i++) qq[i] = (double)i;
|
|---|
| 23 | for (i = 0; i < 10; i++) q[i] = (double)i;
|
|---|
| 24 |
|
|---|
| 25 | #pragma omp parallel default(shared)
|
|---|
| 26 | {
|
|---|
| 27 | #pragma omp for private(i)
|
|---|
| 28 | for (i = 0; i < 10; i++)
|
|---|
| 29 | q[i] += qq[i];
|
|---|
| 30 |
|
|---|
| 31 | #pragma omp critical
|
|---|
| 32 | {
|
|---|
| 33 | q[9] += 1.0;
|
|---|
| 34 | }
|
|---|
| 35 | #pragma omp barrier
|
|---|
| 36 | #pragma omp single
|
|---|
| 37 | {
|
|---|
| 38 | q[9] = q[9] - 1.0;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | for (i = 0; i < 10; i++)printf("%f %f\n",qq[i],q[i]);
|
|---|
| 44 |
|
|---|
| 45 | return 0;
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.