![]() |
fpmas 1.6
|
#include <distributed_graph.h>
Public Member Functions | |
DistributedGraph (const DistributedGraph< DIST_GRAPH_PARAMS_SPEC > &)=delete | |
DistributedGraph & | operator= (const DistributedGraph< DIST_GRAPH_PARAMS_SPEC > &)=delete |
DistributedGraph (DistributedGraph< DIST_GRAPH_PARAMS_SPEC > &&graph) | |
DistributedGraph & | operator= (DistributedGraph< DIST_GRAPH_PARAMS_SPEC > &&graph) |
DistributedGraph (api::communication::MpiCommunicator &comm) | |
api::communication::MpiCommunicator & | getMpiCommunicator () override |
const api::communication::MpiCommunicator & | getMpiCommunicator () const override |
DistributedId | currentNodeId () const override |
void | setCurrentNodeId (DistributedId id) override |
DistributedId | currentEdgeId () const override |
void | setCurrentEdgeId (DistributedId id) override |
NodeType * | importNode (NodeType *node) override |
EdgeType * | importEdge (EdgeType *edge) override |
std::unordered_set< api::graph::DistributedNode< T > * > | getUnsyncNodes () const override |
const SyncMode< T > & | getSyncMode () const |
SyncMode< T > & | synchronizationMode () override |
const LocationManagerImpl< T > & | getLocationManager () const override |
LocationManagerImpl< T > & | getLocationManager () override |
void | balance (api::graph::LoadBalancing< T > &load_balancing) override |
void | balance (api::graph::LoadBalancing< T > &load_balancing, api::graph::PartitionMode partition_mode) override |
void | balance (api::graph::FixedVerticesLoadBalancing< T > &load_balancing, api::graph::PartitionMap fixed_vertices) override |
void | balance (api::graph::FixedVerticesLoadBalancing< T > &load_balancing, api::graph::PartitionMap fixed_vertices, api::graph::PartitionMode partition_mode) override |
void | distribute (api::graph::PartitionMap partition) override |
void | synchronize () override |
void | synchronize (std::unordered_set< NodeType * > nodes, bool synchronize_links=true) override |
NodeType * | buildNode (T &&=std::move(T())) override |
NodeType * | buildNode (const T &) override |
api::graph::DistributedNode< T > * | insertDistant (api::graph::DistributedNode< T > *) override |
EdgeType * | link (NodeType *const src, NodeType *const tgt, api::graph::LayerId layer) override |
void | removeNode (api::graph::DistributedNode< T > *) override |
void | removeNode (DistributedId id) override |
void | unlink (EdgeType *) override |
void | unlink (DistributedId id) override |
void | switchLayer (EdgeType *edge, api::graph::LayerId layer_id) override |
void | addCallOnSetLocal (SetLocalNodeCallback *callback) override |
std::vector< SetLocalNodeCallback * > | onSetLocalCallbacks () const override |
void | addCallOnSetDistant (SetDistantNodeCallback *callback) override |
std::vector< SetDistantNodeCallback * > | onSetDistantCallbacks () const override |
![]() | |
virtual void | insert (NodeType *node)=0 |
virtual void | insert (EdgeType *edge)=0 |
virtual void | erase (NodeType *node)=0 |
virtual void | erase (EdgeType *edge)=0 |
virtual void | addCallOnInsertNode (api::utils::Callback< NodeType * > *callback)=0 |
virtual std::vector< api::utils::Callback< NodeType * > * > | onInsertNodeCallbacks () const =0 |
virtual void | addCallOnEraseNode (api::utils::Callback< NodeType * > *callback)=0 |
virtual std::vector< api::utils::Callback< NodeType * > * > | onEraseNodeCallbacks () const =0 |
virtual void | addCallOnInsertEdge (api::utils::Callback< EdgeType * > *callback)=0 |
virtual std::vector< api::utils::Callback< EdgeType * > * > | onInsertEdgeCallbacks () const =0 |
virtual void | addCallOnEraseEdge (api::utils::Callback< EdgeType * > *callback)=0 |
virtual std::vector< api::utils::Callback< EdgeType * > * > | onEraseEdgeCallbacks () const =0 |
virtual NodeType * | getNode (NodeIdType id)=0 |
virtual const NodeType * | getNode (NodeIdType id) const =0 |
virtual const NodeMap & | getNodes () const =0 |
virtual EdgeType * | getEdge (EdgeIdType id)=0 |
virtual const EdgeType * | getEdge (EdgeIdType) const =0 |
virtual const EdgeMap & | getEdges () const =0 |
virtual void | clear ()=0 |
virtual api::communication::MpiCommunicator & | getMpiCommunicator ()=0 |
virtual const api::communication::MpiCommunicator & | getMpiCommunicator () const =0 |
virtual LocationManager< T > & | getLocationManager ()=0 |
virtual const LocationManager< T > & | getLocationManager () const =0 |
virtual DistributedNode< T > * | importNode (DistributedNode< T > *node)=0 |
virtual DistributedEdge< T > * | importEdge (DistributedEdge< T > *edge)=0 |
virtual std::unordered_set< DistributedNode< T > * > | getUnsyncNodes () const =0 |
virtual DistributedId | currentNodeId () const =0 |
virtual void | setCurrentNodeId (DistributedId id)=0 |
virtual DistributedId | currentEdgeId () const =0 |
virtual void | setCurrentEdgeId (DistributedId id)=0 |
virtual DistributedNode< T > * | buildNode (T &&data)=0 |
virtual DistributedNode< T > * | buildNode (const T &data)=0 |
virtual DistributedNode< T > * | insertDistant (DistributedNode< T > *node)=0 |
virtual void | removeNode (DistributedNode< T > *node)=0 |
virtual void | removeNode (DistributedId id)=0 |
virtual void | unlink (DistributedEdge< T > *edge)=0 |
virtual void | unlink (DistributedId id)=0 |
virtual DistributedEdge< T > * | link (DistributedNode< T > *source, DistributedNode< T > *target, LayerId layer_id)=0 |
virtual void | switchLayer (DistributedEdge< T > *edge, LayerId layer_id)=0 |
virtual void | addCallOnSetLocal (SetLocalNodeCallback *callback)=0 |
virtual std::vector< SetLocalNodeCallback * > | onSetLocalCallbacks () const =0 |
virtual void | addCallOnSetDistant (SetDistantNodeCallback *callback)=0 |
virtual std::vector< SetDistantNodeCallback * > | onSetDistantCallbacks () const =0 |
virtual void | balance (LoadBalancing< T > &lb)=0 |
virtual void | balance (LoadBalancing< T > &lb, PartitionMode partition_mode)=0 |
virtual void | balance (FixedVerticesLoadBalancing< T > &lb, PartitionMap fixed_vertices)=0 |
virtual void | balance (FixedVerticesLoadBalancing< T > &lb, PartitionMap fixed_vertices, PartitionMode partition_mode)=0 |
virtual void | distribute (PartitionMap partition)=0 |
virtual void | synchronize ()=0 |
virtual void | synchronize (std::unordered_set< DistributedNode< T > * > nodes, bool synchronize_links=true)=0 |
virtual synchro::SyncMode< T > & | synchronizationMode ()=0 |
![]() | |
virtual void | insert (DistributedNode< T > *node)=0 |
virtual void | insert (DistributedEdge< T > *edge)=0 |
virtual void | erase (DistributedNode< T > *node)=0 |
virtual void | erase (DistributedEdge< T > *edge)=0 |
virtual void | addCallOnInsertNode (api::utils::Callback< DistributedNode< T > * > *callback)=0 |
virtual std::vector< api::utils::Callback< DistributedNode< T > * > * > | onInsertNodeCallbacks () const=0 |
virtual void | addCallOnEraseNode (api::utils::Callback< DistributedNode< T > * > *callback)=0 |
virtual std::vector< api::utils::Callback< DistributedNode< T > * > * > | onEraseNodeCallbacks () const=0 |
virtual void | addCallOnInsertEdge (api::utils::Callback< DistributedEdge< T > * > *callback)=0 |
virtual std::vector< api::utils::Callback< DistributedEdge< T > * > * > | onInsertEdgeCallbacks () const=0 |
virtual void | addCallOnEraseEdge (api::utils::Callback< DistributedEdge< T > * > *callback)=0 |
virtual std::vector< api::utils::Callback< DistributedEdge< T > * > * > | onEraseEdgeCallbacks () const=0 |
virtual DistributedNode< T > * | getNode (NodeIdType id)=0 |
virtual const DistributedNode< T > * | getNode (NodeIdType id) const=0 |
virtual const NodeMap & | getNodes () const=0 |
virtual DistributedEdge< T > * | getEdge (EdgeIdType id)=0 |
virtual const DistributedEdge< T > * | getEdge (EdgeIdType) const=0 |
virtual const EdgeMap & | getEdges () const=0 |
virtual void | clear ()=0 |
api::graph::DistributedGraph implementation.
typedef api::graph::DistributedNode<T> fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >::NodeType |
DistributedNode API.
typedef api::graph::DistributedEdge<T> fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >::EdgeType |
DistributedEdge API.
fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >::DistributedGraph | ( | DistributedGraph< DIST_GRAPH_PARAMS_SPEC > && | graph | ) |
DistributedGraph move constructor.
|
inline |
DistributedGraph constructor.
comm | MPI communicator |
DistributedGraph< DIST_GRAPH_PARAMS_SPEC > & fpmas::graph::detail::DistributedGraph< DIST_GRAPH_PARAMS >::operator= | ( | DistributedGraph< DIST_GRAPH_PARAMS_SPEC > && | graph | ) |
DistributedGraph move assignment operator.
|
inlineoverridevirtual |
Returns the internal MpiCommunicator.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Returns the internal MpiCommunicator.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Returns the current internal Node ID.
The next node built with buildNode() will have an id equal to currentNodeId()++;
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Sets the current internal Node ID to the specified value.
id | node id |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Returns the current internal Edge ID.
The next edge built with link() will have an id equal to currentEdgeId()++;
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Sets the current internal Edge ID to the specified value.
id | edge id |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
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.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inline |
Returns the internal SyncMode instance.
|
inlineoverridevirtual |
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.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
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.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
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.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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.
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Globally removes the node with the specified id from the graph.
Equivalent to
id | of the node to remove |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Globally unlinks the edge with the specified id.
Equivalent to
id | of the edge to unlink |
Implements fpmas::api::graph::DistributedGraph< T >.
|
overridevirtual |
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 |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Adds a set LOCAL node callback.
A DistributedNode is set LOCAL in the following situations :
callback | set local node callback |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Current set local callbacks list.
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Adds a set DISTANT callback.
A DistributedNode is set DISTANT in the following situations :
callback | set distant node callback |
Implements fpmas::api::graph::DistributedGraph< T >.
|
inlineoverridevirtual |
Current set distant callbacks list.
Implements fpmas::api::graph::DistributedGraph< T >.