Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run forever fixes #1224

Closed
wants to merge 14 commits into from
2 changes: 1 addition & 1 deletion mypy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ man="../SpiNNMan/spinnman"
pacman="../PACMAN/pacman"
spalloc="../spalloc/spalloc_client"

mypy --python-version 3.8 $$utils $machine $man $pacman $spalloc spinn_front_end_common
mypy --python-version 3.8 $utils $machine $man $pacman $spalloc spinn_front_end_common
20 changes: 10 additions & 10 deletions spinn_front_end_common/interface/abstract_spinnaker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,6 @@ def __run(self, run_time: Optional[float], sync_time: float):
"Only binaries that use the simulation interface can be"
" run more than once")

self._adjust_config(run_time)

# Install the Control-C handler
if self.__is_main_thread():
signal.signal(signal.SIGINT, self.__signal_handler)
Expand Down Expand Up @@ -599,7 +597,8 @@ def __run(self, run_time: Optional[float], sync_time: float):

self._add_dependent_verts_and_edges_for_application_graph()

if get_config_bool("Buffers", "use_auto_pause_and_resume"):
if ((get_config_bool("Buffers", "use_auto_pause_and_resume"))
or (run_time is None)):
self._data_writer.set_plan_n_timesteps(get_config_int(
"Buffers", "minimum_auto_time_steps"))
else:
Expand Down Expand Up @@ -672,13 +671,11 @@ def __run(self, run_time: Optional[float], sync_time: float):
logger.info("Running forever")
self._do_run(None, n_sync_steps)
else:
logger.info("Running forever in steps of {}ms",
self._data_writer.get_max_run_time_steps())
while self._data_writer.is_no_stop_requested():
logger.info(f"Run {self._data_writer.next_run_step()}")
self._do_run(
self._data_writer.get_max_run_time_steps(), n_sync_steps)
self._data_writer.clear_run_steps()
logger.warning("Due to recording this simulation "
"should not be run longer than {}ms",
self._data_writer.get_max_run_time_steps())
logger.info("Running until stop is called.")
self._do_run(None, n_sync_steps)

# Indicate that the signal handler needs to act
if self.__is_main_thread():
Expand Down Expand Up @@ -2435,6 +2432,9 @@ def stop_run(self) -> None:
if self._data_writer.is_stop_already_requested():
logger.warning("Second Request to stop_run ignored")
return
if self._data_writer.get_current_run_timesteps() is not None:
logger.exception(
"Stop run has little to no affect if not running forever")
with self._state_condition:
self._data_writer.request_stop()
self._state_condition.notify_all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from spinn_front_end_common.data import FecDataView
from spinn_front_end_common.utilities.constants import BYTES_PER_WORD
from spinn_front_end_common.utilities.exceptions import (
BufferableRegionTooSmall, SpinnFrontEndException)
SpinnFrontEndException)
from spinn_front_end_common.utilities.helpful_functions import (
locate_memory_region_for_placement, locate_extra_monitor_mc_receiver)
from spinn_front_end_common.interface.buffer_management.storage_objects \
Expand Down Expand Up @@ -330,9 +330,9 @@ def _send_initial_messages(
progress.update(len(data))

if not sent_message:
raise BufferableRegionTooSmall(
f"The buffer size {bytes_to_go} is too small for any data to "
f"be added for region {region} of vertex {vertex}")
raise SpinnFrontEndException(
f"Unable to create message for {region=} on {vertex=} "
f"while is_empty reports false")

# If there are no more messages and there is space, add a stop request
if (not vertex.is_next_timestamp(region) and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def is_next_key(self, region: int, timestamp: int) -> bool:

@overrides(AbstractSendsBuffersFromHost.get_next_key)
def get_next_key(self, region: int) -> int:
return self.send_buffers[region].next_key
return self.send_buffers[region].next_key()

@overrides(AbstractSendsBuffersFromHost.is_empty)
def is_empty(self, region: int) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def is_next_key(self, timestamp: int) -> bool:
return bool(self._buffer[timestamp])
return False

@property
def next_key(self) -> int:
"""
The next key to be sent.
Expand Down
14 changes: 0 additions & 14 deletions spinn_front_end_common/interface/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,6 @@ def _reserve_system_vertices(self):
self._data_writer.add_sample_monitor_vertex(
sample_speedup_vertex(), False)

def _adjust_config(self, runtime: Optional[float]):
"""
Adjust and checks the configuration based on runtime

:param runtime:
:type runtime: int or bool
:raises ConfigurationException:
"""
if runtime is None:
if get_config_bool("Reports", "write_energy_report"):
set_config("Reports", "write_energy_report", "False")
logger.info("[Reports]write_energy_report has been set to "
"False as runtime is set to forever")

def _remove_excess_folders(
self, max_kept: int, starting_directory: str,
remove_errored_folders: Optional[bool]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def run_app(
latest_runtime = None
if runtime is None and not run_until_complete:
with state_condition:
while FecDataView.is_no_stop_requested():
state_condition.wait()
state_condition.wait()
self.__send_pause()
self._wait_for_end()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ def compute_energy_used() -> PowerUsed:

:rtype: PowerUsed
"""
ts = FecDataView.get_current_run_timesteps()
assert ts is not None, \
"energy reporting not supported in run forever mode"
machine = FecDataView.get_machine()
with GlobalProvenance() as db:
dsg_time = db.get_category_timer_sum(TimerCategory.DATA_GENERATION)
Expand All @@ -97,7 +94,11 @@ def compute_energy_used() -> PowerUsed:
power_used.data_gen_time_secs = dsg_time / _MS_PER_SECOND
power_used.mapping_time_secs = mapping_time / _MS_PER_SECOND

runtime_total_ms = ts * FecDataView.get_time_scale_factor()
ts = FecDataView.get_current_run_timesteps()
if ts is None:
runtime_total_ms = 0.0 # TODO FIX
else:
runtime_total_ms = ts * FecDataView.get_time_scale_factor()
# TODO: extraction time as currently defined is part of execution time,
# so for now don't add it on, but revisit this in the future
total_booted_time = execute_time + load_time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ def _fill_send_buffer(self) -> None:
"""
first_machine_time_step = FecDataView.get_first_machine_time_step()
run_until_timesteps = FecDataView.get_current_run_timesteps()
if run_until_timesteps is None:
run_until_timesteps = FecDataView.get_run_number()
if (self._first_machine_time_step == first_machine_time_step and
self._run_until_timesteps == run_until_timesteps):
return
Expand Down