![]() |
fpmas 1.6
|
#include <distributed_graph.h>
Public Types | |
typedef api::utils::EventCallback< SetLocalNodeEvent< T > > | SetLocalNodeCallback |
typedef api::utils::EventCallback< SetDistantNodeEvent< T > > | SetDistantNodeCallback |
![]() | |
typedef NodeType::IdType | NodeIdType |
typedef EdgeType::IdType | EdgeIdType |
typedef fpmas::api::graph::IdHash< typename NodeType::IdType > | NodeIdHash |
typedef fpmas::api::graph::IdHash< typename EdgeType::IdType > | EdgeIdHash |
typedef std::unordered_map< NodeIdType, DistributedNode< T > *, NodeIdHash > | NodeMap |
typedef std::unordered_map< EdgeIdType, DistributedEdge< T > *, EdgeIdHash > | EdgeMap |
DistributedGraph API.
The DistributedGraph is an extension of the Graph API, specialized using DistributedNode and DistributedEdge, and introduces some distribution related concepts.
A DistributedGraph is actually a graph distributed across the available MPI processes. The continuity of the graph is ensured thanks to a concept of "distant" nodes representations used to represent the borders of the local graph and allow interactions with nodes located on other processes.
Features are also provided to dynamically distribute and synchronize the graph across processes.
More particularly, the following distant functions are introduced :
Such functions are considered "distant", in the sense that they might involve other processes or at least influence the global state of the graph.
T | node data type |
typedef api::utils::EventCallback<SetLocalNodeEvent<T> > fpmas::api::graph::DistributedGraph< T >::SetLocalNodeCallback |
Callback API to handle SetLocalNodeEvent.
typedef api::utils::EventCallback<SetDistantNodeEvent<T> > fpmas::api::graph::DistributedGraph< T >::SetDistantNodeCallback |
Callback API to handle SetDistantNodeEvent.
|
pure virtual |
Reference to the internal MpiCommunicator.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Reference to the internal MpiCommunicator.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Reference to the internal LocationManager.
The LocationManager is notably used to easily access the LOCAL and DISTANT nodes in independent sets, thanks to the LocationManager::getLocalNodes() and LocationManager::getDistantNodes() functions.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Reference to the internal LocationManager.
The LocationManager is notably used to easily access the LOCAL and DISTANT nodes in independent sets, thanks to the LocationManager::getLocalNodes() and LocationManager::getDistantNodes() functions.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Imports a DistributedNode into the local graph instance.
When a node is imported into the graph, two main events occur :
Finally, the inserted node is returned.
node | node to import |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Imports a DistributedEdge into the local graph instance.
The DistributedEdge must comply with the following requirements:
Moreover, at least the source or the target node of the imported edge must represent a LOCAL node (since edges between two DISTANT nodes are not represented in a DistributedGraph anyway).
Several situations might then occur :
When source or target is DISTANT, the corresponding node might already be represented in the local graph instance. In that case, the imported edge is linked to the existing representation, and the corresponding TemporaryNode is discarded (without a call to the TemporaryNode::build() method).
Else, if no DISTANT representation of the node is available, a DISTANT representation is created into the local graph instance and the edge is linked to this new DISTANT node, built using the TemporaryNode::build() method.
Notice that a DISTANT representation of the imported edge might already exist, notably if the two nodes are LOCAL and at least one of them was imported in the current distribute() operation. In that case, the imported edge can be discarded and the edge already contained in the graph goes LOCAL, without calling insert edge callbacks. Source and target TemporaryNodes are also be discarded.
edge | to import |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Returns a buffer containing nodes that have not been synchronized yet using the getDataSync() component.
This set corresponds to nodes that were created while importing an importEdge() or insertDistant() statement.
Nodes are added to the buffer when importEdge() or insertDistant() is called, each node is removed under two conditions:
getDataSync().synchronize()
or getDataSync().synchronize(node_set)
, that are themselves called by synchronize() and synchronize(std::unordered_set nodes).Notice that what is called "data synchronization" there is still dependent on the current SyncMode: this does not necessarily mean message exchanges or data import.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Returns the current internal Node ID.
The next node built with buildNode() will have an id equal to currentNodeId()++;
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Sets the current internal Node ID to the specified value.
id | node id |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Returns the current internal Edge ID.
The next edge built with link() will have an id equal to currentEdgeId()++;
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Sets the current internal Edge ID to the specified value.
id | edge id |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Builds a new LOCAL node into the graph.
The specified data is moved into the built node.
The node is inserted into the graph, triggering insert node events as specified in Graph::insert(NodeType*).
data | node data |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Builds a new LOCAL node into the graph.
The specified data is copied to the built node.
The node is inserted into the graph, triggering insert node events as specified in Graph::insert(NodeType*).
data | node data |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Inserts a temporary DISTANT node into the graph.
The node is guaranteed to live at least until the next synchronize() call.
Once inserted, the temporary node
can eventually be used as any other DISTANT node, and so can be linked to existing LOCAL and DISTANT nodes or to query data.
However, the DistributedNode::location() must be initialized manually, otherwise operations above might produce unexpected results.
The node
must be dynamically allocated, and the DistributedGraph implementation automatically takes its ownership.
If a node with the same ID is already contained in the graph, the node is simply deleted and a pointer to the existing node is returned. Else, a pointer to the inserted node is returned.
This method can notably be used to implement distributed graph initialization algorithms. Indeed, if a node 0 is built on process 0 and node 1 is built on process 1, it is at first glance impossible to create a link from node 0 to node 1.
But, for example knowing that the node 1 is necessarily instanciated on process 1, it is possible to manually insert a DISTANT representation of node 1 using insertDistant() on process 0, what allows to build a link from node 0 to node 1 on process 0. Such link will be committed at the latest at the next synchronize() call and imported on process 1.
node | temporary DISTANT node to manually insert in the graph |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Globally removes the specified node from the graph.
The removed node might be DISTANT or LOCAL. The node is not guaranteed to be effectively removed upon return, since it might be involved in inter-process communications, depending on the synchronization mode.
However, it is guaranteed that upon return of the next synchronize() call, the node (and its connected edges) are completely removed from all the processes.
In any case, Erase node callbacks, as specified in Graph::erase(NodeType*), are called only when the node is effectively erased from the graph.
The node is assumed to belong to the graph, behavior is unspecified otherwise.
node | pointer to node to remove |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Globally removes the node with the specified id from the graph.
Equivalent to
id | of the node to remove |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Globally unlinks the specified edge.
The specified edge might be LOCAL or DISTANT.
In consequence the edge is not guaranteed to be effectively unlinked upon return, since it might be involved in inter-process communications, depending on the synchronization mode.
However, it is guaranteed that upon return of the next synchronize() call, the edge is completely removed from all the processes.
In any case, Erase edge callbacks, as specified in Graph::erase(EdgeType*), are called only when the edge is effectively erased from the graph.
edge | edge to remove |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Globally unlinks the edge with the specified id.
Equivalent to
id | of the edge to unlink |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Links source to target on the specified layer.
The two nodes might be LOCAL, only one of them might be DISTANT, or **both of them might be DISTANT**. In this last case, it is however required that the two DISTANT representations of source and target nodes already exist in the local graph, i.e. each node is already connected to at least one LOCAL node.
In consequence the edge is not guaranteed to be inserted in the graph upon return, since its creation might require inter-process communications, depending on the synchronization mode.
However, it is guaranteed that upon return of the next synchronize() call, the edge is properly inserted in the graphs hosted by the processes that might require it, i.e. the processes that host at least one of its source and target nodes.
In any case, insert edge callbacks, as specified in Graph::insert(EdgeType*), are called only when the edge is effectively inserted into the graph.
source | source node |
target | target node |
layer_id | layer id |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Switches the edge to the specified layer.
Currently, this operation is only available for LOCAL edges.
The edge is properly re-linked to its source and target node, while the Edge::setLayer() method does not.
edge | edge to switch |
layer_id | new layer |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Adds a set LOCAL node callback.
A DistributedNode is set LOCAL in the following situations :
callback | set local node callback |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Current set local callbacks list.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Adds a set DISTANT callback.
A DistributedNode is set DISTANT in the following situations :
callback | set distant node callback |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Current set distant callbacks list.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Balances the graph across processors using the specified load balancing algorithm and partitioning strategy.
This function act as a synchronization barrier, so all the process must enter this function to ensure progress.
lb | load balancing algorithm |
partition_mode | partitioning strategy |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
|
pure virtual |
Balances the graph using the specified load balancing algorithm with fixed vertices support.
This function act as a synchronization barrier, so all the process must enter this function to ensure progress.
lb | load balancing algorithm |
fixed_vertices | fixed vertices map |
partition_mode | partitioning strategy |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Distributes the Graph across processors according to the specified partition.
The partition describes nodes to export. In consequence, entries specified for nodes that are not LOCAL to this graph are ignored.
The partition is specified as a {node_id, process_rank}
map.
The process then handles node serialization and migrations. Exported nodes becomes DISTANT.
partition | export partition |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Synchronizes the DistributedGraph.
This function acts as a synchronization barrier : all processes blocks until all other perform a synchronize() call.
The synchronization process involves two main steps :
Different synchronization modes might define different policies to perform those synchronizations.
In any case, as specified in the corresponding function, it is guaranteed that :
Since all nodes are synchronized, the getUnsyncNodes() buffer is cleared.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Partially synchronizes the graph, as specified in the synchronize() method, except that the synchro::DataSync::synchronize(std::unordered_set<api::graph::DistributedNode<T>*>) method is used with the specified nodes instead.
Links synchronization is regularly performed with synchronizationMode().getSyncLinker().synchronize()
, unless synchronize_links
is false
.
nodes
are not required to be contained in getUnsyncNodes(), but are removed from this buffer if they do.
The specified nodes
list might contain LOCAL and DISTANT nodes: it is the responsibility of the implemented synchro::DataSync to eventually not do anything with LOCAL nodes.
nodes | nodes to synchronize |
synchronize_links | specifies if synchro::SyncLinker::synchronize() must be called |
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.
|
pure virtual |
Returns the current synchro::SyncMode instance used to synchronize() the graph.
Directly accessing synchronizationMode().getSyncLinker().synchronize() or synchronizationMode().getDataSync().synchronize() can be used to perform corresponding partial synchronizations (contrary to synchronize()) for performance purpose.
Implemented in fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >, and fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS_SPEC >.