Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/proper_reboot_wait' into proper_…
Browse files Browse the repository at this point in the history
…reboot_wait
  • Loading branch information
alan-stokes committed Jul 8, 2020
2 parents 8de86a7 + 91bc0f0 commit b69a892
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python:
- 2.7
- 3.6
- 3.7
dist: xenial
dist: focal
addons:
apt:
packages:
Expand Down
5 changes: 3 additions & 2 deletions spinnman/messages/scp/impl/check_ok_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class CheckOKResponse(AbstractSCPResponse):
def __init__(self, operation, command):
"""
:param str operation: The operation being performed
:param str command: The command that was sent
:param command: The command that was sent
:type command: str or ~enum.Enum or int
"""
super(CheckOKResponse, self).__init__()
self._operation = operation
Expand All @@ -40,4 +41,4 @@ def read_data_bytestring(self, data, offset):
result = self.scp_response_header.result
if result != SCPResult.RC_OK:
raise SpinnmanUnexpectedResponseCodeException(
self._operation, self._command, result.name)
self._operation, str(self._command), result.name)
3 changes: 2 additions & 1 deletion spinnman/messages/scp/impl/iptag_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(self, x, y, host, port, tag, strip, use_sender=False):
"""
:param int x: The x-coordinate of a chip, between 0 and 255
:param int y: The y-coordinate of a chip, between 0 and 255
:param bytes host: The host address, as an array of 4 bytes
:param bytearray or list[int] host: The host address, \
as an array of 4 bytes
:param int port: The port, between 0 and 65535
:param int tag: The tag, between 0 and 7
:param bool strip: if the SDP header should be striped from the packet
Expand Down
48 changes: 45 additions & 3 deletions spinnman/model/executable_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# 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 collections import defaultdict
from spinn_utilities.ordered_set import OrderedSet
from spinn_machine import CoreSubsets
from spinnman.exceptions import SpinnmanInvalidParameterException

Expand All @@ -23,26 +25,33 @@ class ExecutableTargets(object):
__slots__ = [
"_all_core_subsets",
"_targets",
"_total_processors"]
"_total_processors",
"_binary_type_map"]

def __init__(self):
self._targets = dict()
self._total_processors = 0
self._all_core_subsets = CoreSubsets()
self._binary_type_map = defaultdict(OrderedSet)

def add_subsets(self, binary, subsets):
def add_subsets(self, binary, subsets, executable_type=None):
""" Add core subsets to a binary
:param str binary: the path to the binary needed to be executed
:param ~spinn_machine.CoreSubsets subsets:
the subset of cores that the binary needs to be loaded on
:param executable_type: the type of this executable.
None means dont record it.
:return:
"""
for subset in subsets.core_subsets:
for p in subset.processor_ids:
self.add_processor(binary, subset.x, subset.y, p)
if executable_type is not None:
self._binary_type_map[executable_type].add(binary)

def add_processor(self, binary, chip_x, chip_y, chip_p):
def add_processor(
self, binary, chip_x, chip_y, chip_p, executable_type=None):
""" Add a processor to the executable targets
:param str binary: the binary path for executable
Expand All @@ -51,16 +60,49 @@ def add_processor(self, binary, chip_x, chip_y, chip_p):
:param int chip_y:
the coordinate on the machine in terms of y for the chip
:param int chip_p: the processor ID to place this executable on
:param ExecutableType executable_type:
the executable type for locating n cores of
:return:
"""
if self.known(binary, chip_x, chip_y, chip_p):
return
if binary not in self._targets:
self._targets[binary] = CoreSubsets()
if executable_type is not None:
self._binary_type_map[executable_type].add(binary)
self._targets[binary].add_processor(chip_x, chip_y, chip_p)
self._all_core_subsets.add_processor(chip_x, chip_y, chip_p)
self._total_processors += 1

def get_n_cores_for_executable_type(self, executable_type):
""" get the number of cores that the executable type is using
:param ExecutableType executable_type:
the executable type for locating n cores of
:return: the number of cores using this executable type
:rtype: int
"""
return sum(
len(self.get_cores_for_binary(aplx))
for aplx in self._binary_type_map[executable_type])

def get_binaries_of_executable_type(self, executable_type):
""" get the binaries of a given a executable type
:param ExecutableType executable_type: the executable type enum value
:return: iterable of binaries with that executable type
:rtype: iterable(str)
"""
return self._binary_type_map[executable_type]

def executable_types_in_binary_set(self):
""" get the executable types in the set of binaries
:return: iterable of the executable types in this binary set.
:rtype: iterable(ExecutableType)
"""
return self._binary_type_map.keys()

def get_cores_for_binary(self, binary):
""" Get the cores that a binary is to run on
Expand Down

0 comments on commit b69a892

Please sign in to comment.