Skip to content

Commit

Permalink
Merge pull request #558 from SpiNNakerManchester/version2
Browse files Browse the repository at this point in the history
Version and testing for Spin2
  • Loading branch information
rowleya authored Apr 19, 2024
2 parents 5b5f752 + cd6148f commit 696f033
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 110 deletions.
33 changes: 0 additions & 33 deletions pacman/data/pacman_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ class _PacmanDataModel(object):
"_plan_n_timesteps",
"_precompressed",
"_all_monitor_vertices",
"_all_monitor_cores",
"_ethernet_monitor_vertices",
"_ethernet_monitor_cores",
"_routing_infos",
"_routing_table_by_partition",
"_tags",
Expand Down Expand Up @@ -103,9 +101,7 @@ def _hard_reset(self) -> None:
self._placements: Optional[Placements] = None
self._precompressed: Optional[MulticastRoutingTables] = None
self._all_monitor_vertices: List[MachineVertex] = []
self._all_monitor_cores: int = 0
self._ethernet_monitor_vertices: List[MachineVertex] = []
self._ethernet_monitor_cores: int = 0
self._uncompressed: Optional[MulticastRoutingTables] = None
self._routing_infos: Optional[RoutingInfo] = None
self._routing_table_by_partition: Optional[
Expand Down Expand Up @@ -541,20 +537,6 @@ def get_routing_table_by_partition(
raise cls._exception("routing_table_by_partition")
return cls.__pacman_data._routing_table_by_partition

@classmethod
def get_all_monitor_cores(cls) -> int:
"""
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.
:rtype: int
"""
return cls.__pacman_data._all_monitor_cores

@classmethod
def get_all_monitor_sdram(cls) -> AbstractSDRAM:
"""
Expand All @@ -574,21 +556,6 @@ def get_all_monitor_sdram(cls) -> AbstractSDRAM:
sdram += vertex.sdram_required
return sdram

@classmethod
def get_ethernet_monitor_cores(cls) -> int:
"""
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.
:rtype: int
"""
return cls.__pacman_data._ethernet_monitor_cores

@classmethod
def get_ethernet_monitor_sdram(cls) -> AbstractSDRAM:
"""
Expand Down
11 changes: 5 additions & 6 deletions pacman/data/pacman_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def add_edge(cls, edge: ApplicationEdge,
cls.__pacman_data._graph.add_edge(edge, outgoing_edge_partition_name)

def add_sample_monitor_vertex(
self, vertex: MachineVertex, all_cores: bool):
self, vertex: MachineVertex, all_chips: bool):
"""
Accepts a simple of the monitor cores to be added.
Expand All @@ -192,14 +192,13 @@ def add_sample_monitor_vertex(
:param ~pacman.model.graphs.machine.MachineVertex vertex:
One of the vertices added to each core, assumed to be typical of
all.
:param bool all_cores:
If True assumes that this Vertex will be placed on all cores
:param bool 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
"""
self.__pacman_data._ethernet_monitor_cores += 1
self.add_monitor_core(all_chips)
self.__pacman_data._ethernet_monitor_vertices.append(vertex)
if all_cores:
self.__pacman_data._all_monitor_cores += 1
if all_chips:
self.__pacman_data._all_monitor_vertices.append(vertex)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

from spinn_utilities.config_holder import set_config
from spinn_machine.version.version_strings import VersionStrings

from pacman.config_setup import unittest_setup
from pacman.exceptions import PacmanConfigurationException
Expand All @@ -34,7 +35,7 @@ def setUp(self):
unittest_setup()

def test_legacy(self):
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
splitter = SplitterOneAppOneMachine()
v1 = NonLegacyApplicationVertex("v1")
a = str(splitter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

from spinn_utilities.config_holder import set_config
from spinn_machine.version.version_strings import VersionStrings

from pacman.config_setup import unittest_setup
from pacman.exceptions import PacmanConfigurationException
Expand All @@ -29,7 +30,7 @@ def setUp(self):
unittest_setup()

def test_api(self):
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
splitter = SplitterFixedLegacy()
self.assertIsNotNone(str(splitter))
self.assertIsNotNone(repr(splitter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

from spinn_utilities.config_holder import set_config
from spinn_machine.version.version_strings import VersionStrings

from pacman.config_setup import unittest_setup
from pacman.exceptions import PacmanConfigurationException
Expand All @@ -30,7 +31,7 @@ def setUp(self):
unittest_setup()

def test_api(self):
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
splitter = SplitterOneToOneLegacy()
self.assertIsNotNone(str(splitter))
self.assertIsNotNone(repr(splitter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import unittest

from spinn_utilities.config_holder import set_config
from spinn_machine.version.version_strings import VersionStrings

from pacman.config_setup import unittest_setup
from pacman.data import PacmanDataView
Expand All @@ -44,7 +45,7 @@ def setUp(self):
setup for all basic partitioner tests
"""
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)

def test_partition_with_no_fixed(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from spinn_utilities.config_holder import set_config
from spinn_machine.virtual_machine import virtual_machine
from spinn_machine.virtual_machine import virtual_machine_by_cores
from spinn_machine.version.version_strings import VersionStrings
from pacman.data.pacman_data_writer import PacmanDataWriter
from pacman.exceptions import (PacmanPlaceException, PacmanTooBigToPlace)
from pacman.model.partitioner_splitters import (
Expand Down Expand Up @@ -93,7 +94,7 @@ def _make_vertices(

def test_application_placer():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
# fixed early works as this vertex is looked at first
fixed = SimpleTestVertex(10, "FIXED", max_atoms_per_core=1)
Expand All @@ -103,29 +104,36 @@ def test_application_placer():
fixed.splitter.create_machine_vertices(ChipCounter())
for i in range(61):
_make_vertices(writer, 1000, 14, 5, f"app_vertex_{i}")
writer.set_machine(virtual_machine(24, 12))
# Fudge factor needed as not filling chips well
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices() * 1.2))
place_application_graph(Placements())


def test_application_placer_large_groups():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
version = writer.get_machine_version()
# fixed early works as this vertex is looked at first
fixed = SimpleTestVertex(10, "FIXED", max_atoms_per_core=1)
fixed.splitter = SplitterFixedLegacy()
fixed.set_fixed_location(0, 0)
writer.add_vertex(fixed)
fixed.splitter.create_machine_vertices(ChipCounter())
# make groups to fill chips
n_machine_vertices = version.max_cores_per_chip - 2
for i in range(17):
_make_vertices(writer, 1000, 14, 17, f"app_vertex_{i}")
writer.set_machine(virtual_machine(24, 12))
_make_vertices(
writer, 1000, 14, n_machine_vertices, f"app_vertex_{i}")
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
place_application_graph(Placements())


def test_application_placer_too_few_boards():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
# fixed early works as this vertex is looked at first
fixed = SimpleTestVertex(10, "FIXED", max_atoms_per_core=1)
Expand All @@ -135,7 +143,9 @@ def test_application_placer_too_few_boards():
fixed.splitter.create_machine_vertices(ChipCounter())
for i in range(56):
_make_vertices(writer, 1000, 14, 5, f"app_vertex_{i}")
writer.set_machine(virtual_machine(12, 12))
# intentionally too small
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices() / 2))
try:
place_application_graph(Placements())
raise AssertionError("Error not raise")
Expand All @@ -145,7 +155,7 @@ def test_application_placer_too_few_boards():

def test_application_placer_restart_needed():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
for (x, y) in [(1, 0), (1, 1), (0, 1)]:
fixed = SimpleTestVertex(15, f"FIXED {x}:{y}", max_atoms_per_core=1)
Expand All @@ -156,13 +166,14 @@ def test_application_placer_restart_needed():
for i in range(56):
_make_vertices(writer, 1000, 14, 5, f"app_vertex_{i}")
# Don't use a full wrap machine
writer.set_machine(virtual_machine(28, 16))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
place_application_graph(Placements())


def test_application_placer_late_fixed():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
for i in range(56):
_make_vertices(writer, 1000, 14, 5, f"app_vertex_{i}")
Expand All @@ -173,31 +184,35 @@ def test_application_placer_late_fixed():
writer.add_vertex(fixed)
fixed.splitter.create_machine_vertices(ChipCounter())

writer.set_machine(virtual_machine(24, 12))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
place_application_graph(Placements())


def test_application_placer_fill_chips():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.text)
writer = PacmanDataWriter.mock()
# fixed early works as this vertex is looked at first
fixed = SimpleTestVertex(10, "FIXED", max_atoms_per_core=1)
fixed.splitter = SplitterFixedLegacy()
fixed.set_fixed_location(0, 0)
writer.add_vertex(fixed)
fixed.splitter.create_machine_vertices(ChipCounter())
version = writer.get_machine_version()
half = version.max_cores_per_chip // 2
for i in range(17):
_make_vertices(writer, 1000, 14, 9, f"app_vertex_{i}")
_make_vertices(writer, 1000, 14, half, f"app_vertex_{i}")
for i in range(17):
_make_vertices(writer, 1000, 14, 8, f"app_vertex_{i}")
writer.set_machine(virtual_machine(24, 12))
_make_vertices(writer, 1000, 14, half - 1, f"app_vertex_{i}")
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
place_application_graph(Placements())


def test_sdram_bigger_than_chip():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
max_sdram = writer.get_machine_version().max_sdram_per_chip
_make_vertices(writer, 1, 1, 5, "big_app_vertex",
Expand All @@ -211,7 +226,7 @@ def test_sdram_bigger_than_chip():

def test_sdram_bigger_monitors():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
max_sdram = writer.get_machine_version().max_sdram_per_chip
monitor = SimpleMachineVertex(ConstantSDRAM(max_sdram // 2))
Expand All @@ -227,9 +242,10 @@ def test_sdram_bigger_monitors():

def test_more_cores_than_chip():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
_make_vertices(writer, 1, 1, 19, "big_app_vertex")
many = writer.get_machine_version().max_cores_per_chip + 1
_make_vertices(writer, 1, 1, many, "big_app_vertex")
try:
place_application_graph(Placements())
raise AssertionError("Error not raise")
Expand All @@ -239,9 +255,10 @@ def test_more_cores_than_chip():

def test_more_cores_than_user():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
_make_vertices(writer, 1, 1, 18, "big_app_vertex")
many = writer.get_machine_version().max_cores_per_chip
_make_vertices(writer, 1, 1, many, "big_app_vertex")
try:
place_application_graph(Placements())
raise AssertionError("Error not raise")
Expand All @@ -251,24 +268,26 @@ def test_more_cores_than_user():

def test_more_cores_with_monitor():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
monitor = SimpleMachineVertex(ConstantSDRAM(4000))
# This is purely an info call so test check directly
writer.add_sample_monitor_vertex(monitor, True)
many = writer.get_machine_version().max_cores_per_chip - 1
try:
placer = ApplicationPlacer(Placements())
placer._check_could_fit(17, 500000)
placer._check_could_fit(many, 500000)
raise AssertionError("Error not raise")
except PacmanTooBigToPlace as ex:
assert ("reserved for monitors" in str(ex))


def test_could_fit():
unittest_setup()
set_config("Machine", "version", 5)
set_config("Machine", "versions", VersionStrings.ANY.text)
writer = PacmanDataWriter.mock()
monitor = SimpleMachineVertex(ConstantSDRAM(0))
writer.add_sample_monitor_vertex(monitor, True)
placer = ApplicationPlacer(Placements())
placer._check_could_fit(16, 500000)
many = writer.get_machine_version().max_cores_per_chip - 2
placer._check_could_fit(many, 500000)
Loading

0 comments on commit 696f033

Please sign in to comment.