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

Version flexible Virtual Machine #557

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -12,7 +12,7 @@
# 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 pacman.data.pacman_data_writer import PacmanDataWriter
from pacman.exceptions import (PacmanPlaceException, PacmanTooBigToPlace)
from pacman.model.partitioner_splitters import (
Expand Down Expand Up @@ -103,23 +103,30 @@ 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)
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())


Expand All @@ -135,7 +142,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 @@ -156,7 +165,8 @@ 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())


Expand All @@ -173,7 +183,8 @@ 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())


Expand All @@ -187,11 +198,14 @@ def test_application_placer_fill_chips():
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())


Expand Down Expand Up @@ -229,7 +243,8 @@ def test_more_cores_than_chip():
unittest_setup()
set_config("Machine", "version", 5)
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 @@ -241,7 +256,8 @@ def test_more_cores_than_user():
unittest_setup()
set_config("Machine", "version", 5)
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 @@ -256,9 +272,10 @@ def test_more_cores_with_monitor():
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))
Expand All @@ -271,4 +288,5 @@ def test_could_fit():
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)
23 changes: 15 additions & 8 deletions unittests/operations_tests/router_algorithms_tests/test_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from spinn_utilities.timer import Timer
from spinn_utilities.config_holder import set_config
from spinn_machine import virtual_machine
from spinn_machine import (virtual_machine_by_boards, virtual_machine_by_cores)
from pacman.data import PacmanDataView
from pacman.data.pacman_data_writer import PacmanDataWriter
from pacman.exceptions import PacmanRoutingException
Expand Down Expand Up @@ -520,7 +520,8 @@ def test_multi_split(params):
if source != target:
writer.add_edge(ApplicationEdge(source, target), "Test")

writer.set_machine(virtual_machine(24, 24))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(place_application_graph(Placements()))
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand All @@ -538,7 +539,8 @@ def test_multi_self_split(params):
for target in writer.iterate_vertices():
writer.add_edge(ApplicationEdge(source, target), "Test")

writer.set_machine(virtual_machine(24, 24))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(place_application_graph(Placements()))
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand Down Expand Up @@ -609,7 +611,8 @@ def test_internal_only(params):
writer, 1000, 3, 2, 2, "app_vertex",
internal_multicast=True)

writer.set_machine(virtual_machine(24, 24))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(place_application_graph(Placements()))
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand All @@ -629,7 +632,8 @@ def test_internal_and_split(params):
if source != target:
writer.add_edge(ApplicationEdge(source, target), "Test")

writer.set_machine(virtual_machine(24, 24))
writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(place_application_graph(Placements()))
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand Down Expand Up @@ -692,7 +696,6 @@ def test_fpga_link_overlap(params):
set_config("Machine", "version", 5)
writer = PacmanDataWriter.mock()
set_config("Machine", "down_chips", "6,1")
writer.set_machine(virtual_machine(12, 12))
in_device = ApplicationFPGAVertex(
100, [FPGAConnection(0, i, None, None) for i in range(15, 0, -2)],
None)
Expand All @@ -703,6 +706,8 @@ def test_fpga_link_overlap(params):
writer, 1000, 60 * 16, "app_vertex")
writer.add_edge(ApplicationEdge(in_device, app_vertex), "Test")

writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(place_application_graph(Placements()))
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand Down Expand Up @@ -736,6 +741,8 @@ def test_odd_case(params):
x, y, p = next(core_iter)
placements.add_placement(Placement(m_vertex, x, y, p))

writer.set_machine(virtual_machine_by_cores(
n_cores=writer.get_n_machine_vertices()))
writer.set_placements(placements)
routing_tables = _route_and_time(algorithm)
_check_edges(routing_tables)
Expand All @@ -749,7 +756,7 @@ def test_with_ethernet_system_placements(params):
unittest_setup()
set_config("Machine", "version", 5)
writer = PacmanDataWriter.mock()
writer.set_machine(virtual_machine(16, 16))
writer.set_machine(virtual_machine_by_boards(4))
source_vertex = _make_vertices(writer, 200, 3, "app_vertex")
target_vertex = _make_ethernet_vertices(writer, 1, "eth_vertex")
writer.add_edge(ApplicationEdge(source_vertex, target_vertex), "Test")
Expand Down Expand Up @@ -797,7 +804,7 @@ def test_route_around():
# 2,3 3,3 4,3
# 2,2 3,2
set_config("Machine", "down_chips", "2,3:3,2:3,4:4,4:4,3")
machine = virtual_machine(8, 8)
machine = PacmanDataView.get_machine()
vector = machine.get_vector((0, 0), (6, 6))
PacmanDataWriter.mock().set_machine(machine)
nodes = longest_dimension_first(vector, (0, 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_onordered_pair_big(self):

writer = PacmanDataWriter.mock()
writer.set_precompressed(original_tables)
# This tests requires a full wrap machine
# The input includes Chips like 3, 8
writer.set_machine(virtual_machine(24, 24))
with self.assertRaises(PacmanElementAllocationException):
pair_compressor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_oc_big(self):
original_tables = from_json(j_router)
writer = PacmanDataWriter.mock()
writer.set_precompressed(original_tables)
# This tests requires a full wrap machine
# The input includes Chips like 3, 8
writer.set_machine(virtual_machine(24, 24))

compressed_tables = ordered_covering_compressor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def do_pair_big(self, c_sort):
original_tables = from_json(j_router)
writer = PacmanDataWriter.mock()
writer.set_precompressed(original_tables)
# This tests requires a full wrap machine
# The input includes Chips like 3, 8
writer.set_machine(virtual_machine(24, 24))

compressed_tables = pair_compressor(c_sort=c_sort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def test_onordered_pair_big(self):
original_tables = from_json(j_router)
writer = PacmanDataWriter.mock()
writer.set_precompressed(original_tables)
# This tests requires a full wrap machine
# The input includes Chips like 3, 8
writer.set_machine(virtual_machine(24, 24))

# Hack to stop it throwing a wobly for too many entries
Expand Down
Loading
Loading