Skip to content

Commit

Permalink
add in fpga spinnaker/link tests lost in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Apr 5, 2024
1 parent 84fea24 commit 20d0064
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spinn_machine/version/version_201.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,11 @@ def illegal_ethernet_message(self, x: int, y: int) -> Optional[str]:
if x != 0 or y != 0:
return "Only Chip 0, 0 may be an Ethernet Chip"
return None

@overrides(AbstractVersion.spinnaker_links)
def spinnaker_links(self) -> List[Tuple[int, int, int]]:
return []

@overrides(AbstractVersion.fpga_links)
def fpga_links(self) -> List[Tuple[int, int, int, int, int]]:
return []
2 changes: 2 additions & 0 deletions unittests/test_virtual_machine201.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def test_version_201(self):
count += 1
self.assertEqual(1, count)
self.assertEqual((1, 0), vm.get_unused_xy())
self.assertEqual(0, len(list(vm.spinnaker_links)))
self.assertEqual(0, len(vm._fpga_links))

def test_new_vm_with_max_cores(self):
set_config("Machine", "version", 201)
Expand Down
13 changes: 12 additions & 1 deletion unittests/test_virtual_machine3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

import unittest
from spinn_utilities.config_holder import set_config
from spinn_machine.config_setup import unittest_setup
from spinn_machine import Chip, Link, Router, virtual_machine
from spinn_machine.config_setup import unittest_setup
from spinn_machine.link_data_objects import SpinnakerLinkData
from spinn_machine.exceptions import (
SpinnMachineException, SpinnMachineAlreadyExistsException)

Expand Down Expand Up @@ -112,6 +113,16 @@ def test_version_2(self):
count += 1
self.assertEqual(4, count)
self.assertEqual((2, 0), vm.get_unused_xy())
spinnaker_links = (list(vm.spinnaker_links))
expected = []
sp = SpinnakerLinkData(0, 0, 0, 3, '127.0.0.0')
expected.append((('127.0.0.0', 0), sp))
expected.append((((0, 0), 0), sp))
sp = SpinnakerLinkData(1, 1, 0, 0, '127.0.0.0')
expected.append((('127.0.0.0', 1), sp))
expected.append((((1, 0), 1), sp))
self.assertEqual(expected, spinnaker_links)
self.assertEqual(0, len(vm._fpga_links))

def test_new_vm_with_max_cores(self):
set_config("Machine", "version", 2)
Expand Down
119 changes: 118 additions & 1 deletion unittests/test_virtual_machine5.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import unittest
from spinn_utilities.config_holder import set_config
from spinn_machine.config_setup import unittest_setup

from spinn_machine import virtual_machine
from spinn_machine.config_setup import unittest_setup
from spinn_machine.exceptions import SpinnMachineException
from spinn_machine.link_data_objects import SpinnakerLinkData
from spinn_machine.version.version_5 import CHIPS_PER_BOARD


