28 logical,
save :: matvec_impl_missing_reported = .false.
31 integer,
parameter :: numOfBlockPerThread = 100
32 logical,
save :: isFirst = .true.
33 integer,
save :: numOfThread = 1
34 integer,
save,
allocatable :: startPos(:), endPos(:)
35 integer(kind=kint),
save :: sectorCacheSize0, sectorCacheSize1
82 real(kind=
kreal),
intent(in) :: x(:)
83 real(kind=
kreal),
intent(out) :: y(:)
84 real(kind=
kreal),
intent(inout) :: time_ax
85 real(kind=
kreal),
intent(inout),
optional :: commtime
87 real(kind=
kreal) :: start_time, end_time, tcomm
94 time_ax = time_ax + end_time - start_time - tcomm
95 if (
present(commtime)) commtime = commtime + tcomm
97 select case (matvec_impl)
101 if (.not. matvec_impl_missing_reported)
then
102 matvec_impl_missing_reported = .true.
104 '#### MATRIXFORMAT: this build has no matvec for the selected format '// &
105 '-- running the BSR implementation'
123 type (hecmwST_local_mesh),
intent(in) :: hecMESH
124 type (hecmwST_matrix),
intent(in),
target :: hecMAT
125 real(kind=
kreal),
intent(in) :: x(:)
126 real(kind=
kreal),
intent(out) :: y(:)
127 real(kind=
kreal),
intent(inout) :: time_ax
128 real(kind=
kreal),
intent(inout),
optional :: commtime
130 real(kind=
kreal) :: start_time, end_time
131 integer(kind=kint) :: i, j, jS, jE, in
132 real(kind=
kreal) :: yv1, yv2, yv3, x1, x2, x3
134 integer(kind=kint) :: N, NP
135 integer(kind=kint),
pointer :: indexL(:), itemL(:), indexU(:), itemU(:), indexA(:), itemA(:)
136 real(kind=
kreal),
pointer :: al(:), au(:), d(:), a(:)
139 integer(kind=kint) :: threadNum, blockNum, numOfBlock
140 integer(kind=kint) :: blockIndex
145 indexl => hecmat%indexL
146 indexu => hecmat%indexU
147 indexa => hecmat%indexA
148 iteml => hecmat%itemL
149 itemu => hecmat%itemU
150 itema => hecmat%itemA
158 if (.not. isfirst)
then
159 numofblock = numofthread * numofblockperthread
160 if (endpos(numofblock-1) .ne. n-1)
then
161 deallocate(startpos, endpos)
175 if (
present(commtime)) commtime = commtime + end_time - start_time
196 yv1= yv1 + a(9*j-8)*x1 + a(9*j-7)*x2 + a(9*j-6)*x3
197 yv2= yv2 + a(9*j-5)*x1 + a(9*j-4)*x2 + a(9*j-3)*x3
198 yv3= yv3 + a(9*j-2)*x1 + a(9*j-1)*x2 + a(9*j )*x3
217 do blocknum = 0 , numofblockperthread - 1
218 blockindex = blocknum * numofthread + threadnum
219 do i = startpos(blockindex), endpos(blockindex)
223 yv1= d(9*i-8)*x1 + d(9*i-7)*x2 + d(9*i-6)*x3
224 yv2= d(9*i-5)*x1 + d(9*i-4)*x2 + d(9*i-3)*x3
225 yv3= d(9*i-2)*x1 + d(9*i-1)*x2 + d(9*i )*x3
234 yv1= yv1 + al(9*j-8)*x1 + al(9*j-7)*x2 + al(9*j-6)*x3
235 yv2= yv2 + al(9*j-5)*x1 + al(9*j-4)*x2 + al(9*j-3)*x3
236 yv3= yv3 + al(9*j-2)*x1 + al(9*j-1)*x2 + al(9*j )*x3
245 yv1= yv1 + au(9*j-8)*x1 + au(9*j-7)*x2 + au(9*j-6)*x3
246 yv2= yv2 + au(9*j-5)*x1 + au(9*j-4)*x2 + au(9*j-3)*x3
247 yv3= yv3 + au(9*j-2)*x1 + au(9*j-1)*x2 + au(9*j )*x3
264 time_ax = time_ax + end_time - start_time
272 integer(kind=kint),
intent(in) :: N, NP
273 integer(kind=kint),
pointer,
intent(in) :: indexL(:), indexU(:)
274 integer(kind=kint) :: i, blockNum, numOfBlock
275 integer(kind=kint) :: numOfElement, elementCount
276 real(kind=
kreal) :: numofelementperblock
279 numofblock = numofthread * numofblockperthread
280 allocate (startpos(0 : numofblock - 1), endpos(0 : numofblock - 1))
281 numofelement = n + indexl(n) + indexu(n)
282 numofelementperblock = dble(numofelement) / numofblock
285 startpos(blocknum) = 1
287 elementcount = elementcount + 1
288 elementcount = elementcount + (indexl(i) - indexl(i-1))
289 elementcount = elementcount + (indexu(i) - indexu(i-1))
290 if (elementcount > (blocknum + 1) * numofelementperblock)
then
294 blocknum = blocknum + 1
295 startpos(blocknum) = i + 1
296 if (blocknum == (numofblock - 1))
exit
303 do i= blocknum+1, numofblock-1
311 sectorcachesize0, sectorcachesize1)
324 real(kind=
kreal),
intent(in) :: x(:), b(:)
325 real(kind=
kreal),
intent(out) :: r(:)
326 real(kind=
kreal),
intent(inout) :: time_ax
327 real(kind=
kreal),
intent(inout),
optional :: commtime
329 integer(kind=kint) :: i
330 real(kind=
kreal) :: tcomm
334 if (
present(commtime)) commtime = commtime + tcomm
342 do i = 1, hecmat%N * 3
365 real(kind=
kreal),
intent(inout) :: time_ax
366 real(kind=
kreal),
intent(inout),
optional :: commtime
368 real(kind=
kreal),
allocatable :: r(:)
369 real(kind=
kreal) :: bnorm2, rnorm2
370 real(kind=
kreal) :: tcomm
372 allocate(r(hecmat%NDOF*hecmat%NP))
376 hecmat%B, hecmat%B, bnorm2, tcomm)
377 if (bnorm2 == 0.d0)
then
384 if (
present(commtime)) commtime = commtime + tcomm
399 real(kind=
kreal),
intent(in) :: x(:)
400 real(kind=
kreal),
intent(out) :: y(:)
401 real(kind=
kreal),
intent(inout) :: commtime
403 real(kind=
kreal) :: start_time, end_time
404 integer(kind=kint) :: i, j, jj, k, kk
409 commtime = commtime + end_time - start_time
418 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
430 outer:
do i= 1, hecmesh%mpc%n_mpc
431 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
432 if (hecmesh%mpc%mpc_dof(j) > 3) cycle outer
434 k = hecmesh%mpc%mpc_index(i-1) + 1
435 kk = 3 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
437 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
438 jj = 3 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
439 y(kk) = y(kk) - hecmesh%mpc%mpc_val(j) * x(jj)
461 real(kind=
kreal),
intent(in) :: x(:)
462 real(kind=
kreal),
intent(out) :: y(:)
463 real(kind=
kreal),
intent(inout) :: commtime
465 real(kind=
kreal) :: start_time, end_time
466 integer(kind=kint) :: i, j, jj, k, kk
471 commtime = commtime + end_time - start_time
480 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
492 outer:
do i= 1, hecmesh%mpc%n_mpc
493 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
494 if (hecmesh%mpc%mpc_dof(j) > 3) cycle outer
496 k = hecmesh%mpc%mpc_index(i-1) + 1
497 kk = 3 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
499 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
500 jj = 3 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
506 y(jj) = y(jj) - hecmesh%mpc%mpc_val(j) * x(kk)
Jagged Diagonal Matrix storage for vector processors. Original code was provided by JAMSTEC.
subroutine, public hecmw_jad_matvec(hecMESH, hecMAT, X, Y, COMMtime)
integer(kind=kint) function, public hecmw_jad_is_initialized()
integer(kind=kint) function, public hecmw_mat_get_matvec_impl(hecMAT)
integer(kind=kint), parameter, public hecmw_matvec_impl_bsr
subroutine, public hecmw_matresid_33(hecMESH, hecMAT, X, B, R, time_Ax, COMMtime)
subroutine, public hecmw_matvec_33(hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
subroutine, public hecmw_matvec_33_setup(hecMESH, hecMAT)
subroutine hecmw_matvec_33_generic(hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
subroutine, public hecmw_matvec_33_teardown
subroutine setup_tuning_parameters(N, NP, indexL, indexU)
subroutine, public hecmw_ttvec_33(hecMESH, X, Y, COMMtime)
real(kind=kreal) function, public hecmw_rel_resid_l2_33(hecMESH, hecMAT, time_Ax, COMMtime)
subroutine, public hecmw_tvec_33(hecMESH, X, Y, COMMtime)
subroutine hecmw_innerproduct_r(hecMESH, ndof, X, Y, sum, COMMtime)
subroutine, public hecmw_tuning_fx_calc_sector_cache(N, NDOF, sectorCacheSize0, sectorCacheSize1)
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_update_r(hecMESH, val, n, m)