16 integer,
parameter ::
dp = kind(1.0d0)
46 integer,
allocatable :: core_halo_index(:)
49 integer,
allocatable :: nodeinpart(:)
60 character(len=100) :: pname
75 integer :: totalnodes2
78 integer :: globalpartmin
81 integer :: globalpartmax
84 integer :: globalpartextent
87 integer,
allocatable :: localpartmin(:)
90 integer,
allocatable :: localpartmax(:)
93 integer,
allocatable :: localpartextent(:)
96 integer,
allocatable :: order(:)
99 integer,
allocatable :: reorder(:)
105 integer,
allocatable :: nnodesinpart(:)
108 integer,
allocatable :: nnodesinpartall(:)
145 integer,
intent(in) :: pnum, hsize
152 allocate(sg%core_halo_index(hsize))
162 if (
allocated(sg%core_halo_index) .eqv. .true.) &
163 deallocate(sg%core_halo_index)
164 if (
allocated(sg%nodeInPart) .eqv. .true.)
deallocate(sg%nodeInPart)
177 character(len=*),
intent(in) :: pname
178 integer,
intent(in) :: np, nnodes, nnodes2
180 integer :: nprocs, avgparts
181 integer :: i, it, last, nleft
188 gp%totalProcs = nprocs
190 gp%totalNodes = nnodes
191 gp%totalNodes2 = nnodes2
195 gp%globalPartMax = np
196 gp%globalPartExtent = gp%globalPartMax - gp%globalPartMin + 1
198 allocate(gp%localPartMin(nprocs))
199 allocate(gp%localPartMax(nprocs))
200 allocate(gp%localPartExtent(nprocs))
203 avgparts = gp%totalParts / nprocs
205 gp%localPartExtent(i) = avgparts
208 nleft = gp%totalParts - nprocs * avgparts
209 if (nleft .gt. 0)
then
211 gp%localPartExtent(i) = gp%localPartExtent(i) + 1
215 gp%localPartMin(1) = 1
216 gp%localPartMax(1) = gp%localPartExtent(1)
218 gp%localPartMin(i) = gp%localPartMax(i-1) + 1
219 gp%localPartMax(i) = gp%localPartMin(i) + gp%localPartExtent(i) - 1
222 gp%nparts = gp%localPartExtent(gp%myRank+1)
224 allocate(gp%nnodesInPart(np))
225 allocate(gp%nnodesInPartAll(np))
226 allocate(gp%sgraph(np))
229 allocate(gp%order(nnodes))
230 allocate(gp%reorder(nnodes))
238 write(*,*)
"total procs = ", gp%totalProcs
239 write(*,*)
"total nodes = ", gp%totalNodes
240 write(*,*)
"total nodes2 = ", gp%totalNodes2
241 write(*,*)
"total parts = ", gp%totalParts
242 write(*,*)
"local parts = ", gp%nparts
244 write(*,*)
"globalPartMin = ", gp%globalPartMin, &
245 " globalPartMax = ", gp%globalPartMax, &
246 " globalPartExtent = ", gp%globalPartExtent
249 write(*,*)
"rank = ", i-1, &
250 " localPartMin = ", gp%localPartMin(i), &
251 " localPartMax = ", gp%localPartMax(i), &
252 " localPartExtent = ", gp%localPartExtent(i)
268 if (
allocated(gp%localPartMin))
deallocate(gp%localPartMin)
269 if (
allocated(gp%localPartMax))
deallocate(gp%localPartMax)
270 if (
allocated(gp%localPartExtent))
deallocate(gp%localPartExtent)
272 if (
allocated(gp%order))
deallocate(gp%order)
273 if (
allocated(gp%reorder))
deallocate(gp%reorder)
275 if(
allocated(gp%nnodesInPart))
deallocate(gp%nnodesInPart)
276 if(
allocated(gp%nnodesInPartAll))
deallocate(gp%nnodesInPartAll)
278 if (
allocated(gp%sgraph))
then
279 do i = 1, gp%totalParts
282 deallocate(gp%sgraph)
295 if (gp%myRank .ne. 0)
return
300 write(*,*)
"Graph partitioning:"
303 write(*,*)
"name = ", gp%pname
304 write(*,*)
"totalProcs = ", gp%totalProcs
305 write(*,*)
"totalParts = ", gp%totalParts
306 write(*,*)
"totalNodes = ", gp%totalNodes
307 write(*,*)
"totalNodes2 = ", gp%totalNodes2
309 write(*,*)
"globalPartMin = ", gp%globalPartMin, &
310 " globalPartMax = ", gp%globalPartMax, &
311 " globalPartExtent = ", gp%globalPartExtent
315 write(*,*)
"local parts = ", gp%nparts
316 do i = 1, gp%totalProcs
317 write(*,*)
"rank = ", i-1,
" localPartMin = ", gp%localPartMin(i), &
318 " localPartMax = ", gp%localPartMax(i), &
319 " localPartExtent = ", gp%localPartExtent(i)
324 write(*,*)
"Number of iterations = ", gp%maxIter
325 write(*,*)
"SP2 sequence = ", (gp%pp(i),i=1,gp%maxIter)
326 write(*,*)
"mineval = ", gp%mineval ,
"maxeval = ", gp%maxeval
331 write(*,*)
"part = ", i,
" hsize = ", gp%sgraph(i)%hsize, &
332 " lsize = ", gp%sgraph(i)%lsize, &
333 " llsize = ", gp%sgraph(i)%llsize
335 write(*,*)
"Number of core nodes in part = ", gp%nnodesInPart(i)
336 write(*,*)
"nodeInPart = ", &
337 (gp%sgraph(i)%nodeInPart(j), j=1,gp%nnodesInPart(i))
340 write(*,*)
"core_halo_index = ", &
341 (gp%sgraph(i)%core_halo_index(j), j=1,gp%sgraph(i)%lsize)
355 integer,
intent(in) :: nodesperpart, nnodes
357 integer :: i, j, it, np, psize
358 character(len=100) :: pname
361 np = ceiling(real(nnodes) / real(nodesperpart))
362 write(pname,
'("equalParts")')
371 do i = 1, gp%totalParts
373 if ((i * nodesperpart) .le. nnodes)
then
376 psize = nnodes - (nodesperpart * (i-1))
378 allocate(gp%sgraph(i)%nodeInPart(psize))
380 it = (i-1) * nodesperpart + j-1;
381 gp%sgraph(i)%nodeInPart(j) = it
383 gp%nnodesInPart(i) = psize
384 gp%nnodesInPartAll(i) = psize
399 integer,
intent(in) :: nodesperpart, nnodes, ngroup
400 integer,
intent(in) :: hindex(2,ngroup)
402 integer :: i, j, k, ll, np, psize, ind, ptotal
403 character(len=100) :: pname
406 np = ceiling(real(ngroup) / real(nodesperpart))
407 write(pname,
'("equalGroupParts")')
416 do i = 1, gp%totalParts
420 if ((i * nodesperpart) .le. ngroup)
then
423 psize = ngroup - (nodesperpart * (i-1))
427 ind = (i-1)*nodesperpart
430 ptotal = ptotal + hindex(2, ind+j) - hindex(1, ind+j) + 1
432 gp%nnodesInPart(i) = ptotal
433 gp%nnodesInPartAll(i) = ptotal
436 allocate(gp%sgraph(i)%nodeInPart(ptotal))
439 do k = hindex(1, ind+j), hindex(2, ind+j)
440 gp%sgraph(i)%nodeInPart(ll) = k-1
461 character(len=*),
intent(in) :: partfile
472 character(len=*),
intent(in) :: partFile
473 type (graph_partitioning_t),
intent(inout) :: gp
476 integer :: totalNodes, totalParts
477 integer :: i, j, ip, pnode
478 character(len=100) :: pname
481 open(unit=pfile, status=
'old', file=partfile)
484 read(pfile, *) totalnodes, totalparts
489 read(pfile, *) (gp%nnodesInPartAll(i), i=1,gp%totalParts)
490 do i = 1, gp%totalParts
491 gp%nnodesInPart(i) = gp%nnodesInPartAll(i)
495 do i = 1, gp%totalParts
498 allocate(gp%sgraph(i)%nodeInPart(gp%nnodesInPart(i)))
499 read(pfile, *) (gp%sgraph(i)%nodeInPart(j),j=1,gp%nnodesInPart(i))
500 do j = 1, gp%nnodesInPart(i)
501 gp%sgraph(i)%nodeInPart(j) = gp%sgraph(i)%nodeInPart(j) + 1
517 real(
dp),
allocatable :: slocal(:), sglobal(:)
523 allocate(slocal(gp%maxIter))
524 allocate(sglobal(gp%maxIter))
530 gp%vv(i) = sglobal(i)
532 deallocate(slocal, sglobal)
538 gp%vv(i) = sqrt(gp%vv(i))
543 write(*,*)
"prg_fnormGraph:"
545 write(*,*)
"iter = ", i,
" fnorm = ", gp%vv(i)
subroutine, public prg_initgraphpartitioning(gp, pname, np, nnodes, nnodes2)
Initialize graph partitioning.
subroutine, public prg_equalpartition(gp, nodesPerPart, nnodes)
Create equal graph partitions, based on number of rows/orbitals.
subroutine, public prg_initsubgraph(sg, pnum, hsize)
Initialize subgraph.
subroutine, public prg_filepartition(gp, partFile)
Read graph partitions from a file, based on number of rows/orbitals.
subroutine prg_readpart(gp, partFile)
Read parts (core) from part file.
subroutine, public prg_destroygraphpartitioning(gp)
Destroy graph partitioning.
subroutine, public prg_destroysubgraph(sg)
Destroy subgraph.
subroutine, public prg_fnormgraph(gp)
Accumulate trace norm across all subgraphs.
subroutine, public prg_equalgrouppartition(gp, hindex, ngroup, nodesPerPart, nnodes)
Create equal group graph partitions, based on number of atoms/groups.
subroutine, public prg_printgraphpartitioning(gp)
Print graph partitioning structure data.
subroutine, public sumrealparallel(sendBuf, recvBuf, icount)
integer function, public printrank()
integer function, public getnranks()
integer function, public getmyrank()