GHS
Leader Election Based on GHS Minimum Spanning Tree
Classes | Typedefs | Enumerations | Functions | Variables
le::ghs Namespace Reference

Classes

struct  Edge
 A struct to hold all the communication edge information. More...
 
class  GhsState
 The main state machine for the GHS algorithm More...
 
class  Msg
 An aggregate type containing all the data to exchange with to/from information. More...
 

Typedefs

typedef int agent_t
 problems for GhsState More...
 
typedef unsigned long metric_t
 
typedef int level_t
 A "level" which is an internal item for GhsState to track how many times the MST has merged with another.
 

Enumerations

enum  status_t { UNKNOWN = 0, MST = 1, MST_PARENT =2, DELETED =-1 }
 A status enumeration, for the ghs edges. More...
 

Functions

bool is_valid (const agent_t a)
 
Edge worst_edge ()
 
bool is_valid (const Edge e)
 
bool is_valid (const metric_t m)
 

Variables

const agent_t NO_AGENT =-1
 
const metric_t WORST_METRIC =std::numeric_limits<metric_t>::max()
 
const metric_t METRIC_NOT_SET =0
 
const level_t LEVEL_START =0
 All levels start at 0.
 
const unsigned int MAX_MSG_SZ = sizeof(Msg)
 

Detailed Description

GHS

The GHS namespace

Typedef Documentation

◆ agent_t

problems for GhsState

The ghs implementation supports arbitrary integers, as long as they are greater than or equal to zero. Use is_valid() to ensure an agent_t will

◆ metric_t

typedef unsigned long le::ghs::metric_t

A typedef to hold the metrics. There's some work to do to make sure the metrics are:

  • Symmetric (both peer and root agree on the value)
  • unique (no two agents have the same metric)

However, that is not captured here, and is handled at a "higher level". See unique_link_metric_to()

See also
DemoComms::unique_link_metric_to()

Enumeration Type Documentation

◆ status_t

A status enumeration, for the ghs edges.

Enumerator
UNKNOWN 

We have not probed this edge for information yet, or have not recieved a reponse.

MST 

We have added this edge as an MST link.

MST_PARENT 

We have added this edge as parent MST link.

DELETED 

We have decided not to further consider this edge, either it was "bad", or it is already part of our partition.

Function Documentation

◆ is_valid() [1/3]

bool le::ghs::is_valid ( const agent_t  a)

Just in case you want an official alias for a>=0.

Returns
true if a>=0
false if a==NO_AGENT or is otherwise <0

◆ is_valid() [2/3]

bool le::ghs::is_valid ( const Edge  e)
Parameters
ean Edge
Returns
true if edge is not worst_edge() and does not have any uninitialized components.

◆ is_valid() [3/3]

bool le::ghs::is_valid ( const metric_t  m)
Parameters
ma metric_t
Returns
true if the metric_t is not NOT_SET or WORST_METRIC

◆ worst_edge()

Edge le::ghs::worst_edge ( )

Returns the worst possible edge, useful for comparisons in the search for the minimum weight outgoing edge.

Variable Documentation

◆ MAX_MSG_SZ

const unsigned int le::ghs::MAX_MSG_SZ = sizeof(Msg)

For an external class that is interested in allocating static storage to queue a set of Msg s, this is the maximum size of the Msg class.

◆ METRIC_NOT_SET

const metric_t le::ghs::METRIC_NOT_SET =0

This is set to zero because metrics are usually zero initialized by default, and we do not want to have a bunch of zeros floating around in our search

◆ NO_AGENT

const agent_t le::ghs::NO_AGENT =-1

This means not set

◆ WORST_METRIC

const metric_t le::ghs::WORST_METRIC =std::numeric_limits<metric_t>::max()

This is the "worst" metric possible, defined simply as the maximum value reachable.

We all need to agree on the worst metric, since we're all comparing against this to determine if we found a minimum weight outgoing edge. See mwoe()

See also
GhsState::mwoe() for how it is used
DemoComms::unique_link_metric_to() for why it is a size_t
DemoComms::little_iperf()