trappy.stats.Topology module

A Topology can be defined as an arrangement of fundamental nodes, in various levels. Each topology has a default level “all” which has each node represented as a group. For example:

level groups
all [[0, 1, 2, 3, 4]]
cluster [[0, 1], [2, 3, 4]]
cpu [[0], [1], [2], [3], [4], [5]]
class trappy.stats.Topology.Topology(clusters=[])[source]

Bases: object

Topology object allows grouping of pivot values (called nodes) at multiple levels. The implementation is targeted towards CPU topologies but can be used generically as well

Parameters:clusters (list) –

clusters can be defined as a list of groups which are again lists of nodes.

Note

This is not a mandatory argument but can be used to quickly create typical CPU topologies.

For Example:

from trappy.stats.Topology import Topology

CLUSTER_A = [0, 1]
CLUTSER_B = [2, 3]

clusters = [CLUSTER_A, CLUSTER_B]
topology = Topology(clusters=clusters)
add_to_level(level_name, level_vals)[source]

Add a group to a level

This function allows to append a group of nodes to a level. If the level does not exist a new level is created

Parameters:level_name (str) – The name of the level
Level_vals:groups containing nodes
flatten()[source]

Return a flattened list of nodes in the topology

get_index(level, node)[source]

Return the index of the node in the level’s list of nodes

Parameters:
  • level – The name of the level
  • node (list) –

    The group for which the inde is required

    Todo

    Change name of the arg to group

get_level(level_name)[source]

Returns the groups of nodes associated with a level

Parameters:level_name (str) – The name of the level
get_node(level, index)[source]

Get the group at the index in the level

Parameters:
  • level – The name of the level
  • index (int) – Index of the group in the list
has_level(level)[source]

Returns true if level is present

Parameters:level – The name of the level
level_span(level)[source]

Return the number of groups in a level

Parameters:level – The name of the level