Skip to content

Commit

Permalink
Merge branch 'master' into reduce-op-complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows committed Aug 4, 2023
2 parents 37afaca + 5713976 commit 176fe34
Show file tree
Hide file tree
Showing 31 changed files with 1,281 additions and 1,160 deletions.
5 changes: 3 additions & 2 deletions quick_tests/quick_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from spinn_machine.tags import IPTag, ReverseIPTag
from spinnman.data import SpiNNManDataView
from spinnman.config_setup import unittest_setup
from spinnman.transceiver import create_transceiver_from_hostname
from spinnman.extended.extended_transceiver import (
create_transceiver_from_hostname)
from spinnman.model.enums import CPUState
from spinnman.messages.scp.enums import Signal
from spinnman.model import DiagnosticFilter
Expand All @@ -42,6 +43,7 @@
logging.basicConfig(level=logging.INFO)
logging.getLogger("spinnman.transceiver").setLevel(logging.DEBUG)

unittest_setup()
board_config = BoardTestConfiguration()
board_config.set_up_remote_board()

Expand Down Expand Up @@ -352,7 +354,6 @@ def print_transceiver_tests(transceiver):
print(heap_element)


unittest_setup()
with create_transceiver_from_hostname(
board_config.remotehost, board_config.board_version,
bmp_connection_data=board_config.bmp_names,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ packages = find:
zip_safe = True
include_package_data = True
install_requires =
SpiNNMachine == 1!6.0.1
SpiNNMachine == 1!7.1.0
websocket-client

[options.packages.find]
Expand Down
6 changes: 3 additions & 3 deletions spinnman/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "1!6.0.1"
__version_month__ = "May"
__version_year__ = "2021"
__version__ = "1!7.1.0"
__version_month__ = "TBD"
__version_year__ = "TBD"
__version_day__ = "TBD"
__version_name__ = "Not yet released"
9 changes: 0 additions & 9 deletions spinnman/board_test_configuration.cfg

This file was deleted.

51 changes: 21 additions & 30 deletions spinnman/board_test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import configparser
from contextlib import closing
import os
import socket
import unittest
from spinn_utilities.config_holder import set_config
from spinn_utilities.ping import Ping
from spinnman.model import BMPConnectionData
# from spinnman.model import BMPConnectionData

_LOCALHOST = "127.0.0.1"
# Microsoft invalid IP address. For more details see:
Expand All @@ -30,44 +27,38 @@
class BoardTestConfiguration(object):

def __init__(self):
self.localhost = None
self.localport = None
self.remotehost = None
self.board_version = None
self.bmp_names = None
self.auto_detect_bmp = None

self._config = configparser.RawConfigParser()
config_file = os.path.join(
os.path.dirname(__file__), "board_test_configuration.cfg")
self._config.read(config_file)

def set_up_local_virtual_board(self):
self.localhost = _LOCALHOST
self.localport = _PORT
self.remotehost = _LOCALHOST
self.board_version = self._config.getint("Machine", "version")
self.board_version = 5

def set_up_remote_board(self):
self.remotehost = self._config.get("Machine", "machineName")
if not Ping.host_is_reachable(self.remotehost):
raise unittest.SkipTest("test board appears to be down")
self.board_version = self._config.getint("Machine", "version")
self.bmp_names = self._config.get("Machine", "bmp_names")
if self.bmp_names == "None":
self.bmp_names = None
if Ping.host_is_reachable("192.168.240.253"):
self.remotehost = "192.168.240.253"
self.board_version = 3
set_config("Machine", "version", 3)
self.auto_detect_bmp = False
elif Ping.host_is_reachable("spinn-4.cs.man.ac.uk"):
self.remotehost = "spinn-4.cs.man.ac.uk"
self.board_version = 5
set_config("Machine", "version", 5)
elif Ping.host_is_reachable("192.168.240.1"):
self.remotehost = "192.168.240.1"
self.board_version = 5
set_config("Machine", "version", 5)
else:
self.bmp_names = [BMPConnectionData(
0, 0, self.bmp_names, [0], None)]
self.auto_detect_bmp = \
self._config.getboolean("Machine", "auto_detect_bmp")
self.localport = _PORT
with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s:
s.connect((self.remotehost, _PORT))
self.localhost = s.getsockname()[0]
raise unittest.SkipTest("None of the test boards reachable")

# it always was None but this is what to do if not
# self.bmp_names = BMPConnectionData(0, 0, self.bmp_names, [0], None)

def set_up_nonexistent_board(self):
self.localhost = None
self.localport = _PORT
self.remotehost = _NOHOST
self.board_version = self._config.getint("Machine", "version")
self.board_version = None
27 changes: 2 additions & 25 deletions spinnman/connections/udp_packet_connections/bmp_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class BMPConnection(UDPConnection, AbstractSCPConnection):
"""
A BMP connection which supports queries to the BMP of a SpiNNaker machine.
"""
__slots__ = (
"_boards",
"_cabinet",
"_frame")
__slots__ = ("_boards", )

def __init__(self, connection_data: BMPConnectionData):
"""
Expand All @@ -44,28 +41,8 @@ def __init__(self, connection_data: BMPConnectionData):
else connection_data.port_num
super().__init__(
remote_host=connection_data.ip_address, remote_port=port)
self._cabinet = connection_data.cabinet
self._frame = connection_data.frame
self._boards = connection_data.boards

@property
def cabinet(self) -> int:
"""
The cabinet ID of the BMP.
:rtype: int
"""
return self._cabinet

@property
def frame(self) -> int:
"""
The frame ID of the BMP.
:rtype: int
"""
return self._frame

@property
def boards(self) -> Sequence[int]:
"""
Expand Down Expand Up @@ -109,7 +86,7 @@ def send_scp_request(self, scp_request: AbstractSCPRequest):

def __repr__(self):
return (
f"BMPConnection(cabinet={self._cabinet}, frame={self._frame}, "
f"BMPConnection("
f"boards={self._boards}, local_host={self.local_ip_address}, "
f"local_port={self.local_port}, "
f"remote_host={self.remote_ip_address}, "
Expand Down
22 changes: 22 additions & 0 deletions spinnman/extended/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2023 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .bmp_set_led import BMPSetLed
from .de_alloc_sdram_process import DeAllocSDRAMProcess
from .read_adc import ReadADC
from .set_led import SetLED
from .write_memory_flood_process import WriteMemoryFloodProcess

__all__ = ["BMPSetLed", "DeAllocSDRAMProcess", "ReadADC", "SetLED",
"WriteMemoryFloodProcess"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Iterable, Union

from spinn_utilities.overrides import overrides
from spinnman.messages.scp import SCPRequestHeader
from spinnman.messages.scp.abstract_messages import (
AbstractSCPRequest, BMPRequest, BMPOKResponse)
from spinnman.messages.scp.abstract_messages.bmp_request import Boards
from spinnman.messages.scp.enums import SCPCommand, LEDAction
AbstractSCPRequest, BMPRequest)
from spinnman.messages.scp.enums import SCPCommand
from spinnman.messages.scp.impl.check_ok_response import CheckOKResponse


class BMPSetLed(BMPRequest[BMPOKResponse]):
class BMPSetLed(BMPRequest):
"""
Set the LED(s) of a board to either on, off or toggling.
This class is currently deprecated and untested as there is no
known use except for Transceiver.set_led which is itself deprecated.
"""
__slots__ = ()
__slots__ = []

def __init__(self, led: Union[int, Iterable[int]], action: LEDAction,
boards: Boards):
def __init__(self, led, action, boards):
"""
:param led: Number of the LED or an iterable of LEDs to set the
state of (0-7)
Expand All @@ -45,7 +44,7 @@ def __init__(self, led: Union[int, Iterable[int]], action: LEDAction,
if isinstance(led, int):
leds = [led]
else:
leds = list(led)
leds = led

# LED setting actions
arg1 = sum(action.value << (led * 2) for led in leds)
Expand All @@ -60,5 +59,5 @@ def __init__(self, led: Union[int, Iterable[int]], action: LEDAction,
argument_1=arg1, argument_2=arg2)

@overrides(AbstractSCPRequest.get_scp_response)
def get_scp_response(self) -> BMPOKResponse:
return BMPOKResponse("Set the LEDs of a board", SCPCommand.CMD_LED)
def get_scp_response(self):
return CheckOKResponse("Set the LEDs of a board", "CMD_LED")
65 changes: 65 additions & 0 deletions spinnman/extended/de_alloc_sdram_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

# Copyright (c) 2015 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from spinnman.messages.scp.impl import SDRAMDeAlloc
from spinnman.processes.abstract_multi_connection_process import (
AbstractMultiConnectionProcess)


class DeAllocSDRAMProcess(AbstractMultiConnectionProcess):
"""
.. warning::
This class is currently deprecated and untested as there is no
known use except for Transceiver.free_sdram and free_sdram_by_app_id
which are both themselves deprecated.
"""
__slots__ = [
"_no_blocks_freed"]

def __init__(self, connection_selector):
"""
:param connection_selector:
:type connection_selector:
AbstractMultiConnectionProcessConnectionSelector
"""
super().__init__(connection_selector)
self._no_blocks_freed = None

def de_alloc_sdram(self, x, y, app_id, base_address=None):
"""
:param int x:
:param int y:
:param int app_id:
:param base_address:
:type base_address: int or None
"""
callback = None
# deallocate space in the SDRAM
if base_address is None:
callback = self._handle_sdram_alloc_response
self._send_request(SDRAMDeAlloc(x, y, app_id, base_address),
callback=callback)
self._finish()
self.check_for_error()

def _handle_sdram_alloc_response(self, response):
self._no_blocks_freed = response.number_of_blocks_freed

@property
def no_blocks_freed(self):
"""
:rtype: int
"""
return self._no_blocks_freed
Loading

0 comments on commit 176fe34

Please sign in to comment.