#include <mpi_process_group.hpp>
Classes | |
struct | communication_category |
Classification of the capabilities of this process group. More... | |
struct | create_empty |
Used as a tag to help create an "empty" process group. More... | |
struct | message_header |
struct | outgoing_messages |
Stores the outgoing messages for a particular processor. More... | |
Public Types | |
typedef function< void(int source, int tag)> | receiver_type |
The type of a "receive" handler, that will be provided with (source, tag) pairs when a message is received. More... | |
typedef function0< void > | on_synchronize_event_type |
The type of a handler for the on-synchronize event, which will be executed at the beginning of synchronize(). More... | |
typedef boost::mpi::packed_oprimitive::buffer_type | buffer_type |
The type used to buffer message data. More... | |
typedef int | process_id_type |
The type used to identify a process. More... | |
typedef int | process_size_type |
The type used to count the number of processes. More... | |
typedef boost::mpi::communicator | communicator_type |
The type of communicator used to transmit data via MPI. More... | |
Public Member Functions | |
mpi_process_group (communicator_type parent_comm=communicator_type()) | |
Construct a new BSP process group from an MPI communicator. More... | |
mpi_process_group (std::size_t num_headers, std::size_t buffer_size, communicator_type parent_comm=communicator_type()) | |
Construct a new BSP process group from an MPI communicator. More... | |
mpi_process_group (const mpi_process_group &other, const receiver_type &handler, bool out_of_band_receive=false) | |
Construct a copy of the BSP process group for a new distributed data structure. More... | |
mpi_process_group (const mpi_process_group &other, attach_distributed_object, bool out_of_band_receive=false) | |
Construct a copy of the BSP process group for a new distributed data structure. More... | |
mpi_process_group (create_empty) | |
Create an "empty" process group, with no information. More... | |
~mpi_process_group () | |
Destroys this copy of the process group. More... | |
void | replace_handler (const receiver_type &handler, bool out_of_band_receive=false) |
Replace the current message handler with a new message handler. More... | |
void | make_distributed_object () |
Turns this process group into the process group for a new distributed data structure or object, allocating its own tag block. More... | |
void | replace_on_synchronize_handler (const on_synchronize_event_type &handler=0) |
Replace the handler to be invoked at the beginning of synchronize. More... | |
int | my_block_number () const |
Return the block number of the current data structure. More... | |
int | encode_tag (int block_num, int tag) const |
Encode a block number/tag pair into a single encoded tag for transmission. More... | |
std::pair< int, int > | decode_tag (int encoded_tag) const |
Decode an encoded tag into a block number/tag pair. More... | |
int | allocate_block (bool out_of_band_receive=false) |
Allocate a block of tags for this instance. More... | |
bool | maybe_emit_receive (int process, int encoded_tag) const |
Potentially emit a receive event out of band. More... | |
bool | emit_receive (int process, int encoded_tag) const |
Emit a receive event. More... | |
void | emit_on_synchronize () const |
Emit an on-synchronize event to all block handlers. More... | |
template<typename Receiver > | |
Receiver * | get_receiver () |
Retrieve a reference to the stored receiver in this block. More... | |
template<typename T > | |
void | send_impl (int dest, int tag, const T &value, mpl::true_) const |
template<typename T > | |
void | send_impl (int dest, int tag, const T &value, mpl::false_) const |
template<typename T > | |
disable_if < boost::mpi::is_mpi_datatype < T >, void >::type | array_send_impl (int dest, int tag, const T values[], std::size_t n) const |
template<typename T > | |
bool | receive_impl (int source, int tag, T &value, mpl::true_) const |
template<typename T > | |
bool | receive_impl (int source, int tag, T &value, mpl::false_) const |
template<typename T > | |
disable_if < boost::mpi::is_mpi_datatype < T >, bool >::type | array_receive_impl (int source, int tag, T *values, std::size_t &n) const |
optional< std::pair < mpi_process_group::process_id_type, int > > | probe () const |
void | synchronize () const |
operator bool () | |
mpi_process_group | base () const |
template<typename Type , typename Handler > | |
void | trigger (int tag, const Handler &handler) |
Create a new trigger for a specific message tag. More... | |
template<typename Type , typename Handler > | |
void | trigger_with_reply (int tag, const Handler &handler) |
Create a new trigger for a specific message tag, along with a way to send a reply with data back to the sender. More... | |
template<typename Type , typename Handler > | |
void | global_trigger (int tag, const Handler &handler, std::size_t buffer_size=0) |
optional< std::pair< int, int > > | poll (bool wait=false, int block=-1, bool synchronizing=false) const |
Poll for any out-of-band messages. More... | |
trigger_receive_context | trigger_context () const |
Determines the context of the trigger currently executing. More... | |
void | receive_batch (process_id_type source, outgoing_messages &batch) const |
INTERNAL ONLY. More... | |
std::pair < boost::mpi::communicator, int > | actual_communicator_and_tag (int tag, int block) const |
INTERNAL ONLY. More... | |
Static Public Member Functions | |
static void | set_message_buffer_size (std::size_t s) |
set the size of the message buffer used for buffered oob sends More... | |
static std::size_t | message_buffer_size () |
get the size of the message buffer used for buffered oob sends More... | |
Public Attributes | |
shared_ptr< impl > | impl_ |
Data associated with the process group and all of its attached distributed data structures. More... | |
shared_ptr< int > | block_num |
When non-null, indicates that this copy of the process group is associated with a particular distributed data structure. More... | |
int | rank |
Rank of this process, to avoid having to call rank() repeatedly. More... | |
int | size |
Number of processes in this process group, to avoid having to call communicator::size() repeatedly. More... | |
Static Public Attributes | |
static const int | max_tags = 256 |
Number of tags available to each data structure. More... | |
static int | old_buffer_size |
static void * | old_buffer |
typedef boost::mpi::packed_oprimitive::buffer_type boost::graph::distributed::mpi_process_group::buffer_type |
The type used to buffer message data.
The type of communicator used to transmit data via MPI.
The type of a handler for the on-synchronize event, which will be executed at the beginning of synchronize().
The type used to identify a process.
The type used to count the number of processes.
typedef function<void(int source, int tag)> boost::graph::distributed::mpi_process_group::receiver_type |
The type of a "receive" handler, that will be provided with (source, tag) pairs when a message is received.
Users can provide a receive handler for a distributed data structure, for example, to automatically pick up and respond to messages as needed.
boost::graph::distributed::mpi_process_group::mpi_process_group | ( | communicator_type | parent_comm = communicator_type() | ) |
Construct a new BSP process group from an MPI communicator.
The MPI communicator will be duplicated to create a new communicator for this process group to use.
boost::graph::distributed::mpi_process_group::mpi_process_group | ( | std::size_t | num_headers, |
std::size_t | buffer_size, | ||
communicator_type | parent_comm = communicator_type() |
||
) |
Construct a new BSP process group from an MPI communicator.
The MPI communicator will be duplicated to create a new communicator for this process group to use. This constructor allows to tune the size of message batches.
num_headers | The maximum number of headers in a message batch |
buffer_size | The maximum size of the message buffer in a batch. |
boost::graph::distributed::mpi_process_group::mpi_process_group | ( | const mpi_process_group & | other, |
const receiver_type & | handler, | ||
bool | out_of_band_receive = false |
||
) |
Construct a copy of the BSP process group for a new distributed data structure.
This data structure will synchronize with all other members of the process group's equivalence class (including other
), but will have its own set of tags.
other | The process group that this new process group will be based on, using a different set of tags within the same communication and synchronization space. |
handler | A message handler that will be passed (source, tag) pairs for each message received by this data structure. The handler is expected to receive the messages immediately. The handler can be changed after-the-fact by calling replace_handler . |
out_of_band_receive | An anachronism. TODO: remove this. |
boost::graph::distributed::mpi_process_group::mpi_process_group | ( | const mpi_process_group & | other, |
attach_distributed_object | , | ||
bool | out_of_band_receive = false |
||
) |
Construct a copy of the BSP process group for a new distributed data structure.
This data structure will synchronize with all other members of the process group's equivalence class (including other
), but will have its own set of tags.
|
inlineexplicit |
Create an "empty" process group, with no information.
This is an internal routine that users should never need.
boost::graph::distributed::mpi_process_group::~mpi_process_group | ( | ) |
Destroys this copy of the process group.
std::pair<boost::mpi::communicator, int> boost::graph::distributed::mpi_process_group::actual_communicator_and_tag | ( | int | tag, |
int | block | ||
) | const |
INTERNAL ONLY.
Determine the actual communicator and tag will be used for a transmission with the given tag.
Referenced by boost::graph::distributed::send_oob().
int boost::graph::distributed::mpi_process_group::allocate_block | ( | bool | out_of_band_receive = false | ) |
Allocate a block of tags for this instance.
The block should not have been allocated already, e.g., my_block_number() == 0. Returns the newly-allocated block number.
disable_if<boost::mpi::is_mpi_datatype<T>, bool>::type boost::graph::distributed::mpi_process_group::array_receive_impl | ( | int | source, |
int | tag, | ||
T * | values, | ||
std::size_t & | n | ||
) | const |
disable_if<boost::mpi::is_mpi_datatype<T>, void>::type boost::graph::distributed::mpi_process_group::array_send_impl | ( | int | dest, |
int | tag, | ||
const T | values[], | ||
std::size_t | n | ||
) | const |
mpi_process_group boost::graph::distributed::mpi_process_group::base | ( | ) | const |
|
inline |
Decode an encoded tag into a block number/tag pair.
References boost::xpressive::make_pair.
void boost::graph::distributed::mpi_process_group::emit_on_synchronize | ( | ) | const |
Emit an on-synchronize event to all block handlers.
bool boost::graph::distributed::mpi_process_group::emit_receive | ( | int | process, |
int | encoded_tag | ||
) | const |
Emit a receive event.
Returns true if an event was actually sent, false otherwise.
|
inline |
Encode a block number/tag pair into a single encoded tag for transmission.
Receiver* boost::graph::distributed::mpi_process_group::get_receiver | ( | ) |
Retrieve a reference to the stored receiver in this block.
void boost::graph::distributed::mpi_process_group::global_trigger | ( | int | tag, |
const Handler & | handler, | ||
std::size_t | buffer_size = 0 |
||
) |
void boost::graph::distributed::mpi_process_group::make_distributed_object | ( | ) |
Turns this process group into the process group for a new distributed data structure or object, allocating its own tag block.
bool boost::graph::distributed::mpi_process_group::maybe_emit_receive | ( | int | process, |
int | encoded_tag | ||
) | const |
Potentially emit a receive event out of band.
Returns true if an event was actually sent, false otherwise.
|
static |
get the size of the message buffer used for buffered oob sends
Referenced by boost::graph::distributed::send_oob().
|
inline |
Return the block number of the current data structure.
A value of 0 indicates that this particular instance of the process group is not associated with any distributed data structure.
References block_num.
|
inline |
References impl_.
optional<std::pair<int, int> > boost::graph::distributed::mpi_process_group::poll | ( | bool | wait = false , |
int | block = -1 , |
||
bool | synchronizing = false |
||
) | const |
Poll for any out-of-band messages.
This routine will check if any out-of-band messages are available. Those that are available will be handled immediately, if possible.
wait | When true, we should block until a message comes in. |
synchronizing | whether we are currently synchronizing the process group |
Referenced by boost::graph::distributed::send_oob().
optional<std::pair<mpi_process_group::process_id_type, int> > boost::graph::distributed::mpi_process_group::probe | ( | ) | const |
void boost::graph::distributed::mpi_process_group::receive_batch | ( | process_id_type | source, |
outgoing_messages & | batch | ||
) | const |
INTERNAL ONLY.
bool boost::graph::distributed::mpi_process_group::receive_impl | ( | int | source, |
int | tag, | ||
T & | value, | ||
mpl::true_ | |||
) | const |
bool boost::graph::distributed::mpi_process_group::receive_impl | ( | int | source, |
int | tag, | ||
T & | value, | ||
mpl::false_ | |||
) | const |
void boost::graph::distributed::mpi_process_group::replace_handler | ( | const receiver_type & | handler, |
bool | out_of_band_receive = false |
||
) |
Replace the current message handler with a new message handler.
handle | The new message handler. |
out_of_band_receive | An anachronism: remove this |
void boost::graph::distributed::mpi_process_group::replace_on_synchronize_handler | ( | const on_synchronize_event_type & | handler = 0 | ) |
Replace the handler to be invoked at the beginning of synchronize.
void boost::graph::distributed::mpi_process_group::send_impl | ( | int | dest, |
int | tag, | ||
const T & | value, | ||
mpl::true_ | |||
) | const |
void boost::graph::distributed::mpi_process_group::send_impl | ( | int | dest, |
int | tag, | ||
const T & | value, | ||
mpl::false_ | |||
) | const |
|
static |
set the size of the message buffer used for buffered oob sends
void boost::graph::distributed::mpi_process_group::synchronize | ( | ) | const |
void boost::graph::distributed::mpi_process_group::trigger | ( | int | tag, |
const Handler & | handler | ||
) |
Create a new trigger for a specific message tag.
Triggers handle out-of-band messaging, and the handler itself will be called whenever a message is available. The handler itself accepts four arguments: the source of the message, the message tag (which will be the same as tag
), the message data (of type Type
), and a boolean flag that states whether the message was received out-of-band. The last will be true
for out-of-band receives, or false
for receives at the end of a synchronization step.
trigger_receive_context boost::graph::distributed::mpi_process_group::trigger_context | ( | ) | const |
Determines the context of the trigger currently executing.
If multiple triggers are executing (recursively), then the context for the most deeply nested trigger will be returned. If no triggers are executing, returns trc_none
. This might be used, for example, to determine whether a reply to a message should itself be sent out-of-band or whether it can go via the normal, slower communication route.
void boost::graph::distributed::mpi_process_group::trigger_with_reply | ( | int | tag, |
const Handler & | handler | ||
) |
Create a new trigger for a specific message tag, along with a way to send a reply with data back to the sender.
Triggers handle out-of-band messaging, and the handler itself will be called whenever a message is available. The handler itself accepts four arguments: the source of the message, the message tag (which will be the same as tag
), the message data (of type Type
), and a boolean flag that states whether the message was received out-of-band. The last will be true
for out-of-band receives, or false
for receives at the end of a synchronization step. The handler also returns a value, which will be routed back to the sender.
shared_ptr<int> boost::graph::distributed::mpi_process_group::block_num |
When non-null, indicates that this copy of the process group is associated with a particular distributed data structure.
The integer value contains the block number (a value > 0) associated with that data structure. The deleter for this shared_ptr
is a deallocate_block
object that will deallocate the associated block in impl_->blocks
.
Referenced by my_block_number().
shared_ptr<impl> boost::graph::distributed::mpi_process_group::impl_ |
Data associated with the process group and all of its attached distributed data structures.
Referenced by operator bool().
|
static |
Number of tags available to each data structure.
|
static |
|
static |
int boost::graph::distributed::mpi_process_group::rank |
Rank of this process, to avoid having to call rank() repeatedly.
Referenced by boost::graph::distributed::process_id().
int boost::graph::distributed::mpi_process_group::size |
Number of processes in this process group, to avoid having to call communicator::size() repeatedly.
Referenced by boost::graph::distributed::num_processes().