This class virtualize the cluster of PC as a set of processes that communicate. More...
#include <VCluster_base.hpp>
Public Member Functions | |
| Vcluster_base (int *argc, char ***argv, MPI_Comm ext_comm) | |
| Virtual cluster constructor. More... | |
| gpu::ofp_context_t & | getGpuContext (bool iw=true) |
| If nvidia cuda is activated return a gpu context. More... | |
| MPI_Comm | getMPIComm () |
| Get the MPI_Communicator (or processor group) this VCluster is using. More... | |
| size_t | getProcessingUnits () |
| Get the total number of processors. More... | |
| size_t | size () |
| Get the total number of processors. More... | |
| void | print_stats () |
| void | clear_stats () |
| size_t | getProcessUnitID () |
| Get the process unit id. More... | |
| size_t | rank () |
| Get the process unit id. More... | |
| template<typename T > | |
| void | sum (T &num) |
| Sum the numbers across all processors and get the result. More... | |
| template<typename T > | |
| void | max (T &num) |
| Get the maximum number across all processors (or reduction with infinity norm) More... | |
| template<typename T > | |
| void | min (T &num) |
| Get the minimum number across all processors (or reduction with insinity norm) More... | |
| void | progressCommunication () |
| In case of Asynchonous communications like sendrecvMultipleMessagesNBXAsync this function progress the communication. | |
| template<typename T > | |
| void | sendrecvMultipleMessagesNBX (openfpm::vector< size_t > &prc, openfpm::vector< T > &data, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &recv_sz, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages. More... | |
| template<typename T > | |
| void | sendrecvMultipleMessagesNBXAsync (openfpm::vector< size_t > &prc, openfpm::vector< T > &data, openfpm::vector< size_t > &prc_recv, openfpm::vector< size_t > &recv_sz, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages asynchronous version. More... | |
| template<typename T > | |
| void | sendrecvMultipleMessagesNBX (openfpm::vector< size_t > &prc, openfpm::vector< T > &data, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages. More... | |
| template<typename T > | |
| void | sendrecvMultipleMessagesNBXAsync (openfpm::vector< size_t > &prc, openfpm::vector< T > &data, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages asynchronous version. More... | |
| void | sendrecvMultipleMessagesNBX (size_t n_send, size_t sz[], size_t prc[], void *ptr[], size_t n_recv, size_t prc_recv[], size_t sz_recv[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages. More... | |
| void | sendrecvMultipleMessagesNBXAsync (size_t n_send, size_t sz[], size_t prc[], void *ptr[], size_t n_recv, size_t prc_recv[], size_t sz_recv[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages asynchronous version. More... | |
| void | sendrecvMultipleMessagesNBX (size_t n_send, size_t sz[], size_t prc[], void *ptr[], size_t n_recv, size_t prc_recv[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages. More... | |
| void | sendrecvMultipleMessagesNBXAsync (size_t n_send, size_t sz[], size_t prc[], void *ptr[], size_t n_recv, size_t prc_recv[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages asynchronous version. More... | |
| void | sendrecvMultipleMessagesNBX (size_t n_send, size_t sz[], size_t prc[], void *ptr[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages. More... | |
| void | sendrecvMultipleMessagesNBXAsync (size_t n_send, size_t sz[], size_t prc[], void *ptr[], void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE) |
| Send and receive multiple messages Asynchronous version. More... | |
| void | sendrecvMultipleMessagesNBXWait () |
| Send and receive multiple messages wait NBX communication to complete. | |
| bool | send (size_t proc, size_t tag, const void *mem, size_t sz) |
| Send data to a processor. More... | |
| template<typename T , typename Mem , template< typename > class gr> | |
| bool | send (size_t proc, size_t tag, openfpm::vector< T, Mem, gr > &v) |
| Send data to a processor. More... | |
| bool | recv (size_t proc, size_t tag, void *v, size_t sz) |
| Recv data from a processor. More... | |
| template<typename T , typename Mem , template< typename > class gr> | |
| bool | recv (size_t proc, size_t tag, openfpm::vector< T, Mem, gr > &v) |
| Recv data from a processor. More... | |
| template<typename T , typename Mem , template< typename > class gr> | |
| bool | allGather (T &send, openfpm::vector< T, Mem, gr > &v) |
| Gather the data from all processors. More... | |
| template<typename T , typename Mem , template< typename > class layout_base> | |
| bool | Bcast (openfpm::vector< T, Mem, layout_base > &v, size_t root) |
| Broadcast the data to all processors. More... | |
| void | execute () |
| Execute all the requests. | |
| void | clear () |
| Release the buffer used for communication. | |
Data Fields | |
| openfpm::vector< size_t > | sz_recv_tmp |
Protected Attributes | |
| openfpm::vector_fr< BMemory< InternalMemory > > | recv_buf [NQUEUE] |
| Receive buffers. | |
| openfpm::vector< size_t > | tags [NQUEUE] |
| tags receiving | |
Private Member Functions | |
| Vcluster_base & | operator= (const Vcluster_base &) |
| disable operator= | |
| Vcluster_base (const Vcluster_base &) | |
| disable copy constructor | |
| void | queue_all_sends (size_t n_send, size_t sz[], size_t prc[], void *ptr[]) |
Private Attributes | |
| MPI_Comm | ext_comm |
| external communicator | |
| size_t | NBX_cnt |
| Vcluster_log | log |
| log file | |
| openfpm::vector< size_t > | proc_com |
| openfpm::vector< int > | map_scatter |
| vector that contain the scatter map (it is basically an array of one) | |
| openfpm::vector< MPI_Request > | req |
| vector of MPI requests | |
| openfpm::vector< MPI_Status > | stat |
| vector of MPI status | |
| std::vector< int > | post_exe |
| vector of functions to execute after all the request has been performed | |
| gpu::ofp_context_t * | gpuContext |
| standard context for gpu (if cuda is detected otherwise is unused) | |
| int | m_size |
| number of processes | |
| int | m_rank |
| actual rank | |
| int | numPE = 1 |
| number of processing unit per process | |
| NBX_Type | NBX_active [NQUEUE] |
| size_t | rid [NQUEUE] |
| request id | |
| int | NBX_prc_qcnt = -1 |
| NBX comunication on queue (-1 mean 0, 0 mean 1, 1 mean 2, .... ) | |
| bool | NBX_prc_reached_bar_req [NQUEUE] |
| Is the barrier request reached. | |
| int | NBX_prc_cnt_base = 0 |
| size_t | NBX_prc_n_send [NQUEUE] |
| size_t * | NBX_prc_prc [NQUEUE] |
| void ** | NBX_prc_ptr [NQUEUE] |
| size_t * | NBX_prc_sz [NQUEUE] |
| size_t | NBX_prc_n_recv [NQUEUE] |
| void *(* | NBX_prc_msg_alloc [NQUEUE])(size_t, size_t, size_t, size_t, size_t, size_t, void *) |
| size_t * | NBX_prc_prc_recv [NQUEUE] |
| void * | NBX_prc_ptr_arg [NQUEUE] |
| std::vector< red > | r |
| openfpm::vector< void * > | ptr_send [NQUEUE] |
| vector of pointers of send buffers | |
| openfpm::vector< size_t > | sz_send [NQUEUE] |
| vector of the size of send buffers | |
| MPI_Request | bar_req |
| barrier request | |
| MPI_Status | bar_stat |
| barrier status | |
| int | shmrank |
| rank within the node | |
| int | nbx_cycle |
| NBX_cycle. | |
This class virtualize the cluster of PC as a set of processes that communicate.
At the moment it is an MPI-like interface, with a more type aware, and simple, interface. It also give some more complex communication functionalities like Dynamic Sparse Data Exchange
Actually VCluster expose a Computation driven parallelism (MPI-like), with a plan of extending to communication driven parallelism
Definition at line 125 of file VCluster_base.hpp.
|
inline |
Virtual cluster constructor.
| argc | pointer to arguments counts passed to the program |
| argv | pointer to arguments vector passed to the program |
Definition at line 317 of file VCluster_base.hpp.
|
inline |
Gather the data from all processors.
send a primitive data T receive the same primitive T from all the other processors
| v | vector to receive (automaticaly resized) |
| send | data to send |
Definition at line 1730 of file VCluster_base.hpp.
|
inline |
Broadcast the data to all processors.
broadcast a vector of primitives.
| v | vector to send in the case of the root processor and vector where to receive in the case of non-root |
| root | processor (who broadcast) |
Definition at line 1765 of file VCluster_base.hpp.
|
inline |
If nvidia cuda is activated return a gpu context.
| iw | ignore warning |
Definition at line 475 of file VCluster_base.hpp.
|
inline |
Get the MPI_Communicator (or processor group) this VCluster is using.
Definition at line 491 of file VCluster_base.hpp.
|
inline |
Get the total number of processors.
Definition at line 501 of file VCluster_base.hpp.
|
inline |
Get the process unit id.
Definition at line 557 of file VCluster_base.hpp.
|
inline |
Get the maximum number across all processors (or reduction with infinity norm)
| num | to reduce |
Definition at line 603 of file VCluster_base.hpp.
|
inline |
Get the minimum number across all processors (or reduction with insinity norm)
| num | to reduce |
Definition at line 623 of file VCluster_base.hpp.
|
inline |
Get the process unit id.
It is the same as getProcessUnitID()
Definition at line 571 of file VCluster_base.hpp.
|
inline |
Recv data from a processor.
| proc | processor id |
| tag | id |
| v | vector to send |
Definition at line 1701 of file VCluster_base.hpp.
|
inline |
Recv data from a processor.
| proc | processor id |
| tag | id |
| v | buffer to send |
| sz | size of the buffer |
Definition at line 1671 of file VCluster_base.hpp.
|
inline |
Send data to a processor.
| proc | processor id |
| tag | id |
| mem | buffer with the data to send |
| sz | size |
Definition at line 1605 of file VCluster_base.hpp.
|
inline |
Send data to a processor.
| proc | processor id |
| tag | id |
| v | buffer to send |
Definition at line 1636 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive.
suppose the following situation the calling processor want to communicate
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| data | data to send for each processors in contain a pointer to some type T this type T must have a method size() that return the size of the data-structure |
| prc_recv | processor that receive data |
| recv_sz | for each processor indicate the size of the data received |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 785 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function
suppose the following situation the calling processor want to communicate
| prc | list of processors you should communicate with [1,1,6,7,8] |
| data | vector containing the data to send [v=vector<vector<int>>, v.size()=4, T=vector<int>], T at the moment is only tested for vectors of 0 or more generic elements (without pointers) |
| msg_alloc | This is a call-back with the purpose to allocate space for the incoming messages and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, only NONE supported |
Definition at line 935 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive.
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1062 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive, but does not know the size.
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1214 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1382 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages asynchronous version.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive.
suppose the following situation the calling processor want to communicate
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| data | data to send for each processors in contain a pointer to some type T this type T must have a method size() that return the size of the data-structure |
| prc_recv | processor that receive data |
| recv_sz | for each processor indicate the size of the data received |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 866 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages asynchronous version.
This is the Asynchronous version of Send and receive NBX. This call return immediately, use sendrecvMultipleMessagesNBXWait to synchronize. Optionally you can use the function progress_communication to move on the communication
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function
suppose the following situation the calling processor want to communicate
| prc | list of processors you should communicate with [1,1,6,7,8] |
| data | vector containing the data to send [v=vector<vector<int>>, v.size()=4, T=vector<int>], T at the moment is only tested for vectors of 0 or more generic elements (without pointers) |
| msg_alloc | This is a call-back with the purpose to allocate space for the incoming messages and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, only NONE supported |
Definition at line 998 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages asynchronous version.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive.
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1140 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages asynchronous version.
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function. In this particular case the receiver know from which processor is going to receive, but does not know the size.
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1304 of file VCluster_base.hpp.
|
inline |
Send and receive multiple messages Asynchronous version.
This is the Asynchronous version of Send and receive NBX. This call return immediately, use sendrecvMultipleMessagesNBXWait to synchronize. Optionally you can use the function progress_communication to move on the communication
It send multiple messages to a set of processors the and receive multiple messages from another set of processors, all the processor must call this function
suppose the following situation the calling processor want to communicate
| n_send | number of send for this processor [4] |
| prc | list of processor with which it should communicate [1,1,6,7,8] |
| sz | the array contain the size of the message for each processor (zeros must not be presents) [100,100,50,48,70] |
| ptr | array that contain the pointers to the message to send |
| msg_alloc | This is a call-back with the purpose of allocate space for the incoming message and give back a valid pointer, supposing that this call-back has been triggered by the processor of id 5 that want to communicate with me a message of size 100 byte the call-back will have the following 6 parameters in the call-back are in order:
|
| ptr_arg | data passed to the call-back function specified |
| opt | options, NONE (ignored in this moment) |
Definition at line 1488 of file VCluster_base.hpp.
|
inline |
Get the total number of processors.
It is the same as getProcessingUnits()
Definition at line 515 of file VCluster_base.hpp.
|
inline |
Sum the numbers across all processors and get the result.
| num | to reduce, input and output |
Definition at line 583 of file VCluster_base.hpp.
|
private |
NBX has a potential pitfall that must be addressed NBX Send all the messages and than probe for incoming messages If there is an incoming message it receive it producing an acknowledge notification on the sending processor. when all the sends has been acknowledged the processor call the MPI_Ibarrier when all the processor call MPI_Ibarrier all send has been received. While the processors are waiting for the MPI_Ibarrier to complete on all processor they are still have to probe for incoming message, Unfortunately some processor can receive acnoledge from the MPI_Ibarrier before others and this mean that some processor can exit the probing status before others, these processor can in theory start new communications while the other processor are still in probing status producing a wrong send/recv association to resolve this problem an incremental NBX_cnt is used as message TAG to distinguish that the messages come from other send or subsequent NBX procedures
Definition at line 144 of file VCluster_base.hpp.
|
private |
temporal vector used for meta-communication ( or meta-data before the real communication )
Definition at line 151 of file VCluster_base.hpp.
|
private |
This buffer is a temporal buffer for reductions
MPI_Iallreduce does not accept recv and send buffer to be the same r is used to overcome this problem (is given as second parameter) after the execution the data is copied back
Definition at line 212 of file VCluster_base.hpp.