Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Budiardja, Reuben
Fortran Frontier
Commits
dff36bce
Commit
dff36bce
authored
Oct 03, 2021
by
Budiardja, Reuben
Browse files
OpenMP offload Array Reduction test case.
parent
15970fd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cases/Composite/OMP_TargetReduction/OpenMP_TargetArrayReduction.f90
0 → 100644
View file @
dff36bce
program
TargetArrayReduction
use
OMP_LIB
implicit
none
integer
::
&
iV
,
jV
,
kV
,
&
StopCode
real
,
dimension
(
:,
:
),
allocatable
::
&
FEP_1
,
FEP_2
,
FEP_3
real
,
dimension
(
:
),
allocatable
::
&
D_MaxSpeed
,
&
H_MaxSpeed
StopCode
=
0
allocate
(
FEP_1
(
32
,
8
)
)
allocate
(
FEP_2
(
32
,
8
)
)
allocate
(
FEP_3
(
32
,
8
)
)
allocate
(
D_MaxSpeed
(
8
),
H_MaxSpeed
(
8
)
)
call
random_number
(
FEP_1
)
call
random_number
(
FEP_2
)
call
random_number
(
FEP_3
)
!$OMP target enter data map ( to: FEP_1, FEP_2, FEP_3 )
D_MaxSpeed
=
-
huge
(
1.0
)
H_MaxSpeed
=
-
huge
(
1.0
)
print
*
,
'Num devices: '
,
omp_get_num_devices
()
!-- Device reduction
!$OMP target teams distribute parallel do simd &
!$OMP schedule ( static, 1 ) &
!$OMP reduction ( max : D_MaxSpeed ) map ( D_MaxSpeed )
do
jV
=
1
,
size
(
FEP_1
,
dim
=
2
)
do
iV
=
1
,
size
(
FEP_1
,
dim
=
1
)
D_MaxSpeed
(
jV
)
&
=
max
(
FEP_1
(
iV
,
jV
),
FEP_2
(
iV
,
jV
),
&
FEP_3
(
iV
,
jV
),
D_MaxSpeed
(
jV
)
)
end
do
end
do
!$OMP end target teams distribute parallel do simd
!-- Host reduction ( with Fortran )
H_MaxSpeed
=
max
(
maxval
(
FEP_1
,
dim
=
1
),
&
maxval
(
FEP_2
,
dim
=
1
),
&
maxval
(
FEP_3
,
dim
=
1
)
)
print
*
,
'MaxSpeed reduced on device '
,
D_MaxSpeed
print
*
,
'MaxSpeed reduced on host '
,
H_MaxSpeed
if
(
all
(
D_MaxSpeed
==
H_MaxSpeed
)
)
then
print
*
,
'Reduction on device: PASSED'
else
print
*
,
'Reduction on device: FAILED'
end
if
!if ( StopCode /= 0 ) stop StopCode
end
program
TargetArrayReduction
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment