Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module matrix_vector_kernel_mod
GH_REAL, GH_READ, GH_INC, &
ANY_SPACE_1, ANY_SPACE_2, &
CELL_COLUMN
use constants_mod, only : i_def, r_single, r_double
use constants_mod, only : i_def, r_single, r_double, BLOCK_SIZE
use kernel_mod, only : kernel_type

implicit none
Expand Down Expand Up @@ -87,15 +87,20 @@ subroutine matrix_vector_code_r_single(cell, &
real(kind=r_single), dimension(ncell_3d,ndf1,ndf2), intent(in) :: matrix

! Internal variables
integer(kind=i_def) :: df, ik, df2, i1, i2, nl
integer(kind=i_def) :: df, ik, df2, i1, i2, nl, k, kk, kend

nl = nlayers-1
ik = (cell-1)*nlayers +1
do df2 = 1, ndf2
i2 = map2(df2)
do df = 1, ndf1
i1 = map1(df)
lhs(i1:i1+nl) = lhs(i1:i1+nl) + matrix(ik:ik+nl,df,df2)*x(i2:i2+nl)
do k = 0, nl, BLOCK_SIZE
ik = (cell-1)*nlayers + 1
kend = min(BLOCK_SIZE-1, nl-k)
do df2 = 1, ndf2
i2 = map2(df2)
do df = 1, ndf1
i1 = map1(df)
do kk = 0, kend
lhs(i1+kk+k) = lhs(i1+kk+k) + matrix(ik+kk+k,df,df2)*x(i2+kk+k)
end do
end do
end do
end do

Expand Down Expand Up @@ -125,15 +130,21 @@ subroutine matrix_vector_code_r_double(cell, &
real(kind=r_double), dimension(undf1), intent(inout) :: lhs
real(kind=r_double), dimension(ncell_3d,ndf1,ndf2), intent(in) :: matrix

integer(kind=i_def) :: df, ik, df2, i1, i2, nl
! Internal variables
integer(kind=i_def) :: df, ik, df2, i1, i2, nl, k, kk, kend

nl = nlayers-1
ik = (cell-1)*nlayers +1
do df2 = 1, ndf2
i2 = map2(df2)
do df = 1, ndf1
i1 = map1(df)
lhs(i1:i1+nl) = lhs(i1:i1+nl) + matrix(ik:ik+nl,df,df2)*x(i2:i2+nl)
do k = 0, nl, BLOCK_SIZE
ik = (cell-1)*nlayers + 1
kend = min(BLOCK_SIZE-1, nl-k)
do df2 = 1, ndf2
i2 = map2(df2)
do df = 1, ndf1
i1 = map1(df)
do kk = 0, kend
lhs(i1+kk+k) = lhs(i1+kk+k) + matrix(ik+kk+k,df,df2)*x(i2+kk+k)
end do
end do
end do
end do

Expand Down
7 changes: 6 additions & 1 deletion infrastructure/source/utilities/constants_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module constants_mod
LARGE_REAL_NEGATIVE, LARGE_DP_NEGATIVE, LARGE_REAL_POSITIVE, &
PI, degrees_to_radians, radians_to_degrees, &
cache_block, PRECISION_REAL, PRECISION_R_SOLVER, &
PRECISION_R_TRAN, EPS_R_TRAN, default_halo_depth
PRECISION_R_TRAN, EPS_R_TRAN, default_halo_depth, BLOCK_SIZE

! Define default application-defined kinds for all intrinsic data types

Expand Down Expand Up @@ -197,4 +197,9 @@ module constants_mod
integer(i_def), parameter :: default_halo_depth = 1 !< Default halo depth for fields and operators
!> @}

!> @name Vertical loop block size
!> @{
integer(i_def), parameter :: BLOCK_SIZE = 1024 !< Vertical OpenMP loop block size
!> @}

end module constants_mod
Loading