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()
47 logical,
save :: precond_impl_missing_reported = .false.
49 logical,
save :: isFirst = .true.
51 logical,
save :: INITIALIZED = .false.
54 integer(kind=kint),
parameter :: numOfBlockPerThread = 100
55 integer(kind=kint),
save :: numOfThread = 1, numofblock
56 integer(kind=kint),
save,
allocatable :: icToBlockIndex(:)
57 integer(kind=kint),
save,
allocatable :: blockIndexToColorIndex(:)
58 integer(kind=kint),
save :: sectorCacheSize0, sectorCacheSize1
60 integer(kind=kint),
parameter :: DEBUG = 0
67 integer(kind=kint ) :: npl, npu
68 integer(kind=kint ) :: ncolor_in
69 real (kind=
kreal) :: sigma_diag
70 real (kind=
kreal) :: alutmp(3,3), pw(3)
71 integer(kind=kint ) :: ii, i, j, k
72 integer(kind=kint ) :: nthreads = 1
73 integer(kind=kint ),
allocatable :: perm_tmp(:)
74 real (kind=
kreal) :: t0
78 write(*,*)
'DEBUG: SSOR setup start',
hecmw_wtime()-t0
82 if (hecmat%Iarray(98) == 1)
then
84 else if (hecmat%Iarray(97) == 1)
then
102 allocate(colorindex(0:n), perm_tmp(n), perm(n), iperm(n))
104 hecmat%indexU, hecmat%itemU, perm_tmp, iperm)
105 if (debug >= 1)
write(*,*)
'DEBUG: RCM ordering done',
hecmw_wtime()-t0
107 hecmat%indexU, hecmat%itemU, perm_tmp, &
108 ncolor_in, ncolor, colorindex, perm, iperm)
109 if (debug >= 1)
write(*,*)
'DEBUG: MC ordering done',
hecmw_wtime()-t0
113 if (nthreads == 1)
then
115 allocate(colorindex(0:1), perm(n), iperm(n))
123 allocate(colorindex(0:n), perm_tmp(n), perm(n), iperm(n))
125 hecmat%indexU, hecmat%itemU, perm_tmp, iperm)
126 if (debug >= 1)
write(*,*)
'DEBUG: RCM ordering done',
hecmw_wtime()-t0
128 hecmat%indexU, hecmat%itemU, perm_tmp, &
129 ncolor_in, ncolor, colorindex, perm, iperm)
130 if (debug >= 1)
write(*,*)
'DEBUG: MC ordering done',
hecmw_wtime()-t0
138 do j=hecmat%indexU(i-1)+1,hecmat%indexU(i)
139 if( hecmat%itemU(j) > n )
exit
143 npl = max(hecmat%indexL(n),npl)
144 npu = hecmat%indexU(n)
145 allocate(indexl(0:n), indexu(0:n), iteml(npl), itemu(npu))
147 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
148 indexl, indexu, iteml, itemu)
149 if (debug >= 1)
write(*,*)
'DEBUG: reordering profile done',
hecmw_wtime()-t0
152 allocate(d(9*n), al(9*npl), au(9*npu))
154 hecmat%indexL, hecmat%indexU, hecmat%itemL, hecmat%itemU, &
155 hecmat%AL, hecmat%AU, hecmat%D, &
156 indexl, indexu, iteml, itemu, al, au, d)
157 if (debug >= 1)
write(*,*)
'DEBUG: reordering values done',
hecmw_wtime()-t0
177 alutmp(1,1)= alu(9*ii-8) * sigma_diag
178 alutmp(1,2)= alu(9*ii-7)
179 alutmp(1,3)= alu(9*ii-6)
180 alutmp(2,1)= alu(9*ii-5)
181 alutmp(2,2)= alu(9*ii-4) * sigma_diag
182 alutmp(2,3)= alu(9*ii-3)
183 alutmp(3,1)= alu(9*ii-2)
184 alutmp(3,2)= alu(9*ii-1)
185 alutmp(3,3)= alu(9*ii ) * sigma_diag
187 alutmp(k,k)= 1.d0/alutmp(k,k)
189 alutmp(i,k)= alutmp(i,k) * alutmp(k,k)
191 pw(j)= alutmp(i,j) - alutmp(i,k)*alutmp(k,j)
198 alu(9*ii-8)= alutmp(1,1)
199 alu(9*ii-7)= alutmp(1,2)
200 alu(9*ii-6)= alutmp(1,3)
201 alu(9*ii-5)= alutmp(2,1)
202 alu(9*ii-4)= alutmp(2,2)
203 alu(9*ii-3)= alutmp(2,3)
204 alu(9*ii-2)= alutmp(3,1)
205 alu(9*ii-1)= alutmp(3,2)
206 alu(9*ii )= alutmp(3,3)
218 hecmat%Iarray(98) = 0
219 hecmat%Iarray(97) = 0
221 if (debug >= 1)
write(*,*)
'DEBUG: SSOR setup done',
hecmw_wtime()-t0
225 subroutine setup_tuning_parameters
228 integer(kind=kint) :: blockindex, elementcount, numofelement, ii
229 real(kind=
kreal) :: numofelementperblock
230 integer(kind=kint) :: my_rank
231 integer(kind=kint) :: ic, i
232 if (debug >= 1)
write(*,*)
'DEBUG: setting up tuning parameters for SSOR'
237 numofblock = numofthread * numofblockperthread
238 if (
allocated(ictoblockindex))
deallocate(ictoblockindex)
239 if (
allocated(blockindextocolorindex))
deallocate(blockindextocolorindex)
240 allocate (ictoblockindex(0:ncolor), &
241 blockindextocolorindex(0:numofblock + ncolor))
242 numofelement = n + indexl(n) + indexu(n)
243 numofelementperblock = dble(numofelement) / numofblock
246 ictoblockindex(0) = 0
247 blockindextocolorindex = -1
248 blockindextocolorindex(0) = 0
257 do i = colorindex(ic-1)+1, colorindex(ic)
258 elementcount = elementcount + 1
259 elementcount = elementcount + (indexl(i) - indexl(i-1))
260 elementcount = elementcount + (indexu(i) - indexu(i-1))
261 if (elementcount > ii * numofelementperblock &
262 .or. i == colorindex(ic))
then
264 blockindex = blockindex + 1
265 blockindextocolorindex(blockindex) = i
270 ictoblockindex(ic) = blockindex
272 numofblock = blockindex
275 sectorcachesize0, sectorcachesize1 )
276 end subroutine setup_tuning_parameters
281 real(kind=
kreal),
intent(inout) :: zp(:)
283 select case (precond_impl)
287 if (.not. precond_impl_missing_reported)
then
288 precond_impl_missing_reported = .true.
290 '#### MATRIXFORMAT: this build has no SSOR preconditioner for the selected '// &
291 'format -- running the BSR implementation'
299 real(kind=
kreal),
intent(inout) :: zp(:)
300 integer(kind=kint) :: ic, i, iold, j, isL, ieL, isU, ieU, k
301 real(kind=
kreal) :: sw1, sw2, sw3, x1, x2, x3
304 integer(kind=kint) :: blockIndex
308 call setup_tuning_parameters
331 do i = colorindex(ic-1)+1, colorindex(ic)
334 do blockindex = ictoblockindex(ic-1)+1, ictoblockindex(ic)
335 do i = blockindextocolorindex(blockindex-1)+1, &
336 blockindextocolorindex(blockindex)
351 sw1= sw1 - al(9*j-8)*x1 - al(9*j-7)*x2 - al(9*j-6)*x3
352 sw2= sw2 - al(9*j-5)*x1 - al(9*j-4)*x2 - al(9*j-3)*x3
353 sw3= sw3 - al(9*j-2)*x1 - al(9*j-1)*x2 - al(9*j )*x3
359 x2= x2 - alu(9*i-5)*x1
360 x3= x3 - alu(9*i-2)*x1 - alu(9*i-1)*x2
362 x2= alu(9*i-4)*( x2 - alu(9*i-3)*x3 )
363 x1= alu(9*i-8)*( x1 - alu(9*i-6)*x3 - alu(9*i-7)*x2)
382 do i = colorindex(ic-1)+1, colorindex(ic)
385 do blockindex = ictoblockindex(ic), ictoblockindex(ic-1)+1, -1
386 do i = blockindextocolorindex(blockindex), &
387 blockindextocolorindex(blockindex-1)+1, -1
404 sw1= sw1 + au(9*j-8)*x1 + au(9*j-7)*x2 + au(9*j-6)*x3
405 sw2= sw2 + au(9*j-5)*x1 + au(9*j-4)*x2 + au(9*j-3)*x3
406 sw3= sw3 + au(9*j-2)*x1 + au(9*j-1)*x2 + au(9*j )*x3
412 x2= x2 - alu(9*i-5)*x1
413 x3= x3 - alu(9*i-2)*x1 - alu(9*i-1)*x2
415 x2= alu(9*i-4)*( x2 - alu(9*i-3)*x3 )
416 x1= alu(9*i-8)*( x1 - alu(9*i-6)*x3 - alu(9*i-7)*x2)
418 zp(3*iold-2)= zp(3*iold-2) - x1
419 zp(3*iold-1)= zp(3*iold-1) - x2
420 zp(3*iold )= zp(3*iold ) - x3
444 integer(kind=kint ) :: nthreads = 1
448 if (
associated(colorindex))
deallocate(colorindex)
449 if (
associated(perm))
deallocate(perm)
450 if (
associated(iperm))
deallocate(iperm)
451 if (
associated(alu))
deallocate(alu)
452 if (nthreads >= 1)
then
453 if (
associated(d))
deallocate(d)
454 if (
associated(al))
deallocate(al)
455 if (
associated(au))
deallocate(au)
456 if (
associated(indexl))
deallocate(indexl)
457 if (
associated(indexu))
deallocate(indexu)
458 if (
associated(iteml))
deallocate(iteml)
459 if (
associated(itemu))
deallocate(itemu)
472 initialized = .false.
real(kind=kreal) function, public hecmw_mat_get_sigma_diag(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_precond_impl(hecMAT)
integer(kind=kint), parameter, public hecmw_precond_impl_bsr
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_33_apply(ZP)
subroutine hecmw_precond_ssor_33_apply_generic(ZP)
subroutine, public hecmw_precond_ssor_33_setup(hecMAT)
subroutine, public hecmw_precond_ssor_33_clear(hecMAT)
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, 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)