Skip to content

Commit

Permalink
Merge pull request #413 from SpiNNakerManchester/no_executor2
Browse files Browse the repository at this point in the history
No executor algorithms now functions and No xml
  • Loading branch information
rowleya committed Nov 24, 2021
2 parents 40f5644 + ac4535e commit a015273
Show file tree
Hide file tree
Showing 55 changed files with 688 additions and 1,464 deletions.
5 changes: 0 additions & 5 deletions pacman/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@
"""
The algorithms in the subpackages are generally :py:obj:`callable`.
"""

import os

algorithms_metdata_file = os.path.join(
os.path.dirname(__file__), "algorithms_metadata.xml")
612 changes: 0 additions & 612 deletions pacman/operations/algorithms_metadata.xml

This file was deleted.

114 changes: 0 additions & 114 deletions pacman/operations/algorithms_metadata_schema.xsd

This file was deleted.

4 changes: 2 additions & 2 deletions pacman/operations/chip_id_allocator_algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .malloc_based_chip_id_allocator import MallocBasedChipIdAllocator
from .malloc_based_chip_id_allocator import malloc_based_chip_id_allocator

__all__ = ['MallocBasedChipIdAllocator', ]
__all__ = ['malloc_based_chip_id_allocator', ]
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ def __init__(self, vertex):
vertex.spinnaker_link_id, vertex.board_address))


class MallocBasedChipIdAllocator(ElementAllocatorAlgorithm):
def malloc_based_chip_id_allocator(machine, graph):
"""
:param ~spinn_machine.Machine machine:
:param graph:
:type graph: Graph
:rtype: ~spinn_machine.Machine
:raises PacmanConfigurationException:
If a virtual chip is in an impossible position.
"""
allocator = _MallocBasedChipIdAllocator()
return allocator._run(machine, graph)


class _MallocBasedChipIdAllocator(ElementAllocatorAlgorithm):
""" A Chip ID Allocation Allocator algorithm that keeps track of\
chip IDs and attempts to allocate them as requested
"""
Expand All @@ -58,7 +71,7 @@ def __init__(self):
# we only want one virtual chip per 'link'
self._virtual_chips = dict()

def __call__(self, machine, graph=None):
def _run(self, machine, graph=None):
"""
:param ~spinn_machine.Machine machine:
:param graph:
Expand Down
4 changes: 2 additions & 2 deletions pacman/operations/fixed_route_router/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .fixed_route_router import FixedRouteRouter
from .fixed_route_router import fixed_route_router

__all__ = ["FixedRouteRouter"]
__all__ = ["fixed_route_router"]
38 changes: 28 additions & 10 deletions pacman/operations/fixed_route_router/fixed_route_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,24 @@
PacmanRoutingException)


class FixedRouteRouter(object):
def fixed_route_router(machine, placements, destination_class):
""" Runs the fixed route generator for all boards on machine
:param ~spinn_machine.Machine machine: SpiNNMachine object
:param Placements placements: placements object
:param destination_class: the destination class to route packets to
:type destination_class: type or tuple(type,...)
:return: router tables for fixed route paths
:rtype: dict(tuple(int,int), ~spinn_machine.FixedRouteEntry)
:raises PacmanConfigurationException: if no placement processor found
:raises PacmanRoutingException:
:raises PacmanAlreadyExistsException:
"""
router = _FixedRouteRouter(machine, placements, destination_class)
return router._run()


class _FixedRouteRouter(object):
""" Computes the fixed routes used to direct data out traffic to the
board-local gatherer processors.
"""
Expand All @@ -29,7 +46,13 @@ class FixedRouteRouter(object):
"_destination_class", "_fixed_route_tables",
"_machine", "_placements"]

def __call__(self, machine, placements, destination_class):
def __init__(self, machine, placements, destination_class):
self._machine = machine
self._destination_class = destination_class
self._placements = placements
self._fixed_route_tables = dict()

def _run(self):
""" Runs the fixed route generator for all boards on machine
:param ~spinn_machine.Machine machine: SpiNNMachine object
Expand All @@ -43,18 +66,13 @@ def __call__(self, machine, placements, destination_class):
:raises PacmanAlreadyExistsException:
"""
# pylint: disable=attribute-defined-outside-init

self._machine = machine
self._destination_class = destination_class
self._placements = placements
self._fixed_route_tables = dict()

progress = ProgressBar(
len(machine.ethernet_connected_chips),
len(self._machine.ethernet_connected_chips),
"Generating fixed router routes")

# handle per board
for ethernet_chip in progress.over(machine.ethernet_connected_chips):
for ethernet_chip in progress.over(
self._machine.ethernet_connected_chips):
self._do_fixed_routing(ethernet_chip)
return self._fixed_route_tables

Expand Down
4 changes: 2 additions & 2 deletions pacman/operations/partition_algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .splitter_partitioner import SplitterPartitioner
from .splitter_partitioner import splitter_partitioner

__all__ = ['SplitterPartitioner']
__all__ = ['splitter_partitioner']
29 changes: 27 additions & 2 deletions pacman/operations/partition_algorithms/splitter_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,32 @@
from pacman.utilities import utility_calls as utils


class SplitterPartitioner(AbstractSplitterPartitioner):
def splitter_partitioner(
app_graph, machine, plan_n_time_steps, pre_allocated_resources=None):
"""
:param ApplicationGraph app_graph: The application_graph to partition
:param ~spinn_machine.Machine machine:
The machine with respect to which to partition the application
graph
:param plan_n_time_steps:
the number of time steps to plan to run for
:type plan_n_time_steps: int or None
:param pre_allocated_resources:
res needed to be preallocated before making new machine vertices
:type pre_allocated_resources: PreAllocatedResourceContainer or None
:return:
A machine_graph of partitioned vertices and partitioned edges,
and the number of chips needed to satisfy this partitioning.
:rtype: tuple(MachineGraph, int)
:raise PacmanPartitionException:
If something goes wrong with the partitioning
"""
partitioner = _SplitterPartitioner()
return partitioner._run(
app_graph, machine, plan_n_time_steps, pre_allocated_resources)


class _SplitterPartitioner(AbstractSplitterPartitioner):
""" Partitioner which hands the partitioning work to application vertices'\
splitter objects.
"""
Expand Down Expand Up @@ -59,7 +84,7 @@ class SplitterPartitioner(AbstractSplitterPartitioner):
__slots__ = []

# inherited from AbstractPartitionAlgorithm
def __call__(
def _run(
self, app_graph, machine, plan_n_time_steps,
pre_allocated_resources=None):
"""
Expand Down
12 changes: 6 additions & 6 deletions pacman/operations/placer_algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .radial_placer import RadialPlacer
from .one_to_one_placer import OneToOnePlacer
from .spreader_placer import SpreaderPlacer
from .connective_based_placer import ConnectiveBasedPlacer
from .radial_placer import radial_placer
from .one_to_one_placer import one_to_one_placer
from .spreader_placer import spreader_placer
from .connective_based_placer import connective_based_placer