Expand Down Expand Up @@ -79,6 +81,88 @@ def test_version_5_8_by_8(self):
self.assertEqual(240, count)
count = sum(_chip.n_processors for _chip in vm.chips)
self.assertEqual(count, 856)
spinnaker_links = (list(vm.spinnaker_links))
expected = []
sp = SpinnakerLinkData(0, 0, 0, 4, '127.0.0.0')
expected.append((('127.0.0.0', 0), sp))
expected.append((((0, 0), 0), sp))
self.assertEqual(expected, spinnaker_links)
# 8 links on each of the 6 sides recorded 3 times
# Except for the Ethernet Chip's 3 links which are only recorded twice
expected_fpgas = 8 * 6 * 3 - 3
self.assertEqual(expected_fpgas, len(vm._fpga_links))
keys = set([('127.0.0.0', 0, 0), ((7, 3), 0, 0), ((0, 0), 0, 0),
('127.0.0.0', 0, 1), ((7, 3), 0, 1), ((0, 0), 0, 1),
('127.0.0.0', 0, 2), ((6, 2), 0, 2), ((0, 0), 0, 2),
('127.0.0.0', 0, 3), ((6, 2), 0, 3), ((0, 0), 0, 3),
('127.0.0.0', 0, 4), ((5, 1), 0, 4), ((0, 0), 0, 4),
('127.0.0.0', 0, 5), ((5, 1), 0, 5), ((0, 0), 0, 5),
('127.0.0.0', 0, 6), ((4, 0), 0, 6), ((0, 0), 0, 6),
('127.0.0.0', 0, 7), ((4, 0), 0, 7), ((0, 0), 0, 7),
('127.0.0.0', 0, 8), ((4, 0), 0, 8), ((0, 0), 0, 8),
('127.0.0.0', 0, 9), ((3, 0), 0, 9), ((0, 0), 0, 9),
('127.0.0.0', 0, 10), ((3, 0), 0, 10), ((0, 0), 0, 10),
('127.0.0.0', 0, 11), ((2, 0), 0, 11), ((0, 0), 0, 11),
('127.0.0.0', 0, 12), ((2, 0), 0, 12), ((0, 0), 0, 12),
('127.0.0.0', 0, 13), ((1, 0), 0, 13), ((0, 0), 0, 13),
('127.0.0.0', 0, 14), ((1, 0), 0, 14), ((0, 0), 0, 14),
('127.0.0.0', 0, 15), ((0, 0), 0, 15),
('127.0.0.0', 1, 0), ((0, 0), 1, 0),
('127.0.0.0', 1, 1), ((0, 0), 1, 1),
('127.0.0.0', 1, 2), ((0, 1), 1, 2), ((0, 0), 1, 2),
('127.0.0.0', 1, 3), ((0, 1), 1, 3), ((0, 0), 1, 3),
('127.0.0.0', 1, 4), ((0, 2), 1, 4), ((0, 0), 1, 4),
('127.0.0.0', 1, 5), ((0, 2), 1, 5), ((0, 0), 1, 5),
('127.0.0.0', 1, 6), ((0, 3), 1, 6), ((0, 0), 1, 6),
('127.0.0.0', 1, 7), ((0, 3), 1, 7), ((0, 0), 1, 7),
('127.0.0.0', 1, 8), ((0, 3), 1, 8), ((0, 0), 1, 8),
('127.0.0.0', 1, 9), ((1, 4), 1, 9), ((0, 0), 1, 9),
('127.0.0.0', 1, 10), ((1, 4), 1, 10), ((0, 0), 1, 10),
('127.0.0.0', 1, 11), ((2, 5), 1, 11), ((0, 0), 1, 11),
('127.0.0.0', 1, 12), ((2, 5), 1, 12), ((0, 0), 1, 12),
('127.0.0.0', 1, 13), ((3, 6), 1, 13), ((0, 0), 1, 13),
('127.0.0.0', 1, 14), ((3, 6), 1, 14), ((0, 0), 1, 14),
('127.0.0.0', 1, 15), ((4, 7), 1, 15), ((0, 0), 1, 15),
('127.0.0.0', 2, 0), ((4, 7), 2, 0), ((0, 0), 2, 0),
('127.0.0.0', 2, 1), ((4, 7), 2, 1), ((0, 0), 2, 1),
('127.0.0.0', 2, 2), ((5, 7), 2, 2), ((0, 0), 2, 2),
('127.0.0.0', 2, 3), ((5, 7), 2, 3), ((0, 0), 2, 3),
('127.0.0.0', 2, 4), ((6, 7), 2, 4), ((0, 0), 2, 4),
('127.0.0.0', 2, 5), ((6, 7), 2, 5), ((0, 0), 2, 5),
('127.0.0.0', 2, 6), ((7, 7), 2, 6), ((0, 0), 2, 6),
('127.0.0.0', 2, 7), ((7, 7), 2, 7), ((0, 0), 2, 7),
('127.0.0.0', 2, 8), ((7, 7), 2, 8), ((0, 0), 2, 8),
('127.0.0.0', 2, 9), ((7, 6), 2, 9), ((0, 0), 2, 9),
('127.0.0.0', 2, 10), ((7, 6), 2, 10), ((0, 0), 2, 10),
('127.0.0.0', 2, 11), ((7, 5), 2, 11), ((0, 0), 2, 11),
('127.0.0.0', 2, 12), ((7, 5), 2, 12), ((0, 0), 2, 12),
('127.0.0.0', 2, 13), ((7, 4), 2, 13), ((0, 0), 2, 13),
('127.0.0.0', 2, 14), ((7, 4), 2, 14), ((0, 0), 2, 14),
('127.0.0.0', 2, 15), ((7, 3), 2, 15), ((0, 0), 2, 15)])
self.assertEqual(keys, set(vm._fpga_links.keys()))
data = set()
for (_, fpga_id, fpga_link), link in vm._fpga_links.items():
data.add((link.connected_chip_x, link.connected_chip_y,
link.connected_link, fpga_id, fpga_link))
expected = set([(7, 3, 0, 0, 0), (7, 3, 5, 0, 1), (6, 2, 0, 0, 2),
(6, 2, 5, 0, 3), (5, 1, 0, 0, 4), (5, 1, 5, 0, 5),
(4, 0, 0, 0, 6), (4, 0, 5, 0, 7), (4, 0, 4, 0, 8),
(3, 0, 5, 0, 9), (3, 0, 4, 0, 10), (2, 0, 5, 0, 11),
(2, 0, 4, 0, 12), (1, 0, 5, 0, 13), (1, 0, 4, 0, 14),
(0, 0, 5, 0, 15),
(0, 0, 4, 1, 0), (0, 0, 3, 1, 1), (0, 1, 4, 1, 2),
(0, 1, 3, 1, 3), (0, 2, 4, 1, 4), (0, 2, 3, 1, 5),
(0, 3, 4, 1, 6), (0, 3, 3, 1, 7), (0, 3, 2, 1, 8),
(1, 4, 3, 1, 9), (1, 4, 2, 1, 10), (2, 5, 3, 1, 11),
(2, 5, 2, 1, 12), (3, 6, 3, 1, 13), (3, 6, 2, 1, 14),
(4, 7, 3, 1, 15),
(4, 7, 2, 2, 0), (4, 7, 1, 2, 1), (5, 7, 2, 2, 2),
(5, 7, 1, 2, 3), (6, 7, 2, 2, 4), (6, 7, 1, 2, 5),
(7, 7, 2, 2, 6), (7, 7, 1, 2, 7), (7, 7, 0, 2, 8),
(7, 6, 1, 2, 9), (7, 6, 0, 2, 10), (7, 5, 1, 2, 11),
(7, 5, 0, 2, 12), (7, 4, 1, 2, 13), (7, 4, 0, 2, 14),
(7, 3, 1, 2, 15)])
self.assertEqual(data, expected)

