|
ESyS-Particle
4.0.1
|
Message buffer for sending and receiving packed data. Data types are not checked. The implementation has been derived from the old CVarMPIBuffer class. More...
#include <packed_message.h>


Public Member Functions | |
| TML_Packed_Message (MPI_Comm, unsigned int size=64) | |
| virtual | ~TML_Packed_Message () |
| char * | buffer () |
| int | size () |
| virtual void | begin_pack () |
| virtual void | begin_unpack () |
| virtual void | append (int) |
| virtual void | append (double) |
| virtual void | append (const string &) |
| virtual void | append (const Vec3 &) |
| virtual void | append (bool) |
| virtual int | pop_int () |
| virtual double | pop_double () |
| virtual void | pop_doubles (double *, int) |
| virtual string | pop_string () |
| virtual Vec3 | pop_vec3 () |
| virtual bool | pop_bool () |
Protected Member Functions | |
| void | grow () |
| void | growTo (int) |
Protected Attributes | |
| MPI_Comm | m_comm |
| char * | m_buffer |
| int | m_buffersize |
| the size of the buffer | |
| int | m_pack_pos |
| the current end of the content | |
| int | m_unpack_pos |
| the current pos for unpacking | |
| int | m_int_increment |
| int | m_dbl_increment |
| the "packing size" of int/double | |
Message buffer for sending and receiving packed data. Data types are not checked. The implementation has been derived from the old CVarMPIBuffer class.
| TML_Packed_Message::TML_Packed_Message | ( | MPI_Comm | comm, |
| unsigned int | s = 64 |
||
| ) |
Constructor. Allocates the buffer and sets the MPI communicator to be used for pack/unpack operations. If the initial buffer size is not given a buffer of initial size 64 is allocated.
| comm | the MPI communicator |
| s | the initial size of the buffer |
References m_buffersize, m_dbl_increment, m_pack_pos, and m_unpack_pos.
| TML_Packed_Message::~TML_Packed_Message | ( | ) | [virtual] |
Destructor. Free buffer.
| void TML_Packed_Message::append | ( | int | i | ) | [virtual] |
Append an integer to the buffer. If necessary, the buffer is enlarged.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, and m_pack_pos.
Referenced by append().


| void TML_Packed_Message::append | ( | double | d | ) | [virtual] |
Append a double to the buffer. If necessary, the buffer is enlarged.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, m_dbl_increment, and m_pack_pos.

| void TML_Packed_Message::append | ( | const string & | str | ) | [virtual] |
Append a STL string to the buffer. The string is internally handeled by packing the length frist and then the string. If necessary, the buffer is enlarged.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, and m_pack_pos.

| void TML_Packed_Message::append | ( | const Vec3 & | v | ) | [virtual] |
Append a Vec3 to the message buffer. Calls append(double) per element
Implements TML_PackedMessageInterface.
References append().

| void TML_Packed_Message::append | ( | bool | b | ) | [virtual] |
Append a boolean to the message buffer. The bool gest transported as an int (1/0) because MPI doesn't have a native boolean type. Therefore calls append(int).
Implements TML_PackedMessageInterface.
References append().

| void TML_Packed_Message::grow | ( | ) | [protected] |
Grows the buffer to twice its current size, thus guaranteeing that append works in amortized constant time.
References growTo(), and m_buffersize.
Referenced by append().


| void TML_Packed_Message::growTo | ( | int | size | ) | [protected] |
Grows the buffer to a given size. If the buffer is already larger that the given size, nothing is done. Used by receiveFrom.
| size | size to which the buffer is grown |
References m_buffersize, and m_pack_pos.
Referenced by grow().

| bool TML_Packed_Message::pop_bool | ( | ) | [virtual] |
Pop a boolean value of the buffer. Booleans are transported as int (0/1)
Implements TML_PackedMessageInterface.
References pop_int().

| double TML_Packed_Message::pop_double | ( | ) | [virtual] |
Pops a double from the buffer.
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
Referenced by pop_vec3().

| void TML_Packed_Message::pop_doubles | ( | double * | dbl, |
| int | ndb | ||
| ) | [virtual] |
pop a C-array of doubles from a buffer. Faster than doing multiple pop_double operations
| dbl | the array |
| ndb | the number of doubles to be popped |
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
| int TML_Packed_Message::pop_int | ( | ) | [virtual] |
Pops an integer from the buffer, i.e. it pops the last sizeof(MPI_INT) bytes of the buffer, interpreting them as an int.
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
Referenced by pop_bool(), TML_Comm::receive_cont_packed(), TML_Comm::recv_broadcast_cont_packed(), TML_Comm::recv_scatter_packed(), TML_Comm::sendrecv_cont_packed(), and TML_Comm::sendrecv_cont_packed_replace().

| string TML_Packed_Message::pop_string | ( | ) | [virtual] |
Pops a string from the buffer. The first for bytes are interpreted as int, giving the length of the string (without terminating '\0'), the rest as the characters.
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
| Vec3 TML_Packed_Message::pop_vec3 | ( | ) | [virtual] |
Pop a Vec3 of the buffer. Calls pop_double per element
Implements TML_PackedMessageInterface.
References pop_double().

1.7.6.1