123 integer,
allocatable :: ghost_sendpos(:)
125 integer,
allocatable :: ghost_rdispls(:)
126 integer,
allocatable :: ghost_sdispls(:)
127 integer,
allocatable :: ghost_rcounts(:)
128 integer,
allocatable :: ghost_scounts(:)
129 integer :: ghost_scount
130 integer,
allocatable :: ghost_sendmap(:)
131 integer,
allocatable :: ghost_recvmap(:)
132 type(accel_mem_t) :: buff_sendmap
133 type(accel_mem_t) :: buff_recvmap
136 type(mpi_grp_t) :: mpi_grp
138 integer(int64) :: np_global
140 integer,
allocatable :: np_local_vec(:)
144 integer(int64),
allocatable,
private :: xlocal_vec(:)
148 integer(int64) :: xlocal
151 integer(int64),
allocatable,
private :: local(:)
153 integer,
allocatable :: recv_count(:)
154 integer,
allocatable :: send_count(:)
156 integer,
allocatable :: recv_disp(:)
157 integer,
allocatable :: send_disp(:)
158 integer(int64),
allocatable:: sendmap(:)
159 integer(int64),
allocatable:: recvmap(:)
163 integer(int64),
allocatable,
private :: bndry(:)
165 type(lihash_t),
private :: global
168 integer(int64),
allocatable,
private :: ghost(:)
206 subroutine par_vec_init(mpi_grp, np_global, idx, stencil, space, partition, pv, namespace)
209 integer(int64),
intent(in) :: np_global
221 integer(int64) :: gip, index
222 integer :: ip, jp, jj, inode
223 integer :: p1(space%dim)
226 integer(int64),
allocatable :: boundary_inv(:), ghost_inv(:)
228 character(len=6) :: filenum
231 integer :: idir, ipart, itmp
232 integer(int64) :: tmp
233 integer,
allocatable :: points(:), part_ghost(:), part_ghost_tmp(:)
234 integer(int64),
allocatable :: indices(:), ghost_tmp(:)
243 pv%rank = mpi_grp%rank
244 pv%partno = pv%rank + 1
247 pv%np_global = np_global
251 safe_allocate(pv%np_local_vec(1:npart))
252 safe_allocate(pv%xlocal_vec(1:npart))
253 safe_allocate(pv%ghost_rcounts(1:npart))
254 safe_allocate(pv%ghost_scounts(1:npart))
259 pv%np_local = pv%np_local_vec(pv%partno)
266 pv%xlocal_vec(inode) = pv%xlocal_vec(inode - 1) + pv%np_local_vec(inode - 1)
268 pv%xlocal = pv%xlocal_vec(pv%partno)
270 safe_allocate(pv%local(pv%xlocal:pv%xlocal + pv%np_local - 1))
277 do ip = 1, pv%np_local
286 safe_allocate(boundary_inv(1:pv%np_local))
287 safe_allocate(ghost_inv(1:pv%np_local))
290 do gip = pv%xlocal, pv%xlocal + pv%np_local - 1
294 do jj = 1, stencil%size
298 message(1) =
"Internal error: a stencil neighbour of a local mesh point is not a mesh point."
299 message(2) =
"The mesh has holes. The most likely cause is grid points on a box face being"
300 message(3) =
"rejected by the box membership tolerance."
307 if (index > np_global)
then
310 pv%np_bndry = pv%np_bndry + 1
312 if (pv%np_bndry >= ubound(boundary_inv, 1))
call make_array_larger(boundary_inv, pv%np_bndry*2)
313 boundary_inv(pv%np_bndry) = index
317 pv%np_ghost = pv%np_ghost + 1
319 if (pv%np_ghost >= ubound(ghost_inv, 1))
call make_array_larger(ghost_inv, pv%np_ghost*2)
320 ghost_inv(pv%np_ghost) = index
325 safe_allocate(pv%bndry(1:pv%np_bndry))
326 do ip = 1, pv%np_bndry
327 pv%bndry(ip) = boundary_inv(ip)
331 safe_allocate(ghost_tmp(1:pv%np_ghost))
332 do ip = 1, pv%np_ghost
333 ghost_tmp(ip) = ghost_inv(ip)
337 safe_deallocate_a(ghost_inv)
338 safe_deallocate_a(boundary_inv)
340 safe_allocate(part_ghost_tmp(1:pv%np_ghost))
342 ghost_tmp, part_ghost_tmp)
345 pv%ghost_rcounts(:) = 0
346 do ip = 1, pv%np_ghost
347 ipart = part_ghost_tmp(ip)
348 pv%ghost_rcounts(ipart) = pv%ghost_rcounts(ipart)+1
350 assert(sum(pv%ghost_rcounts) == pv%np_ghost)
352 safe_allocate(pv%ghost_rdispls(1:pv%npart))
353 pv%ghost_rdispls(1) = 0
354 do ipart = 2, pv%npart
355 pv%ghost_rdispls(ipart) = pv%ghost_rdispls(ipart - 1) + pv%ghost_rcounts(ipart - 1)
359 safe_allocate(pv%ghost(1:pv%np_ghost))
360 safe_allocate(part_ghost(1:pv%np_ghost))
361 safe_allocate(points(1:pv%npart))
363 do ip = 1, pv%np_ghost
364 ipart = part_ghost_tmp(ip)
365 points(ipart) = points(ipart)+1
367 jp = pv%ghost_rdispls(ipart) + points(ipart)
368 pv%ghost(jp) = ghost_tmp(ip)
369 part_ghost(jp) = part_ghost_tmp(ip)
371 safe_deallocate_a(points)
372 safe_deallocate_a(ghost_tmp)
373 safe_deallocate_a(part_ghost_tmp)
375 call pv%mpi_grp%alltoall(pv%ghost_rcounts, 1, mpi_integer, &
376 pv%ghost_scounts, 1, mpi_integer)
378 safe_allocate(pv%ghost_sdispls(1:pv%npart))
380 pv%ghost_sdispls(1) = 0
381 do ipart = 2, pv%npart
382 pv%ghost_sdispls(ipart) = pv%ghost_sdispls(ipart - 1) + pv%ghost_scounts(ipart - 1)
384 pv%ghost_scount = sum(pv%ghost_scounts)
386 safe_allocate(pv%ghost_recvmap(1:pv%np_ghost))
387 safe_allocate(points(1:pv%npart))
389 do ip = 1, pv%np_ghost
390 ipart = part_ghost(ip)
391 points(ipart) = points(ipart) + 1
392 pv%ghost_recvmap(ip) = pv%ghost_rdispls(ipart) + points(ipart)
394 safe_deallocate_a(points)
396 safe_allocate(indices(1:pv%np_ghost))
397 do ip = 1, pv%np_ghost
398 indices(pv%ghost_recvmap(ip)) = pv%ghost(ip)
400 safe_allocate(pv%ghost_sendmap(1:pv%ghost_scount))
401 safe_allocate(ghost_tmp(1:pv%ghost_scount))
402 call pv%mpi_grp%alltoallv(indices, pv%ghost_rcounts, pv%ghost_rdispls, mpi_integer8, &
403 ghost_tmp, pv%ghost_scounts, pv%ghost_sdispls, mpi_integer8)
404 do ip = 1, pv%ghost_scount
408 pv%ghost_sendmap(ip) = jp
410 safe_deallocate_a(indices)
411 safe_deallocate_a(ghost_tmp)
426 call io_mkdir(
'debug/mesh_partition', namespace, parents=.
true.)
428 write(filenum,
'(i6.6)') pv%partno
429 iunit =
io_open(
'debug/mesh_partition/ghost_points.'//filenum, namespace, action=
'write')
430 do ip = 1, pv%np_ghost
432 write(iunit,
'(99i8)') pv%ghost(ip), (p1(idir), idir = 1, space%dim)
441 do ip = 1, pv%np_ghost
442 call lihash_insert(pv%global, pv%ghost(ip), ip + pv%np_local)
445 do ip = 1, pv%np_bndry
446 call lihash_insert(pv%global, pv%bndry(ip), ip + pv%np_local + pv%np_ghost)
449 safe_deallocate_a(part_ghost)
455 integer :: ip, nn, direction
456 integer(int64) :: ipg
457 integer :: bsize(space%dim), order, point(space%dim), number_of_blocks(space%dim)
458 integer(int64),
allocatable :: reorder_indices(:)
459 integer(int64),
allocatable :: reordered(:)
460 integer,
allocatable :: global_indices(:)
462 logical :: increase_with_dimension
463 integer,
parameter :: &
485 call parse_variable(namespace,
'MeshLocalOrder', order_blocks, order)
487 if (space%dim == 1)
then
506 call parse_variable(namespace,
'MeshLocalBlockDirection', 1, direction)
507 increase_with_dimension = direction == 1
508 if (direction /= 1 .and. direction /= 2)
then
515 case (order_blocks, order_cube)
516 if (order == order_cube)
then
517 bsize(1:space%dim) = idx%nr(2, 1:space%dim) - idx%nr(1, 1:space%dim) + 1
530 if (
conf%target_states_block_size < 16)
then
531 bsize(1) = 80 * 4 / abs(
conf%target_states_block_size)
532 if (space%dim > 1) bsize(2) = 4
533 if (space%dim > 2) bsize(3:) = 10
535 bsize(1) = max(4 * 16 / abs(
conf%target_states_block_size), 1)
536 if (space%dim > 1) bsize(2) = 15
537 if (space%dim > 2) bsize(3:) = 15
540 if (
parse_block(namespace,
'MeshLocalBlockSize', blk) == 0)
then
542 if (nn /= space%dim)
then
543 message(1) =
"Error: number of entries in MeshLocalBlockSize must match the umber of dimensions."
552 number_of_blocks(1:space%dim) = idx%ll(1:space%dim)/bsize(1:space%dim) + 1
555 safe_allocate(reorder_indices(1:pv%np_local))
556 safe_allocate(global_indices(1:pv%np_local))
557 do ip = 1, pv%np_local
558 ipg = pv%local(ip + pv%xlocal - 1)
560 point = point + idx%offset + idx%enlarge
561 reorder_indices(ip) =
get_blocked_index(space%dim, point, bsize, number_of_blocks, increase_with_dimension)
564 call sort(reorder_indices, global_indices)
565 safe_deallocate_a(reorder_indices)
568 safe_allocate(reordered(1:pv%np_local))
569 do ip = 1, pv%np_local
570 reordered(ip) = pv%local(global_indices(ip) + pv%xlocal - 1)
572 safe_deallocate_a(global_indices)
575 do ip = 1, pv%np_local
576 pv%local(ip + pv%xlocal - 1) = reordered(ip)
578 safe_deallocate_a(reordered)
584 do ip = 1, pv%np_local
585 call lihash_insert(pv%global, pv%local(pv%xlocal + ip - 1), ip)
593 integer,
allocatable :: part_local(:)
597 safe_allocate(part_local(1:pv%np_local))
598 safe_allocate(indices(1:pv%np_local))
599 do ip = 1, pv%np_local
600 indices(ip) = pv%xlocal + ip - 1
604 safe_deallocate_a(indices)
606 safe_allocate(pv%send_count(1:npart))
607 safe_allocate(pv%recv_count(1:npart))
608 safe_allocate(pv%send_disp(1:npart))
609 safe_allocate(pv%recv_disp(1:npart))
612 do ip = 1, pv%np_local
613 ipart = part_local(ip)
614 pv%send_count(ipart) = pv%send_count(ipart) + 1
618 pv%send_disp(ipart) = pv%send_disp(ipart - 1) + pv%send_count(ipart - 1)
621 call pv%mpi_grp%alltoall(pv%send_count, 1, mpi_integer, &
622 pv%recv_count, 1, mpi_integer)
626 pv%recv_disp(ipart) = pv%recv_disp(ipart - 1) + pv%recv_count(ipart - 1)
630 safe_allocate(pv%sendmap(1:pv%np_local))
631 safe_allocate(points(1:pv%npart))
633 do ip = 1, pv%np_local
634 ipart = part_local(ip)
635 points(ipart) = points(ipart) + 1
636 pv%sendmap(ip) = pv%send_disp(ipart) + points(ipart)
638 safe_deallocate_a(points)
640 safe_allocate(indices(1:pv%np_local))
641 do ip = 1, pv%np_local
642 indices(pv%sendmap(ip)) = pv%xlocal + ip - 1
644 safe_allocate(pv%recvmap(1:sum(pv%recv_count)))
645 call pv%mpi_grp%alltoallv(indices, pv%send_count, pv%send_disp, mpi_integer8, &
646 pv%recvmap, pv%recv_count, pv%recv_disp, mpi_integer8)
647 do ip = 1, sum(pv%recv_count)
651 pv%recvmap(ip) = index
653 safe_deallocate_a(indices)
666 safe_deallocate_a(pv%ghost_rdispls)
667 safe_deallocate_a(pv%ghost_sdispls)
668 safe_deallocate_a(pv%ghost_rcounts)
669 safe_deallocate_a(pv%ghost_scounts)
670 safe_deallocate_a(pv%ghost_sendpos)
671 safe_deallocate_a(pv%ghost_recvmap)
672 safe_deallocate_a(pv%ghost_sendmap)
673 safe_deallocate_a(pv%send_disp)
674 safe_deallocate_a(pv%recv_disp)
675 safe_deallocate_a(pv%np_local_vec)
676 safe_deallocate_a(pv%xlocal_vec)
677 safe_deallocate_a(pv%local)
678 safe_deallocate_a(pv%send_count)
679 safe_deallocate_a(pv%recv_count)
680 safe_deallocate_a(pv%sendmap)
681 safe_deallocate_a(pv%recvmap)
682 safe_deallocate_a(pv%bndry)
683 safe_deallocate_a(pv%ghost)
701 integer(int64),
intent(in) :: ipg
708 if (pv%npart > 1)
then
713 assert(ipg < huge(ip))
722 integer,
intent(in) :: ip
726 if (pv%npart == 1)
then
729 if (ip <= pv%np_local)
then
730 ipg = pv%local(pv%xlocal + ip - 1)
731 else if (ip <= pv%np_local + pv%np_ghost)
then
732 ipg = pv%ghost(ip - pv%np_local)
733 else if (ip <= pv%np_local + pv%np_ghost + pv%np_bndry)
then
734 ipg = pv%bndry(ip - pv%np_local - pv%np_ghost)
745 integer,
intent(in) :: root
746 integer(int64),
allocatable,
intent(inout) :: local_vec(:)
748 integer(int64),
allocatable :: xlocal_tmp(:)
752 safe_allocate(xlocal_tmp(1:pv%npart))
753 xlocal_tmp(:) = pv%xlocal_vec(:) - 1
755 call pv%mpi_grp%gatherv(pv%local(pv%xlocal:), pv%np_local, mpi_integer8, &
756 local_vec, pv%np_local_vec, xlocal_tmp, mpi_integer8, root)
757 safe_deallocate_a(xlocal_tmp)
763#include "complex.F90"
764#include "par_vec_inc.F90"
768#include "par_vec_inc.F90"
771#include "integer.F90"
772#include "par_vec_inc.F90"
776#include "par_vec_inc.F90"
779#include "complex32.F90"
780#include "par_vec_inc.F90"
This is the common interface to a sorting routine. It performs the shell algorithm,...
subroutine, public accel_free_buffer(this, async)
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
type(debug_t), save, public debug
type(conf_t), public conf
Global instance of Octopus configuration.
This module implements a simple hash table for non-negative integer keys and integer values.
integer function, public lihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
subroutine, public lihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
subroutine, public lihash_end(h)
Free a hash table.
subroutine, public lihash_init(h)
Initialize a hash table h.
This module implements the index, used for the mesh points.
integer(int64) function, public get_blocked_index(dim, point, bsize, number_of_blocks, increase_with_dimensions)
subroutine, public index_spatial_to_point(idx, dim, ispatial, point)
subroutine, public index_to_coords(idx, ip, ix)
Given a global point index, this function returns the set of integer coordinates of the point.
integer(int64) function, public index_from_coords(idx, ix)
This function takes care of the boundary conditions for a given vector of integer coordinates it retu...
subroutine, public io_close(iunit, grp)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
MPI_THREAD_FUNNELED allows for calls to MPI from an OMP region if the thread is the team master.
Some general things and nomenclature:
subroutine cpar_vec_scatter(pv, root, v_local, v)
Generally: Xpar_vec_gather and Xpar_vec_scatter only consider inner points. Xpar_vec_scatter_bndry ta...
subroutine, public par_vec_end(pv)
Deallocate memory used by pv.
integer function, public par_vec_global2local(pv, ipg)
Returns local number of global point ip on the local node If the result is zero, the point is not ava...
subroutine ipar_vec_scatter(pv, root, v_local, v)
Generally: Xpar_vec_gather and Xpar_vec_scatter only consider inner points. Xpar_vec_scatter_bndry ta...
subroutine dpar_vec_allgather(pv, v, v_local)
Like Xpar_vec_gather but the result is gathered on all nodes, i. e. v has to be a properly allocated ...
subroutine zpar_vec_scatter(pv, root, v_local, v)
Generally: Xpar_vec_gather and Xpar_vec_scatter only consider inner points. Xpar_vec_scatter_bndry ta...
subroutine dpar_vec_scatter(pv, root, v_local, v)
Generally: Xpar_vec_gather and Xpar_vec_scatter only consider inner points. Xpar_vec_scatter_bndry ta...
integer(int64) function, public par_vec_local2global(pv, ip)
Returns global index of local point ip.
subroutine, public par_vec_init(mpi_grp, np_global, idx, stencil, space, partition, pv, namespace)
Initializes a par_vec_type object (parallel vector).
subroutine spar_vec_gather(pv, root, v_local, v)
Reverse operation of Xpar_vec_scatter. All v_locals from the nodes are packed together into v on node...
subroutine ipar_vec_gather(pv, root, v_local, v)
Reverse operation of Xpar_vec_scatter. All v_locals from the nodes are packed together into v on node...
subroutine zpar_vec_gather(pv, root, v_local, v)
Reverse operation of Xpar_vec_scatter. All v_locals from the nodes are packed together into v on node...
subroutine spar_vec_allgather(pv, v, v_local)
Like Xpar_vec_gather but the result is gathered on all nodes, i. e. v has to be a properly allocated ...
subroutine gather_local_vec(pv, root, local_vec)
subroutine cpar_vec_gather(pv, root, v_local, v)
Reverse operation of Xpar_vec_scatter. All v_locals from the nodes are packed together into v on node...
subroutine dpar_vec_gather(pv, root, v_local, v)
Reverse operation of Xpar_vec_scatter. All v_locals from the nodes are packed together into v on node...
subroutine cpar_vec_allgather(pv, v, v_local)
Like Xpar_vec_gather but the result is gathered on all nodes, i. e. v has to be a properly allocated ...
subroutine zpar_vec_allgather(pv, v, v_local)
Like Xpar_vec_gather but the result is gathered on all nodes, i. e. v has to be a properly allocated ...
subroutine spar_vec_scatter(pv, root, v_local, v)
Generally: Xpar_vec_gather and Xpar_vec_scatter only consider inner points. Xpar_vec_scatter_bndry ta...
subroutine ipar_vec_allgather(pv, v, v_local)
Like Xpar_vec_gather but the result is gathered on all nodes, i. e. v has to be a properly allocated ...
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public partition_get_np_local(partition, np_local_vec)
Given the partition, returns the corresponding number of local points that each partition has.
subroutine, public partition_get_local(partition, rbuffer, np_local)
Calculates the local vector of all partitions in parallel. Local vector stores the global point indic...
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
This module is intended to contain "only mathematical" functions and procedures.
This module defines stencils used in Octopus.
type(type_t), parameter, public type_integer
This module is intended to contain simple general-purpose utility functions and procedures.
subroutine, public make_array_larger(array, new_size)
subroutine init_mpi_alltoall()
subroutine reorder_points()
This is defined even when running serial.
The partition is an array that contains the mapping between some global index and a process,...
The class representing the stencil, which is used for non-local mesh operations.