TPIE

2362a60
tpie::pipelining::bits::runtime Class Reference

Execute the pipeline contained in a node_map. More...

#include <tpie/pipelining/runtime.h>

Public Member Functions

 runtime (node_map::ptr nodeMap)
 Construct a runtime object. More...
 
size_t get_node_count ()
 Number of nodes contained in node map. More...
 
gocontext_ptr go_init (stream_size_type items, progress_indicator_base &progress, memory_size_type files, memory_size_type memory, const char *file, const char *function)
 
void go_until (gocontext *gc, node *node=nullptr)
 
void go (stream_size_type items, progress_indicator_base &progress, memory_size_type files, memory_size_type memory, const char *file, const char *function)
 Execute the pipeline. More...
 
void get_item_sources (std::vector< node * > &itemSources)
 Get all sources of the item flow graph. More...
 
void get_item_sinks (std::vector< node * > &itemSinks)
 Get all sinks of the item flow graph. More...
 
void get_phase_map (std::map< node *, size_t > &phaseMap)
 Partition nodes into phases (using union-find). More...
 
void get_phase_graph (const std::map< node *, size_t > &phaseMap, graph< size_t > &phaseGraph)
 Set up phase graph so we can find a topological order. More...
 
void get_phases (const std::map< node *, size_t > &phaseMap, const graph< size_t > &phaseGraph, std::unordered_set< node_map::id_t > &evacuateWhenDone, std::vector< std::vector< node * > > &phases)
 Compute topological phase order. More...
 
void get_item_flow_graphs (std::vector< std::vector< node * > > &phases, std::vector< graph< node * > > &itemFlow)
 Internal method used by go(). More...
 
void get_actor_graphs (std::vector< std::vector< node * > > &phases, std::vector< graph< node * > > &actors)
 Internal method used by go(). More...
 
void get_graph (std::vector< node * > &phase, graph< node * > &result, bool itemFlow)
 Internal method used by get_{actor,item_flow}_graphs(). More...
 
bool is_initiator (node *n)
 Check if the node is a phase initiator. More...
 
bool has_initiator (const std::vector< node * > &phase)
 Equivalent to any_of(begin(phase), end(phase), is_initiator). More...
 
void ensure_initiators (const std::vector< std::vector< node * > > &phases)
 Ensure that all phases have at least one initiator. More...
 
void prepare_all (const std::vector< graph< node * > > &itemFlow)
 Call prepare on all nodes in item source to sink order. More...
 
void evacuate_all (const std::vector< node * > &phase, const std::unordered_set< node_map::id_t > &evacuateWhenDone)
 Call evacuate on all nodes in evacuateWhenDone for which can_evacuate() is true. More...
 
void propagate_all (const graph< node * > &itemFlow)
 Call propagate on all nodes in item source to sink order. More...
 
void set_progress_indicators (const std::vector< node * > &phase, progress_indicator_base &pi)
 Call set_progress_indicator on all nodes in the phase. More...
 
void go_initiators (const std::vector< node * > &phase)
 Call go() on all initiators after setting the given progress indicator. More...
 

Static Public Member Functions

static std::vector< size_t > inverse_permutation (const std::vector< size_t > &f)
 Compute the inverse of a permutation. More...
 
static void set_resource_being_assigned (const std::vector< node * > &nodes, resource_type type)
 Internal method used by go(). More...
 
static void assign_files (const std::vector< std::vector< node * > > &phases, memory_size_type files)
 Internal method used by go(). More...
 
static void reassign_files (const std::vector< std::vector< node * > > &phases, memory_size_type phase, memory_size_type files)
 Internal method used by go(). More...
 
static double get_files_factor (memory_size_type files, const file_runtime &frt)
 Internal method used by assign_memory(). More...
 
static void assign_memory (const std::vector< std::vector< node * > > &phases, memory_size_type memory, datastructure_runtime &drt)
 Internal method used by go(). More...
 
static void reassign_memory (const std::vector< std::vector< node * > > &phases, memory_size_type phase, memory_size_type memory, const datastructure_runtime &drt)
 Internal method used by go(). More...
 
static double get_memory_factor (memory_size_type memory, memory_size_type phase, const memory_runtime &mrt, const datastructure_runtime &drt, bool datastructures_locked)
 Internal method used by assign_memory(). More...
 

Detailed Description

Execute the pipeline contained in a node_map.

Definition at line 51 of file runtime.h.

Constructor & Destructor Documentation

tpie::pipelining::bits::runtime::runtime ( node_map::ptr  nodeMap)

Construct a runtime object.

Does nothing other than copy the smart pointer given.

Member Function Documentation

static void tpie::pipelining::bits::runtime::assign_files ( const std::vector< std::vector< node * > > &  phases,
memory_size_type  files 
)
static

Internal method used by go().

static void tpie::pipelining::bits::runtime::assign_memory ( const std::vector< std::vector< node * > > &  phases,
memory_size_type  memory,
datastructure_runtime &  drt 
)
static

Internal method used by go().

void tpie::pipelining::bits::runtime::ensure_initiators ( const std::vector< std::vector< node * > > &  phases)

Ensure that all phases have at least one initiator.

If a phase has no initiators, throw no_initiator_node().

void tpie::pipelining::bits::runtime::evacuate_all ( const std::vector< node * > &  phase,
const std::unordered_set< node_map::id_t > &  evacuateWhenDone 
)