__all__ = ['RadialPlacer', 'OneToOnePlacer', "SpreaderPlacer",
'ConnectiveBasedPlacer']
__all__ = ['radial_placer', 'one_to_one_placer', "spreader_placer",
'connective_based_placer']
29 changes: 26 additions & 3 deletions pacman/operations/placer_algorithms/connective_based_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pacman.model.constraints.placer_constraints import (
AbstractPlacerConstraint)
from pacman.model.placements import Placements
from pacman.operations.placer_algorithms import RadialPlacer
from pacman.operations.placer_algorithms.radial_placer import _RadialPlacer
from pacman.utilities.algorithm_utilities.placer_algorithm_utilities import (
sort_vertices_by_known_constraints, get_same_chip_vertex_groups)
from pacman.utilities.utility_calls import locate_constraints_of_type
Expand All @@ -28,7 +28,30 @@
logger = FormatAdapter(logging.getLogger(__name__))


class ConnectiveBasedPlacer(RadialPlacer):
def connective_based_placer(machine_graph, machine, plan_n_timesteps):
"""
Runs a placer that considers connectivity
A radial algorithm that can place a machine graph onto a\
machine using a circle out behaviour from a Ethernet at a given point\
and which will place things that are most connected closest to each\
other
:param MachineGraph machine_graph: The machine_graph to place
:param ~spinn_machine.Machine machine:
The machine with respect to which to partition the application
graph
:param int plan_n_timesteps: number of timesteps to plan for
:return: A set of placements
:rtype: ~pacman.model.placements.Placements
:raise PacmanPlaceException:
If something goes wrong with the placement
"""
placer = _ConnectiveBasedPlacer()
return placer._run(machine_graph, machine, plan_n_timesteps)


class _ConnectiveBasedPlacer(_RadialPlacer):
""" A radial algorithm that can place a machine graph onto a\
machine using a circle out behaviour from a Ethernet at a given point\
and which will place things that are most connected closest to each\
Expand All @@ -37,7 +60,7 @@ class ConnectiveBasedPlacer(RadialPlacer):

__slots__ = []

def __call__(self, machine_graph, machine, plan_n_timesteps):
def _run(self, machine_graph, machine, plan_n_timesteps):
"""
:param MachineGraph machine_graph: The machine_graph to place
:param ~spinn_machine.Machine machine:
Expand Down
24 changes: 21 additions & 3 deletions pacman/operations/placer_algorithms/one_to_one_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
PacmanException, PacmanInvalidParameterException, PacmanValueError,
PacmanPlaceException)
from pacman.model.placements import Placement, Placements
from pacman.operations.placer_algorithms import RadialPlacer
from pacman.operations.placer_algorithms.radial_placer import _RadialPlacer
from pacman.utilities.utility_objs import ResourceTracker
from pacman.utilities.algorithm_utilities.placer_algorithm_utilities import (
create_vertices_groups, get_same_chip_vertex_groups,
Expand All @@ -42,14 +42,32 @@ def _conflict(x, y, post_x, post_y):
return False


class OneToOnePlacer(RadialPlacer):
def one_to_one_placer(machine_graph, machine, plan_n_timesteps):
""" Placer that puts vertices which are directly connected to only its\
destination on the same chip
:param MachineGraph machine_graph: The machine_graph to place
:param ~spinn_machine.Machine machine:
The machine with respect to which to partition the application
graph
:param int plan_n_timesteps: number of timesteps to plan for
:return: A set of placements
:rtype: Placements
:raise PacmanPlaceException:
If something goes wrong with the placement
"""
placer = _OneToOnePlacer()
return placer._run(machine_graph, machine, plan_n_timesteps)


class _OneToOnePlacer(_RadialPlacer):
""" Placer that puts vertices which are directly connected to only its\
destination on the same chip
"""

__slots__ = []

def __call__(self, machine_graph, machine, plan_n_timesteps):
def _run(self, machine_graph, machine, plan_n_timesteps):
"""
:param MachineGraph machine_graph: The machine_graph to place
:param ~spinn_machine.Machine machine:
Expand Down

0 comments on commit a015273

Please sign in to comment.