pacman.model.routing_info package¶
Module contents¶
- class pacman.model.routing_info.AppVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, app_vertex: ApplicationVertex, max_machine_index: int, machine_mask: int)¶
Bases:
VertexRoutingInfoRouting information for an application vertex.
- Parameters:
key_and_mask
partition_id
app_vertex
max_machine_index
machine_mask
- property app_mask: int¶
The application mask for the vertices
This includes both the Application index and the machine index
- property app_vertex: ApplicationVertex¶
The Application vertex of the information.
If the vertex is a Machine Vertex returns its application vertex
- merge_machine_entries(entries: List[Tuple[RoutingEntry, MachineVertexRoutingInfo]]) Iterable[MulticastRoutingEntry][source]¶
Merge the machine entries.
- Parameters:
entries – The entries to merge
- Returns:
The routing info in the merged/ multicast format.
- Raises:
PacmanValueError – If the masks are not shiftable
- property vertex: ApplicationVertex¶
The vertex of the information.
- class pacman.model.routing_info.BaseKeyAndMask(base_key: int, mask: int)¶
Bases:
objectA Key and Mask to be used for routing.
- Parameters:
base_key – The routing key
mask – The routing mask
- Raises:
PacmanConfigurationException – If key & mask != key i.e. the key is not valid for the given mask
- get_keys(key_array: ndarray | None = None, offset: int = 0, n_keys: int | None = None) Tuple[ndarray, int][source]¶
Get the ordered list of keys that the combination allows.
- Parameters:
key_array – Optional array into which the returned keys will be placed
offset – Optional offset into the array at which to start placing keys
n_keys – Optional limit on the number of keys returned. If less than this number of keys are available, only the keys available will be added
- Returns:
A tuple of an array of keys and the number of keys added to the array
- class pacman.model.routing_info.FixedAppVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, app_vertex: ApplicationVertex, max_machine_index: int, machine_mask: int)¶
Bases:
AppVertexRoutingInfoRouting information for an application vertex with fixed keys and masks
This class is used even if the fixed masks are the global ones.
:param key_and_mask :param partition_id: :param app_vertex: :param machine_mask: :param max_machine_index:
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- property has_global_machine_masks: bool¶
True if all masks machine are the global ones defined by the zones
- class pacman.model.routing_info.FixedMachineVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, machine_vertex: MachineVertex, index: int, app_key_and_mask: BaseKeyAndMask)¶
Bases:
MachineVertexRoutingInfoAssociates a machine vertex and partition identifier to its routing information (keys and masks).
This is used then the Vertex has fixed masks even if they are the global ones.
- Parameters:
key_and_mask – The key and mask associated to the partition
partition_id – The partition to set the keys for
machine_vertex – The vertex to set the keys for
index – The index of the machine vertex
app_key_and_mask – The application key and mask
- get_atom_bits_needed_range() Tuple[int, int][source]¶
The range of atom bit values that this info can support.
Based on the Application and Machine keys it may be able to alter the Application Mask without changing now results.
The number of atom bits will be large enough to not blank out any ones in the application key but also small enough to blank out the machine index. (The part of the Machine key that are not also application key)
- Returns:
Smallest and largest application zone supportable
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- property has_global_machine_masks: bool¶
True if all masks machine are the global ones defined by the zones
- class pacman.model.routing_info.GlobalAppVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, app_vertex: ApplicationVertex, max_machine_index: int, machine_mask: int)¶
Bases:
AppVertexRoutingInfoRouting information for an application vertex.
This info come from a Vertex without fixed keys
- Parameters:
key_and_mask
partition_id
app_vertex
max_machine_index
machine_mask
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- class pacman.model.routing_info.GlobalMachineVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, machine_vertex: MachineVertex, index: int, app_mask: int)¶
Bases:
MachineVertexRoutingInfoAssociates a machine vertex and partition identifier to its key.
The Vertex will not have fixed keys.
- Parameters:
key_and_mask – The key and mask associated to the partition
partition_id – The partition to set the keys for
machine_vertex – The vertex to set the keys for
index – The index of the machine vertex
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- class pacman.model.routing_info.MachineVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, machine_vertex: MachineVertex, index: int, app_mask: int)¶
Bases:
VertexRoutingInfoAssociates a machine vertex and partition identifier to its routing information (keys and masks).
- Parameters:
key_and_mask – The key and mask associated to the partition
partition_id – The partition to set the keys for
machine_vertex – The vertex to set the keys for
index – The index of the machine vertex
- property app_mask: int¶
The application mask for the vertices
This includes both the Application index and the machine index
- property app_vertex: ApplicationVertex¶
The Application vertex of the information.
If the vertex is a Machine Vertex returns its application vertex
- property machine_mask: int¶
The machine mask as reported by the vertex
This includes both the Application index and the machine index
- property machine_vertex: MachineVertex¶
The machine vertex.
- property vertex: MachineVertex¶
The vertex of the information.
- class pacman.model.routing_info.RoutingInfo¶
Bases:
objectAn association of machine vertices to a non-overlapping set of keys and masks.
- add_routing_info(info: VertexRoutingInfo) None[source]¶
Add a routing information item.
- Parameters:
info – The routing information item to add
- Raises:
PacmanAlreadyExistsException – If the partition is already in the set of edges
- add_zones(min_bits_machine_and_atoms: int, max_bits_machine: int, max_bits_atoms: int, size_app_part_bits: int, target_app_bits: int, target_machine_bits: int, target_atom_bits: int) None[source]¶
Copy in the zone info from the allocator
- Parameters:
min_bits_machine_and_atoms
max_bits_machine
max_bits_atoms
size_app_part_bits
target_app_bits
target_machine_bits
target_atom_bits
- Returns:
- check_info_from(vertex: AbstractVertex, allowed_partition_ids: Set[str]) None[source]¶
Check that the partition ids for a vertex are in the allowed set.
- Parameters:
vertex – The vertex to search for
allowed_partition_ids – The allowed partition ids
- Raises:
KeyError – If the vertex has an unknown partition ID
- get_info_from(vertex: AbstractVertex, partition_id: str) VertexRoutingInfo[source]¶
- Parameters:
vertex – The vertex to search for
partition_id – The ID of the partition for which to get the routing information
- Returns:
Routing information for a given partition_id from a vertex.
- Raises:
KeyError – If the vertex/partition_id combination is not in the routing information
- get_key_from(vertex: AbstractVertex, partition_id: str) int[source]¶
Get the first key for the partition starting at a vertex.
- Parameters:
vertex – The vertex which the partition starts at
partition_id – The ID of the partition for which to get the routing information
- Returns:
The routing key of the partition
- Raises:
KeyError – If the vertex/partition_id combination is not in the routing information
- get_partitions_from(vertex: AbstractVertex) Iterable[str][source]¶
Get the outgoing partitions from a vertex.
- Parameters:
vertex – The vertex to search for
- Returns:
The partition ids for routes from this Vertex
- get_single_info_from(vertex: AbstractVertex) VertexRoutingInfo | None[source]¶
Get routing information for a given vertex. Fails if the vertex has more than one outgoing partition.
- Parameters:
vertex – The vertex to search for
- Returns:
The only routing from this vertex
- Raises:
KeyError – If the vertex has more than one outgoing partition
- get_single_key_from(vertex: AbstractVertex) int | None[source]¶
Get the first key for the partition starting at a vertex. Fails if the vertex has more than one outgoing partition.
- Parameters:
vertex – The vertex which the partition starts at
- Returns:
The key of the only route from this vertex
- Raises:
KeyError – If the vertex has more than one outgoing partition
- property global_app_mask: int¶
The default app mask for all infos.
Used for all info except possibly fixed ones
- property global_machine_mask: int¶
The default Machine Masks for all infos.
May not be used if there are fixed masks or a combination of Vertices with cores and others with a larger number of atoms per core.
- property has_app_keys_overlap: bool¶
True if infos have the same app_key for multiple Application vertices
- property has_fixed_keys: bool¶
True if ANY vertex requires fixed keys and masks
Fixed keys may be global
- property has_global_app_masks: bool¶
True if all app masks in ALL infos are global ones defined by the zones
- property has_global_machine_masks: bool¶
True if all app masks in ALL infos are global ones defined by the zones
- has_info_from(vertex: AbstractVertex, partition_id: str) bool[source]¶
Check if there is routing information for a given vertex and ID.
- Parameters:
vertex – The vertex to search for
partition_id – The ID of the partition for which to get the routing information
- Returns:
True if there is a route from this vertex for this partition.
- property is_machine_shiftable: bool¶
Flag to say all infos are Machine mask shiftable
True if no info.machine_shift will cause an exception
- property max_bits_machine: int¶
Maximum number of bits to represent the machine indexes for any vertex
- property min_bits_machine_and_atoms: int¶
Minimum size needed for the combined machine and atoms zone
This is the maximum needed to represent the keys and masks for a single app vertex / partition ID
- property size_app_part_bits: int¶
Size of the App vertex / Partition name zone
This is the calculated size ignoring fixed keys.
- property target_app_bits: int¶
Size of the application partition ID part for keys.
This is the number of application bits used by all vertices.
It will be at least as big as size_app_part_bits
It may go as big as the bits not needed by min_bits_machine_and_atoms.
Ideally it will be the bits not needed by max_bits_machine and max_bits_atoms.
If there are fixed keys this will be a value that works with the fixed keys and meets the above min and max.
- class pacman.model.routing_info.SpecificAppVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, app_vertex: ApplicationVertex, max_machine_index: int, machine_mask: int, global_machine_mask: int)¶
Bases:
AppVertexRoutingInfoRouting information for an application vertex.
In these the global Machine Mask is not used.
- Parameters:
key_and_mask
partition_id
app_vertex
machine_mask
max_machine_index
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- class pacman.model.routing_info.SpecificMachineVertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str, machine_vertex: MachineVertex, index: int, app_mask: int, global_machine_mask: int)¶
Bases:
MachineVertexRoutingInfoAssociates a machine vertex and partition identifier to its routing information (keys and masks).
The global Machine mask is not used, the global application mask is still used
- Parameters:
key_and_mask – The key and mask associated to the partition
partition_id – The partition to set the keys for
machine_vertex – The vertex to set the keys for
index – The index of the machine vertex
app_mask – The application mask
global_machine_mask – The global machine mask
- property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- class pacman.model.routing_info.VertexRoutingInfo(key_and_mask: BaseKeyAndMask, partition_id: str)¶
Bases:
objectAssociates a partition identifier to its routing information (keys and masks).
- Parameters:
key_and_mask – The key and mask associated to the partition
partition_id – The partition to set the keys for
- property app_mask: int¶
The application mask for the vertices
This includes both the Application index and the machine index
- abstract property app_vertex: ApplicationVertex¶
The Application vertex of the information.
If the vertex is a Machine Vertex returns its application vertex
- get_keys(n_keys: int | None = None) ndarray[source]¶
Get the ordered list of individual keys allocated to the edge.
- Parameters:
n_keys – Optional limit on the number of keys to return
- Returns:
An array of keys
- abstract property global_app_mask: int¶
The global application mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- property global_app_shift: int¶
The shift global for the application zone.
This is a class method so will be the same value for all Vertices.
For Fixed Masks this may not be the shift of the actual Application mask but is a value that will work.
- abstract property global_machine_mask: int¶
The global machine mask used by the allocator
As this is a class method this is reported by all infos even ones that do not respect it.
- abstract property has_app_keys_overlap: bool¶
True unless the allocator has marked this info as having an overlap
- abstract property has_fixed_keys: bool¶
True if the vertex requires fixed
Fixed keys may be shiftable and even global
- abstract property has_global_app_masks: bool¶
True if all masks are the global ones defined by the zones
While all infos will work with the global shift they may not actually have the global app mask.
- abstract property has_global_machine_masks: bool¶
True if all masks machine are the global ones defined by the zones
- property is_machine_shiftable: bool¶
Flag to say the Machine mask is shiftable
True if machine_shift will not cause an exception
- property key_and_mask: BaseKeyAndMask¶
The only key and mask.
- property machine_index_mask: int¶
The mask for the zone with the machine index.
Semantic sugar for app mask minus the machine mask.
This includes ONLY the machine index and not the Application index.
May be an empty mask for fixed vertices with one app one Machine
- abstract property machine_mask: int¶
The machine mask as reported by the vertex
This includes both the Application index and the machine index
- property machine_shift: int¶
The shift for the machine zone.
- Raises:
PacmanValueError – If the mask is not shiftable
- abstractmethod set_app_keys_overlap() None[source]¶
Flags the info as sharing an app key with another info
That is the key here shifted by the global app shit will result in the same value as another info with a different app_vertex or partition ID
- set_global_masks(app_mask: int, machine_mask: int) None[source]¶
Sets the global masks once the allocator has picked them
- abstract property vertex: AbstractVertex¶
The vertex of the information.