-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|