23 logical,
save :: async_matvec_flg = .false.
37 real(kind=
kreal),
intent(in) :: x(:)
38 real(kind=
kreal),
intent(out) :: y(:)
39 real(kind=
kreal),
intent(inout) :: time_ax
40 real(kind=
kreal),
intent(inout),
optional :: commtime
42 real(kind=
kreal) :: tcomm
43 real(kind=
kreal),
allocatable :: wk(:)
48 allocate(wk(hecmat%NP * hecmat%NDOF))
52 call hecmw_matvec_22_inner(hecmesh, hecmat, x, y, time_ax, tcomm)
55 if (
present(commtime)) commtime = commtime + tcomm
72 subroutine hecmw_matvec_22_inner (hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
83 real(kind=
kreal),
intent(in) :: x(:)
84 real(kind=
kreal),
intent(out) :: y(:)
85 real(kind=
kreal),
intent(inout) :: time_ax
86 real(kind=
kreal),
intent(inout),
optional :: commtime
88 real(kind=
kreal) :: start_time, end_time, tcomm
89 integer(kind=kint) :: i, j, js, je, in
90 real(kind=
kreal) :: yv1, yv2, x1, x2
92 integer(kind=kint) :: n, np
93 integer(kind=kint),
pointer :: indexl(:), iteml(:), indexu(:), itemu(:)
94 real(kind=
kreal),
pointer :: al(:), au(:), d(:)
97 integer,
parameter :: numofblockperthread = 100
98 logical,
save :: isfirst = .true.
99 integer,
save :: numofthread = 1
100 integer,
save,
allocatable :: startpos(:), endpos(:)
101 integer(kind=kint),
save :: sectorcachesize0, sectorcachesize1
102 integer(kind=kint) :: threadnum, blocknum, numofblock
103 integer(kind=kint) :: numofelement, elementcount, blockindex
104 real(kind=
kreal) :: numofelementperblock
112 time_ax = time_ax + end_time - start_time - tcomm
113 if (
present(commtime)) commtime = commtime + tcomm
118 indexl => hecmat%indexL
119 indexu => hecmat%indexU
120 iteml => hecmat%itemL
121 itemu => hecmat%itemU
127 if (.not. isfirst)
then
128 numofblock = numofthread * numofblockperthread
129 if (endpos(numofblock-1) .ne. n-1)
then
130 deallocate(startpos, endpos)
136 numofblock = numofthread * numofblockperthread
137 allocate (startpos(0 : numofblock - 1), endpos(0 : numofblock - 1))
138 numofelement = n + indexl(n) + indexu(n)
139 numofelementperblock = dble(numofelement) / numofblock
142 startpos(blocknum) = 1
144 elementcount = elementcount + 1
145 elementcount = elementcount + (indexl(i) - indexl(i-1))
146 elementcount = elementcount + (indexu(i) - indexu(i-1))
147 if (elementcount > (blocknum + 1) * numofelementperblock)
then
149 blocknum = blocknum + 1
150 startpos(blocknum) = i + 1
151 if (blocknum == (numofblock - 1))
exit
156 do i= blocknum+1, numofblock-1
162 sectorcachesize0, sectorcachesize1)
171 if (
present(commtime)) commtime = commtime + end_time - start_time
186 do blocknum = 0 , numofblockperthread - 1
187 blockindex = blocknum * numofthread + threadnum
188 do i = startpos(blockindex), endpos(blockindex)
191 yv1= d(4*i-3)*x1 + d(4*i-2)*x2
192 yv2= d(4*i-1)*x1 + d(4*i )*x2
200 yv1= yv1 + al(4*j-3)*x1 + al(4*j-2)*x2
201 yv2= yv2 + al(4*j-1)*x1 + al(4*j )*x2
209 yv1= yv1 + au(4*j-3)*x1 + au(4*j-2)*x2
210 yv2= yv2 + au(4*j-1)*x1 + au(4*j )*x2
224 time_ax = time_ax + end_time - start_time
227 end subroutine hecmw_matvec_22_inner
243 real(kind=
kreal) :: x(:), b(:), r(:)
246 real(kind=
kreal) :: time_ax
247 real(kind=
kreal),
optional :: commtime
249 integer(kind=kint) :: i
250 real(kind=
kreal) :: tcomm
254 if (
present(commtime)) commtime = commtime + tcomm
257 do i = 1, hecmat%N * 2
277 real(kind=
kreal) :: time_ax
278 real(kind=
kreal),
optional :: commtime
280 real(kind=
kreal) :: r(hecmat%NDOF*hecmat%NP)
281 real(kind=
kreal) :: bnorm2, rnorm2
282 real(kind=
kreal) :: tcomm
286 if (bnorm2 == 0.d0)
then
291 if (
present(commtime)) commtime = commtime + tcomm
306 real(kind=
kreal),
intent(in) :: x(:)
307 real(kind=
kreal),
intent(out) :: y(:)
308 real(kind=
kreal),
intent(inout) :: commtime
310 real(kind=
kreal) :: start_time, end_time
311 integer(kind=kint) :: i, j, jj, k, kk
316 commtime = commtime + end_time - start_time
320 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
326 outer:
do i= 1, hecmesh%mpc%n_mpc
327 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
328 if (hecmesh%mpc%mpc_dof(j) > 2) cycle outer
330 k = hecmesh%mpc%mpc_index(i-1) + 1
331 kk = 2 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
333 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
334 jj = 2 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
335 y(kk) = y(kk) - hecmesh%mpc%mpc_val(j) * x(jj)
353 real(kind=
kreal),
intent(in) :: x(:)
354 real(kind=
kreal),
intent(out) :: y(:)
355 real(kind=
kreal),
intent(inout) :: commtime
357 real(kind=
kreal) :: start_time, end_time
358 integer(kind=kint) :: i, j, jj, k, kk
363 commtime = commtime + end_time - start_time
367 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
373 outer:
do i= 1, hecmesh%mpc%n_mpc
374 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
375 if (hecmesh%mpc%mpc_dof(j) > 2) cycle outer
377 k = hecmesh%mpc%mpc_index(i-1) + 1
378 kk = 2 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
380 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
381 jj = 2 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
383 y(jj) = y(jj) - hecmesh%mpc%mpc_val(j) * x(kk)
401 real(kind=
kreal),
intent(in) :: x(:)
402 real(kind=
kreal),
intent(out) :: y(:), w(:)
403 real(kind=
kreal),
intent(inout) :: time_ax
404 real(kind=
kreal),
intent(inout) :: commtime
407 call hecmw_matvec_22_inner(hecmesh, hecmat, y, w, time_ax, commtime)
424 real(kind=
kreal),
intent(inout),
optional :: commtime
425 real(kind=
kreal),
allocatable :: w(:,:)
426 real(kind=
kreal),
pointer :: d(:)
427 integer(kind=kint) :: ip
428 real(kind=
kreal) :: start_time, end_time
429 allocate(w(2*hecmat%NP,2))
432 w(2*ip-1,1)= d(4*ip-3); w(2*ip-1,2)= d(4*ip-2);
433 w(2*ip-0,1)= d(4*ip-1); w(2*ip-0,2)= d(4*ip-0);
439 if (
present(commtime)) commtime = commtime + end_time - start_time
440 do ip= hecmat%N+1, hecmat%NP
441 d(4*ip-3)= w(2*ip-1,1); d(4*ip-2)= w(2*ip-1,2);
442 d(4*ip-1)= w(2*ip-0,1); d(4*ip-0)= w(2*ip-0,2);