-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into upgrade_travis_dist_to_bionic
- Loading branch information
Showing
28 changed files
with
653 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
pacman/model/routing_tables/abstract_multicast_routing_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright (c) 2019-2020 The University of Manchester | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# 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 six import add_metaclass | ||
from spinn_utilities.abstract_base import AbstractBase, abstractproperty, \ | ||
abstractmethod | ||
|
||
|
||
@add_metaclass(AbstractBase) | ||
class AbsractMulticastRoutingTable(object): | ||
|
||
@abstractproperty | ||
def x(self): | ||
"""The x-coordinate of the chip of this table | ||
:return: The x-coordinate | ||
:rtype: int | ||
""" | ||
|
||
@abstractproperty | ||
def y(self): | ||
""" The y-coordinate of the chip of this table | ||
:return: The y-coordinate | ||
:rtype: int | ||
""" | ||
|
||
@abstractproperty | ||
def multicast_routing_entries(self): | ||
""" The multicast routing entries in the table | ||
:return: an iterable of multicast routing entries | ||
:rtype: iterable(:py:class:`spinn_machine.MulticastRoutingEntry`) | ||
:raise None: does not raise any known exceptions | ||
""" | ||
|
||
@abstractproperty | ||
def number_of_entries(self): | ||
""" The number of multi-cast routing entries there are in the\ | ||
multicast routing table | ||
:return: int | ||
""" | ||
|
||
@abstractproperty | ||
def number_of_defaultable_entries(self): | ||
""" The number of multi-cast routing entries that are set to be\ | ||
defaultable within this multicast routing table | ||
:return: int | ||
""" | ||
|
||
@abstractmethod | ||
def __eq__(self, other): | ||
"""equals method""" | ||
|
||
@abstractmethod | ||
def __ne__(self, other): | ||
""" not equals method""" | ||
|
||
@abstractmethod | ||
def __hash__(self): | ||
"""hash""" | ||
|
||
@abstractmethod | ||
def __repr__(self): | ||
"""repr""" |
127 changes: 127 additions & 0 deletions
127
pacman/model/routing_tables/compressed_multicast_routing_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Copyright (c) 2019-2020 The University of Manchester | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# 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 pacman.model.routing_tables.abstract_multicast_routing_table import \ | ||
AbsractMulticastRoutingTable | ||
from spinn_utilities.overrides import overrides | ||
|
||
|
||
class CompressedMulticastRoutingTable(AbsractMulticastRoutingTable): | ||
""" Represents a compressed routing table for a chip. | ||
""" | ||
|
||
__slots__ = [ | ||
# The x-coordinate of the chip for which this is the routing table | ||
"_x", | ||
|
||
# The y-coordinate of the chip for which this is the routing tables | ||
"_y", | ||
|
||
# An iterable of routing entries to add to the table | ||
"_multicast_routing_entries", | ||
|
||
# counter of how many entries in their multicast routing table are | ||
# defaultable | ||
"_number_of_defaulted_routing_entries" | ||
] | ||
|
||
def __init__(self, x, y, multicast_routing_entries=None): | ||
""" | ||
:param x: \ | ||
The x-coordinate of the chip for which this is the routing table | ||
:type x: int | ||
:param y: \ | ||
The y-coordinate of the chip for which this is the routing tables | ||
:type y: int | ||
:param multicast_routing_entries: \ | ||
The routing entries to add to the table | ||
:type multicast_routing_entries: \ | ||
iterable(:py:class:`spinn_machine.MulticastRoutingEntry`) | ||
:raise pacman.exceptions.PacmanAlreadyExistsException: If any two\ | ||
routing entries contain the same key-mask combination | ||
""" | ||
self._x = x | ||
self._y = y | ||
self._number_of_defaulted_routing_entries = 0 | ||
self._multicast_routing_entries = list() | ||
|
||
if multicast_routing_entries is not None: | ||
for multicast_routing_entry in multicast_routing_entries: | ||
self.add_multicast_routing_entry(multicast_routing_entry) | ||
|
||
def add_multicast_routing_entry(self, multicast_routing_entry): | ||
""" Adds a routing entry to this table | ||
:param multicast_routing_entry: The route to add | ||
:type multicast_routing_entry:\ | ||
:py:class:`spinn_machine.MulticastRoutingEntry` | ||
:rtype: None | ||
:raise pacman.exceptions.PacmanAlreadyExistsException: If a routing\ | ||
entry with the same key-mask combination already exists | ||
""" | ||
self._multicast_routing_entries.append(multicast_routing_entry) | ||
|
||
# update default routed counter if required | ||
if multicast_routing_entry.defaultable: | ||
self._number_of_defaulted_routing_entries += 1 | ||
|
||
@property | ||
@overrides(AbsractMulticastRoutingTable.x) | ||
def x(self): | ||
return self._x | ||
|
||
@property | ||
@overrides(AbsractMulticastRoutingTable.y) | ||
def y(self): | ||
return self._y | ||
|
||
@property | ||
@overrides(AbsractMulticastRoutingTable.multicast_routing_entries) | ||
def multicast_routing_entries(self): | ||
return self._multicast_routing_entries | ||
|
||
@property | ||
@overrides(AbsractMulticastRoutingTable.number_of_entries) | ||
def number_of_entries(self): | ||
return len(self._multicast_routing_entries) | ||
|
||
@property | ||
@overrides(AbsractMulticastRoutingTable.number_of_defaultable_entries) | ||
def number_of_defaultable_entries(self): | ||
return self._number_of_defaulted_routing_entries | ||
|
||
@overrides(AbsractMulticastRoutingTable.__eq__) | ||
def __eq__(self, other): | ||
if not isinstance(other, CompressedMulticastRoutingTable): | ||
return False | ||
if self._x != other.x and self._y != other.y: | ||
return False | ||
return self._multicast_routing_entries == \ | ||
other.multicast_routing_entries | ||
|
||
@overrides(AbsractMulticastRoutingTable.__ne__) | ||
def __ne__(self, other): | ||
return not self.__eq__(other) | ||
|
||
@overrides(AbsractMulticastRoutingTable.__repr__) | ||
def __repr__(self): | ||
entry_string = "" | ||
for entry in self._multicast_routing_entries: | ||
entry_string += "{}\n".format(entry) | ||
return "{}:{}\n\n{}".format(self._x, self._y, entry_string) | ||
|
||
@overrides(AbsractMulticastRoutingTable.__hash__) | ||
def __hash__(self): | ||
return id(self) |
Oops, something went wrong.