Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1dc95fb
View handles add Machine vertex
Christian-B Oct 21, 2025
ce4a371
more view methods
Christian-B Oct 21, 2025
696c41c
seperate machine add methods
Christian-B Oct 21, 2025
0f9aae2
unused import
Christian-B Oct 21, 2025
0238d02
move data_utils
Christian-B Oct 21, 2025
e4098a2
load cofigs from config setuip classes
Christian-B Oct 24, 2025
5894781
move move_set_n_required down
Christian-B Oct 24, 2025
d5500a8
set_up_timings timstep in ms
Christian-B Oct 27, 2025
56b1c2c
push down set_up_timings
Christian-B Oct 27, 2025
26ec0ec
timestep in milli seconds
Christian-B Oct 27, 2025
a70c3c3
remove unused imports
Christian-B Oct 27, 2025
fc0aba0
Merge branch 'move_set_n_required' into simulator_clean
Christian-B Oct 27, 2025
a5e71a9
keyword argumenets for init
Christian-B Oct 27, 2025
f298e98
AbstractSpiNNManSimulation
Christian-B Oct 27, 2025
8df5d8a
remove spaces around keyword
Christian-B Oct 27, 2025
daaa8ad
Merge remote-tracking branch 'origin/set_cfg_file_name' into simulato…
Christian-B Oct 29, 2025
a93a2e1
Merge branch 'move_data_utils' into simulator_clean
Christian-B Oct 29, 2025
72912b0
Merge remote-tracking branch 'origin/view_work' into simulator_clean
Christian-B Oct 29, 2025
0b1fda0
param docs
Christian-B Oct 29, 2025
3ad627b
returns docs
Christian-B Oct 29, 2025
b99317d
two levels of doc checks
Christian-B Oct 29, 2025
9442214
flake8
Christian-B Oct 29, 2025
5d6821c
config template changes
Christian-B Oct 30, 2025
7ffd29d
SpiNNaker
Christian-B Oct 30, 2025
a1b7fb3
Merge branch 'set_cfg_file_name' into simulator_clean
Christian-B Oct 30, 2025
0c5f1ff
Merge remote-tracking branch 'origin/docs_fix' into simulator_clean
Christian-B Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from spinn_front_end_common.abstract_models.impl import (
MachineDataSpecableVertex)
from spinnaker_graph_front_end.utilities import SimulatorVertex
from spinnaker_graph_front_end.utilities.data_utils import (
from spinn_front_end_common.utilities.data_utils import (
generate_system_data_region)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import (
get_recording_data_constant_size, get_recording_header_size)
from spinnaker_graph_front_end.utilities import SimulatorVertex
from spinnaker_graph_front_end.utilities.data_utils import (
from spinn_front_end_common.utilities.data_utils import (
generate_system_data_region)


Expand Down
2 changes: 1 addition & 1 deletion gfe_examples/hello_world_untimed/hello_world_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
recording_utilities)
from spinn_front_end_common.interface.ds import DataSpecificationGenerator
from spinnaker_graph_front_end.utilities import SimulatorVertex
from spinnaker_graph_front_end.utilities.data_utils import (
from spinn_front_end_common.utilities.data_utils import (
generate_steps_system_data_region)
import numpy

Expand Down
2 changes: 1 addition & 1 deletion gfe_examples/sync_test/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

front_end.setup(
n_boards_required=3, model_binary_folder=os.path.dirname(__file__),
machine_time_step=500000, time_scale_factor=1)
timestep=500, time_scale_factor=1)

machine = front_end.machine()
boot_chip = machine.boot_chip
Expand Down
2 changes: 1 addition & 1 deletion gfe_examples/sync_test/sync_test_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from spinn_front_end_common.abstract_models import (
AbstractGeneratesDataSpecification, AbstractHasAssociatedBinary)

from spinnaker_graph_front_end.utilities.data_utils import (
from spinn_front_end_common.utilities.data_utils import (
generate_system_data_region)
from pacman.model.graphs.application.abstract import (
AbstractOneAppOneMachineVertex)
Expand Down
45 changes: 18 additions & 27 deletions spinnaker_graph_front_end/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@

from pacman.model.graphs.application import (
ApplicationEdge, ApplicationVertex)
from pacman.model.graphs.application.abstract import (
AbstractOneAppOneMachineVertex)
from pacman.model.graphs.machine import MachineEdge, MachineVertex
from pacman.model.routing_info import RoutingInfo
from pacman.model.tags import Tags
Expand Down Expand Up @@ -96,7 +94,7 @@ def setup(model_binary_module: Optional[ModuleType] = None,
n_chips_required: Optional[int] = None,
n_boards_required: Optional[int] = None,
time_scale_factor: Optional[int] = None,
machine_time_step: Optional[int] = None) -> None:
*, timestep: Optional[int] = None) -> None:
"""
Set up a graph, ready to have vertices and edges added to it, and the
simulator engine that will execute the graph.
Expand Down Expand Up @@ -124,6 +122,11 @@ def setup(model_binary_module: Optional[ModuleType] = None,
your graph, then fill this in with a general idea of the number of
boards you need so that the spalloc system can allocate you a machine
big enough for your needs.
:param time_scale_factor: multiplicative factor to the machine time step
(does not affect the models accuracy)
:param timestep:
the time step of the simulations in microseconds;
if `None`, the configuration value is used
:raise ~spinn_front_end_common.utilities.exceptions.ConfigurationException:
if mutually exclusive options are given.
"""
Expand Down Expand Up @@ -155,7 +158,7 @@ def setup(model_binary_module: Optional[ModuleType] = None,
__simulator = SpiNNaker(
n_chips_required=n_chips_required,
n_boards_required=n_boards_required,
machine_time_step=machine_time_step,
timestep=timestep,
time_scale_factor=time_scale_factor)
FecDataView.add_database_socket_addresses(database_socket_addresses)

Expand Down Expand Up @@ -236,11 +239,7 @@ def add_machine_vertex_instance(machine_vertex: MachineVertex) -> None:
:param machine_vertex:
The vertex to add
"""
app_vertex = AbstractOneAppOneMachineVertex(
machine_vertex, machine_vertex.label)
FecDataView.add_vertex(app_vertex)
# pylint: disable=protected-access
machine_vertex._app_vertex = app_vertex
FecDataView.add_machine_vertex(machine_vertex)


def add_machine_edge_instance(edge: MachineEdge, partition_id: str) -> None:
Expand All @@ -252,11 +251,7 @@ def add_machine_edge_instance(edge: MachineEdge, partition_id: str) -> None:
:param partition_id:
The ID of the partition that the edge belongs to.
"""
pre_app = edge.pre_vertex.app_vertex
assert pre_app is not None
post_app = edge.post_vertex.app_vertex
assert post_app is not None
FecDataView.add_edge(ApplicationEdge(pre_app, post_app), partition_id)
FecDataView.add_machine_edge(edge, partition_id)


def add_socket_address(database_ack_port_num: Optional[int],
Expand All @@ -272,32 +267,28 @@ def add_socket_address(database_ack_port_num: Optional[int],
:param database_notify_port_num:
port that the external device will be notified on.
"""
database_socket = SocketAddress(
listen_port=database_ack_port_num,
notify_host_name=database_notify_host,
notify_port_no=database_notify_port_num)

FecDataView.add_database_socket_address(database_socket)
FecDataView.add_database_socket_port(
database_ack_port_num, database_notify_host, database_notify_port_num)


def get_number_of_available_cores_on_machine() -> int:
"""
Get the number of cores on this machine that are available to the
:returns: The number of cores on this machine that are available to the
simulation.
"""
return __get_simulator().get_number_of_available_cores_on_machine


def has_ran() -> bool:
"""
Get whether the simulation has already run.
:returns: True if and only if the simulation has already run.
"""
return FecDataView.is_ran_ever()


def routing_infos() -> RoutingInfo:
"""
Get information about how messages are routed on the machine.
:returns: The information about how messages are routed on the machine.
"""
return FecDataView.get_routing_infos()

Expand Down Expand Up @@ -328,21 +319,21 @@ def placements() -> Never:

def tags() -> Tags:
"""
Get the IPTAGs allocated on the machine.
:returns: The IPTAGs allocated on the machine.
"""
return FecDataView.get_tags()


def buffer_manager() -> BufferManager:
"""
Get the buffer manager being used for loading/extracting buffers.
:returns: The buffer manager being used for loading/extracting buffers.
"""
return FecDataView.get_buffer_manager()


def machine() -> Machine:
"""
Get the model of the attached/allocated machine.
:returns: The model of the attached/allocated machine.
"""
logger.warning(
"If you are getting the machine object to locate how many cores you "
Expand All @@ -355,7 +346,7 @@ def machine() -> Machine:

def is_allocated_machine() -> bool:
"""
Get whether a machine is allocated.
:return: True if and only if a machine is allocated.
"""
return FecDataView.has_machine()

Expand Down
30 changes: 11 additions & 19 deletions spinnaker_graph_front_end/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,20 @@

import os
from spinn_utilities.config_holder import (
clear_cfg_files, set_cfg_files)
from spinn_front_end_common.interface.config_setup import (
add_default_cfg, add_spinnaker_cfg)
add_default_cfg, clear_cfg_files)
from spinn_front_end_common.interface.config_setup import add_spinnaker_cfg
from spinn_front_end_common.data.fec_data_writer import FecDataWriter

#: The name of the configuration file
CONFIG_FILE_NAME = "spiNNakerGraphFrontEnd.cfg"
GFE_CFG = "spiNNakerGraphFrontEnd.cfg"


def setup_configs() -> None:
def add_gfe_cfg() -> None:
"""
Sets up the configurations including the user's configuration file.

Clears out any previous read configurations but does not load the new
configurations so a warning is generated if a configuration is used before
:py:func:`~spinnaker_graph_front_end.setup` is called.
Adds the Graph Front end cfg default file and all previous ones
"""
clear_cfg_files(False)
add_spinnaker_cfg() # This add its dependencies too
set_cfg_files(
config_file=CONFIG_FILE_NAME,
default=os.path.join(os.path.dirname(__file__), CONFIG_FILE_NAME))
FecDataWriter.mock()
add_default_cfg(os.path.join(os.path.dirname(__file__), GFE_CFG))


def unittest_setup() -> None:
Expand All @@ -51,12 +42,13 @@ def unittest_setup() -> None:
included.
The user configuration is *not* included!

Unsets any previous simulators and temporary directories.
Actual loading of the cfg file is done by config_holder
if and only if config values are needed.

.. note::
This file should only be called from spinnaker_graph_front_end tests
This method should only be called from spinnaker_graph_front_end tests
that do not call :py:func:`~spinnaker_graph_front_end.setup`.
"""
clear_cfg_files(True)
add_spinnaker_cfg() # This add its dependencies too
add_default_cfg(os.path.join(os.path.dirname(__file__), CONFIG_FILE_NAME))
add_gfe_cfg()
FecDataWriter.mock()
35 changes: 25 additions & 10 deletions spinnaker_graph_front_end/spinnaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
# limitations under the License.

import logging
from typing import Optional
from typing import Optional, Type

from spinn_utilities.config_holder import is_config_none
from spinn_utilities.log import FormatAdapter
from spinn_utilities.overrides import overrides

from spinn_front_end_common.data import FecDataView
from spinn_front_end_common.data.fec_data_writer import FecDataWriter
from spinn_front_end_common.interface.abstract_spinnaker_base import (
AbstractSpinnakerBase)
from spinn_front_end_common.interface.config_setup import (
add_spinnaker_template)
from spinn_front_end_common.interface.provenance import GlobalProvenance

from spinnaker_graph_front_end.config_setup import setup_configs
from spinnaker_graph_front_end.config_setup import add_gfe_cfg, GFE_CFG
from ._version import __version__ as version

logger = FormatAdapter(logging.getLogger(__name__))
Expand All @@ -49,7 +53,7 @@ def __init__(
self, n_chips_required: Optional[int] = None,
n_boards_required: Optional[int] = None,
time_scale_factor: Optional[int] = None,
machine_time_step: Optional[int] = None):
timestep: Optional[int] = None):
"""
:param n_chips_required:
How many chips are required.
Expand All @@ -58,23 +62,34 @@ def __init__(
How many boards are required. Unnecessary with a local board.
:param time_scale_factor:
The time slow-down factor
:param machine_time_step:
:param timestep:
The size of the machine time step, in microseconds
"""
# DSG algorithm store for user defined algorithms

# At import time change the default FailedState
setup_configs()

super().__init__()
super().__init__(n_boards_required=n_boards_required,
n_chips_required=n_chips_required,
timestep=timestep,
time_scale_factor=time_scale_factor)

with GlobalProvenance() as db:
db.insert_version("SpiNNakerGraphFrontEnd", version)

self._data_writer.set_n_required(n_boards_required, n_chips_required)
@overrides(AbstractSpinnakerBase._add_cfg_defaults_and_template)
def _add_cfg_defaults_and_template(self) -> None:
add_gfe_cfg()
add_spinnaker_template()

@property
@overrides(AbstractSpinnakerBase._user_cfg_file)
def _user_cfg_file(self) -> str:
return GFE_CFG

self._data_writer.set_up_timings(
machine_time_step, time_scale_factor, 1)
@property
@overrides(AbstractSpinnakerBase._data_writer_cls)
def _data_writer_cls(self) -> Type[FecDataWriter]:
return FecDataWriter

def __repr__(self) -> str:
if FecDataView.has_ipaddress():
Expand Down
25 changes: 6 additions & 19 deletions spinnaker_graph_front_end/utilities/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
from typing import TYPE_CHECKING
from spinn_front_end_common.abstract_models import (
AbstractHasAssociatedBinary)
from spinn_front_end_common.utilities.constants import SIMULATION_N_BYTES
from spinn_front_end_common.interface.ds import DataSpecificationGenerator
from spinn_front_end_common.interface.simulation.simulation_utilities import (
get_simulation_header_array, get_simulation_header_array_no_timestep)
if TYPE_CHECKING:
from .simulator_vertex import SimulatorVertex

Expand All @@ -33,14 +30,9 @@ def generate_system_data_region(
:param region_id: The region to write to
:param machine_vertex: The machine vertex to write for
"""
# reserve memory regions
spec.reserve_memory_region(
region=region_id, size=SIMULATION_N_BYTES, label='systemInfo')

# simulation .c requirements
spec.switch_write_focus(region_id)
spec.write_array(get_simulation_header_array(
machine_vertex.get_binary_file_name()))
_ = (spec, region_id, machine_vertex)
raise NotImplementedError(
"Moved to spinn_front_end_common.utilities.data_utils")


def generate_steps_system_data_region(
Expand All @@ -53,11 +45,6 @@ def generate_steps_system_data_region(
:param region_id: The region to write to
:param machine_vertex: The machine vertex to write for
"""
# reserve memory regions
spec.reserve_memory_region(
region=region_id, size=SIMULATION_N_BYTES, label='systemInfo')

# simulation .c requirements
spec.switch_write_focus(region_id)
spec.write_array(get_simulation_header_array_no_timestep(
machine_vertex.get_binary_file_name()))
_ = (spec, region_id, machine_vertex)
raise NotImplementedError(
"Moved to spinn_front_end_common.utilities.data_utils")
4 changes: 3 additions & 1 deletion spinnaker_graph_front_end/utilities/simulator_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
recording_utilities)
from spinn_front_end_common.interface.ds import DataSpecificationGenerator

from spinnaker_graph_front_end.utilities.data_utils import (
from spinn_front_end_common.utilities.data_utils import (
generate_system_data_region)
log = FormatAdapter(logging.getLogger(__file__))

Expand Down Expand Up @@ -135,6 +135,8 @@ def generate_recording_region(
:param spec: The data specification being built
:param region_id:
Which region is the recording region.
:param channel_sizes: List of int being the number of regions
and then for each region its size then two zeros
"""
spec.reserve_memory_region(
region=region_id,
Expand Down
Loading
Loading