Octopus
ring_pattern_oct_m Module Reference

This module is an helper to perform ring-pattern communications among all states. More...

Detailed Description

This module is an helper to perform ring-pattern communications among all states.

This takes into account possible double-sided communication, to reduce the number of commuications

Data Types

type  ring_pattern_t
 

Functions/Subroutines

subroutine ring_pattern_start (this, mpi_grp, double_sided_comms)
 Starts the ring pattern scheme. More...
 
integer pure function ring_pattern_get_nsteps (this)
 Returns the total number of steps in the ring. More...
 
integer pure function ring_pattern_get_rank_to (this, istep)
 Returns the rank where to send the information. More...
 
integer pure function ring_pattern_get_rank_from (this, istep)
 Returns the rank from which we receive the information. More...
 

Function/Subroutine Documentation

◆ ring_pattern_start()

subroutine ring_pattern_oct_m::ring_pattern_start ( class(ring_pattern_t), intent(inout)  this,
type(mpi_grp_t), intent(in)  mpi_grp,
logical, intent(in)  double_sided_comms 
)
private

Starts the ring pattern scheme.

Initializes the quantities properly

We send to the p+s task and receive from the p-s task This follows the scheme of Cardfiff et al. J. Phys.: Condens. Matter 30 095901 (2018)

Definition at line 145 of file ring_pattern.F90.

◆ ring_pattern_get_nsteps()

integer pure function ring_pattern_oct_m::ring_pattern_get_nsteps ( class(ring_pattern_t), intent(in)  this)
private

Returns the total number of steps in the ring.

Definition at line 168 of file ring_pattern.F90.

◆ ring_pattern_get_rank_to()

integer pure function ring_pattern_oct_m::ring_pattern_get_rank_to ( class(ring_pattern_t), intent(in)  this,
integer, intent(in)  istep 
)
private

Returns the rank where to send the information.

Returned values are from -1 to thismpi_grpsize, where -1 means no communication.

If we do double sided communications, we halve the number of communications. For odd or even, the behavior is not the same, so this check ends the communications by setting the receiving rank to -1 (ranks starts at 0), causing the loop to exit. What this means is that for certain steps, not all tasks will send or receive information. This is the scheme that works like this.

The example is four tasks we get 2 steps to do

in step 1, we do 1 <-> 2, 2<->3, 3<->4, 4<->1 in step 2, we do 1<->3, 2<->4 but 3<->1 and 4<->2 are excluded.

(Here <-> means the combination of sending to ->, and getting back from <- )

You can show easily that for the last step, for even grid, only the first half of the tasks need to send something. This is the condition implemented here.

Definition at line 193 of file ring_pattern.F90.

◆ ring_pattern_get_rank_from()

integer pure function ring_pattern_oct_m::ring_pattern_get_rank_from ( class(ring_pattern_t), intent(in)  this,
integer, intent(in)  istep 
)
private

Returns the rank from which we receive the information.

Definition at line 213 of file ring_pattern.F90.