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_33_inner(hecmesh, hecmat, x, y, time_ax, tcomm)
58 if (
present(commtime)) commtime = commtime + tcomm
120 subroutine hecmw_matvec_33_inner (hecMESH, hecMAT, X, Y, time_Ax, COMMtime)
131 real(kind=
kreal),
intent(in) :: x(:)
132 real(kind=
kreal),
intent(out) :: y(:)
133 real(kind=
kreal),
intent(inout) :: time_ax
134 real(kind=
kreal),
intent(inout),
optional :: commtime
136 real(kind=
kreal) :: start_time, end_time, tcomm
137 integer(kind=kint) :: i, j, js, je, in
138 real(kind=
kreal) :: yv1, yv2, yv3, x1, x2, x3
140 integer(kind=kint) :: n, np
141 integer(kind=kint),
pointer :: indexl(:), iteml(:), indexu(:), itemu(:)
142 real(kind=
kreal),
pointer :: al(:), au(:), d(:)
145 integer,
parameter :: numofblockperthread = 100
146 logical,
save :: isfirst = .true.
147 integer,
save :: numofthread = 1
148 integer,
save,
allocatable :: startpos(:), endpos(:)
149 integer(kind=kint),
save :: sectorcachesize0, sectorcachesize1
150 integer(kind=kint) :: threadnum, blocknum, numofblock
151 integer(kind=kint) :: numofelement, elementcount, blockindex
152 real(kind=
kreal) :: numofelementperblock
160 time_ax = time_ax + end_time - start_time - tcomm
161 if (
present(commtime)) commtime = commtime + tcomm
166 indexl => hecmat%indexL
167 indexu => hecmat%indexU
168 iteml => hecmat%itemL
169 itemu => hecmat%itemU
175 if (.not. isfirst)
then
176 numofblock = numofthread * numofblockperthread
177 if (endpos(numofblock-1) .ne. n-1)
then
178 deallocate(startpos, endpos)
184 numofblock = numofthread * numofblockperthread
185 allocate (startpos(0 : numofblock - 1), endpos(0 : numofblock - 1))
186 numofelement = n + indexl(n) + indexu(n)
187 numofelementperblock = dble(numofelement) / numofblock
190 startpos(blocknum) = 1
192 elementcount = elementcount + 1
193 elementcount = elementcount + (indexl(i) - indexl(i-1))
194 elementcount = elementcount + (indexu(i) - indexu(i-1))
195 if (elementcount > (blocknum + 1) * numofelementperblock)
then
199 blocknum = blocknum + 1
200 startpos(blocknum) = i + 1
201 if (blocknum == (numofblock - 1))
exit
208 do i= blocknum+1, numofblock-1
216 sectorcachesize0, sectorcachesize1)
229 if (
present(commtime)) commtime = commtime + end_time - start_time
244 do blocknum = 0 , numofblockperthread - 1
245 blockindex = blocknum * numofthread + threadnum
246 do i = startpos(blockindex), endpos(blockindex)
250 yv1= d(9*i-8)*x1 + d(9*i-7)*x2 + d(9*i-6)*x3
251 yv2= d(9*i-5)*x1 + d(9*i-4)*x2 + d(9*i-3)*x3
252 yv3= d(9*i-2)*x1 + d(9*i-1)*x2 + d(9*i )*x3
261 yv1= yv1 + al(9*j-8)*x1 + al(9*j-7)*x2 + al(9*j-6)*x3
262 yv2= yv2 + al(9*j-5)*x1 + al(9*j-4)*x2 + al(9*j-3)*x3
263 yv3= yv3 + al(9*j-2)*x1 + al(9*j-1)*x2 + al(9*j )*x3
273 yv1= yv1 + au(9*j-8)*x1 + au(9*j-7)*x2 + au(9*j-6)*x3
274 yv2= yv2 + au(9*j-5)*x1 + au(9*j-4)*x2 + au(9*j-3)*x3
275 yv3= yv3 + au(9*j-2)*x1 + au(9*j-1)*x2 + au(9*j )*x3
291 time_ax = time_ax + end_time - start_time
327 end subroutine hecmw_matvec_33_inner
339 real(kind=
kreal),
intent(in) :: x(:), b(:)
340 real(kind=
kreal),
intent(out) :: r(:)
341 real(kind=
kreal),
intent(inout) :: time_ax
342 real(kind=
kreal),
intent(inout),
optional :: commtime
344 integer(kind=kint) :: i
345 real(kind=
kreal) :: tcomm
349 if (
present(commtime)) commtime = commtime + tcomm
352 do i = 1, hecmat%N * 3
371 real(kind=
kreal),
intent(inout) :: time_ax
372 real(kind=
kreal),
intent(inout),
optional :: commtime
374 real(kind=
kreal),
allocatable :: r(:)
375 real(kind=
kreal) :: bnorm2, rnorm2
376 real(kind=
kreal) :: tcomm
378 allocate(r(hecmat%NDOF*hecmat%NP))
382 hecmat%B, hecmat%B, bnorm2, tcomm)
383 if (bnorm2 == 0.d0)
then
390 if (
present(commtime)) commtime = commtime + tcomm
405 real(kind=
kreal),
intent(in) :: x(:)
406 real(kind=
kreal),
intent(out) :: y(:)
407 real(kind=
kreal),
intent(inout) :: commtime
409 real(kind=
kreal) :: start_time, end_time
410 integer(kind=kint) :: i, j, jj, k, kk
415 commtime = commtime + end_time - start_time
419 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
425 outer:
do i= 1, hecmesh%mpc%n_mpc
426 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
427 if (hecmesh%mpc%mpc_dof(j) > 3) cycle outer
429 k = hecmesh%mpc%mpc_index(i-1) + 1
430 kk = 3 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
432 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
433 jj = 3 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
434 y(kk) = y(kk) - hecmesh%mpc%mpc_val(j) * x(jj)
452 real(kind=
kreal),
intent(in) :: x(:)
453 real(kind=
kreal),
intent(out) :: y(:)
454 real(kind=
kreal),
intent(inout) :: commtime
456 real(kind=
kreal) :: start_time, end_time
457 integer(kind=kint) :: i, j, jj, k, kk
462 commtime = commtime + end_time - start_time
466 do i= 1, hecmesh%nn_internal * hecmesh%n_dof
472 outer:
do i= 1, hecmesh%mpc%n_mpc
473 do j= hecmesh%mpc%mpc_index(i-1) + 1, hecmesh%mpc%mpc_index(i)
474 if (hecmesh%mpc%mpc_dof(j) > 3) cycle outer
476 k = hecmesh%mpc%mpc_index(i-1) + 1
477 kk = 3 * (hecmesh%mpc%mpc_item(k) - 1) + hecmesh%mpc%mpc_dof(k)
479 do j= hecmesh%mpc%mpc_index(i-1) + 2, hecmesh%mpc%mpc_index(i)
480 jj = 3 * (hecmesh%mpc%mpc_item(j) - 1) + hecmesh%mpc%mpc_dof(j)
482 y(jj) = y(jj) - hecmesh%mpc%mpc_val(j) * x(kk)
500 real(kind=
kreal),
intent(in) :: x(:)
501 real(kind=
kreal),
intent(out) :: y(:), w(:)
502 real(kind=
kreal),
intent(inout) :: time_ax
503 real(kind=
kreal),
intent(inout) :: commtime
506 call hecmw_matvec_33_inner(hecmesh, hecmat, y, w, time_ax, commtime)
523 real(kind=
kreal),
intent(inout),
optional :: commtime
524 real(kind=
kreal),
allocatable :: w(:,:)
525 real(kind=
kreal),
pointer :: d(:)
526 integer(kind=kint) :: ip
527 real(kind=
kreal) :: start_time, end_time
528 allocate(w(3*hecmat%NP,3))
531 w(3*ip-2,1)= d(9*ip-8); w(3*ip-2,2)= d(9*ip-7); w(3*ip-2,3)= d(9*ip-6)
532 w(3*ip-1,1)= d(9*ip-5); w(3*ip-1,2)= d(9*ip-4); w(3*ip-1,3)= d(9*ip-3)
533 w(3*ip ,1)= d(9*ip-2); w(3*ip ,2)= d(9*ip-1); w(3*ip ,3)= d(9*ip )
540 if (
present(commtime)) commtime = commtime + end_time - start_time
541 do ip= hecmat%N+1, hecmat%NP
542 d(9*ip-8)= w(3*ip-2,1); d(9*ip-7)= w(3*ip-2,2); d(9*ip-6)= w(3*ip-2,3)
543 d(9*ip-5)= w(3*ip-1,1); d(9*ip-4)= w(3*ip-1,2); d(9*ip-3)= w(3*ip-1,3)
544 d(9*ip-2)= w(3*ip ,1); d(9*ip-1)= w(3*ip ,2); d(9*ip )= w(3*ip ,3)