Skip to content

Commit

Permalink
Merge pull request #428 from SpiNNakerManchester/constraints
Browse files Browse the repository at this point in the history
Constraints
  • Loading branch information
rowleya committed Mar 31, 2022
2 parents e50b18c + da7a002 commit 4ef3f23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
11 changes: 6 additions & 5 deletions pacman/operations/placer_algorithms/radial_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def _run(self, machine_graph, machine, plan_n_timesteps):
If something goes wrong with the placement
"""
# check that the algorithm can handle the constraints
self._check_constraints(machine_graph.vertices)
self._check_constraints(
machine_graph.vertices,
additional_placement_constraints={SameChipAsConstraint})

placements = Placements()
vertices = sort_vertices_by_known_constraints(machine_graph.vertices)
Expand All @@ -87,11 +89,10 @@ def _run(self, machine_graph, machine, plan_n_timesteps):

def _check_constraints(
self, vertices, additional_placement_constraints=None):
placement_constraints = {
RadialPlacementFromChipConstraint, SameChipAsConstraint
}
if additional_placement_constraints is not None:
placement_constraints.update(additional_placement_constraints)
placement_constraints = additional_placement_constraints
else:
placement_constraints = {}
ResourceTracker.check_constraints(
vertices, additional_placement_constraints=placement_constraints)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import unittest
from spinn_machine import virtual_machine
from pacman.config_setup import unittest_setup
from pacman.exceptions import PacmanAlreadyPlacedError
from pacman.model.graphs.machine import MachineGraph, SimpleMachineVertex
from pacman.model.resources import ResourceContainer
from pacman.model.constraints.placer_constraints import SameChipAsConstraint
from pacman.model.routing_info import DictBasedMachinePartitionNKeysMap
from pacman.operations.placer_algorithms import (
connective_based_placer, one_to_one_placer, radial_placer, spreader_placer)
from pacman.exceptions import PacmanInvalidParameterException


class TestSameChipConstraint(unittest.TestCase):
Expand Down Expand Up @@ -84,11 +84,8 @@ def _do_test(self, placer):
"Vertex was not placed on the same chip as requested")

def test_connective_based(self):
try:
with self.assertRaises(PacmanInvalidParameterException):
self._do_test("ConnectiveBasedPlacer")
except PacmanAlreadyPlacedError:
raise unittest.SkipTest(
"https://github.com/SpiNNakerManchester/PACMAN/issues/406")

def test_one_to_one(self):
self._do_test("OneToOnePlacer")
Expand Down

0 comments on commit 4ef3f23

Please sign in to comment.