def test_version_5_12_by_12(self):
set_config("Machine", "version", 5)
Expand All @@ -92,6 +176,39 @@ def test_version_5_12_by_12(self):
count += 1
self.assertEqual(48, count)
self.assertEqual((12, 0), vm.get_unused_xy())
spinnaker_links = (list(vm.spinnaker_links))
expected = []
self.assertEqual(expected, spinnaker_links)
# 8 links on each of the 6 sides recorded 3 times
# Except for the Ethernet Chip's 3 links which are only recorded twice
expected_fpgas = (8 * 6 * 3 - 3) * 3
self.assertEqual(expected_fpgas, len(vm._fpga_links))

def test_version_5_16_by_16(self):
set_config("Machine", "version", 5)
vm = virtual_machine(height=16, width=16, validate=True)
self.assertEqual(144, vm.n_chips)
self.assertEqual(3, len(vm.ethernet_connected_chips))
count = sum(1 for _chip in vm.chips for _link in _chip.router.links)
self.assertEqual(768, count)
count = 0
for _chip in vm.get_existing_xys_on_board(vm[1, 1]):
count += 1
self.assertEqual(48, count)
self.assertEqual((0, 4), vm.get_unused_xy())
spinnaker_links = (list(vm.spinnaker_links))
expected = []
sp = SpinnakerLinkData(0, 0, 0, 4, '127.0.0.0')
expected.append((('127.0.0.0', 0), sp))
expected.append((((0, 0), 0), sp))
sp = SpinnakerLinkData(0, 4, 8, 4, '127.0.4.8')
expected.append((('127.0.4.8', 0), sp))
expected.append((((4, 8), 0), sp))
self.assertEqual(expected, spinnaker_links)
# 8 links on each of the 6 sides recorded 3 times
# Except for the Ethernet Chip's 3 links which are only recorded twice
expected_fpgas = (8 * 6 * 3 - 3) * 3
self.assertEqual(expected_fpgas, len(vm._fpga_links))

def test_version_5_hole(self):
set_config("Machine", "version", 5)
Expand Down

0 comments on commit 20d0064

Please sign in to comment.