GraphLab: Distributed Graph-Parallel API
2.1
|
The context object mediates the interaction between the vertex program and the graphlab execution environment and implements the icontext interface. More...
#include <graphlab/vertex_program/context.hpp>
Public Types | |
typedef Engine | engine_type |
typedef icontext< typename Engine::graph_type, typename Engine::gather_type, typename Engine::message_type > | icontext_type |
typedef icontext_type::graph_type | graph_type |
the user graph type (typically distributed_graph) | |
typedef icontext_type::vertex_id_type | vertex_id_type |
the global vertex identifier (see graphlab::vertex_id_type). | |
typedef icontext_type::vertex_type | vertex_type |
the opaque vertex_type defined in the ivertex_program::graph_type (typically distributed_graph::vertex_type) | |
typedef icontext_type::message_type | message_type |
typedef icontext_type::gather_type | gather_type |
Public Member Functions | |
context (engine_type &engine, graph_type &graph) | |
Construct a context for a particular engine and graph pair. | |
size_t | num_vertices () const |
Get the total number of vertices in the graph. | |
size_t | num_edges () const |
size_t | procid () const |
size_t | num_procs () const |
Get the number of processes in the current execution. | |
std::ostream & | cout () const |
Returns a standard output object (like cout) which only prints once even when running distributed. | |
std::ostream & | cerr () const |
Returns a standard error object (like cerr) which only prints once even when running distributed. | |
float | elapsed_seconds () const |
int | iteration () const |
void | stop () |
void | signal (const vertex_type &vertex, const message_type &message=message_type()) |
void | signal_vid (vertex_id_type vid, const message_type &message=message_type()) |
void | post_delta (const vertex_type &vertex, const gather_type &delta) |
virtual void | clear_gather_cache (const vertex_type &vertex) |
virtual void | signal (const vertex_type &vertex, const message_type &message=message_type()) |
Signal a vertex with a particular message. | |
virtual void | signal_vid (vertex_id_type gvid, const message_type &message=message_type()) |
Send a message to a vertex ID. | |
virtual void | post_delta (const vertex_type &vertex, const gather_type &delta) |
Post a change to the cached sum for the vertex. |
The context object mediates the interaction between the vertex program and the graphlab execution environment and implements the icontext interface.
Engine | the engine that is using this context. |
Definition at line 44 of file context.hpp.
typedef Engine graphlab::context< Engine >::engine_type |
The engine that created this context object
Definition at line 51 of file context.hpp.
typedef icontext_type::gather_type graphlab::context< Engine >::gather_type |
The type returned by the gather operation. (see ivertex_program::gather_type)
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 61 of file context.hpp.
typedef icontext<typename Engine::graph_type, typename Engine::gather_type, typename Engine::message_type> graphlab::context< Engine >::icontext_type |
The parent type
Definition at line 56 of file context.hpp.
typedef icontext_type::message_type graphlab::context< Engine >::message_type |
The message type specified by the user-defined vertex-program. (see ivertex_program::message_type)
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 60 of file context.hpp.
|
inlinevirtual |
Returns a standard error object (like cerr) which only prints once even when running distributed.
This returns a C++ standard output stream object which maps directly to std::cerr on machine with process ID 0, and to empty output streamss on all other processes. Calling,
will therefore only print if the code is run on machine 0. This is useful in the finalize operation in aggregators.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 99 of file context.hpp.
|
inlinevirtual |
Invalidate the cached gather on the vertex.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 150 of file context.hpp.
|
inlinevirtual |
Returns a standard output object (like cout) which only prints once even when running distributed.
This returns a C++ standard output stream object which maps directly to std::cout on machine with process ID 0, and to empty output streamss on all other processes. Calling,
will therefore only print if the code is run on machine 0. This is useful in the finalize operation in aggregators.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 95 of file context.hpp.
|
inlinevirtual |
Get the elapsed time in seconds
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 106 of file context.hpp.
|
inlinevirtual |
Return the current interation number (if supported).
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 111 of file context.hpp.
|
inlinevirtual |
Get the number of edges in the graph
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 83 of file context.hpp.
|
inlinevirtual |
Get the number of processes in the current execution.
This is typically the number of mpi jobs created:
would imply that num_procs() returns 16.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 93 of file context.hpp.
|
inlinevirtual |
Get the total number of vertices in the graph.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 78 of file context.hpp.
|
inline |
Post a change to the cached sum for the vertex
Definition at line 142 of file context.hpp.
|
inlinevirtualinherited |
Post a change to the cached sum for the vertex.
Often a vertex program will be signaled due to a change in one or a few of its neighbors. However the gather operation will be rerun on all neighbors potentially producing the same value as previous invocations and wasting computation time. To address this some engines support caching (see gather_caching for details) of the gather phase.
When caching is enabled the engines save a copy of the previous gather for each vertex. On subsequent calls to gather if their is a cached gather then the gather phase is skipped and the cached value is passed to the ivertex_program::apply function. Therefore it is the responsibility of the vertex program to update the cache values for neighboring vertices. This is accomplished by using the icontext::post_delta function. Posted deltas are atomically added to the cache.
vertex | [in] the vertex whose cache we want to update |
delta | [in] the change that we want to add to the current cache. |
Definition at line 254 of file icontext.hpp.
|
inlinevirtual |
Get an estimate of the number of update functions executed up to this point.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 91 of file context.hpp.
|
inline |
Send a message to a vertex.
Definition at line 121 of file context.hpp.
|
inlinevirtualinherited |
Signal a vertex with a particular message.
This function is an essential part of the GraphLab abstraction and is used to encode iterative computation. Typically a vertex program will signal neighboring vertices during the scatter phase. A vertex program may choose to signal neighbors on when changes made during the previos phases break invariants or warrant future computation on neighboring vertices.
The signal function takes two arguments. The first is mandatory and specifies which vertex to signal. The second argument is optional and is used to send a message. If no message is provided then the default message is used.
vertex | [in] The vertex to send the message to |
message | [in] The message to send, defaults to message_type(). |
Definition at line 213 of file icontext.hpp.
|
inline |
Send a message to a vertex ID.
Definition at line 133 of file context.hpp.
|
inlinevirtualinherited |
Send a message to a vertex ID.
gvid | [in] the vertex id of the vertex to signal |
message | [in] the message to send to that vertex, defaults to message_type(). |
Definition at line 227 of file icontext.hpp.
|
inlinevirtual |
Force the engine to stop executing additional update functions.
Reimplemented from graphlab::icontext< Engine::graph_type, Engine::gather_type, Engine::message_type >.
Definition at line 116 of file context.hpp.