27 integer(kind=kint) :: N
28 real(kind=
kreal),
pointer :: d(:) => null()
29 real(kind=
kreal),
pointer :: al(:) => null()
30 real(kind=
kreal),
pointer :: au(:) => null()
31 integer(kind=kint),
pointer :: indexL(:) => null()
32 integer(kind=kint),
pointer :: indexU(:) => null()
33 integer(kind=kint),
pointer :: itemL(:) => null()
34 integer(kind=kint),
pointer :: itemU(:) => null()
35 real(kind=
kreal),
pointer :: alu(:) => null()
37 integer(kind=kint) :: NColor
38 integer(kind=kint),
pointer :: COLORindex(:) => null()
39 integer(kind=kint),
pointer :: perm(:) => null()
40 integer(kind=kint),
pointer :: iperm(:) => null()
42 logical,
save :: isFirst = .true.
44 logical,
save :: INITIALIZED = .false.
50 real(kind=
kreal),
save :: omega = 1.d0
53 integer(kind=kint),
parameter :: numOfBlockPerThread = 100
54 integer(kind=kint),
save :: numOfThread = 1, numofblock
55 integer(kind=kint),
save,
allocatable :: icToBlockIndex(:)
56 integer(kind=kint),
save,
allocatable :: blockIndexToColorIndex(:)
57 integer(kind=kint),
save :: sectorCacheSize0, sectorCacheSize1
59 integer(kind=kint),
parameter :: SSOR_DEBUG = 0
66 integer(kind=kint ) :: npl, npu
67 integer(kind=kint ) :: ncolor_in
68 real (kind=
kreal) :: omega_inv
69 real (kind=
kreal) :: alutmp(2,2), pw(2)
70 integer(kind=kint ) :: ii, i, j, k
71 integer(kind=kint ) :: nthreads = 1
72 integer(kind=kint ),
allocatable :: perm_tmp(:)
73 real (kind=
kreal) :: t0
75 if (ssor_debug >= 1)
then
77 write(*,*)
'DEBUG: SSOR setup start',
hecmw_wtime()-t0
81 if (hecmat%Iarray(98) == 1)
then
83 else if (hecmat%Iarray(97) == 1)
then
98 omega_inv = 1.d0 / omega
101 allocate(colorindex(0:n), perm_tmp(n), perm(n), iperm(n))
103 hecmat%indexU, hecmat%itemU, perm_tmp, iperm)
104 if (ssor_debug >= 1)
write(*,*)
'DEBUG: RCM ordering done',
hecmw_wtime()-t0
106 hecmat%indexU, hecmat%itemU, perm_tmp, &
107 ncolor_in, ncolor, colorindex, perm, iperm)
108 if (ssor_debug >= 1)
write(*,*)
'DEBUG: MC ordering done',
hecmw_wtime()-t0
112 if (nthreads == 1)
then
114 allocate(colorindex(0:1), perm(n), iperm(n))
122 allocate(colorindex(0:n), perm_tmp(n), perm(n), iperm(n))
124 hecmat%indexU, hecmat%itemU, perm_tmp, iperm)
125 if (ssor_debug >= 1)
write(*,*)
'DEBUG: RCM ordering done',
hecmw_wtime()-t0
127 hecmat%indexU, hecmat%itemU, perm_tmp, &
128 ncolor_in, ncolor, colorindex, perm, iperm)
129 if (ssor_debug >= 1)
write(*,*)
'DEBUG: MC ordering done',
hecmw_wtime()-t0
137 do j=hecmat%indexU(i-1)+1,hecmat%indexU(i)
138 if( hecmat%itemU(j) > n )
exit
142 npl = max(hecmat%indexL(n),npl)
143 npu = hecmat%indexU(n)
144 allocate(indexl(0:n), indexu(0:n), iteml(npl), itemu(npu))
146 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
147 indexl, indexu, iteml, itemu)
148 if (ssor_debug >= 1)
write(*,*)
'DEBUG: reordering profile done',
hecmw_wtime()-t0
151 allocate(d(4*n), al(4*npl), au(4*npu))
153 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
154 hecmat%AL, hecmat%AU, hecmat%D, &
155 indexl, indexu, iteml, itemu, al, au, d)
156 if (ssor_debug >= 1)
write(*,*)
'DEBUG: reordering values done',
hecmw_wtime()-t0
176 alutmp(1,1)= alu(4*ii-3) * omega_inv
177 alutmp(1,2)= alu(4*ii-2) * omega_inv
178 alutmp(2,1)= alu(4*ii-1) * omega_inv
179 alutmp(2,2)= alu(4*ii-0) * omega_inv
181 alutmp(k,k)= 1.d0/alutmp(k,k)
183 alutmp(i,k)= alutmp(i,k) * alutmp(k,k)
185 pw(j)= alutmp(i,j) - alutmp(i,k)*alutmp(k,j)
192 alu(4*ii-3)= alutmp(1,1)
193 alu(4*ii-2)= alutmp(1,2)
194 alu(4*ii-1)= alutmp(2,1)
195 alu(4*ii-0)= alutmp(2,2)
207 hecmat%Iarray(98) = 0
208 hecmat%Iarray(97) = 0
210 if (ssor_debug >= 1)
write(*,*)
'DEBUG: SSOR setup done',
hecmw_wtime()-t0
214 subroutine setup_tuning_parameters
217 integer(kind=kint) :: blockindex, elementcount, numofelement, ii
218 real(kind=
kreal) :: numofelementperblock
219 integer(kind=kint) :: ic, i
220 if (ssor_debug >= 1)
write(*,*)
'DEBUG: setting up tuning parameters for SSOR'
225 numofblock = numofthread * numofblockperthread
226 if (
allocated(ictoblockindex))
deallocate(ictoblockindex)
227 if (
allocated(blockindextocolorindex))
deallocate(blockindextocolorindex)
228 allocate (ictoblockindex(0:ncolor), &
229 blockindextocolorindex(0:numofblock + ncolor))
230 numofelement = n + indexl(n) + indexu(n)
231 numofelementperblock = dble(numofelement) / numofblock
234 ictoblockindex(0) = 0
235 blockindextocolorindex = -1
236 blockindextocolorindex(0) = 0
240 do i = colorindex(ic-1)+1, colorindex(ic)
241 elementcount = elementcount + 1
242 elementcount = elementcount + (indexl(i) - indexl(i-1))
243 elementcount = elementcount + (indexu(i) - indexu(i-1))
244 if (elementcount > ii * numofelementperblock &
245 .or. i == colorindex(ic))
then
247 blockindex = blockindex + 1
248 blockindextocolorindex(blockindex) = i
251 ictoblockindex(ic) = blockindex
253 numofblock = blockindex
256 sectorcachesize0, sectorcachesize1 )
257 end subroutine setup_tuning_parameters
261 real(kind=
kreal),
intent(inout) :: zp(:)
262 integer(kind=kint) :: ic, i, iold, j, isl, iel, isu, ieu, k
263 real(kind=
kreal) :: sw1, sw2, x1, x2
265 real(kind=
kreal) :: omega_fac
268 integer(kind=kint) :: blockindex
272 call setup_tuning_parameters
278 omega_fac = 2.d0 - omega
297 do i = colorindex(ic-1)+1, colorindex(ic)
300 do blockindex = ictoblockindex(ic-1)+1, ictoblockindex(ic)
301 do i = blockindextocolorindex(blockindex-1)+1, &
302 blockindextocolorindex(blockindex)
305 sw1= omega_fac * zp(2*iold-1)
306 sw2= omega_fac * zp(2*iold-0)
313 sw1= sw1 - al(4*j-3)*x1 - al(4*j-2)*x2
314 sw2= sw2 - al(4*j-1)*x1 - al(4*j-0)*x2
319 x2= x2 - alu(4*i-1)*x1
321 x1= alu(4*i-3)*( x1 - alu(4*i-2)*x2)
339 do i = colorindex(ic-1)+1, colorindex(ic)
342 do blockindex = ictoblockindex(ic), ictoblockindex(ic-1)+1, -1
343 do i = blockindextocolorindex(blockindex), &
344 blockindextocolorindex(blockindex-1)+1, -1
358 sw1= sw1 + au(4*j-3)*x1 + au(4*j-2)*x2
359 sw2= sw2 + au(4*j-1)*x1 + au(4*j-0)*x2
364 x2= x2 - alu(4*i-1)*x1
366 x1= alu(4*i-3)*( x1 - alu(4*i-2)*x2 )
369 zp(2*iold-1)= zp(2*iold-1) - x1
370 zp(2*iold )= zp(2*iold ) - x2
394 if (
associated(colorindex))
deallocate(colorindex)
395 if (
associated(perm))
deallocate(perm)
396 if (
associated(iperm))
deallocate(iperm)
397 if (
associated(alu))
deallocate(alu)
398 if (
associated(d))
deallocate(d)
399 if (
associated(al))
deallocate(al)
400 if (
associated(au))
deallocate(au)
401 if (
associated(indexl))
deallocate(indexl)
402 if (
associated(indexu))
deallocate(indexu)
403 if (
associated(iteml))
deallocate(iteml)
404 if (
associated(itemu))
deallocate(itemu)
416 initialized = .false.
real(kind=kreal) function, public hecmw_mat_get_omega(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_ncolor_in(hecMAT)
subroutine, public hecmw_matrix_reorder_values(N, NDOF, perm, iperm, indexL, indexU, itemL, itemU, AL, AU, D, indexLp, indexUp, itemLp, itemUp, ALp, AUp, Dp)
subroutine, public hecmw_matrix_reorder_renum_item(N, perm, indexXp, itemXp)
subroutine, public hecmw_matrix_reorder_profile(N, perm, iperm, indexL, indexU, itemL, itemU, indexLp, indexUp, itemLp, itemUp)
subroutine, public hecmw_precond_ssor_22_apply(ZP)
subroutine, public hecmw_precond_ssor_22_setup(hecMAT)
subroutine, public hecmw_precond_ssor_22_clear(hecMAT)
subroutine, public hecmw_tuning_fx_calc_sector_cache(N, NDOF, sectorCacheSize0, sectorCacheSize1)
integer(kind=4), parameter kreal
real(kind=kreal) function hecmw_wtime()
subroutine, public hecmw_matrix_ordering_rcm(N, indexL, itemL, indexU, itemU, perm, iperm)
subroutine, public hecmw_matrix_ordering_mc(N, indexL, itemL, indexU, itemU, perm_cur, ncolor_in, ncolor_out, COLORindex, perm, iperm)