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.3 KB
|
| Rev | Line | |
|---|
| [e3f356c] | 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 is a program based on a test contributed by Yizi Gu@Rice Univ.
|
|---|
| 9 | !* Classic Fibonacci calculation using task+taskwait. No data races.
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | module DRB105
|
|---|
| 13 | implicit none
|
|---|
| 14 | integer input
|
|---|
| 15 | contains
|
|---|
| 16 | recursive function fib(n) result(r)
|
|---|
| 17 | use omp_lib
|
|---|
| 18 | implicit none
|
|---|
| 19 | integer :: n, i, j, r
|
|---|
| 20 |
|
|---|
| 21 | if (n<2) then
|
|---|
| 22 | r = n
|
|---|
| 23 | else
|
|---|
| 24 | !$omp task shared(i)
|
|---|
| 25 | i = fib(n-1)
|
|---|
| 26 | !$omp end task
|
|---|
| 27 | !$omp task shared(j)
|
|---|
| 28 | j = fib(n-2)
|
|---|
| 29 | !$omp end task
|
|---|
| 30 | !$omp taskwait
|
|---|
| 31 | r = i+j
|
|---|
| 32 | end if
|
|---|
| 33 | end function
|
|---|
| 34 | end module
|
|---|
| 35 |
|
|---|
| 36 | program DRB105_taskwait_orig_no
|
|---|
| 37 | use omp_lib
|
|---|
| 38 | use DRB105
|
|---|
| 39 | implicit none
|
|---|
| 40 |
|
|---|
| 41 | integer :: result
|
|---|
| 42 | input = 30
|
|---|
| 43 |
|
|---|
| 44 | !$omp parallel
|
|---|
| 45 | !$omp single
|
|---|
| 46 | result = fib(input)
|
|---|
| 47 | !$omp end single
|
|---|
| 48 | !$omp end parallel
|
|---|
| 49 |
|
|---|
| 50 | print 100, input, result
|
|---|
| 51 | 100 format ('Fib for ',3i8,' =',3i8)
|
|---|
| 52 | end program
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.