Skip to content

Commit

Permalink
Merge pull request #469 from SpiNNakerManchester/placement_by_type
Browse files Browse the repository at this point in the history
Fix power monitor buffer extraction
  • Loading branch information
Christian-B committed Sep 28, 2022
2 parents e776117 + 2adce41 commit b294fdb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
19 changes: 17 additions & 2 deletions pacman/data/pacman_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ def iterate_placemements(cls):
raise cls._exception("placements")
return cls.__pacman_data._placements.placements

@classmethod
def iterate_placements_by_vertex_type(cls, vertex_type):
"""
Iterate over placements on any chip with this vertex_type
:param class vertex_type: Class of vertex to find
:rtype: Placement
:raises ~spinn_utilities.exceptions.SpiNNUtilsException:
If the placements are currently unavailable
"""
if cls.__pacman_data._placements is None:
raise cls._exception("placements")
return cls.__pacman_data._placements.\
iterate_placements_by_vertex_type(vertex_type)

@classmethod
def iterate_placements_on_core(cls, x, y):
"""
Expand All @@ -319,7 +334,7 @@ def iterate_placements_on_core(cls, x, y):
return cls.__pacman_data._placements.iterate_placements_on_core(x, y)

@classmethod
def iterate_placements_with_vertex_type(cls, x, y, vertex_type):
def iterate_placements_by_xy_and_type(cls, x, y, vertex_type):
"""
Iterate over placements with this x, y and this type
Expand All @@ -333,7 +348,7 @@ def iterate_placements_with_vertex_type(cls, x, y, vertex_type):
if cls.__pacman_data._placements is None:
raise cls._exception("placements")
return cls.__pacman_data._placements.\
iterate_placements_with_vertex_type(x, y, vertex_type)
iterate_placements_by_xy_and_type(x, y, vertex_type)

@classmethod
def get_n_placements(cls):
Expand Down
15 changes: 13 additions & 2 deletions pacman/model/placements/placements.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def iterate_placements_on_core(self, x, y):
"""
return self._placements[x, y].values()

def iterate_placements_with_vertex_type(self, x, y, vertex_type):
def iterate_placements_by_xy_and_type(self, x, y, vertex_type):
"""
Iterate over placements with this x, y and this type
Iterate over placements with this x, y and this vertex_type
:param int x: x coordinate to find placements for.
:param int y: y coordinate to find placements for.
Expand All @@ -152,6 +152,17 @@ def iterate_placements_with_vertex_type(self, x, y, vertex_type):
if isinstance(placement.vertex, vertex_type):
yield placement

def iterate_placements_by_vertex_type(self, vertex_type):
"""
Iterate over placements on any chip with this vertex_type
:param class vertex_type: Class of vertex to find
:rtype: Placement
"""
for placement in self._machine_vertices.values():
if isinstance(placement.vertex, vertex_type):
yield placement

def n_placements_on_chip(self, x, y):
""" The number of placements on the given chip
:param int x: x coordinate of chip.
Expand Down
2 changes: 1 addition & 1 deletion pacman/operations/fixed_route_router/fixed_route_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __locate_destination(self, chip):
"""
x = chip.x
y = chip.y
for placement in PacmanDataView.iterate_placements_with_vertex_type(
for placement in PacmanDataView.iterate_placements_by_xy_and_type(
x, y, self._destination_class):
return placement.p
raise PacmanConfigurationException(
Expand Down

0 comments on commit b294fdb

Please sign in to comment.