This module provides the data structure for the communication during the simulation.
Several exchange methods are implemented. CoCo is heavily used here to allow for a concise definition of exchanges for various data types. The basic idea is to initialize the buffers, use them in exchanges and finalize them when not needed anymore. In the definition of the buffers, an array of positions in the original linearized data array is used to describe the origin or target positions for communicated data.
If you introduce a new type to exchange, you will need to introduce appropriate CoCo copy statements everywhere.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer(kind=long_k), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer(kind=long_k), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer, | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer, | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
real(kind=rk), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
real(kind=rk), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me |
process-wise buffer for data of type integer(kind=long_k)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=long_k), | private, | pointer | :: | val(:) | => | null() | explicit buffer for data to be transferred |
type(c_ptr), | private | :: | mem_mpi | explicit buffer in memory allocated by mpi |
|||
integer, | private, | allocatable | :: | pos(:) | position in the input vector from where to read the entries in val_long |
||
integer, | private | :: | nvals | number of values to exchange |
|||
integer, | private | :: | memindexed | handle for the mpi-datatype to describe the memory access, without explicit copying in the application. |
process-wise buffer for data of type integer
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private, | pointer | :: | val(:) | => | null() | explicit buffer for data to be transferred |
type(c_ptr), | private | :: | mem_mpi | explicit buffer in memory allocated by mpi |
|||
integer, | private, | allocatable | :: | pos(:) | position in the input vector from where to read the entries in val_int |
||
integer, | private | :: | nvals | number of values to exchange |
|||
integer, | private | :: | memindexed | handle for the mpi-datatype to describe the memory access, without explicit copying in the application. |
process-wise buffer for data of type real(kind=rk)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=rk), | private, | pointer | :: | val(:) | => | null() | explicit buffer for data to be transferred |
type(c_ptr), | private | :: | mem_mpi | explicit buffer in memory allocated by mpi |
|||
integer, | private, | allocatable | :: | pos(:) | position in the input vector from where to read the entries in val_real |
||
integer, | private | :: | nvals | number of values to exchange |
|||
integer, | private | :: | memindexed | handle for the mpi-datatype to describe the memory access, without explicit copying in the application. |
Description of communication data
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private | :: | nProcs | = | 0 | ||
integer, | private, | allocatable | :: | proc(:) | partition MPI rank |
||
integer, | private, | allocatable | :: | nElemsProc(:) | How many data elements need to be exchanged with proc (per process). |
||
integer, | private, | allocatable | :: | rqHandle(:) | Request handle array |
||
type(grw_intarray_type), | private, | allocatable | :: | elemPos(:) | Data element positions in the actual arrays, used to built the pos information in the actual buffers (per process). |
||
type(tem_longbuffer_type), | private, | allocatable | :: | buf_long(:) | declare communication buffers for each variable type |
||
type(tem_intbuffer_type), | private, | allocatable | :: | buf_int(:) | |||
type(tem_realbuffer_type), | private, | allocatable | :: | buf_real(:) |
General description of the communication pattern to use.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=40), | private | :: | style | ||||
procedure(tem_exchange_long), | private, | nopass, pointer | :: | exchange_long | |||
procedure(tem_commbuf_long_init), | private, | nopass, pointer | :: | initbuf_long | |||
procedure(tem_commbuf_long_fin), | private, | nopass, pointer | :: | finbuf_long | |||
procedure(tem_exchange_int), | private, | nopass, pointer | :: | exchange_int | |||
procedure(tem_commbuf_int_init), | private, | nopass, pointer | :: | initbuf_int | |||
procedure(tem_commbuf_int_fin), | private, | nopass, pointer | :: | finbuf_int | |||
procedure(tem_exchange_real), | private, | nopass, pointer | :: | exchange_real | |||
procedure(tem_commbuf_real_init), | private, | nopass, pointer | :: | initbuf_real | |||
procedure(tem_commbuf_real_fin), | private, | nopass, pointer | :: | finbuf_real |
This subroutine loads the communication pattern from a Lua script and sets the exchange routine to be used accordingly.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_commPattern_type), | intent(out) | :: | me | commpattern to set |
||
type(flu_State), | optional | :: | conf | handle to the Lua script |
||
character(len=*), | intent(in), | optional | :: | style | optional communication style |
Write communication type data to nUnit (debugging routine)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(in) | :: | me | |||
integer, | intent(in) | :: | nUnit |
Allocate tem_communication_type and its variables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | nProcs |
Allocate tem_communication_type and its variables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | comm_size | communicator size |
||
integer, | intent(in) | :: | nHalos(comm_size) | number of halos for each other processes |
Routine to build communication buffer using elemRanks. This routine can be used only if all elements need to be communicated but they need process-wise seperation. Uses nScalars to get position in the value array to communicate. For send buffer: elemRanks contains target ranks to send data to For recv buffer: elemRanks contains source ranks to recv data from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(out) | :: | commBuffer | send or recv communication buffer to be created |
||
integer, | intent(in) | :: | nScalars | Number of scalars per element |
||
integer, | intent(in) | :: | nElems | Total number of elements or points to communicate |
||
integer, | intent(in) | :: | elemRanks(nElems) | Target or source rank for each element or point |
All to all exchange of a single integer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | targets(:) | List of target ranks to send an integer to. |
||
integer, | intent(in) | :: | send_buffer(:) | Data to send to the respective target ranks. This array has to have the same ordering as targets. |
||
integer, | intent(out), | allocatable | :: | sources(:) | List of ranks we received data from (source ranks). The array will be allocated with a size according to the number of processes that send a request to this process. |
|
integer, | intent(out), | allocatable | :: | recv_buffer(:) | Received data from the sources. The array has the same size and ordering as the sources array. |
|
integer, | intent(in) | :: | comm | MPI Communicator to use for this data exchange. |
||
integer, | intent(in), | optional | :: | tag | Tag to use in the communications. Defaults to 22. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | me | communication type to be destroyed |
||
type(tem_commPattern_type), | intent(in) | :: | commPattern | Communication pattern |
fill the positions that describe how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillpos routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me |
fill the positions that describe how the data in the state vector relates to the entries in the buffer use memory that is allocated by mpi for the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillmpimem routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me |
fill the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillindexed routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me |
gather the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer. in contrast to the simple indexed type above, we try to minimize the number of blocks here, and gather contiguous blocks of memory together.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_longbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
exchange the communication buffers with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer(kind=long_k), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer(kind=long_k), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
fill send buffers and start sending
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer(kind=long_k), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer(kind=long_k), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
exchange the communication mes with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer(kind=long_k), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer(kind=long_k), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
fill the positions that describe how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillpos routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me |
fill the positions that describe how the data in the state vector relates to the entries in the buffer use memory that is allocated by mpi for the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillmpimem routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me |
fill the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillindexed routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me |
gather the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer. in contrast to the simple indexed type above, we try to minimize the number of blocks here, and gather contiguous blocks of memory together.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_intbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
exchange the communication buffers with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer, | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer, | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
fill send buffers and start sending
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer, | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer, | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
exchange the communication mes with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
integer, | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
integer, | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
fill the positions that describe how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillpos routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me |
fill the positions that describe how the data in the state vector relates to the entries in the buffer use memory that is allocated by mpi for the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillmpimem routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me |
fill the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
free the communication buffer allocated by the fillindexed routine again.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me |
gather the indexed mpi datatype, which describes how the data in the state vector relates to the entries in the buffer. in contrast to the simple indexed type above, we try to minimize the number of blocks here, and gather contiguous blocks of memory together.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_realbuffer_type), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | pos(nvals) | |||
integer, | intent(in) | :: | nvals |
exchange the communication buffers with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
real(kind=rk), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
real(kind=rk), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
fill send buffers and start sending
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
real(kind=rk), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
real(kind=rk), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |
exchange the communication mes with a non-blocking mpi communication using preposted irecv and isend with a waitall
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_communication_type), | intent(inout) | :: | send | |||
type(tem_communication_type), | intent(inout) | :: | recv | |||
real(kind=rk), | intent(inout) | :: | state(*) | |||
integer, | intent(in) | :: | message_flag | |||
real(kind=rk), | intent(in), | optional | :: | send_state(*) | ||
integer, | intent(in) | :: | comm | mpi communicator |