Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
galois::graphs::CustomMasterAssignment Class Reference

Policies that use a custom assignment of masters (from the user). More...

#include <BasePolicies.h>

Inheritance diagram for galois::graphs::CustomMasterAssignment:
galois::graphs::PartitioningScaffold FennelP GingerP SugarColumnFlipP SugarP

Public Member Functions

 CustomMasterAssignment (uint32_t hostID, uint32_t numHosts, uint64_t numNodes, uint64_t numEdges)
 Calls parent constructor to initialize common data. More...
 
uint32_t retrieveMaster (uint32_t gid) const
 Retrieves a saved master mapping: does not fail if a GID mapping is not found but instead returns -1 if in stage 1, else fails. More...
 
void saveGID2HostInfo (std::unordered_map< uint64_t, uint32_t > &gid2offsets, std::vector< uint32_t > &localNodeToMaster, uint64_t nodeOffset)
 Given gid to master mapping info, save it into a local map. More...
 
bool masterAssignPhase () const
 Returns true as policies that inherit from this should define master assignment function. More...
 
void enterStage2 ()
 Shifts master assignment phase to stage 2. More...
 
template<typename EdgeTy >
uint32_t getMaster (uint32_t, galois::graphs::BufferedGraph< EdgeTy > &, const std::vector< uint32_t > &, std::unordered_map< uint64_t, uint32_t > &, const std::vector< uint64_t > &, std::vector< galois::CopyableAtomic< uint64_t >> &, const std::vector< uint64_t > &, std::vector< galois::CopyableAtomic< uint64_t >> &)
 CuSP's "getMaster" function. More...
 
bool addMasterMapping (uint32_t gid, uint32_t mappedMaster)
 Add a new master mapping to the local map: needs to be in stage 1. More...
 
- Public Member Functions inherited from galois::graphs::PartitioningScaffold
 PartitioningScaffold (uint32_t hostID, uint32_t numHosts, uint64_t numNodes, uint64_t numEdges)
 Constructor for Scaffold. More...
 
void saveGIDToHost (std::vector< std::pair< uint64_t, uint64_t >> &gid2host)
 Save a provided map from host to nodes a host has read into this object. More...
 

Protected Member Functions

unsigned getHostReader (uint64_t gid) const
 Return the reader of a particular node. More...
 

Protected Attributes

char _status
 Specifies what phase of master assignment partitioner is on. More...
 
std::vector< uint32_t > _localNodeToMaster
 Metadata for determining where a node's master is. More...
 
std::unordered_map< uint64_t,
uint32_t > 
_gid2masters
 Map GID to its master. More...
 
uint64_t _nodeOffset
 This host's node offset (each host reads a distinct contiguous portion of graph. More...
 
- Protected Attributes inherited from galois::graphs::PartitioningScaffold
uint32_t _hostID
 host ID of owner of this object More...
 
uint32_t _numHosts
 total number of hosts More...
 
uint64_t _numNodes
 number of nodes in graph More...
 
uint64_t _numEdges
 number of edges in graph More...
 
std::vector< std::pair
< uint64_t, uint64_t > > 
_gid2host
 maps from host id to nodes that host as read from disk More...
 

Detailed Description

Policies that use a custom assignment of masters (from the user).

Needs to go through a master assignment phase, which adds overhead to partitioning, but may get better quality partitions.

Constructor & Destructor Documentation

galois::graphs::CustomMasterAssignment::CustomMasterAssignment ( uint32_t  hostID,
uint32_t  numHosts,
uint64_t  numNodes,
uint64_t  numEdges 
)
inline

Calls parent constructor to initialize common data.

Member Function Documentation

bool galois::graphs::CustomMasterAssignment::addMasterMapping ( uint32_t  gid,
uint32_t  mappedMaster 
)
inline

Add a new master mapping to the local map: needs to be in stage 1.

Parameters
gidGID to map; should not be a GID read by this host (won't cause problems, but would just be a waste of compute resouces)
mappedMastermaster to map a GID to
Returns
true if new mapping added; false if already existed in map
void galois::graphs::CustomMasterAssignment::enterStage2 ( )
inline

Shifts master assignment phase to stage 2.

unsigned galois::graphs::CustomMasterAssignment::getHostReader ( uint64_t  gid) const
inlineprotected

Return the reader of a particular node.

Parameters
gidGID of node to get reader of
Returns
Host reader of node passed in as param
template<typename EdgeTy >
uint32_t galois::graphs::CustomMasterAssignment::getMaster ( uint32_t  ,
galois::graphs::BufferedGraph< EdgeTy > &  ,
const std::vector< uint32_t > &  ,
std::unordered_map< uint64_t, uint32_t > &  ,
const std::vector< uint64_t > &  ,
std::vector< galois::CopyableAtomic< uint64_t >> &  ,
const std::vector< uint64_t > &  ,
std::vector< galois::CopyableAtomic< uint64_t >> &   
)
inline

CuSP's "getMaster" function.

This function should be defined by user in child class to assign a node to a host.

Returns
Host id in which to assing a node
bool galois::graphs::CustomMasterAssignment::masterAssignPhase ( ) const
inline

Returns true as policies that inherit from this should define master assignment function.

uint32_t galois::graphs::CustomMasterAssignment::retrieveMaster ( uint32_t  gid) const
inline

Retrieves a saved master mapping: does not fail if a GID mapping is not found but instead returns -1 if in stage 1, else fails.

Parameters
gidGID to get master of
Returns
Master of specified GID, -1, unsigned, if not found
void galois::graphs::CustomMasterAssignment::saveGID2HostInfo ( std::unordered_map< uint64_t, uint32_t > &  gid2offsets,
std::vector< uint32_t > &  localNodeToMaster,
uint64_t  nodeOffset 
)
inline

Given gid to master mapping info, save it into a local map.

Parameters
gid2offsetsMap a GID to an offset into a vector containing master mapping information
localNodeToMasterVector that represents the master mapping of local nodes
nodeOffsetFirst GID of nodes read by this host

Member Data Documentation

std::unordered_map<uint64_t, uint32_t> galois::graphs::CustomMasterAssignment::_gid2masters
protected

Map GID to its master.

std::vector<uint32_t> galois::graphs::CustomMasterAssignment::_localNodeToMaster
protected

Metadata for determining where a node's master is.

uint64_t galois::graphs::CustomMasterAssignment::_nodeOffset
protected

This host's node offset (each host reads a distinct contiguous portion of graph.

char galois::graphs::CustomMasterAssignment::_status
protected

Specifies what phase of master assignment partitioner is on.


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