25 logical,
save :: async_matvec_flg = .false.
40 real(kind=
kreal),
intent(in) :: x(:)
41 real(kind=
kreal),
intent(out) :: y(:)
42 real(kind=
kreal),
intent(inout) :: time_ax
43 real(kind=
kreal),
intent(inout),
optional :: commtime
45 real(kind=
kreal) :: tcomm
46 real(kind=
kreal),
allocatable :: wk(:)
51 allocate(wk(hecmat%NP * hecmat%NDOF))
55 call hecmw_matvec_44_inner(hecmesh, hecmat, x, y, time_ax, tcomm)
58 if (
present(commtime)) commtime = commtime + tcomm
88 subroutine hecmw_matvec_44_inner (hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
99 real(kind=
kreal),
intent(in) :: x(:)
100 real(kind=
kreal),
intent(out) :: y(:)
101 real(kind=
kreal),
intent(inout) :: time_ax
102 real(kind=
kreal),
intent(inout),
optional :: commtime
104 real(kind=
kreal) :: start_time, end_time, tcomm
105 integer(kind=kint) :: i, j, js, je, in
106 real(kind=
kreal) :: yv1, yv2, yv3, yv4, x1, x2, x3, x4
108 integer(kind=kint) :: n, np
109 integer(kind=kint),
pointer :: indexl(:), iteml(:), indexu(:), itemu(:)
110 real(kind=
kreal),
pointer :: al(:), au(:), d(:)
113 integer,
parameter :: numofblockperthread = 100
114 logical,
save :: isfirst = .true.
115 integer,
save :: numofthread = 1
116 integer,
save,
allocatable :: startpos(:), endpos(:)
117 integer(kind=kint),
save :: sectorcachesize0, sectorcachesize1
118 integer(kind=kint) :: threadnum, blocknum, numofblock
119 integer(kind=kint) :: numofelement, elementcount, blockindex
120 real(kind=
kreal) :: numofelementperblock
128 time_ax = time_ax + end_time - start_time - tcomm
129 if (
present(commtime)) commtime = commtime + tcomm
134 indexl => hecmat%indexL
135 indexu => hecmat%indexU
136 iteml => hecmat%itemL
137 itemu => hecmat%itemU
143 if (.not. isfirst)
then
144 numofblock = numofthread * numofblockperthread
145 if (endpos(numofblock-1) .ne. n-1)
then
146 deallocate(startpos, endpos)
152 numofblock = numofthread * numofblockperthread
153 allocate (startpos(0 : numofblock - 1), endpos(0 : numofblock - 1))
154 numofelement = n + indexl(n) + indexu(n)
155 numofelementperblock = dble(numofelement) / numofblock
158 startpos(blocknum) = 1
160 elementcount = elementcount + 1
161 elementcount = elementcount + (indexl(i) - indexl(i-1))
162 elementcount = elementcount + (indexu(i) - indexu(i-1))
163 if (elementcount > (blocknum + 1) * numofelementperblock)
then
167 blocknum = blocknum + 1
168 startpos(blocknum) = i + 1
169 if (blocknum == (numofblock - 1))
exit
176 do i= blocknum+1, numofblock-1
184 sectorcachesize0, sectorcachesize1)
196 if (
present(commtime)) commtime = commtime + end_time - start_time
211 do blocknum = 0 , numofblockperthread - 1
212 blockindex = blocknum * numofthread + threadnum
213 do i = startpos(blockindex), endpos(blockindex)
218 yv1= d(16*i-15)*x1 + d(16*i-14)*x2 + d(16*i-13)*x3 + d(16*i-12)*x4
219 yv2= d(16*i-11)*x1 + d(16*i-10)*x2 + d(16*i- 9)*x3 + d(16*i- 8)*x4
220 yv3= d(16*i- 7)*x1 + d(16*i- 6)*x2 + d(16*i- 5)*x3 + d(16*i- 4)*x4
221 yv4= d(16*i- 3)*x1 + d(16*i- 2)*x2 + d(16*i- 1)*x3 + d(16*i )*x4
231 yv1= yv1 + al(16*j-15)*x1 + al(16*j-14)*x2 + al(16*j-13)*x3 + al(16*j-12)*x4
232 yv2= yv2 + al(16*j-11)*x1 + al(16*j-10)*x2 + al(16*j- 9)*x3 + al(16*j- 8)*x4
233 yv3= yv3 + al(16*j- 7)*x1 + al(16*j- 6)*x2 + al(16*j- 5)*x3 + al(16*j- 4)*x4
234 yv4= yv4 + al(16*j- 3)*x1 + al(16*j- 2)*x2 + al(16*j- 1)*x3 + al(16*j )*x4
245 yv1= yv1 + au(16*j-15)*x1 + au(16*j-14)*x2 + au(16*j-13)*x3 + au(16*j-12)*x4
246 yv2= yv2 + au(16*j-11)*x1 + au(16*j-10)*x2 + au(16*j- 9)*x3 + au(16*j- 8)*x4
247 yv3= yv3 + au(16*j- 7)*x1 + au(16*j- 6)*x2 + au(16*j- 5)*x3 + au(16*j- 4)*x4
248 yv4= yv4 + au(16*j- 3)*x1 + au(16*j- 2)*x2 + au(16*j- 1)*x3 + au(16*j )*x4
265 time_ax = time_ax + end_time - start_time
268 end subroutine hecmw_matvec_44_inner
280 real(kind=
kreal),
intent(in) :: x(:), b(:)
281 real(kind=
kreal),
intent(out) :: r(:)
282 real(kind=
kreal),
intent(inout) :: time_ax
283 real(kind=
kreal),
intent(inout),
optional :: commtime
285 integer(kind=kint) :: i
286 real(kind=
kreal) :: tcomm
290 if (
present(commtime)) commtime = commtime + tcomm
293 do i = 1, hecmat%N * 4
312 real(kind=
kreal),
intent(inout) :: time_ax
313 real(kind=
kreal),
intent(inout),
optional :: commtime
315 real(kind=
kreal),
allocatable :: r(:)
316 real(kind=
kreal) :: bnorm2, rnorm2
317 real(kind=
kreal) :: tcomm
319 allocate(r(hecmat%NDOF*hecmat%NP))
323 hecmat%B, hecmat%B, bnorm2, tcomm)
324 if (bnorm2 == 0.d0)
then
331 if (
present(commtime)) commtime = commtime + tcomm
346 real(kind=
kreal),
intent(in) :: x(:)
347 real(kind=
kreal),
intent(out) :: y(:)
348 real(kind=
kreal),
intent(inout) :: commtime
350 real(kind=
kreal) :: start_time, end_time
351 integer(kind=kint) :: i, j, jj, k, kk
356 commtime = commtime + end_time - start_time
360 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
366 outer:
do i= 1, hecmesh%mpc%n_mpc
367 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
368 if (hecmesh%mpc%mpc_dof(j) > 4) cycle outer
370 k = hecmesh%mpc%mpc_index(i-1) + 1
371 kk = 4 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
373 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
374 jj = 4 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
375 y(kk) = y(kk) - hecmesh%mpc%mpc_val(j) * x(jj)
393 real(kind=
kreal),
intent(in) :: x(:)
394 real(kind=
kreal),
intent(out) :: y(:)
395 real(kind=
kreal),
intent(inout) :: commtime
397 real(kind=
kreal) :: start_time, end_time
398 integer(kind=kint) :: i, j, jj, k, kk
403 commtime = commtime + end_time - start_time
407 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
413 outer:
do i= 1, hecmesh%mpc%n_mpc
414 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
415 if (hecmesh%mpc%mpc_dof(j) > 4) cycle outer
417 k = hecmesh%mpc%mpc_index(i-1) + 1
418 kk = 4 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
420 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
421 jj = 4 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
423 y(jj) = y(jj) - hecmesh%mpc%mpc_val(j) * x(kk)
441 real(kind=
kreal),
intent(in) :: x(:)
442 real(kind=
kreal),
intent(out) :: y(:), w(:)
443 real(kind=
kreal),
intent(inout) :: time_ax
444 real(kind=
kreal),
intent(inout) :: commtime
447 call hecmw_matvec_44_inner(hecmesh, hecmat, y, w, time_ax, commtime)
464 real(kind=
kreal),
intent(inout),
optional :: commtime
465 real(kind=
kreal),
allocatable :: w(:,:)
466 real(kind=
kreal),
pointer :: d(:)
467 integer(kind=kint) :: ip
468 real(kind=
kreal) :: start_time, end_time
469 allocate(w(4*hecmat%NP,4))
472 w(4*ip-3,1)= d(16*ip-15); w(4*ip-3,2)= d(16*ip-14); w(4*ip-3,3)= d(16*ip-13); w(4*ip-3,4)= d(16*ip-12)
473 w(4*ip-2,1)= d(16*ip-11); w(4*ip-2,2)= d(16*ip-10); w(4*ip-2,3)= d(16*ip- 9); w(4*ip-2,4)= d(16*ip- 8)
474 w(4*ip-1,1)= d(16*ip- 7); w(4*ip-1,2)= d(16*ip- 6); w(4*ip-1,3)= d(16*ip- 5); w(4*ip-1,4)= d(16*ip- 4)
475 w(4*ip ,1)= d(16*ip- 3); w(4*ip ,2)= d(16*ip- 2); w(4*ip ,3)= d(16*ip- 1); w(4*ip ,4)= d(16*ip )
483 if (
present(commtime)) commtime = commtime + end_time - start_time
484 do ip= hecmat%N+1, hecmat%NP
485 d(16*ip-15)= w(4*ip-3,1); d(16*ip-14)= w(4*ip-3,2); d(16*ip-13)= w(4*ip-3,3); d(16*ip-12)= w(4*ip-3,4)
486 d(16*ip-11)= w(4*ip-2,1); d(16*ip-10)= w(4*ip-2,2); d(16*ip- 9)= w(4*ip-2,3); d(16*ip- 8)= w(4*ip-2,4)
487 d(16*ip- 7)= w(4*ip-1,1); d(16*ip- 6)= w(4*ip-1,2); d(16*ip- 5)= w(4*ip-1,3); d(16*ip- 4)= w(4*ip-1,4)
488 d(16*ip- 3)= w(4*ip ,1); d(16*ip- 2)= w(4*ip ,2); d(16*ip- 1)= w(4*ip ,3); d(16*ip )= w(4*ip ,4)