diff --git a/spinn_front_end_common/interface/abstract_spinnaker_base.py b/spinn_front_end_common/interface/abstract_spinnaker_base.py index 733bccceef..c219ae7b94 100644 --- a/spinn_front_end_common/interface/abstract_spinnaker_base.py +++ b/spinn_front_end_common/interface/abstract_spinnaker_base.py @@ -79,8 +79,7 @@ execute_application_data_specs, execute_system_data_specs, graph_binary_gatherer, graph_data_specification_writer, graph_provenance_gatherer, - host_based_bit_field_router_compressor, - hbp_allocator, hbp_max_machine_generator, + host_based_bit_field_router_compressor, hbp_allocator, insert_chip_power_monitors_to_graphs, insert_extra_monitor_vertices_to_graphs, split_lpg_vertices, load_app_images, load_fixed_routes, load_sys_images, @@ -90,7 +89,6 @@ read_routing_tables_from_machine, router_provenance_gatherer, routing_setup, routing_table_loader, sdram_outgoing_partition_allocator, spalloc_allocator, - spalloc_max_machine_generator, system_multicast_routing_generator, tags_loader, virtual_machine_generator) from spinn_front_end_common.interface.interface_functions.\ @@ -177,11 +175,7 @@ class AbstractSpinnakerBase(ConfigHandler): # Flag to say is compressed routing tables are on machine # TODO remove this when the data change only algorithms are done - "_multicast_routes_loaded", - - # Flag to say if current machine is a temporary max machine - # the temp /max machine is held in the "machine" slot - "_max_machine" + "_multicast_routes_loaded" ] def __init__( @@ -244,7 +238,6 @@ def _hard_reset(self): self._data_writer.get_transceiver().stop_application( self._data_writer.get_app_id()) self._data_writer.hard_reset() - self._max_machine = False self._multicast_routes_loaded = False self.__close_allocation_controller() @@ -513,9 +506,6 @@ def __run(self, run_time, sync_time): else: self._data_writer.set_plan_n_timesteps(n_machine_time_steps) - self._get_known_machine(total_run_time) - if not self._data_writer.has_machine(): - self._execute_get_max_machine(total_run_time) self._do_mapping(total_run_time) # Check if anything has per-timestep SDRAM usage @@ -723,9 +713,6 @@ def _execute_allocator(self, category, total_run_time): """ if self._data_writer.has_machine(): return None - if (not self._data_writer.has_n_boards_required() and - not self._data_writer.has_n_chips_needed()): - return if get_config_str("Machine", "spalloc_server") is not None: with FecTimer(category, "SpallocAllocator"): return spalloc_allocator() @@ -778,31 +765,6 @@ def _execute_machine_generator(self, category, allocator_data): self._data_writer.set_transceiver(transceiver) self._data_writer.set_machine(machine) - def _execute_get_max_machine(self, total_run_time): - """ - Runs, times and logs the a MaxMachineGenerator if required - - Will set the "machine" value if not already set - - Sets the _max_machine to True if the "machine" value is a temporary - max machine. - - :param total_run_time: The total run time to request - :type total_run_time: int or None - """ - self._max_machine = True - if get_config_str("Machine", "spalloc_server"): - with FecTimer(GET_MACHINE, "Spalloc max machine generator"): - self._data_writer.set_machine(spalloc_max_machine_generator()) - - elif get_config_str("Machine", "remote_spinnaker_url"): - with FecTimer(GET_MACHINE, "HBPMaxMachineGenerator"): - self._data_writer.set_machine(hbp_max_machine_generator( - total_run_time)) - - else: - raise NotImplementedError("No machine generataion possible") - def _get_known_machine(self, total_run_time=0.0): """ The python machine description object. @@ -1387,9 +1349,6 @@ def _do_mapping(self, total_run_time): self._execute_delay_support_adder() self._execute_splitter_partitioner() - if self._max_machine: - self._max_machine = False - self._data_writer.clear_machine() allocator_data = self._execute_allocator(MAPPING, total_run_time) self._execute_machine_generator(MAPPING, allocator_data) self._json_machine() diff --git a/spinn_front_end_common/interface/interface_functions/__init__.py b/spinn_front_end_common/interface/interface_functions/__init__.py index 3da992d250..88d38f82da 100644 --- a/spinn_front_end_common/interface/interface_functions/__init__.py +++ b/spinn_front_end_common/interface/interface_functions/__init__.py @@ -33,7 +33,6 @@ graph_data_specification_writer) from .graph_provenance_gatherer import graph_provenance_gatherer from .hbp_allocator import hbp_allocator -from .hbp_max_machine_generator import hbp_max_machine_generator from .host_bit_field_router_compressor import ( host_based_bit_field_router_compressor) from .host_execute_data_specification import ( @@ -55,7 +54,6 @@ from .routing_setup import routing_setup from .routing_table_loader import routing_table_loader from .spalloc_allocator import spalloc_allocator -from .spalloc_max_machine_generator import spalloc_max_machine_generator from .tags_loader import tags_loader from .virtual_machine_generator import virtual_machine_generator from .read_routing_tables_from_machine import read_routing_tables_from_machine @@ -76,7 +74,6 @@ "graph_binary_gatherer", "graph_data_specification_writer", "graph_provenance_gatherer", "hbp_allocator", "host_based_bit_field_router_compressor", - "hbp_max_machine_generator", "insert_chip_power_monitors_to_graphs", "insert_extra_monitor_vertices_to_graphs", "split_lpg_vertices", @@ -87,7 +84,7 @@ "read_routing_tables_from_machine", "router_provenance_gatherer", "routing_setup", "routing_table_loader", "sdram_outgoing_partition_allocator", - "spalloc_allocator", "spalloc_max_machine_generator", + "spalloc_allocator", "system_multicast_routing_generator", "tags_loader", "virtual_machine_generator", ] diff --git a/spinn_front_end_common/interface/interface_functions/hbp_max_machine_generator.py b/spinn_front_end_common/interface/interface_functions/hbp_max_machine_generator.py deleted file mode 100644 index af6fef3c46..0000000000 --- a/spinn_front_end_common/interface/interface_functions/hbp_max_machine_generator.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2017-2019 The University of Manchester -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import requests -from spinn_utilities.config_holder import (get_config_int, get_config_str) -from spinn_machine import Machine -from spinn_machine.virtual_machine import virtual_machine - - -def hbp_max_machine_generator(total_run_time): - """ Generates a virtual machine of the width and height of the maximum\ - machine a given HBP server can generate. - - :param int total_run_time: The total run time to request - :rtype: ~spinn_machine.Machine - """ - max_machine_core_reduction = get_config_int( - "Machine", "max_machine_core_reduction") - max_machine = _max_machine_request( - get_config_str("Machine", "remote_spinnaker_url"), total_run_time) - - n_cpus_per_chip = (Machine.max_cores_per_chip() - - max_machine_core_reduction) - - # Return the width and height and assume that it has wrap arounds - return virtual_machine( - width=max_machine["width"], height=max_machine["height"], - n_cpus_per_chip=n_cpus_per_chip, validate=False) - - -def _max_machine_request(url, total_run_time): - """ - :param str url: - :param int total_run_time: - :rtype: dict - """ - if url.endswith("/"): - url = url[:-1] - r = requests.get("{}/max".format(url), params={ - 'runTime': total_run_time}) - r.raise_for_status() - return r.json() diff --git a/spinn_front_end_common/interface/interface_functions/spalloc_max_machine_generator.py b/spinn_front_end_common/interface/interface_functions/spalloc_max_machine_generator.py deleted file mode 100644 index 1e912ce675..0000000000 --- a/spinn_front_end_common/interface/interface_functions/spalloc_max_machine_generator.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2017-2019 The University of Manchester -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from spalloc import ProtocolClient -from spinn_utilities.config_holder import get_config_int, get_config_str -from spinn_machine.virtual_machine import virtual_machine -from spinn_machine.machine import Machine - - -def spalloc_max_machine_generator(): - """ - Generates a maximum virtual machine a given allocation server can generate. - - :return: A virtual machine - :rtype: ~spinn_machine.Machine - """ - spalloc_server = get_config_str("Machine", "spalloc_server") - spalloc_port = get_config_int("Machine", "spalloc_port") - spalloc_machine = get_config_str("Machine", "spalloc_machine") - max_machine_core_reduction = get_config_int( - "Machine", "max_machine_core_reduction") - - with ProtocolClient(spalloc_server, spalloc_port) as client: - machines = client.list_machines() - # Close the context immediately; don't want to keep this particular - # connection around as there's not a great chance of this code - # being rerun in this process any time soon. - max_width = None - max_height = None - max_area = -1 - - for machine in _filter(machines, spalloc_machine): - # Get the width and height in chips, and logical area in chips**2 - width, height, area = _get_size(machine) - - # The "biggest" board is the one with the most chips - if area > max_area: - max_area = area - max_width = width - max_height = height - - if max_width is None: - raise Exception( - "The spalloc server appears to have no compatible machines") - - n_cpus_per_chip = (Machine.max_cores_per_chip() - - max_machine_core_reduction) - - # Return the width and height, and make no assumption about wrap- - # arounds or version. - return virtual_machine( - width=max_width, height=max_height, - n_cpus_per_chip=n_cpus_per_chip, validate=False) - - -def _filter(machines, target_name): - """ - :param list(dict(str,str)) machines: - :param str target_name: - :rtype: iterable(dict(str,str or int)) - """ - if target_name is None: - return (m for m in machines if "default" in m["tags"]) - return (m for m in machines if m["name"] == target_name) - - -def _get_size(machine): - """ - :param dict(str,int) machine: - :return: width, height, area - :rtype: tuple(int,int,int) - """ - # Get the width and height in chips - width = machine["width"] * 12 - height = machine["height"] * 12 - - # A specific exception is the 1-board machine, which is represented as - # a 3 board machine with 2 dead boards. In this case the width and - # height are 8. - if (machine["width"] == 1 and - machine["height"] == 1 and - len(machine["dead_boards"]) == 2): - return 8, 8, 48 - - return width, height, width * height diff --git a/unittests/interface/interface_functions/test_front_end_common_spalloc_max_machine_generator.py b/unittests/interface/interface_functions/test_front_end_common_spalloc_max_machine_generator.py deleted file mode 100644 index d43663db40..0000000000 --- a/unittests/interface/interface_functions/test_front_end_common_spalloc_max_machine_generator.py +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) 2017-2019 The University of Manchester -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import unittest -import socket -from threading import Thread -import json -from spinn_utilities.config_holder import set_config -from spinn_front_end_common.interface.config_setup import unittest_setup -from spinn_front_end_common.interface.interface_functions import ( - spalloc_max_machine_generator) - - -class _MockSpallocServer(Thread): - - def __init__(self, name, width, height, dead_boards, dead_links, tags): - super().__init__() - self._name = name - self._width = width - self._height = height - self._dead_boards = dead_boards - self._dead_links = dead_links - self._tags = tags - - self._socket = socket.socket() - self._socket.bind(("", 0)) - _, self._port = self._socket.getsockname() - self._socket.listen(5) - - @property - def port(self): - return self._port - - def run(self): - client, _ = self._socket.accept() - data = b"" - while b"\n" not in data: - data += client.recv(100) - message = {"return": [{ - "name": self._name, "width": self._width, "height": self._height, - "dead_boards": self._dead_boards, "dead_links": self._dead_links, - "tags": self._tags}]} - client.send(json.dumps(message).encode("utf-8") + b"\n") - - -class TestFrontEndCommonSpallocMaxMachineGenerator(unittest.TestCase): - - def setUp(self): - unittest_setup() - - def test_single_board(self): - server = _MockSpallocServer( - "test", 1, 1, [(0, 0, 1), (0, 0, 2)], [], ["default"]) - server.start() - set_config("Machine", "spalloc_port", server.port) - set_config("Machine", "spalloc_server", "localhost") - machine = spalloc_max_machine_generator() - self.assertEqual(machine.max_chip_x, 7) - self.assertEqual(machine.max_chip_y, 7) - - def test_multiboard(self): - server = _MockSpallocServer( - "test", 1, 1, [], [], ["default"]) - server.start() - set_config("Machine", "spalloc_port", server.port) - set_config("Machine", "spalloc_server", "localhost") - machine = spalloc_max_machine_generator() - self.assertEqual(machine.max_chip_x, 11) - self.assertEqual(machine.max_chip_y, 11) - - def test_specific_board(self): - server = _MockSpallocServer( - "test", 3, 2, [], [], ["test"]) - server.start() - set_config("Machine", "spalloc_port", server.port) - set_config("Machine", "spalloc_machine", "test") - set_config("Machine", "spalloc_server", "localhost") - machine = spalloc_max_machine_generator() - self.assertEqual(machine.max_chip_x, (12 * 3) - 1) - self.assertEqual(machine.max_chip_y, (12 * 2) - 1) - - -if __name__ == "__main__": - unittest.main()