Пример #1
0
    def __init__(self,
                 x,
                 y,
                 ip_address,
                 report_default_directory,
                 write_data_speed_up_report,
                 constraints=None):
        super(DataSpeedUpPacketGatherMachineVertex, self).__init__(
            label="mc_data_speed_up_packet_gatherer_on_{}_{}".format(x, y),
            constraints=constraints)

        # data holders for the output, and sequence numbers
        self._view = None
        self._max_seq_num = None
        self._output = None

        # Create a connection to be used
        self._connection = SCAMPConnection(chip_x=x,
                                           chip_y=y,
                                           remote_host=ip_address)

        # local provenance storage
        self._provenance_data_items = defaultdict(list)

        # create report if it doesn't already exist
        self._report_path = \
            os.path.join(report_default_directory, self.REPORT_NAME)
        self._write_data_speed_up_report = write_data_speed_up_report

        # Stored reinjection status for resetting timeouts
        self._last_status = None
Пример #2
0
    def test_clear_iobuf_process(self):
        receiver = MockMachine()
        receiver.start()

        # Set up a connection to the "machine"
        connection = SCAMPConnection(0,
                                     0,
                                     remote_host="127.0.0.1",
                                     remote_port=receiver.local_port)
        selector = RoundRobinConnectionSelector([connection])

        # Create the process and run it
        process = ClearIOBUFProcess(selector)
        process.clear_iobuf(CoreSubsets([CoreSubset(0, 0, [1])]), 1)
        receiver.stop()

        # Check the message received
        self.assertTrue(receiver.is_next_message)
        data = receiver.next_message
        sdp_header = SDPHeader.from_bytestring(data, 2)
        self.assertEqual(sdp_header.destination_chip_x, 0)
        self.assertEqual(sdp_header.destination_chip_y, 0)
        self.assertEqual(sdp_header.destination_cpu, 1)
        command = struct.unpack_from("<H", data, 10)[0]
        self.assertEqual(command,
                         SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE.value)
Пример #3
0
 def test_scp_read_memory_request_and_response_board(self):
     board_config.set_up_remote_board()
     connection = SCAMPConnection(remote_host=board_config.remotehost)
     scp_link = ReadMemory(0, 0, 0x70000000, 256)
     connection.send_scp_request(scp_link)
     result, _, _, _ = connection.receive_scp_response()
     self.assertEqual(result, SCPResult.RC_OK)
Пример #4
0
 def test_send_scp_request_to_nonexistent_host(self):
     with self.assertRaises(SpinnmanTimeoutException):
         board_config.set_up_nonexistent_board()
         connection = SCAMPConnection(remote_host=board_config.remotehost)
         scp = ReadMemory(0, 0, 0, 256)
         connection.send_scp_request(scp)
         _, _, _, _ = connection.receive_scp_response(2)
Пример #5
0
 def test_create_new_transceiver_to_board(self):
     board_config.set_up_remote_board()
     connections = list()
     connections.append(
         SCAMPConnection(remote_host=board_config.remotehost))
     trans = transceiver.Transceiver(ver, connections=connections)
     trans.close()
Пример #6
0
    def test_set_watch_dog(self):
        connections = []
        connections.append(SCAMPConnection(remote_host=None))
        tx = MockWriteTransceiver(version=5, connections=connections)

        # All chips
        tx.set_watch_dog(True)
        tx.set_watch_dog(False)
        tx.set_watch_dog(5)

        # The expected write values for the watch dog
        expected_writes = (
            SystemVariableDefinition.software_watchdog_count.default, 0, 5)

        # Check the values that were "written" for set_watch_dog,
        # which should be one per chip
        written_memory = tx.written_memory
        write_item = 0
        for write in range(3):
            for x, y in tx.get_machine_details().chip_coordinates:
                assert written_memory[write_item][0] == x
                assert written_memory[write_item][1] == y
                assert written_memory[write_item][2] == (
                    constants.SYSTEM_VARIABLE_BASE_ADDRESS +
                    SystemVariableDefinition.software_watchdog_count.offset)
                expected_data = struct.pack("B", expected_writes[write])
                assert written_memory[write_item][3] == expected_data
                write_item += 1
