59 integer :: nbatch_to_receive
60 integer :: nbatch_to_send
63 integer :: nblock_to_receive
64 integer :: nblock_to_send
66 logical :: gpu_aware = .false.
68 type(MPI_Request),
allocatable :: send_req(:)
107 class(states_elec_all_to_all_communications_t),
intent(inout) :: this
108 type(states_elec_t),
intent(in) :: st
109 integer,
intent(in) :: task_from, task_to
110 logical,
optional,
intent(in) :: gpu_aware
114 this%task_from = task_from
115 this%task_to = task_to
123 this%n_comms = max(this%nbatch_to_send, this%nbatch_to_receive)
131 type(states_elec_t),
intent(in) :: st
132 integer,
intent(in) :: task_from
133 integer,
intent(out) :: nblock_to_receive
135 integer :: st_start, st_end, kpt_start, kpt_end, ib
139 nbatch_to_receive = 0
140 nblock_to_receive = 0
143 if (task_from > -1)
then
144 st_start = st%st_kpt_task(task_from, 1)
145 st_end = st%st_kpt_task(task_from, 2)
146 kpt_start = st%st_kpt_task(task_from, 3)
147 kpt_end = st%st_kpt_task(task_from, 4)
149 nblock_to_receive = 0
150 do ib = 1, st%group%nblocks
151 if (st%group%block_range(ib, 1) >= st_start .and. st%group%block_range(ib, 2) <= st_end)
then
152 nblock_to_receive = nblock_to_receive + 1
155 nbatch_to_receive = nblock_to_receive * (kpt_end-kpt_start+1)
158 write(
message(1),
'(a,i5,a,i5,a,i5)')
'Debug: Task ', st%st_kpt_mpi_grp%rank,
' will receive ', &
159 nbatch_to_receive,
' batches from task ', task_from
169 integer,
intent(in) :: task_to
170 integer,
intent(out) :: nblock_to_send
177 if (task_to > -1)
then
178 nblock_to_send = (st%group%block_end-st%group%block_start+1)
179 nbatch_to_send = nblock_to_send*(st%d%kpt%end-st%d%kpt%start+1)
182 write(
message(1),
'(a,i5,a,i5,a,i5)')
'Debug: Task ', st%st_kpt_mpi_grp%rank,
' will send ', nbatch_to_send, &
183 ' batches to task ', task_to
194 n_comms = this%n_comms
202 nbatch_to_receive = this%nbatch_to_receive
207 integer pure function states_elec_all_to_all_communications_get_nsend(this) result(nbatch_to_send)
210 nbatch_to_send = this%nbatch_to_send
217 type(states_elec_t),
intent(in) :: st
218 integer,
intent(in) :: icom
219 integer,
intent(in) :: np
220 type(wfs_elec_t),
intent(out) :: psib
222 integer :: block_id, ib, ik
227 block_id = mod(icom-1, this%nblock_to_receive)+1
228 ik = int((icom-block_id)/this%nblock_to_receive) + st%st_kpt_task(this%task_from, 3)
229 ib = block_id - 1 + st%group%iblock(st%st_kpt_task(this%task_from, 1))
231 write(message(1),
'(a,i5,a,i5,a,i5)')
'Debug: Task ', st%st_kpt_mpi_grp%rank,
' allocates memory for block ', &
232 ib,
' and k-point ', ik
233 call messages_info(1, all_nodes=.
true., debug_only=.
true.)
235 call states_elec_parallel_allocate_batch(st, psib, np, ib, ik, packed=.
true.)
238 if (this%gpu_aware)
then
239 call psib%do_pack(batch_device_packed, copy = .false.)
249 type(states_elec_t),
intent(in) :: st
250 integer,
intent(in) :: icom
251 integer,
intent(out) :: ib
252 integer,
intent(out) :: ik
257 ib = mod(icom-1, this%nblock_to_send) + 1
258 ik = int((icom-ib)/this%nblock_to_send) + st%d%kpt%start
259 ib = ib - 1 + st%group%iblock(st%st_start)
261 write(message(1),
'(a,i5,a,i5,a,i5)')
'Debug: Task ', st%st_kpt_mpi_grp%rank,
' will send the block ', &
262 ib,
' with k-point ', ik
263 call messages_info(1, all_nodes=.
true., debug_only=.
true.)
272 type(states_elec_t),
intent(in) :: st
273 integer,
intent(in) :: icom
274 integer,
intent(out) :: ib
275 integer,
intent(out) :: ik
280 ib = mod(icom-1, this%nblock_to_receive)+1
281 ik = int((icom-ib)/this%nblock_to_receive) + st%st_kpt_task(this%task_from, 3)
282 ib = ib - 1 + st%group%iblock(st%st_kpt_task(this%task_from, 1))
285 write(message(1),
'(a,i5,a,i5,a,i5)')
'Task ', st%st_kpt_mpi_grp%rank,
' will receive the block ', &
286 ib,
' with k-point ', ik
287 call messages_info(1, all_nodes=.
true.)
297 type(states_elec_t),
intent(in) :: st
300 call profiling_in(
"ALL_TO_ALL_COMM")
302 if (
allocated(this%send_req))
then
304 call st%st_kpt_mpi_grp%wait(this%nbatch_to_send, this%send_req)
306 safe_deallocate_a(this%send_req)
310 call profiling_out(
"ALL_TO_ALL_COMM")
318#include "states_elec_all_to_all_communications_inc.F90"
321#include "complex.F90"
322#include "states_elec_all_to_all_communications_inc.F90"
326#include "states_elec_all_to_all_communications_inc.F90"
329#include "complex32.F90"
330#include "states_elec_all_to_all_communications_inc.F90"
This module implements batches of mesh functions.
This module is intended to contain "only mathematical" functions and procedures.
This module defines the meshes, which are used in Octopus.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module provides routines for communicating all batches in a ring-pattern scheme.
subroutine states_elec_all_to_all_communications_get_receive_indices(this, st, icom, ib, ik)
Given the icom step, returns the block and k-point indices to be received.
subroutine sstates_elec_all_to_all_communications_isend_batch_to(this, st, np, psib, node_to, icom, send_req)
Post a single MPI isend for an explicit batch to node_to.
integer function states_elec_all_to_all_communications_eval_nsend(st, task_to, nblock_to_send)
How many batches we will send from task_send.
subroutine zstates_elec_all_to_all_communications_isend_batch_to(this, st, np, psib, node_to, icom, send_req)
Post a single MPI isend for an explicit batch to node_to.
subroutine zstates_elec_all_to_all_communications_mpi_irecv_batch(this, st, np, node_fr, icom, psib_receiv, recv_req)
Allocate a batch and post the MPI_Irecv for it. The caller must wait on recv_req before using the bat...
subroutine sstates_elec_all_to_all_communications_mpi_irecv_batch(this, st, np, node_fr, icom, psib_receiv, recv_req)
Allocate a batch and post the MPI_Irecv for it. The caller must wait on recv_req before using the bat...
subroutine states_elec_all_to_all_communications_wait_all_isend(this, st)
Do a MPI waitall for the isend requests.
subroutine zstates_elec_all_to_all_communications_post_all_mpi_isend(this, st, np, node_to)
Post all isend commands for all batches of a given task.
integer pure function states_elec_all_to_all_communications_get_nreceive(this)
Returns the number of receiv calls.
subroutine sstates_elec_all_to_all_communications_recv_batch_from(this, st, np, psib, node_fr, icom)
Blocking MPI recv into an already-allocated batch from node_fr.
subroutine cstates_elec_all_to_all_communications_isend_batch_to(this, st, np, psib, node_to, icom, send_req)
Post a single MPI isend for an explicit batch to node_to.
subroutine states_elec_all_to_all_communications_alloc_receive_batch(this, st, icom, np, psib)
Given the icom step, allocate the receiv buffer (wfs_elec_t)
subroutine dstates_elec_all_to_all_communications_isend_batch(this, st, np, ib_send, ik_send, node_to, icom, send_req)
Post a single MPI isend for the batch (ib_send, ik_send) to node_to.
integer pure function states_elec_all_to_all_communications_get_ncom(this)
Returns the number of communications.
subroutine cstates_elec_all_to_all_communications_recv_batch_from(this, st, np, psib, node_fr, icom)
Blocking MPI recv into an already-allocated batch from node_fr.
subroutine dstates_elec_all_to_all_communications_post_all_mpi_isend(this, st, np, node_to)
Post all isend commands for all batches of a given task.
subroutine states_elec_all_to_all_communications_get_send_indices(this, st, icom, ib, ik)
Given the icom step, returns the block and k-point indices to be sent.
subroutine cstates_elec_all_to_all_communications_post_all_mpi_isend(this, st, np, node_to)
Post all isend commands for all batches of a given task.
subroutine cstates_elec_all_to_all_communications_mpi_irecv_batch(this, st, np, node_fr, icom, psib_receiv, recv_req)
Allocate a batch and post the MPI_Irecv for it. The caller must wait on recv_req before using the bat...
integer function states_elec_all_to_all_communications_eval_nreceive(st, task_from, nblock_to_receive)
How many batches we will receive from task_from.
subroutine states_elec_all_to_all_communications_start(this, st, task_from, task_to, gpu_aware)
Given a task to send to, and a task to receive from, initializes a states_elec_all_to_all_communicati...
subroutine sstates_elec_all_to_all_communications_isend_batch(this, st, np, ib_send, ik_send, node_to, icom, send_req)
Post a single MPI isend for the batch (ib_send, ik_send) to node_to.
subroutine dstates_elec_all_to_all_communications_mpi_irecv_batch(this, st, np, node_fr, icom, psib_receiv, recv_req)
Allocate a batch and post the MPI_Irecv for it. The caller must wait on recv_req before using the bat...
subroutine cstates_elec_all_to_all_communications_isend_batch(this, st, np, ib_send, ik_send, node_to, icom, send_req)
Post a single MPI isend for the batch (ib_send, ik_send) to node_to.
subroutine zstates_elec_all_to_all_communications_recv_batch_from(this, st, np, psib, node_fr, icom)
Blocking MPI recv into an already-allocated batch from node_fr.
subroutine sstates_elec_all_to_all_communications_post_all_mpi_isend(this, st, np, node_to)
Post all isend commands for all batches of a given task.
subroutine dstates_elec_all_to_all_communications_isend_batch_to(this, st, np, psib, node_to, icom, send_req)
Post a single MPI isend for an explicit batch to node_to.
integer pure function states_elec_all_to_all_communications_get_nsend(this)
Returns the number send calls.
subroutine dstates_elec_all_to_all_communications_recv_batch_from(this, st, np, psib, node_fr, icom)
Blocking MPI recv into an already-allocated batch from node_fr.
subroutine zstates_elec_all_to_all_communications_isend_batch(this, st, np, ib_send, ik_send, node_to, icom, send_req)
Post a single MPI isend for the batch (ib_send, ik_send) to node_to.
This module provides routines for communicating states when using states parallelization.
The states_elec_t class contains all electronic wave functions.