Skip to content

Commit

Permalink
Merge pull request #17 from SpiNNakerManchester/iptag_allocation_fix
Browse files Browse the repository at this point in the history
Iptag allocation fix

done
  • Loading branch information
alan-stokes committed Mar 6, 2015
2 parents 75ad358 + a4922f1 commit a6eb2c5
Show file tree
Hide file tree
Showing 71 changed files with 2,330 additions and 1,623 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from abc import ABCMeta
from six import add_metaclass
from pacman.model.constraints.abstract_constraint import AbstractConstraint

from pacman.model.constraints.abstract_constraints.abstract_constraint\
import AbstractConstraint
from pacman.exceptions import PacmanInvalidParameterException


@add_metaclass(ABCMeta)
class AbstractConstrainedVertex(object):
""" Represents a AbstractConstrainedVertex of a partitionable_graph, \
which contains a number of atoms, and\
which contains a number of atoms, and\
which can be partitioned into a number of subvertices, such that the\
total number of atoms in the subvertices adds up to the number of atoms\
in the vertex
total number of atoms in the subvertices adds up to the number of \
atoms in the vertex
"""

def __init__(self, label, constraints=None):
Expand Down Expand Up @@ -64,17 +66,17 @@ def add_constraint(self, constraint):
self._constraints.append(constraint)

def add_constraints(self, constraints):
""" Add an iterable of constraints to the collection of constraints for\
the vertex
""" Add an iterable of constraints to the collection of constraints \
for the vertex
:param constraints: iterable of constraints to add
:type constraints: iterable of\
:py:class:`pacman.model.constraints.abstract_constraint\
.AbstractConstraint`
:return: None
:rtype: None
:raise pacman.exceptions.PacmanInvalidParameterException: If one of the\
constraints is not valid
:raise pacman.exceptions.PacmanInvalidParameterException: If one of \
the constraints is not valid
"""
if constraints is not None:
for next_constraint in constraints:
Expand All @@ -90,8 +92,8 @@ def set_constraints(self, constraints):
.AbstractConstraint`
:return: None
:rtype: None
:raise pacman.exceptions.PacmanInvalidParameterException: If one of the\
constraints is not valid
:raise pacman.exceptions.PacmanInvalidParameterException: If one of \
the constraints is not valid
"""
self._constraints = list()
self.add_constraints(constraints)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,38 @@

@add_metaclass(ABCMeta)
class AbstractConstraint(object):
""" This represents a general constraint in PACMAN, which tells the various\
modules what they can and can't do
""" This represents a general constraint in PACMAN, which tells the \
various modules what they can and can't do
"""

def __init__(self, label):
"""
:param label: A label for the constraint
"""
self._label = label

@property
def label(self):
"""getter for label
""" The label of the constraint
:return: string rep of the constraint
:return: string representation of the constraint
:rtype: str
:raise None: this does not raise any known exception
"""
return self._label

@abstractmethod
def is_constraint(self):
""" Determine if this is a constraint - for abstract to work correctly
""" Determine if this is a constraint - for is_instance to work\
correctly
"""
pass

@classmethod
def __subclasshook__(cls, othercls):
""" Checks if all the abstract methods are present on the subclass
is only here for duck typing
"""
if not isabstract(cls) and not isabstract(othercls):
return NotImplemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
from abc import abstractmethod
from six import add_metaclass

from pacman.model.constraints.abstract_constraint import AbstractConstraint
from pacman.model.constraints.abstract_constraints.abstract_constraint \
import AbstractConstraint


@add_metaclass(ABCMeta)
class AbstractPartitionerConstraint(AbstractConstraint):
""" A constraint that will be used by the partitioner
"""

def __init__(self, label):
"""
:param label: A label for the constraint
"""
AbstractConstraint.__init__(self, label)

def is_constraint(self):
return True

Expand All @@ -18,6 +26,3 @@ def is_partitioner_constraint(self):
""" Determine if this is a partitioner constraint
"""
pass

def __init__(self, label):
AbstractConstraint.__init__(self, label)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from abc import abstractmethod
from six import add_metaclass

from pacman.model.constraints.abstract_constraint import AbstractConstraint
from pacman.model.constraints.abstract_constraints.abstract_constraint \
import AbstractConstraint


@add_metaclass(ABCMeta)
Expand All @@ -11,6 +12,10 @@ class AbstractPlacerConstraint(AbstractConstraint):
"""

def __init__(self, label):
"""
:param label: A label for the constraint
"""
AbstractConstraint.__init__(self, label)

def is_constraint(self):
Expand All @@ -23,10 +28,11 @@ def is_placer_constraint(self):
pass