Пример #7
0
    def test_listener_creation(self):
        # Tests the creation of listening sockets

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(remote_host=None))
        orig_connection = EIEIOConnection()
        connections.append(orig_connection)

        # Create transceiver
        with Transceiver(version=5, connections=connections) as trnx:
            # Register a UDP listeners
            connection_1 = trnx.register_udp_listener(
                callback=None, connection_class=EIEIOConnection)
            connection_2 = trnx.register_udp_listener(
                callback=None, connection_class=EIEIOConnection)
            connection_3 = trnx.register_udp_listener(
                callback=None,
                connection_class=EIEIOConnection,
                local_port=orig_connection.local_port)
            connection_4 = trnx.register_udp_listener(
                callback=None,
                connection_class=EIEIOConnection,
                local_port=orig_connection.local_port + 1)

            assert connection_1 == orig_connection
            assert connection_2 == orig_connection
            assert connection_3 == orig_connection
            assert connection_4 != orig_connection
    def test_listener_creation(self):
        # Test of buffer manager listener creation problem, where multiple
        # listeners were being created for the buffer manager traffic from
        # individual boards, where it's preferred all traffic is received by
        # a single listener

        # Create two vertices
        v1 = _TestVertex(10, "v1", 256)
        v2 = _TestVertex(10, "v2", 256)

        # Create two tags - important thing is port=None
        t1 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=1, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')
        t2 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=2, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')

        # Create 'Tags' object and add tags
        t = Tags()
        t.add_ip_tag(t1, v1)
        t.add_ip_tag(t2, v2)

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(
            remote_host=None))
        connections.append(EIEIOConnection())

        # Create two placements and 'Placements' object
        pl1 = Placement(v1, 0, 1, 1)
        pl2 = Placement(v2, 0, 2, 1)
        pl = Placements([pl1, pl2])

        # Create transceiver
        trnx = Transceiver(version=5, connections=connections)
        # Alternatively, one can register a udp listener for testing via:
        # trnx.register_udp_listener(callback=None,
        #        connection_class=EIEIOConnection)

        # Create buffer manager
        bm = BufferManager(pl, t, trnx)

        # Register two listeners, and check the second listener uses the
        # first rather than creating a new one
        bm._add_buffer_listeners(vertex=v1)
        bm._add_buffer_listeners(vertex=v2)

        number_of_listeners = 0
        for i in bm._transceiver._udp_listenable_connections_by_class[
                EIEIOConnection]:
            # Check if listener is registered on connection - we only expect
            # one listener to be registered, as all connections can use the
            # same listener for the buffer manager
            if not i[1] is None:
                number_of_listeners += 1
            print i
        self.assertEqual(number_of_listeners, 1)
Пример #9
0
 def __reset_connection(self):
     remote_port = self._connection.remote_port
     local_port = self._connection.local_port
     local_ip = self._connection.local_ip_address
     remote_ip = self._connection.remote_ip_address
     self._connection.close()
     self._connection = SCAMPConnection(local_port=local_port,
                                        remote_port=remote_port,
                                        local_host=local_ip,
                                        remote_host=remote_ip)
Пример #10
0
 def test_scp_version_request_and_response_board(self):
     board_config.set_up_remote_board()
     connection = SCAMPConnection(remote_host=board_config.remotehost)
     scp_req = GetVersion(0, 0, 0)
     scp_response = GetVersionResponse()
     connection.send_scp_request(scp_req)
     _, _, data, offset = connection.receive_scp_response()
     scp_response.read_bytestring(data, offset)
     print(scp_response.version_info)
     self.assertEqual(scp_response._scp_response_header._result,
                      SCPResult.RC_OK)
Пример #11
0
    def test_create_new_transceiver_from_list_connections(self):
        board_config.set_up_remote_board()
        connections = list()
        connections.append(
            SCAMPConnection(remote_host=board_config.remotehost))
        board_config.set_up_local_virtual_board()
        connections.append(BootConnection(remote_host=board_config.remotehost))
        with transceiver.Transceiver(ver, connections=connections) as trans:
            instantiated_connections = trans.get_connections()

            for connection in connections:
                assert connection in instantiated_connections
Пример #12
0
    def test_retrieving_machine_details(self):
        board_config.set_up_remote_board()
        connections = list()
        connections.append(
            SCAMPConnection(remote_host=board_config.remotehost))
        board_config.set_up_local_virtual_board()
        connections.append(BootConnection(remote_host=board_config.remotehost))
        with transceiver.Transceiver(ver, connections=connections) as trans:
            if board_config.board_version in (2, 3):
                assert trans.get_machine_dimensions().width == 2
                assert trans.get_machine_dimensions().height == 2
            elif board_config.board_version in (4, 5):
                assert trans.get_machine_dimensions().width == 8
                assert trans.get_machine_dimensions().height == 8
            else:
                size = trans.get_machine_dimensions()
                print(f"Unknown board with size {size.width} x {size.height}")

            assert trans.is_connected()
            print(trans.get_scamp_version())
            print(trans.get_cpu_information())
Пример #13
0
 def test_create_new_transceiver_one_connection(self):
     board_config.set_up_remote_board()
     connections = set()
     connections.add(SCAMPConnection(remote_host=board_config.remotehost))
     with transceiver.Transceiver(ver, connections=connections) as trans:
         assert trans.get_connections() == connections