Skip to content

Commit

Permalink
Merge branch 'amd-stg-openmp' of https://github.com/ROCm-Developer-To…
Browse files Browse the repository at this point in the history
…ols/aomp into amd-stg-openmp
  • Loading branch information
estewart08 committed Nov 5, 2020
2 parents b2ef21b + b69a4cd commit 509ed19
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/smoke/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TESTS_DIR = \
flang_isystem_prob \
flang_math \
flang_omp_map \
flang_omp_red_3d \
flang_real16_prob \
flang_tgt_alloc_ptr \
function \
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/check_smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo " A non-zero exit code means a failure occured." >> check
echo "Tests that need to be visually inspected: devices, pfspecify, pfspecify_str, stream" >> check-smoke.txt
echo "***********************************************************************************" >> check-smoke.txt

known_fails="targ_static target_teams_reduction tasks omp_get_initial flang_gen_sptr_prob"
known_fails="targ_static target_teams_reduction tasks omp_get_initial flang_gen_sptr_prob flang_omp_red_3d"

if [ "$SKIP_FAILURES" == 1 ] ; then
skip_tests=$known_fails
Expand Down
16 changes: 16 additions & 0 deletions test/smoke/flang_omp_red_3d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include ../Makefile.defs

TESTNAME = flang_omp_red_3d
TESTSRC_MAIN = flang_omp_red_3d.f90
TESTSRC_AUX =
TESTSRC_ALL = $(TESTSRC_MAIN) $(TESTSRC_AUX)

TARGET = -fopenmp -O3 -w -i8 -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=$(AOMP_GPU)

FLANG = flang
OMP_BIN = $(AOMP)/bin/$(FLANG)
CC = $(OMP_BIN) $(VERBOSE)
#-ccc-print-phases
#"-\#\#\#"

include ../Makefile.rules
88 changes: 88 additions & 0 deletions test/smoke/flang_omp_red_3d/flang_omp_red_3d.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
program TargetReduction_3D

use OMP_LIB
implicit none

integer :: &
iV, jV, kV, &
StopCode
integer, dimension ( 3 ) :: &
lV, uV, oV
real, dimension ( :, :, : ), allocatable :: &
FEP_1, FEP_2, FEP_3, &
FEM_1, FEM_2, FEM_3
real :: &
MaxSpeed
real, parameter :: &
DEFINED_MAX_SPEED = 10.0

StopCode = 0

allocate ( FEP_1 ( 32, 16, 8 ) )
allocate ( FEP_2 ( 32, 16, 8 ) )
allocate ( FEP_3 ( 32, 16, 8 ) )
allocate ( FEM_1 ( 32, 16, 8 ) )
allocate ( FEM_2 ( 32, 16, 8 ) )
allocate ( FEM_3 ( 32, 16, 8 ) )

call random_number ( FEP_1 )
call random_number ( FEP_2 )
call random_number ( FEP_3 )
call random_number ( FEM_1 )
call random_number ( FEM_2 )
call random_number ( FEM_3 )

lV = lbound ( FEP_1 )
uV = ubound ( FEP_1 )

FEM_1 = -1.0 * FEM_1
FEM_2 = -1.0 * FEM_2
FEM_3 = -1.0 * FEM_3

FEP_1 ( 15, 15, 4 ) = DEFINED_MAX_SPEED

!$OMP target enter data &
!$OMP map ( to: FEP_1, FEP_2, FEP_3, FEM_1, FEM_2, FEM_3 )

MaxSpeed = - huge ( 1.0 )

print*, 'MaxSpeed init', MaxSpeed
print*, 'Num devices: ', omp_get_num_devices()
print*, 'Expected MaxSpeed: ', DEFINED_MAX_SPEED

!$OMP target teams distribute parallel do simd collapse ( 3 ) &
!$OMP schedule ( static, 1 ) private ( iV, jV, kV ) &
!$OMP reduction ( max : MaxSpeed )
do kV = lV ( 3 ), uV ( 3 )
do jV = lV ( 2 ), uV ( 2 )
do iV = lV ( 1 ), uV ( 1 )
MaxSpeed &
= max ( FEP_1 ( iV, jV, kV ), FEP_2 ( iV, jV, kV ), &
FEP_3 ( iV, jV, kV ), -FEM_1 ( iV, jV, kV ), &
-FEM_2 ( iV, jV, kV ), -FEM_3 ( iV, jV, kV ), MaxSpeed )
end do
end do
end do
!$OMP end target teams distribute parallel do simd

print*, 'MaxSpeed reduced on device ', MaxSpeed
if ( MaxSpeed /= DEFINED_MAX_SPEED ) then
print*, 'Reduction on device: FAILED'
StopCode = 1
end if

MaxSpeed = - huge ( 1.0 )
MaxSpeed = max ( maxval ( FEP_1 ), maxval ( FEP_2 ), &
maxval ( FEP_3 ), maxval ( -FEM_1 ), &
maxval ( -FEM_2 ), maxval ( -FEM_3 ), MaxSpeed )

print*, 'MaxSpeed reduced on host ', MaxSpeed
if ( MaxSpeed /= DEFINED_MAX_SPEED ) then
print*, 'Reduction on host: FAILED'
StopCode = 1
end if

if ( StopCode /= 0 ) stop StopCode

end program TargetReduction_3D

0 comments on commit 509ed19

Please sign in to comment.