source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks-fortran/DRB097-target-teams-distribute-orig-no.f95

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.6 KB
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!use of omp target + teams + distribute + parallel for. No data race pairs.
9
10program DRB097_target_teams_distribute_orig_no
11 use omp_lib
12 use ISO_C_Binding
13 implicit none
14 integer, parameter :: dp = kind(1.0d0)
15 integer, parameter :: double_kind = c_double
16 integer (kind=8) :: i, i2, len, l_limit, tmp
17 real(dp) :: sum, sum2
18 real(dp), dimension(:), allocatable :: a, b
19
20 len = 2560
21 sum = real(0.0,dp)
22 sum2 = real(0.0,dp)
23
24 allocate (a(len))
25 allocate (b(len))
26
27 do i = 1, len
28 a(i) = real(i,dp)/real(2.0,dp)
29 b(i) = real(i,dp)/real(3.0,dp)
30 end do
31
32 !$omp target map(to: a(0:len), b(0:len)) map(tofrom: sum)
33 !$omp teams num_teams(10) thread_limit(256) reduction (+:sum)
34 !$omp distribute
35 do i2 = 1, len, 256
36 !$omp parallel do reduction (+:sum)
37 do i = i2+1, merge(i2+256,len,i2+256<len)
38 sum = sum+a(i)*b(i)
39 end do
40 !$omp end parallel do
41 end do
42 !$omp end distribute
43 !$omp end teams
44 !$omp end target
45
46 !$omp parallel do reduction (+:sum2)
47 do i = 1, len
48 sum2 = sum2+a(i)*b(i)
49 end do
50 !$omp end parallel do
51
52 print*,'sum =',int(sum),'; sum2 =',int(sum2)
53
54 deallocate(a,b)
55end program
Note: See TracBrowser for help on using the repository browser.