@abstractmethod
def rank(self):
"""property method for all placer constraints to have for sorting
:return: the importance of this constraint over others in the same \
catergory
:rtype: int between 0 and sys.maxint.
def get_rank(self):
""" Relative importance of this constraint to other placement\
constraints
:return: The rank of the constraint, between 0 (least important)\
and sys.maxint (most important)
:rtype: int
:raise None: does not raise any known exception
"""
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
from abc import abstractmethod
from six import add_metaclass

from pacman.model.constraints.abstract_constraint import AbstractConstraint
from pacman.model.constraints.abstract_constraints.abstract_constraint \
import AbstractConstraint


@add_metaclass(ABCMeta)
class AbstractRouterConstraint(AbstractConstraint):
""" A constraint that will be used by the router
"""

def __init__(self, label):
"""
:param label: A label for the constraint
"""
AbstractConstraint.__init__(self, label)

def is_constraint(self):
return True

@abstractmethod
def is_router_constraint(self):
""" Determine if this is a placer constraint
""" Determine if this is a router constraint
"""
pass

def __init__(self, label):
AbstractConstraint.__init__(self, label)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
from abc import abstractmethod
from six import add_metaclass

from pacman.model.constraints.abstract_constraint import AbstractConstraint
from pacman.model.constraints.abstract_constraints.abstract_constraint \
import AbstractConstraint


@add_metaclass(ABCMeta)
class AbstractUtilityConstraint(AbstractConstraint):
""" A constraint that will be used by the router
""" A general purpose constraint not associated with any particular\
component
"""

def __init__(self, label):
"""
:param label: A label for the constraint
"""
AbstractConstraint.__init__(self, label)

def is_constraint(self):
return True

Expand All @@ -18,6 +27,3 @@ def is_utility_constraint(self):
""" Determine if this is a placer constraint
"""
pass

def __init__(self, label):
AbstractConstraint.__init__(self, label)
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pacman.model.constraints.abstract_router_constraint \
from pacman.model.constraints.abstract_constraints.abstract_router_constraint \
import AbstractRouterConstraint


Expand All @@ -21,8 +21,9 @@ def __init__(self, key_mask_function_call,
"""
AbstractRouterConstraint.__init__(
self, "key allocator constraint where subedges coming from the "
"vertex requires a specific key and mask which are generated "
"from the function call {}".format(key_mask_function_call))
"vertex requires a specific key and mask which are "
"generated from the function call {}".format(
key_mask_function_call))
self._key_function_call = key_mask_function_call
self._atom_ids_function_call = key_with_atom_ids_function_call

Expand All @@ -35,4 +36,4 @@ def key_function_call(self):

@property
def key_with_atom_ids_function_call(self):
return self._atom_ids_function_call
return self._atom_ids_function_call
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pacman.model.constraints.abstract_partitioner_constraint \
import AbstractPartitionerConstraint
from pacman.model.constraints.abstract_constraints\
.abstract_partitioner_constraint import AbstractPartitionerConstraint


class PartitionerMaximumSizeConstraint(AbstractPartitionerConstraint):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pacman.model.constraints.abstract_partitioner_constraint \
import AbstractPartitionerConstraint
from pacman.model.constraints.abstract_constraints\
.abstract_partitioner_constraint import AbstractPartitionerConstraint


class PartitionerSameSizeAsVertexConstraint(AbstractPartitionerConstraint):
Expand All @@ -12,12 +12,14 @@ def __init__(self, vertex):
"""
:param vertex: The vertex to which the constraint refers
:type vertex: :py:class:`pacman.model.graph.vertex.AbstractConstrainedVertex`
:type vertex:\
:py:class:`pacman.model.graph.vertex.AbstractConstrainedVertex`
:raise None: does not raise any known exceptions
"""
AbstractPartitionerConstraint.__init__(
self, "partitioner same size as other vertex constraint with vertex"
"{}".format(vertex))
self,
"partitioner same size as other vertex constraint with vertex"
"{}".format(vertex))
self._vertex = vertex

def is_partitioner_constraint(self):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pacman.model.constraints.abstract_placer_constraint \
import AbstractPlacerConstraint
import sys

from pacman.model.constraints.abstract_constraints.abstract_placer_constraint \
import AbstractPlacerConstraint


class PlacerChipAndCoreConstraint(AbstractPlacerConstraint):
""" Creates a constraint object to place a vertex or a subvertex on a\
Expand Down Expand Up @@ -29,8 +30,7 @@ def __init__(self, x, y, p=None):
def is_placer_constraint(self):
return True

@property
def rank(self):
def get_rank(self):
if self.p is not None:
return sys.maxint
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pacman.model.constraints.abstract_placer_constraint import \
AbstractPlacerConstraint

import sys

from pacman.model.constraints.abstract_constraints.\
abstract_placer_constraint import AbstractPlacerConstraint


class PlacerRadialPlacementFromChipConstraint(AbstractPlacerConstraint):
""" Creates a constraint object to place a vertex or a subvertex on a\
""" Creates a constraint object to place the subvertices of a vertex on a\
specific chip, and optionally a specific core on that chip
"""

Expand Down Expand Up @@ -33,9 +33,8 @@ def x(self):
def y(self):
return self._y

@property
def rank(self):
return sys.maxint - 3
def get_rank(self):
return sys.maxint - 10

def is_placer_constraint(self):
return True
40 changes: 0 additions & 40 deletions pacman/model/constraints/placer_subvertex_same_chip_constraint.py

This file was deleted.

Empty file.

0 comments on commit a6eb2c5

Please sign in to comment.