spinn_machine.data package¶
Submodules¶
spinn_machine.data.machine_data_writer module¶
- class spinn_machine.data.machine_data_writer.MachineDataWriter(state: DataStatus)[source]¶
Bases:
UtilsDataWriter,MachineDataViewSee UtilsDataWriter.
This class is designed to only be used directly within the SpiNNMachine repository unit tests as all methods are available to subclasses.
- Parameters:
state – State writer should be in
- add_monitor_core(all_chips: bool) None[source]¶
Accepts a simple of the monitor cores to be added.
Called by PacmanDataWriter add_sample_monitor_vertex.
Only affect is to change the numbers reported by the get_all/ethernet_monitor methods.
- Parameters:
all_chips – If True assumes that this Vertex will be placed on all chips including Ethernet ones. If False assumes that this Vertex type will only be placed on Ethernet Vertices
- clear_machine() None[source]¶
Clears any previously set machine and any data related to the Machine
Warning
Designed to only be used by ASB to remove a machine when something went wrong before it could be returned from get machine
- get_user_accessed_machine() bool[source]¶
Reports if …View.get_machine has been called outside of sim.run.
Designed to only be used from ASB. Any other use is not supported
- Returns:
True if get_machine has been called other than by the run process
- set_machine(machine: Machine) None[source]¶
Sets the machine.
- Parameters:
machine
- Raises:
TypeError – it the machine is not a Machine
- set_n_chips_in_graph(n_chips_in_graph: int) None[source]¶
Sets the number of chips needed by the graph.
- set_n_required(n_boards_required: int | None, n_chips_required: int | None) None[source]¶
Sets (if not None) the number of boards/chips requested by the user.
- Parameters:
n_boards_required – None or the number of boards requested by the user
n_chips_required – None or the number of chips requested by the user
Module contents¶
- class spinn_machine.data.MachineDataView¶
Bases:
UtilsDataViewAdds the extra Methods to the View for Machine level.
See
UtilsDataViewfor a more detailed description.This class is designed to only be used directly within the SpiNNMachine repository as all methods are available to subclasses
- classmethod get_all_monitor_cores() int[source]¶
The number of cores on every chip reported to be used by monitor vertices.
Ethernet-enabled chips may have more.
Does not include the system core reserved by the machine/ scamp.
- Returns:
The number of core that will be allocated for special monitor on each none Ethernet Chip
- classmethod get_chip_at(x: int, y: int) Chip[source]¶
Gets the chip at (x, y).
Almost Semantic sugar for get_machine()[x, y]
The method however does not return None but rather raises a KeyError if the chip is not known
- Parameters:
x
y
- Returns:
The Chip or bust
- Raises:
SpiNNUtilsException – If the machine is currently unavailable
KeyError – If the chip does not exist but the machine does
- classmethod get_ethernet_monitor_cores() int[source]¶
The number of cores on every Ethernet chip reported to be used by monitor vertices.
This includes the one returned by get_all_monitor_cores unless for some reason these are not on Ethernet chips.
Does not include the system core reserved by the machine/ scamp.
- Returns:
The number of core that will be allocated for special monitor on each Ethernet Chip
- classmethod get_machine() Machine[source]¶
Returns the Machine if it has been set.
In Mock mode will create and return a virtual 8 * 8 board
- ..note::
Unlike sim.get_machine this method does not protect against inconstancy of Machine if reset has or will be called.
- Returns:
The already existing Machine or Virtual 8 * 8 Machine.
- Raises:
SpiNNUtilsException – If the machine is currently unavailable
- classmethod get_machine_version() AbstractVersion[source]¶
Returns the Machine Version if it has or can be set.
May call version_factory to create the version.
- Returns:
A superclass of AbstractVersion
- Raises:
SpinnMachineException – If the cfg version is not set correctly
- classmethod get_n_boards_required() int[source]¶
Gets the number of boards requested by the user during setup if known.
Guaranteed to be positive
- Returns:
The number of boards requested by the user
- Raises:
SpiNNUtilsException – If the n_boards_required is currently unavailable
- classmethod get_n_chips_needed() int[source]¶
Gets the number of chips needed, if set.
This will be the number of chips requested by the user during setup, even if this is less that what the partitioner reported.
If the partitioner has run and the user has not specified a number, this will be what the partitioner requested.
Guaranteed to be positive if set
- Returns:
the number of chips needed
- Raises:
SpiNNUtilsException – If data for n_chips_needed is not available
- classmethod get_nearest_ethernet(x: int, y: int) Tuple[int, int][source]¶
Gets the nearest Ethernet-enabled chip (x, y) for the chip at (x, y) if it exists.
If there is no machine or no chip at (x, y) this method, or any other issue will just return (x, y)
Note
This method will never request a new machine. Therefore a call to this method will not trigger a hard reset
- Parameters:
x – Chip X coordinate
y – Chip Y coordinate
- Returns:
Chip (x,`y`)’s nearest_ethernet info or if that is not available just (x, y)
- classmethod get_physical_core_id(xy: Tuple[int, int], virtual_p: int) int[source]¶
Get the physical core ID from a virtual core ID.
Note: This call only works for Version 1
- Parameters:
xy – The Chip or its XY coordinates
virtual_p – The virtual core ID
- Returns:
The physical ID for the core on machine
- Raises:
SpiNNUtilsException – If v_to_p map not set, including if the MachineVersion does not support v_to_p_map
KeyError – If xy not in the v_to_p_map
IndexError – If virtual_p not in the v_to_p_map[xy]
- classmethod get_physical_quad(virtual_p: int) Tuple[int, int, int][source]¶
Returns the quad qx, qy and qp for this virtual id
Does not include XY so does not check if the Core exists on a Chip
- Parameters:
virtual_p
- Raises:
SpiNNUtilsException – If quad_map map not set, MachineVersion does not support quad_map
KeyError – If virtual_p not in the quad_map
- Returns:
A report / debug representation of the Chip and physical quad
- classmethod get_physical_string(xy: Tuple[int, int], virtual_p: int) str[source]¶
Returns a String representing the physical core
- Parameters:
xy – The Chip or its XY coordinates
virtual_p – The virtual (python) id for the core
- Returns:
A report / debug representation of the Chip and physical core
- classmethod has_existing_machine() bool[source]¶
Reports if a machine is currently already created.
Unlike has_machine this method returns false if a machine could be mocked
- Returns:
True if a Machine has already been created.
- classmethod has_machine() bool[source]¶
Reports if a machine is currently set or can be mocked.
Unlike has_existing_machine for unit tests this will return True even if a Machine has not yet been created
- Returns:
True if a Machine is available. (Already read Physically or can be Mocked if needed)
- classmethod has_n_boards_required() bool[source]¶
Reports if a user has sets the number of boards requested during setup.
- Returns:
True if the user has sets the number of boards requested
- Raises:
SpiNNUtilsException – If n_boards_required is not set or set to None
- classmethod has_n_chips_needed() bool[source]¶
Detects if the number of chips needed has been set.
This will be the number of chips requested by the use during setup or what the partitioner requested.
- Returns:
True if the number of required chips is known
- classmethod set_v_to_p_map(v_to_p_map: Dict[Tuple[int, int], bytes]) None[source]¶
Registers the mapping from Virtual to int physical core ids
Note: Only expected to be used in Version 1
- Parameters:
v_to_p_map
- classmethod where_is_chip(chip: Chip) str[source]¶
Gets a string saying where chip is if possible.
Almost Semantic sugar for get_machine().where_is_chip()
The method does not raise an exception rather returns a String of the exception
Note
This method will never request a new machine. Therefore a call to this method will not trigger a hard reset
- Parameters:
chip
- Returns:
A human-readable description of the location of a chip.
- classmethod where_is_xy(x: int, y: int) str[source]¶
Gets a string saying where chip at x and y is if possible.
Almost Semantic sugar for get_machine().where_is_xy()
The method does not raise an exception rather returns a String of the exception
Note
This method will never request a new machine. Therefore a call to this method will not trigger a hard reset
- Parameters:
x
y
- Returns:
A human-readable description of the location of a chip.