pacman.model.graphs.machine package¶
Module contents¶
-
class
pacman.model.graphs.machine.
AbstractMachineEdgePartition
[source]¶ Bases:
object
A simple implementation of a machine edge partition that will communicate with a traffic type.
-
check_edge
(edge)[source]¶ check a edge traffic type.
Parameters: edge (AbstractEdge) – the edge to check Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType
-
-
class
pacman.model.graphs.machine.
AbstractSDRAMPartition
[source]¶ Bases:
pacman.model.graphs.machine.abstract_machine_edge_partition.AbstractMachineEdgePartition
An edge partition that contains SDRAM edges.
-
get_sdram_base_address_for
(vertex)[source]¶ Get the SDRAM base address for a edge given which side the vertex is on.
Parameters: vertex – the vertex to find SDRAM base address of Returns: the SDRAM address for this vertex
-
-
class
pacman.model.graphs.machine.
ConstantSDRAMMachinePartition
(identifier, pre_vertex, label)[source]¶ Bases:
pacman.model.graphs.abstract_single_source_partition.AbstractSingleSourcePartition
,pacman.model.graphs.machine.abstract_sdram_partition.AbstractSDRAMPartition
An SDRAM partition that uses a fixed amount of memory. The edges in the partition must agree on how much memory is required.
-
MISSING_EDGE_ERROR_MESSAGE
= 'Partition {} has no edges'¶
-
add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters: - edge (AbstractEdge) – the edge to add
- graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges Return type: ConstantSDRAMMachinePartition
-
get_sdram_base_address_for
(vertex)[source]¶ Get the SDRAM base address for a edge given which side the vertex is on.
Parameters: vertex – the vertex to find SDRAM base address of Returns: the SDRAM address for this vertex
-
get_sdram_size_of_region_for
(vertex)[source]¶ Get the size of the region for a vertex given a edge.
Parameters: vertex – the vertex to find SDRAM size of Returns: the SDRAM size for this vertex
-
sdram_base_address
¶
-
total_sdram_requirements
()[source]¶ Get the total SDRAM required by this outgoing partition.
Returns: int
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType
-
-
class
pacman.model.graphs.machine.
DestinationSegmentedSDRAMMachinePartition
(identifier, pre_vertex, label)[source]¶ Bases:
pacman.model.graphs.abstract_single_source_partition.AbstractSingleSourcePartition
,pacman.model.graphs.machine.abstract_sdram_partition.AbstractSDRAMPartition
An SDRAM partition that gives each edge its own slice of memory from a contiguous block. The edges all have the same source vertex.
-
add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters: - edge (AbstractEdge) – the edge to add
- graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges Return type: DestinationSegmentedSDRAMMachinePartition
-
get_sdram_base_address_for
(vertex)[source]¶ Get the SDRAM base address for a edge given which side the vertex is on.
Parameters: vertex – the vertex to find SDRAM base address of Returns: the SDRAM address for this vertex
-
get_sdram_size_of_region_for
(vertex)[source]¶ Get the size of the region for a vertex given a edge.
Parameters: vertex – the vertex to find SDRAM size of Returns: the SDRAM size for this vertex
-
sdram_base_address
¶
-
total_sdram_requirements
()[source]¶ Get the total SDRAM required by this outgoing partition.
Returns: int
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType
-
-
class
pacman.model.graphs.machine.
FixedRouteEdgePartition
(pre_vertex, identifier, constraints=None, label=None, traffic_weight=1)[source]¶ Bases:
pacman.model.graphs.abstract_single_source_partition.AbstractSingleSourcePartition
,pacman.model.graphs.machine.abstract_machine_edge_partition.AbstractMachineEdgePartition
A simple implementation of a machine edge partition that will communicate with SpiNNaker multicast packets. They have a common set of sources with the same semantics and so can share a single key.
Parameters: - identifier (str) – The identifier of the partition
- constraints (list(AbstractConstraint)) – Any initial constraints
- label (str) – An optional label of the partition
- traffic_weight (int) – The weight of traffic going down this partition
-
add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters: - edge (AbstractEdge) – the edge to add
- graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges Return type: FixedRouteEdgePartition
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType
-
class
pacman.model.graphs.machine.
MachineEdge
(pre_vertex, post_vertex, traffic_type=<EdgeTrafficType.MULTICAST: 1>, label=None, traffic_weight=1, app_edge=None)[source]¶ Bases:
pacman.model.graphs.abstract_edge.AbstractEdge
A simple implementation of a machine edge.
Parameters: - pre_vertex (MachineVertex) – The vertex at the start of the edge.
- post_vertex (MachineVertex) – The vertex at the end of the edge.
- traffic_type (EdgeTrafficType) – The type of traffic that this edge will carry.
- label (str or None) – The name of the edge.
- traffic_weight (int) – The optional weight of traffic expected to travel down this edge relative to other edges. (default is 1)
- app_edge (ApplicationEdge or None) – The application edge from which this was created. If None, this edge is part of a pure machine graph.
-
app_edge
¶ The application edge from which this was created
Return type: ApplicationEdge or None
-
associate_application_edge
()[source]¶ Asks the application edge (if any) to remember this machine edge.
-
post_vertex
¶ The vertex at the end of the edge.
Return type: MachineVertex
-
pre_vertex
¶ The vertex at the start of the edge.
Return type: MachineVertex
-
traffic_type
¶ Return type: EdgeTrafficType
-
class
pacman.model.graphs.machine.
MachineFPGAVertex
(fpga_id, fpga_link_id, board_address=None, label=None, constraints=None, app_vertex=None, vertex_slice=None)[source]¶ Bases:
pacman.model.graphs.machine.machine_vertex.MachineVertex
,pacman.model.graphs.abstract_fpga.AbstractFPGA
A virtual vertex on an FPGA link.
-
board_address
¶ The IP address of the board to which the device is connected, or
None
for the boot board.Return type: str
-
resources_required
¶ The resources required by the vertex
Return type: ResourceContainer
-
set_virtual_chip_coordinates
(virtual_chip_x, virtual_chip_y)[source]¶ Set the details of the virtual chip that has been added to the machine for this vertex.
Parameters:
-
-
class
pacman.model.graphs.machine.
MachineGraph
(label, application_graph=None)[source]¶ Bases:
pacman.model.graphs.graph.Graph
A graph whose vertices can fit on the chips of a machine.
Parameters: - label (str or None) – The label for the graph.
- application_graph (ApplicationGraph or None) – The application graph that this machine graph is derived from, if it is derived from one at all.
-
MISSING_APP_VERTEX_ERROR_MESSAGE
= 'The vertex does not have an app_vertex, which is required when other app_vertices exist.'¶
-
UNEXPECTED_APP_VERTEX_ERROR_MESSAGE
= 'The vertex has an app_vertex, which is not allowed when other vertices not have app_vertices.'¶
-
add_edge
(edge, outgoing_edge_partition_name)[source]¶ Add an edge to the graph and its partition
If required and possible will create a new partition in the graph
Returns the partition the edge was added to
Parameters: - edge (AbstractEdge) – The edge to add
- outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex
Return type: Raises: PacmanInvalidParameterException – If the edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one
-
add_outgoing_edge_partition
(edge_partition)[source]¶ Add an edge partition to the graph.
Will also add any edges already in the partition as well
Parameters: edge_partition (AbstractEdgePartition) – The edge partition to add Raises: PacmanAlreadyExistsException – If a partition already exists with the same pre_vertex and identifier
-
add_vertex
(vertex)[source]¶ Add a vertex to the graph.
Parameters: vertex (AbstractVertex) – The vertex to add
Raises: - PacmanInvalidParameterException – If the vertex is not of a valid type
- PacmanConfigurationException – If there is an attempt to add the same vertex more than once
-
clone
()[source]¶ Makes as shallow as possible copy of the graph.
Vertices and edges are copied over. Partition will be new objects.
Returns: A shallow copy of this graph Return type: MachineGraph Raises: PacmanInvalidParameterException – If called on a none empty graph when Application Vertexes exist
-
get_edge_partitions_ending_at_vertex
(vertex)[source]¶ Get all the edge partitions that end at the given vertex.
Parameters: vertex (MachineVertex) – The vertex at which the SDRAM edge partitions to find starts Return type: iterable(AbstractPartition)
-
get_fixed_route_edge_partitions_ending_at_vertex
(vertex)[source]¶ Get only the fixed_route edge partitions that end at the vertex.
Parameters: vertex (MachineVertex) – The vertex at which the edge partitions to find starts Return type: iterable(FixedRouteEdgePartition)
-
get_fixed_route_edge_partitions_starting_at_vertex
(vertex)[source]¶ Get only the fixed_route edge partitions that start at the vertex.
Parameters: vertex (MachineVertex) – The vertex at which the edge partitions to find starts Return type: iterable(FixedRouteEdgePartition)
-
get_multicast_edge_partitions_ending_at_vertex
(vertex)[source]¶ Get only the multicast edge partitions that end at the vertex.
Parameters: vertex (MachineVertex) – The vertex at which the edge partitions to find starts Return type: iterable(MulticastEdgePartition)
-
get_multicast_edge_partitions_starting_at_vertex
(vertex)[source]¶ Get only the multicast edge partitions that start at the vertex.
Parameters: vertex (MachineVertex) – The vertex at which the edge partitions to find starts Return type: iterable(MulticastEdgePartition)
-
get_outgoing_edge_partitions_starting_at_vertex
(vertex)[source]¶ Get all the edge partitions that start at the given vertex.
Parameters: vertex (AbstractVertex) – The vertex at which the edge partitions to find starts Return type: iterable(AbstractEdgePartition)
-
get_sdram_edge_partitions_ending_at_vertex
(vertex)[source]¶ Get all the sdram edge partitions that end at the given vertex.
Parameters: vertex (MachineVertex) – The vertex at which the SDRAM edge partitions to find starts Return type: iterable(AbstractSDRAMPartition)
-
get_sdram_edge_partitions_starting_at_vertex
(vertex)[source]¶ Get all the SDRAM edge partitions that start at the given vertex.
Parameters: vertex (MachineVertex) – The vertex at which the sdram edge partitions to find starts Return type: iterable(AbstractSDRAMPartition)
-
multicast_partitions
¶ Returns a double dictionary of app id then outgoing_edge_partition_name to a set of machine_vertex that act as pre vertices for these multicast edges
The app_id is normally the (machine) edge.pre_vertex.app_vertex. This then groups the edges which come from the same app_vertex If the (machine) edge.pre_vertex has no app vertex then the app_id will be the machine vertex which will then form its own group of 1
Return type: dict(ApplicationVertex, dict(str, set(MachineVertex))
-
new_edge_partition
(name, edge)[source]¶ How we create a new
AbstractSingleSourcePartition
in the first place. Uses the first/only element in the allowed partition types argument to the graph’s constructor.Called from
add_edge()
. Can be overridden if different arguments should be passed.Parameters: - name (str) – The identifier of the partition
- edge (AbstractEdge) – An edge for the partition
Returns: the new edge partition
Return type:
-
outgoing_edge_partitions
¶ The edge partitions in the graph.
Return type: iterable(AbstractEdgePartition)
-
class
pacman.model.graphs.machine.
MachineGraphView
(other)[source]¶ Bases:
pacman.model.graphs.machine.machine_graph.MachineGraph
A frozen view of a Machine Graph
As this shares all the same objects as the graph it is a view over except for the class and id. So any changes to the other are reflected.
All methods that allow changes to the graph should be disabled.
-
add_edge
(edge, outgoing_edge_partition_name)[source]¶ Add an edge to the graph and its partition
If required and possible will create a new partition in the graph
Returns the partition the edge was added to
Parameters: - edge (AbstractEdge) – The edge to add
- outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex
Return type: Raises: PacmanInvalidParameterException – If the edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one
-
add_outgoing_edge_partition
(edge_partition)[source]¶ Add an edge partition to the graph.
Will also add any edges already in the partition as well
Parameters: edge_partition (AbstractEdgePartition) – The edge partition to add Raises: PacmanAlreadyExistsException – If a partition already exists with the same pre_vertex and identifier
-
add_vertex
(vertex)[source]¶ Add a vertex to the graph.
Parameters: vertex (AbstractVertex) – The vertex to add
Raises: - PacmanInvalidParameterException – If the vertex is not of a valid type
- PacmanConfigurationException – If there is an attempt to add the same vertex more than once
-
-
class
pacman.model.graphs.machine.
MachineSpiNNakerLinkVertex
(spinnaker_link_id, board_address=None, label=None, constraints=None, app_vertex=None, vertex_slice=None)[source]¶ Bases:
pacman.model.graphs.machine.machine_vertex.MachineVertex
,pacman.model.graphs.abstract_spinnaker_link.AbstractSpiNNakerLink
A virtual vertex on a SpiNNaker Link.
-
board_address
¶ The IP address of the board to which the device is connected, or
None
for the boot board.Return type: str
-
resources_required
¶ The resources required by the vertex
Return type: ResourceContainer
-
set_virtual_chip_coordinates
(virtual_chip_x, virtual_chip_y)[source]¶ Set the details of the virtual chip that has been added to the machine for this vertex.
Parameters:
-
-
class
pacman.model.graphs.machine.
MachineVertex
(label=None, constraints=None, app_vertex=None, vertex_slice=None)[source]¶ Bases:
pacman.model.graphs.abstract_vertex.AbstractVertex
A machine graph vertex.
Parameters: - label (str or None) – The optional name of the vertex
- constraints (iterable(AbstractConstraint) or None) – The optional initial constraints of the vertex
- app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.
- vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.
Raises: - PacmanInvalidParameterException – If one of the constraints is not valid
- PacmanValueError – If the slice of the machine_vertex is too big
- AttributeError – If a not None app_vertex is not an ApplicationVertex
-
app_vertex
¶ - The application vertex that caused this machine vertex to be
- created. If None, there is no such application vertex.
Return type: ApplicationVertex or None
-
get_n_keys_for_partition
(_partition)[source]¶ Get the number of keys required by the given partition of edges.
Parameters: _partition (OutgoingEdgePartition) – An partition that comes out of this vertex Returns: The number of keys required Return type: int
-
resources_required
¶ The resources required by the vertex
Return type: ResourceContainer
-
class
pacman.model.graphs.machine.
MulticastEdgePartition
(pre_vertex, identifier, constraints=None, label=None, traffic_weight=1)[source]¶ Bases:
pacman.model.graphs.abstract_single_source_partition.AbstractSingleSourcePartition
,pacman.model.graphs.machine.abstract_machine_edge_partition.AbstractMachineEdgePartition
A simple implementation of a machine edge partition that will communicate with SpiNNaker multicast packets. They have a common set of sources with the same semantics and so can share a single key.
Parameters: - pre_vertex – the pre vertex of this partition.
- identifier (str) – The identifier of the partition
- constraints (list(AbstractConstraint)) – Any initial constraints
- label (str) – An optional label of the partition
- traffic_weight (int) – The weight of traffic going down this partition
-
add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters: - edge (AbstractEdge) – the edge to add
- graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges Return type: MulticastEdgePartition
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType
-
class
pacman.model.graphs.machine.
SDRAMMachineEdge
(pre_vertex, post_vertex, label, app_edge=None)[source]¶ Bases:
pacman.model.graphs.machine.machine_edge.MachineEdge
-
DISAGREEMENT_MESSAGE
= 'The pre vertex sdram size {} does not agree with the post vertex sdram size {}. The SDRAM machine edge does not yet know how to handle this case. Please fix and try again.'¶
-
NO_SUPPORT_MESSAGE
= "The {}vertex {} does not implement the AbstractSupportsSDRAMEdges API that can be found at ' pacman.model.graphs.abstract_supports_sdram_edges '. Please fix and try again so that sdram edge {} can know its required size."¶
-
sdram_base_address
¶
-
sdram_size
¶
-
-
class
pacman.model.graphs.machine.
SimpleMachineVertex
(resources, label=None, constraints=None, app_vertex=None, vertex_slice=None)[source]¶ Bases:
pacman.model.graphs.machine.machine_vertex.MachineVertex
A MachineVertex that stores its own resources.
- This class is mainly intended for json and testing as it support the
- mininal API. If a more complex Vertex is required consider the MockMachineVertex.
-
resources_required
¶ The resources required by the vertex
Return type: ResourceContainer
-
class
pacman.model.graphs.machine.
SourceSegmentedSDRAMMachinePartition
(identifier, label, pre_vertices)[source]¶ Bases:
pacman.model.graphs.abstract_multiple_partition.AbstractMultiplePartition
,pacman.model.graphs.machine.abstract_sdram_partition.AbstractSDRAMPartition
An SDRAM partition that gives each edge its own slice of memory from a contiguous block. The edges all have the same destination vertex.
Parameters: - identifier (str) – The identifier of the partition
- label (str) – A label of the partition
- pre_vertices (iterable(AbstractVertex)) – The vertices that an edge in this partition may originate at
-
add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters: - edge (AbstractEdge) – the edge to add
- graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition
-
clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges Return type: SourceSegmentedSDRAMMachinePartition
-
get_sdram_base_address_for
(vertex)[source]¶ Get the SDRAM base address for a edge given which side the vertex is on.
Parameters: vertex – the vertex to find SDRAM base address of Returns: the SDRAM address for this vertex
-
get_sdram_size_of_region_for
(vertex)[source]¶ Get the size of the region for a vertex given a edge.
Parameters: vertex – the vertex to find SDRAM size of Returns: the SDRAM size for this vertex
-
traffic_type
¶ The traffic type of all the edges in this edge partition.
Note
The reason for a abstract property which all machine outgoing partitions is purely due the need for multiple slots and python’s lack of support for this.
Return type: EdgeTrafficType