Skip to content

Commit

Permalink
Merge pull request #21 from SpiNNakerManchester/reload_without_reinje…
Browse files Browse the repository at this point in the history
…ction

updates to work with reload script

tested and assumed due to rowley being on hols and having pointed out errors in file loss (most of which were just movement losses) that the merge is valid
  • Loading branch information
alan-stokes committed Jul 27, 2015
2 parents cc5ff8b + 567e0e7 commit 15dbe15
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions pacman/model/data_request_interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from abc import ABCMeta
from six import add_metaclass
from abc import abstractmethod

@add_metaclass(ABCMeta)
class RequiresRoutingInfoPartitionedVertex(object):
"""
class which can be inhirttied from, which will then force the key
allocator to inform the vertex of itw keys when decided upon.
"""

def __init__(self):
pass

@abstractmethod
def set_routing_infos(self, subedge_routing_infos):
"""
abstract method to force systems which need to adjust their code when
keys are allocated.
:param subedge_routing_infos: a iterable of subedge_routing_info
:return: none
"""
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
BasicRoutingInfoAllocator
"""
from pacman.model.data_request_interfaces.\
abstract_requires_routing_info_partitioned_vertex import \
RequiresRoutingInfoPartitionedVertex
from pacman.model.routing_info.routing_info import RoutingInfo
from pacman.model.routing_info.subedge_routing_info import SubedgeRoutingInfo
from pacman.operations.abstract_algorithms.\
Expand Down Expand Up @@ -27,9 +33,17 @@ def __init__(self):
AbstractRoutingInfoAllocatorAlgorithm.__init__(self)

def allocate_routing_info(self, subgraph, placements, n_keys_map):
"""
executes the routing info alloc
:param subgraph:
:param placements:
:param n_keys_map:
:return:
"""

# check that this algorithm supports the constraints put onto the
# partitioned_edges
self._supported_constraints.append(RequiresRoutingInfoPartitionedVertex)
utility_calls.check_algorithm_can_support_constraints(
constrained_vertices=subgraph.subedges,
supported_constraints=self._supported_constraints,
Expand Down Expand Up @@ -59,6 +73,21 @@ def allocate_routing_info(self, subgraph, placements, n_keys_map):
subedge_routing_info = SubedgeRoutingInfo(
keys_and_masks, out_going_subedge)
routing_infos.add_subedge_info(subedge_routing_info)

# handle the request for all partitioned vertices which require the
# routing info for configuring their data.
for partitioned_vertex in subgraph.subvertices:
if isinstance(partitioned_vertex,
RequiresRoutingInfoPartitionedVertex):
vertex_sub_edge_routing_infos = list()
outgoing_edges = subgraph.\
outgoing_subedges_from_subvertex(partitioned_vertex)
for outgoing_edge in outgoing_edges:
vertex_sub_edge_routing_infos.append(
routing_infos.
get_subedge_information_from_subedge(outgoing_edge))
partitioned_vertex.set_routing_infos(
vertex_sub_edge_routing_infos)
progress_bar.update()
progress_bar.end()
return routing_infos
Expand All @@ -73,4 +102,4 @@ def _get_key_from_placement(placement):
:return: The key
:rtype: int
"""
return placement.x << 24 | placement.y << 16 | placement.p << 11
return placement.x << 24 | placement.y << 16 | placement.p << 11
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.key_allocator_same_keys_constraint import KeyAllocatorSameKeysConstraint
from pacman.model.constraints.key_allocator_constraints\
.key_allocator_fixed_mask_constraint import KeyAllocatorFixedMaskConstraint
from pacman.model.data_request_interfaces.abstract_requires_routing_info_partitioned_vertex import \
RequiresRoutingInfoPartitionedVertex
from pacman.operations.routing_info_allocator_algorithms\
.malloc_based_routing_allocator.key_field_generator \
import KeyFieldGenerator
Expand Down Expand Up @@ -96,6 +98,21 @@ def allocate_routing_info(self, subgraph, placements, n_keys_map):
SubedgeRoutingInfo(keys_and_masks, edge))
progress_bar.update()

# handle the request for all partitioned vertices which require the
# routing info for configuring their data.
for partitioned_vertex in subgraph.subvertices:
if isinstance(partitioned_vertex,
RequiresRoutingInfoPartitionedVertex):
vertex_sub_edge_routing_infos = list()
outgoing_edges = subgraph.\
outgoing_subedges_from_subvertex(partitioned_vertex)
for outgoing_edge in outgoing_edges:
vertex_sub_edge_routing_infos.append(
routing_infos.
get_subedge_information_from_subedge(outgoing_edge))
partitioned_vertex.set_routing_infos(
vertex_sub_edge_routing_infos)

progress_bar.end()
return routing_infos

Expand Down Expand Up @@ -361,4 +378,4 @@ def _allocate_keys_and_masks(self, fixed_mask, fields, edge_n_keys,
return keys_and_masks

raise PacmanRouteInfoAllocationException(
"Could not find space to allocate keys")
"Could not find space to allocate keys")

0 comments on commit 15dbe15

Please sign in to comment.