#include <network.hh>
Public Member Functions | |
bool | abort (void) |
Abort computation. | |
bool | all_gather (char *sbuf, int ssize, char *rbuf, int rsize) |
Similar to gather(), but the collected information are received on every workstation. | |
bool | barrier (void) |
Finalizes network, essentially closes connections and frees buffers. | |
bool | finalize () |
Finalizes network, frees all allocated buffers. | |
bool | flush_all_buffers () |
All buffers flush. | |
bool | flush_all_buffers_timed_out_only () |
Only timed out buffers flush. | |
bool | flush_buffer (int dest) |
One send buffer flush. | |
bool | flush_some_buffers () |
Some buffers flush. | |
bool | gather (char *sbuf, int ssize, char *rbuf, int rsize, int root) |
Similar to barrier() but allows to collect some data on selected workstation. | |
bool | get_all_barriers_cnt (int &cnt) |
Get count of all barrier() calls. | |
bool | get_all_buffers_flushes_cnt (int &cnt) |
Get number of flushes of all send buffers. | |
bool | get_all_received_msgs_cnt (int &cnt) |
Get all received messages count (including urgent messages). | |
bool | get_all_sent_msgs_cnt (int &cnt) |
Get all sent messages count (including urgent messages). | |
bool | get_all_total_pending_size (int &size, bool test) |
Get total size of pending (blocked) send buffers for all workstations. | |
bool | get_buf_msgs_cnt_limit (int &limit) |
Get send buffer's message count limit. | |
bool | get_buf_size_limit (int &limit) |
Get send buffer's size limit. | |
bool | get_buf_time_limit (int &limit_sec, int &limit_msec) |
Get send buffer's time limit. | |
bool | get_buffer_flushes_cnt (int dest, int &cnt) |
Get number of flushes of send buffer for workstation dest. | |
bool | get_cluster_size (int &size) |
Retrieves the number of computers in the cluster. | |
bool | get_comm_matrix_rnm (pcomm_matrix_t &ret, int target) |
Get communication matrix of received normal messages. | |
bool | get_comm_matrix_rum (pcomm_matrix_t &ret, int target) |
Get communication matrix of received urgent messages. | |
bool | get_comm_matrix_snm (pcomm_matrix_t &ret, int target) |
Get communication matrix of sent normal messages. | |
bool | get_comm_matrix_sum (pcomm_matrix_t &ret, int target) |
Get communication matrix of sent urgent messages. | |
bool | get_id (int &id) |
Retrieves the identifier of the calling workstation. | |
bool | get_processor_name (char *proc_name, int &length) |
Retrieves the name of the calling workstation. | |
int | get_recv_msgs_cnt_recv_from (int from) |
Get number of messages received from given workstation. | |
bool | get_recv_msgs_cnt_recv_from (int from, int &cnt) |
Get number of messages received from given workstation. | |
int | get_sent_msgs_cnt_sent_to (int to) |
Get number of messages sent to a given workstation. | |
bool | get_sent_msgs_cnt_sent_to (int to, int &cnt) |
Get number of messages sent to a given workstation. | |
bool | get_total_pending_size (int dest, int &size, bool test) |
Get size of pending (blocked) send buffer for workstation dest. | |
bool | get_user_received_msgs_cnt (int &cnt) |
Get normal received messages count (only normal messages, without urgent messages). | |
bool | get_user_sent_msgs_cnt (int &cnt) |
Get normal sent messages count (only normal messages, without urgent messages). | |
bool | initialize_buffers () |
Completes initialization, must be called after and only after initialize_network(). | |
bool | initialize_network (int &argc, char **&argv) |
bool | is_new_message (int &size, int &src, int &tag, bool &flag) |
Non-blocking message probe. | |
bool | is_new_message_from_source (int &size, int src, int &tag, bool &flag) |
Non-blocking message from specific source probe. | |
bool | is_new_urgent_message (int &size, int &src, int &tag, bool &flag) |
Non-blocking urgent message probe. | |
bool | is_new_urgent_message_from_source (int &size, int src, int &tag, bool &flag) |
Non-blocking urgent message probe from specific source. | |
network_t (error_vector_t &arg0=gerr) | |
bool | receive_message (message_t &message, int &src, int &tag) |
Blocking message receive. | |
bool | receive_message (char *buf, int &size, int &src, int &tag) |
Blocking message receive. | |
bool | receive_message_from_source (char *buf, int &size, int src, int &tag) |
Blocking message from source receive. | |
bool | receive_message_non_exc (char *&buf, int &size, int &src, int &tag) |
Blocking message receive, which sets buf to point to internal buffer. | |
bool | receive_urgent_message (char *buf, int &size, int &src, int &tag) |
Blocking message receive. | |
bool | receive_urgent_message_from_source (char *buf, int &size, int src, int &tag) |
Blocking urgent message from source receive. | |
bool | receive_urgent_message_non_exc (char *&buf, int &size, int &src, int &tag) |
Blocking urgent message receive, which sets buf to point to internal buffer. | |
bool | send_message (const message_t &message, int dest, int tag) |
Blocking message send. | |
bool | send_message (char *buf, int size, int dest, int tag) |
Blocking message send. | |
bool | send_urgent_message (const message_t &message, int dest, int tag) |
Blocking urgent message send. | |
bool | send_urgent_message (char *buf, int size, int dest, int tag) |
Blocking urgent message send. | |
bool | set_buf_msgs_cnt_limit (int limit) |
Set send buffer's message count limit, see get_buf_msgs_cnt_limit() doc for more info. | |
bool | set_buf_size_limit (int limit) |
Set send buffer's size limit, see get_buf_size_limit() doc for more info. | |
bool | set_buf_time_limit (int limit_sec, int limit_msec) |
Set send buffer's time limit, see get_buf_time_limit() doc for more info. | |
void | stats_init (statistics *stats) |
double | stats_max (statistics *stats) |
double | stats_mean (statistics *stats) |
double | stats_min (statistics *stats) |
unsigned | stats_num (statistics *stats) |
double | stats_sqrt_var (statistics *stats) |
void | stats_update (statistics *stats, double val) |
double | stats_var (statistics *stats) |
~network_t () | |
A destructor, frees allocated memory. | |
Public Attributes | |
statistics | stats_Recv_bytes |
statistics | stats_Sent_bytes_local |
double | stats_slice_begin |
double | stats_slice_end |
double | stats_time_begin |
Protected Attributes | |
error_vector_t & | errvec |
This class mainly provides methods for buffered transmission of messages. Additionally barrier and gather methods are included. Methods for detailed statistics are a matter of course.
network_t | ( | error_vector_t & | arg0 = gerr |
) |
A constructor, does't initialize network!,
non-default error handling vector can be specified
bool abort | ( | void | ) |
Abort computation.
References ERR_triplet_t::message, NET_ERR_ABORT_FAILED, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool all_gather | ( | char * | sbuf, | |
int | ssize, | |||
char * | rbuf, | |||
int | rsize | |||
) |
Similar to gather(), but the collected information are received on every workstation.
Differs from gather() in that all workstations must have rbuf and rsize valid, not only one workstation.
References ERR_triplet_t::message, NET_ERR_ALLGATHER_FAILED, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool barrier | ( | void | ) |
Finalizes network, essentially closes connections and frees buffers.
References ERR_triplet_t::message, NET_ERR_BARRIER_FAILED, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::synchronized().
bool flush_all_buffers | ( | ) |
All buffers flush.
References flush_buffer(), ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::set_idle().
bool flush_all_buffers_timed_out_only | ( | ) |
Only timed out buffers flush.
References flush_buffer(), ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::process_messages().
bool flush_buffer | ( | int | dest | ) |
One send buffer flush.
dest | - identifcation of the buffer (id of the workstation the buffer is designated for) to be flushed |
References ERR_triplet_t::message, NET_ERR_INVALID_DESTINATION, net_err_msgs, NET_ERR_NOT_INITIALIZED, NET_ERR_SEND_MSG_FAILED, and NET_TAG_NORMAL.
Referenced by flush_all_buffers(), flush_all_buffers_timed_out_only(), and flush_some_buffers().
bool flush_some_buffers | ( | ) |
Some buffers flush.
References flush_buffer(), ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::set_idle().
bool gather | ( | char * | sbuf, | |
int | ssize, | |||
char * | rbuf, | |||
int | rsize, | |||
int | root | |||
) |
Similar to barrier() but allows to collect some data on selected workstation.
sbuf | - pointer to buffer that contains the data to be collected | |
ssize | - size of the data sbuf points to (in sizeof(char)) | |
rbuf | - pointer to buffer that receives the collected data (relevant only on selected workstation) | |
rsize | - size of the collected data corresponding to one workstation, therefore rsize should be equal to ssize (relevant only on selected workstation) | |
root | - id of the selected workstation that receives the collected data |
The collected data are in order imposed by workstation ids.
References ERR_triplet_t::message, NET_ERR_GATHER_FAILED, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool get_all_barriers_cnt | ( | int & | cnt | ) |
Get count of all barrier() calls.
cnt | - output parameter that receives the count of all barrier() function calls on the calling workstation |
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by logger_t::log_now().
bool get_all_buffers_flushes_cnt | ( | int & | cnt | ) |
Get number of flushes of all send buffers.
cnt | - output parameter that receives the count of all send buffer flushes on the calling workstation |
References get_buffer_flushes_cnt(), ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by logger_t::log_now().
bool get_all_received_msgs_cnt | ( | int & | cnt | ) |
Get all received messages count (including urgent messages).
cnt | - output parameter that receives the count of all messages received on the calling workstation |
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by logger_t::log_now(), and distributed_t::process_messages().
bool get_all_sent_msgs_cnt | ( | int & | cnt | ) |
Get all sent messages count (including urgent messages).
cnt | - output parameter that receives the count of all messages sent by the calling workstation |
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by logger_t::log_now(), and distributed_t::process_messages().
bool get_all_total_pending_size | ( | int & | size, | |
bool | test | |||
) |
Get total size of pending (blocked) send buffers for all workstations.
size | - output parameter that receives total size of memory occupied by all pending send buffers | |
test | - if test = true, tests are performed and exact value is retrieved, if test = false, upper estimate is returned |
References get_total_pending_size(), ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool get_buf_msgs_cnt_limit | ( | int & | limit | ) |
Get send buffer's message count limit.
limit | - the maximal count of messages send buffer can hold |
100 messages is default.
This limit can be set by set_buf_msgs_cnt_limit() function, but only before initialize_buffers() function is called.
bool get_buf_size_limit | ( | int & | limit | ) |
Get send buffer's size limit.
limit | - the maximal size of the send buffer |
8192 chars is default.
This limit can be set by set_buf_size_limit() function, but only before initialize_buffers function is called.
bool get_buf_time_limit | ( | int & | limit_sec, | |
int & | limit_msec | |||
) |
Get send buffer's time limit.
limit_sec | - together with limit_msec the "maximal" amount of time send buffer can hold data without flush (in seconds) | |
limit_msec | - together with limit_sec the "maximal" amount of time send buffer can hold data without flush (in miliseconds) |
300 miliseconds is default.
This limit can be set by set_buf_time_limit() function, but only before initialize buffers function is called.
Setting the limit to 0 seconds and 0 miliseconds turns timed flushing off.
bool get_buffer_flushes_cnt | ( | int | dest, | |
int & | cnt | |||
) |
Get number of flushes of send buffer for workstation dest.
dest | - identification of the send buffer | |
cnt | - output parameter that receives the count of all times the send buffer designated for workstation with id dest has been flushed |
References ERR_triplet_t::message, NET_ERR_INVALID_DESTINATION, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by get_all_buffers_flushes_cnt().
bool get_cluster_size | ( | int & | size | ) |
Retrieves the number of computers in the cluster.
size | - output parameter that receives the retrieved value |
You must call initialize_network() function before this function.
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::network_initialize().
bool get_comm_matrix_rnm | ( | pcomm_matrix_t & | ret, | |
int | target | |||
) |
Get communication matrix of received normal messages.
Similar to get_comm_matrix_snm(), but the position (i, j) of the matrix contains the count of normal messages (sent by send_message() function) received on workstation with id i from workstation with id j.
bool get_comm_matrix_rum | ( | pcomm_matrix_t & | ret, | |
int | target | |||
) |
Get communication matrix of received urgent messages.
Similar to get_comm_matrix_snm(), but the position (i, j) of the matrix contains the count of urgent messages (sent by send_urgent_message() function) received on workstation with id i from workstation with id j.
bool get_comm_matrix_snm | ( | pcomm_matrix_t & | ret, | |
int | target | |||
) |
Get communication matrix of sent normal messages.
ret | - output parameter, pointer to communication matrix (of type comm_matrix_t) that contains at position (i, j) the count of normal messages (sent by function send_message()) sent by workstation with id i to workstation with id j | |
target | - only one workstation gets valid pointer ret, this workstation is specified by target parameter, which must be the same on all workstations |
bool get_comm_matrix_sum | ( | pcomm_matrix_t & | ret, | |
int | target | |||
) |
Get communication matrix of sent urgent messages.
Similar to get_comm_matrix_snm(), but the position (i, j) of the matrix contains the count of urgent messages (sent by send_urgent_message() function) sent by workstation with id i to workstation with id j.
bool get_id | ( | int & | id | ) |
Retrieves the identifier of the calling workstation.
id | - output parameter that receives the workstation id |
You must call initialize_network() function before this function.
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::network_initialize().
bool get_processor_name | ( | char * | proc_name, | |
int & | length | |||
) |
Retrieves the name of the calling workstation.
proc_name | - output parameter that receives the workstation name | |
length | - output parameter that receives the number of characters in the name |
You must call initialize_network() function before this function.
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::network_initialize().
int get_recv_msgs_cnt_recv_from | ( | int | from | ) |
Get number of messages received from given workstation.
from | - specifies the workstation we are interested in |
References ERR_triplet_t::message, NET_ERR_INVALID_WORKSTATION_NUMBER, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool get_recv_msgs_cnt_recv_from | ( | int | from, | |
int & | cnt | |||
) |
Get number of messages received from given workstation.
from | - specifies the workstation we are interested in | |
cnt | - output parameter that receives the count of all message received on the calling workstation from the workstation specified by from parameter. |
References ERR_triplet_t::message, NET_ERR_INVALID_WORKSTATION_NUMBER, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
int get_sent_msgs_cnt_sent_to | ( | int | to | ) |
Get number of messages sent to a given workstation.
to | - specifies the workstation we are interested in |
References ERR_triplet_t::message, NET_ERR_INVALID_WORKSTATION_NUMBER, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool get_sent_msgs_cnt_sent_to | ( | int | to, | |
int & | cnt | |||
) |
Get number of messages sent to a given workstation.
to | - specifies the workstation we are interested in | |
cnt | - output parameter that receives the count of all messages sent by calling workstation to a workstation specified by to parameter. |
References ERR_triplet_t::message, NET_ERR_INVALID_WORKSTATION_NUMBER, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by logger_t::log_now().
bool get_total_pending_size | ( | int | dest, | |
int & | size, | |||
bool | test | |||
) |
Get size of pending (blocked) send buffer for workstation dest.
dest | - identification of the send buffer | |
size | - output parameter that receives total size of memory occupied by pending send buffer designated for workstation with id dest | |
test | - if test = true, tests are performed and exact value is retrieved, if test = false, upper estimate is returned |
References ERR_triplet_t::message, NET_ERR_INVALID_DESTINATION, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by get_all_total_pending_size().
bool get_user_received_msgs_cnt | ( | int & | cnt | ) |
Get normal received messages count (only normal messages, without urgent messages).
cnt | - output parameter that receives the count of all normal messages received on the calling workstation |
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool get_user_sent_msgs_cnt | ( | int & | cnt | ) |
Get normal sent messages count (only normal messages, without urgent messages).
cnt | - output parameter that receives the count of all normal messages sent by the calling workstation |
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
bool initialize_buffers | ( | ) |
Completes initialization, must be called after and only after initialize_network().
References ERR_triplet_t::message, net_err_msgs, and NET_ERR_NOT_INITIALIZED.
Referenced by distributed_t::initialize().
bool initialize_network | ( | int & | argc, | |
char **& | argv | |||
) |
Initializes network, essentially establishes connections and gives all workstations
the command line parameters
argc | - number of command line parameters, passing the first parameter of main() is recommended | |
argv | - command line parameters, passing the second parameter of main() is recommended |
References ERR_triplet_t::message, NET_ERR_ALREADY_INITIALIZED, NET_ERR_INITIALIZATION_FAILED, and net_err_msgs.
Referenced by distributed_t::network_initialize().
bool is_new_message | ( | int & | size, | |
int & | src, | |||
int & | tag, | |||
bool & | flag | |||
) |
Non-blocking message probe.
size | - output parameter that receives the size of the message, if there is one | |
src | - output parameter that receives the source workstation of the message, if there is one | |
tag | - output parameter that receives the tag of the message, if there is one | |
flag | - output parameter that determines if there is a message waiting to be received |
This function only looks for messages sent by send_message() function.
Referenced by distributed_t::process_messages().
bool is_new_message_from_source | ( | int & | size, | |
int | src, | |||
int & | tag, | |||
bool & | flag | |||
) |
Non-blocking message from specific source probe.
Similar to is_new_message(), but the src parameter is input. It means that the function only looks for messages from speceified source workstation.
bool is_new_urgent_message | ( | int & | size, | |
int & | src, | |||
int & | tag, | |||
bool & | flag | |||
) |
Non-blocking urgent message probe.
Similar to is_new_message(), but it looks only for messages sent by send_urgent_message() function.
Referenced by distributed_t::process_messages().
bool is_new_urgent_message_from_source | ( | int & | size, | |
int | src, | |||
int & | tag, | |||
bool & | flag | |||
) |
Non-blocking urgent message probe from specific source.
Similar to is_new_message(), but it looks only for messages sent by send_urgent_message() function and only for those of them that are from source workstation specified by the input parameter src.
bool receive_message | ( | message_t & | message, | |
int & | src, | |||
int & | tag | |||
) |
Blocking message receive.
message | - instance of message_t, where the data will be stored | |
src | - output parameter that gets id of the source workstation of the received message | |
tag | - output parameter that gets the tag of the received message |
This function only concerns messages sent by the send_message() function.
References message_t::get_allocated_size(), message_t::get_data(), receive_message(), message_t::set_data(), and message_t::set_written_size().
bool receive_message | ( | char * | buf, | |
int & | size, | |||
int & | src, | |||
int & | tag | |||
) |
Blocking message receive.
buf | - pointer to memory used to store the received data | |
size | - output parameter that receives the size of the received message | |
src | - output parameter that gets id of the source workstation of the received message | |
tag | - output parameter that gets the tag of the received message |
This function only concerns messages sent by the send_message() function.
Referenced by distributed_t::process_messages(), and receive_message().
bool receive_message_from_source | ( | char * | buf, | |
int & | size, | |||
int | src, | |||
int & | tag | |||
) |
Blocking message from source receive.
Similar to receive_message(), but it receives only messages sent by send_urgent_message function.
bool receive_message_non_exc | ( | char *& | buf, | |
int & | size, | |||
int & | src, | |||
int & | tag | |||
) |
Blocking message receive, which sets buf to point to internal buffer.
Similar to receive_message(), but the buf parameter is output and need not be initialized, because the function sets it to point to internal buffer containing the received data, which saves both memory and time. It is obvious that the memory buf points to must neither be freed nor rewritten.
Referenced by distributed_t::process_messages().
bool receive_urgent_message | ( | char * | buf, | |
int & | size, | |||
int & | src, | |||
int & | tag | |||
) |
Blocking message receive.
Similar to receive_message(), but it receives only messages sent by send_urgent_message function.
Referenced by distributed_t::process_messages().
bool receive_urgent_message_from_source | ( | char * | buf, | |
int & | size, | |||
int | src, | |||
int & | tag | |||
) |
Blocking urgent message from source receive.
Similar to receive_message_from source(), but it receives only messages sent by send_urgent_message() function.
bool receive_urgent_message_non_exc | ( | char *& | buf, | |
int & | size, | |||
int & | src, | |||
int & | tag | |||
) |
Blocking urgent message receive, which sets buf to point to internal buffer.
Similar to receive_message_non_exc(), but it receives only messages sent by send_urgent_message() function.
Referenced by distributed_t::process_messages().
bool send_message | ( | const message_t & | message, | |
int | dest, | |||
int | tag | |||
) |
Blocking message send.
message | - a message to send | |
dest | - id of the workstation that receives the data | |
tag | - additional information attached to the message, which is typically used to identify the type of the message |
The function is connected to a buffering mechnism, it means that the messages are not sent instantly, but they are accumulated in a special buffer. There is one such buffer for each workstation. The data from a buffer are sent to the destination workstation as soon as one of the limits (set by functions set_buf_msgs_cnt_limit(), set_buf_size_limit(), set_buf_time_limit()) is exceeded or flush_buffer() function is called.
References message_t::get_data(), message_t::get_written_size(), and send_message().
bool send_message | ( | char * | buf, | |
int | size, | |||
int | dest, | |||
int | tag | |||
) |
Blocking message send.
buf | - pointer to data that are to be sent | |
size | - size of the data to be sent (in sizeof(char)) | |
dest | - id of the workstation that receives the data | |
tag | - additional information attached to the message, which is typically used to identify the type of the message |
The function is connected to a buffering mechnism, it means that the messages are not sent instantly, but they are accumulated in a special buffer. There is one such buffer for each workstation. The data from a buffer are sent to the destination workstation as soon as one of the limits (set by functions set_buf_msgs_cnt_limit(), set_buf_size_limit(), set_buf_time_limit()) is exceeded or flush_buffer() function is called.
Referenced by send_message().
bool send_urgent_message | ( | const message_t & | message, | |
int | dest, | |||
int | tag | |||
) |
Blocking urgent message send.
Similar to send_message() function but of course there are differences. The function is not connected to buffering mechanism, so the messages are sent immediately. Different functions are used to receive messages sent by this function.
References message_t::get_data(), message_t::get_written_size(), and send_urgent_message().
bool send_urgent_message | ( | char * | buf, | |
int | size, | |||
int | dest, | |||
int | tag | |||
) |
Blocking urgent message send.
Similar to send_message() function but of course there are differences. The function is not connected to buffering mechanism, so the messages are sent immediately. Different functions are used to receive messages sent by this function.
Referenced by distributed_t::process_messages(), and send_urgent_message().