Call evacuate on all nodes in evacuateWhenDone for which can_evacuate() is true.

void tpie::pipelining::bits::runtime::get_actor_graphs ( std::vector< std::vector< node * > > &  phases,
std::vector< graph< node * > > &  actors 
)

Internal method used by go().

static double tpie::pipelining::bits::runtime::get_files_factor ( memory_size_type  files,
const file_runtime &  frt 
)
static

Internal method used by assign_memory().

void tpie::pipelining::bits::runtime::get_graph ( std::vector< node * > &  phase,
graph< node * > &  result,
bool  itemFlow 
)

Internal method used by get_{actor,item_flow}_graphs().

void tpie::pipelining::bits::runtime::get_item_flow_graphs ( std::vector< std::vector< node * > > &  phases,
std::vector< graph< node * > > &  itemFlow 
)

Internal method used by go().

void tpie::pipelining::bits::runtime::get_item_sinks ( std::vector< node * > &  itemSinks)

Get all sinks of the item flow graph.

An item sink node has no outgoing edges in the item flow graph of its phase, and no phase depends on its phase.

This is the set of nodes used when fetching out-of-band data from the pipeline.

void tpie::pipelining::bits::runtime::get_item_sources ( std::vector< node * > &  itemSources)

Get all sources of the item flow graph.

An item source node has no ingoing edges in the item flow graph of its phase, and its phase does not depend on any phases.

This is the set of nodes used when forwarding out-of-band data into the pipeline.

static double tpie::pipelining::bits::runtime::get_memory_factor ( memory_size_type  memory,
memory_size_type  phase,
const memory_runtime &  mrt,
const datastructure_runtime &  drt,
bool  datastructures_locked 
)
static

Internal method used by assign_memory().

size_t tpie::pipelining::bits::runtime::get_node_count ( )

Number of nodes contained in node map.

Returns m_nodeMap.size().

void tpie::pipelining::bits::runtime::get_phase_graph ( const std::map< node *, size_t > &  phaseMap,
graph< size_t > &  phaseGraph 
)

Set up phase graph so we can find a topological order.

void tpie::pipelining::bits::runtime::get_phase_map ( std::map< node *, size_t > &  phaseMap)

Partition nodes into phases (using union-find).

void tpie::pipelining::bits::runtime::get_phases ( const std::map< node *, size_t > &  phaseMap,
const graph< size_t > &  phaseGraph,
std::unordered_set< node_map::id_t > &  evacuateWhenDone,
std::vector< std::vector< node * > > &  phases 
)

Compute topological phase order.

The vector phases[i] will contain the nodes in the ith phase to run. For each node in phase[i], if the node has a memory share dependency to any node not in phases[i-1], the node is contained in evacuateWhenDone.

void tpie::pipelining::bits::runtime::go ( stream_size_type  items,
progress_indicator_base progress,
memory_size_type  files,
memory_size_type  memory,
const char *  file,
const char *  function 
)

Execute the pipeline.

This is the main entry point. The method go() sets up all nodes for execution and executes all initiators in turn:

Call node::prepare in item source to item sink order for each phase.

Assign memory according to memory constraints and memory priorities.

For each phase, call propagate, begin, go and end on nodes as appropriate. We call propagate in item source to item sink order; we call begin in leaf to root actor order; we call end in root to leaf actor order.

void tpie::pipelining::bits::runtime::go_initiators ( const std::vector< node * > &  phase)

Call go() on all initiators after setting the given progress indicator.

bool tpie::pipelining::bits::runtime::has_initiator ( const std::vector< node * > &  phase)

Equivalent to any_of(begin(phase), end(phase), is_initiator).

static std::vector<size_t> tpie::pipelining::bits::runtime::inverse_permutation ( const std::vector< size_t > &  f)
static

Compute the inverse of a permutation.

A permutation of N elements is given as a std::vector of size N, in which each entry maps to a distinct integer in [0, N). The inverse permutation of f is g if and only if f[g[i]] == g[f[i]] == i for all i in [0,N).

bool tpie::pipelining::bits::runtime::is_initiator ( node n)

Check if the node is a phase initiator.

A node is a phase initiator if it has no ingoing edges in the actor graph, or in other words if no node pushes to it or pulls from it.

void tpie::pipelining::bits::runtime::prepare_all ( const std::vector< graph< node * > > &  itemFlow)

Call prepare on all nodes in item source to sink order.

void tpie::pipelining::bits::runtime::propagate_all ( const graph< node * > &  itemFlow)

Call propagate on all nodes in item source to sink order.

static void tpie::pipelining::bits::runtime::reassign_files ( const std::vector< std::vector< node * > > &  phases,
memory_size_type  phase,
memory_size_type  files 
)
static

Internal method used by go().

static void tpie::pipelining::bits::runtime::reassign_memory ( const std::vector< std::vector< node * > > &  phases,
memory_size_type  phase,
memory_size_type  memory,
const datastructure_runtime &  drt 
)
static

Internal method used by go().

void tpie::pipelining::bits::runtime::set_progress_indicators ( const std::vector< node * > &  phase,
progress_indicator_base pi 
)

Call set_progress_indicator on all nodes in the phase.

static void tpie::pipelining::bits::runtime::set_resource_being_assigned ( const std::vector< node * > &  nodes,
resource_type  type 
)
static

Internal method used by go().


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