Public Types | Public Member Functions

graphlab::core< VertexType, EdgeType > Class Template Reference

A GraphLab core is the base (or core) data structure in GraphLab. More...

#include <core.hpp>

List of all members.

Public Types

typedef graphlab::types
< graphlab::graph< VertexType,
EdgeType > > 
types

Public Member Functions

 core ()
 default constructor does nothing
types::graphgraph ()
 Get a modifiable reference to the graph associated with this core.
const types::graphgraph () const
 Get a constant reference to the graph associated with this core.
void set_scheduler_type (const std::string &scheduler_type)
 Set the type of scheduler.
void set_scope_type (const std::string &scope_type)
 Set the scope consistency model used in this engine.
void set_engine_type (const std::string &engine_type)
 Set the engine type.
void set_metrics_type (const std::string &metrics_type)
 Sets the output format of any recorded metrics.
void reset ()
 Destroys a created engine (if any).
void set_ncpus (size_t ncpus)
 Set the number of cpus that the engine will use.
types::iengineengine ()
bool rebuild_engine ()
 Destroys and reconstructs the current engine, reprocessing the engine arguments.
void set_engine_options (const engine_options &opts)
 Set the engine options by passing in an engine options object.
imetrics_reporter & get_reporter ()
const engine_optionsget_engine_options () const
 Returns the engine options.
scheduler_optionssched_options ()
 Returns a modifiable reference to the scheduler options.
const scheduler_optionssched_options () const
 Returns a constant reference to the scheduler options.
bool parse_engine_options (int argc, char **argv)
 Set the engine options by simply parsing the command line arguments.
double start ()
 Run the engine until a termination condition is reached or there are no more tasks remaining to execute.
void add_task (vertex_id_t vertex, typename types::update_function func, double priority)
 Add a single update function to a single vertex.
void add_task (typename types::update_task task, double priority)
 Add a single task with a fixed priority.
void add_tasks (const std::vector< vertex_id_t > &vertices, typename types::update_function func, double priority)
 Add the update function to all the veritces in the provided vector with the given priority.
void add_task_to_all (typename types::update_function func, double priority)
 Add the given function to all vertices using the given priority.
size_t last_update_count ()
 Get the number of updates executed by the engine.
void fill_metrics ()
void reset_metrics ()
void report_metrics ()
 Outputs the recorded metrics.
void set_sync (glshared_base &shared, typename types::iengine::sync_function_type sync, glshared_base::apply_function_type apply, const any &zero, size_t sync_interval=0, typename types::iengine::merge_function_type merge=NULL, vertex_id_t rangelow=0, vertex_id_t rangehigh=-1)
 Registers a sync with the engine.
void sync_now (glshared_base &shared)

Detailed Description

template<typename VertexType, typename EdgeType>
class graphlab::core< VertexType, EdgeType >

A GraphLab core is the base (or core) data structure in GraphLab.

Because many GraphLab programs will consists of a graph and an engine we have created a single data-structure, called a core, which manages all the pieces of GraphLab including engine and scheduler construction parameters.

The core is templatized over the VertexType and EdgeType however by using the ref types typedef, one can simply create a core by doing the following:

     gl::core glcore;

cd The core contains the

The core also manages the engine and scheduler construction parameters.

The core will invisibly recreate the engine each time engine options are modified. This will mean that this internal behavior of the core should be pretty much "transparent" for the typical use case where engine options and scheduler options are defined before tasks are added to the scheduler.

Otherwise, modifications to the engine options will result in the clearing of all scheduler tasks.

Definition at line 85 of file core.hpp.


Member Function Documentation

template<typename VertexType , typename EdgeType >
types::iengine& graphlab::core< VertexType, EdgeType >::engine (  )  [inline]

Get a reference to the active engine. If no engine exists one is created.

Definition at line 225 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_engine_type ( const std::string &  engine_type  )  [inline]

Set the engine type.

This will destroy the current engine and any tasks associated with the current scheduler.

  • "async" This is the regular multithreaded engine
  • "async_sim" This is a single threaded engine. But it can be be started with multiple "simulated threads". The simulation is low-fidelity however, and should be used with caution.

Definition at line 169 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_metrics_type ( const std::string &  metrics_type  )  [inline]

Sets the output format of any recorded metrics.

  • "none" No reporting
  • "basic" Outputs to screen
  • "file" Outputs to a text file graphlab_metrics.txt
  • "html" Outputs to a html file graphlab_metrics.html

Definition at line 183 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_ncpus ( size_t  ncpus  )  [inline]

Set the number of cpus that the engine will use.

This will destroy the current engine and any tasks associated with the current scheduler.

Definition at line 214 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_scheduler_type ( const std::string &  scheduler_type  )  [inline]

Set the type of scheduler.

This will destroy the current engine and any tasks currently associated with the scheduler. See Schedulers for the list of supported schedulers.

Definition at line 127 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_scope_type ( const std::string &  scope_type  )  [inline]

Set the scope consistency model used in this engine.

This will destroy the current engine and any tasks associated with the current scheduler. The available scopes are:

  • "full" This ensures full data consistency within the scope
  • "edge" This ensures data consistency with just the vertex and edges
  • "vertex" This ensures that a vertex cannot be updated by two processors simultaneously
  • "none" This eliminates all locking

See Scopes for details

Definition at line 149 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::set_sync ( glshared_base shared,
typename types::iengine::sync_function_type  sync,
glshared_base::apply_function_type  apply,
const any zero,
size_t  sync_interval = 0,
typename types::iengine::merge_function_type  merge = NULL,
vertex_id_t  rangelow = 0,
vertex_id_t  rangehigh = -1 
) [inline]

Registers a sync with the engine.

Registers a sync with the engine. The sync will be performed approximately every "interval" updates, and will perform a reduction over all vertices from rangelow to rangehigh inclusive. The merge function may be NULL, in which it will not be used. However, it is highly recommended to provide a merge function since this allow the sync operation to be parallelized.

The sync operation is guaranteed to be strictly sequentially consistent with all other execution.

Parameters:
shared The shared variable to synchronize
sync The reduction function
apply The final apply function which writes to the shared value
zero The initial zero value passed to the reduction
sync_interval Frequency at which the sync is initiated. Corresponds approximately to the number of update function calls before the sync is reevaluated. If 0, the sync will only be evaluated once at engine start, and will never be evaluated again. Defaults to 0.
merge Combined intermediate reduction value. defaults to NULL. in which case, it will not be used.
rangelow he lower range of vertex id to start syncing. The range is inclusive. i.e. vertex with id 'rangelow' and vertex with id 'rangehigh' will be included. Defaults to 0.
rangehigh The upper range of vertex id to stop syncing. The range is inclusive. i.e. vertex with id 'rangelow' and vertex with id 'rangehigh' will be included. Defaults to infinity.

Definition at line 425 of file core.hpp.

template<typename VertexType , typename EdgeType >
void graphlab::core< VertexType, EdgeType >::sync_now ( glshared_base shared  )  [inline]

Performs a sync immediately. This function requires that the shared variable already be registered with the engine.

Definition at line 444 of file core.hpp.


The documentation for this class was generated from the following file: