def __init__(self, nearest_neighbour_id, n_blocks, x=None, y=None):
        """
        :param int nearest_neighbour_id:
            The ID of the packet, between 0 and 127
        :param int n_blocks:
            The number of blocks of data that will be sent, between 0 and 255
        :param int x: The x-coordinate of the chip to load the data on to. If
            not specified, the data will be loaded on to all chips
        :param int y: The y-coordinate of the chip to load the data on to. If
            not specified, the data will be loaded on to all chips
        """
        key = ((_NNP_FLOOD_FILL_START << 24) | (nearest_neighbour_id << 16) |
               (n_blocks << 8))
        data = 0xFFFF
        if x is not None and y is not None:
            m = ((y & 3) * 4) + (x & 3)
            data = (((x & 0xfc) << 24) + ((y & 0xfc) << 16) + (3 << 16) +
                    (1 << m))

        super().__init__(SDPHeader(
            flags=SDPFlag.REPLY_EXPECTED,
            destination_port=0,
            destination_cpu=0,
            destination_chip_x=self.DEFAULT_DEST_X_COORD,
            destination_chip_y=self.DEFAULT_DEST_Y_COORD),
                         SCPRequestHeader(command=SCPCommand.CMD_NNP),
                         argument_1=key,
                         argument_2=data,
                         argument_3=_NNP_FORWARD_RETRY)
Ejemplo n.º 2
0
 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 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
     :param bool use_sender:
         if the sender IP address and port should be used
     """
     # pylint: disable=too-many-arguments
     strip_value = int(bool(strip))
     sender_value = int(bool(use_sender))
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(strip_value << 28) | (sender_value << 30)
                      | (_IPTAG_SET << 16) | tag,
                      argument_2=port,
                      argument_3=((host[3] << 24) | (host[2] << 16) |
                                  (host[1] << 8) | host[0]))
Ejemplo n.º 3
0
    def __init__(self, x, y, destination_x, destination_y, destination_p, port,
                 tag, sdp_port):
        """
        :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 int destination_x:
            The x-coordinate of the destination chip, between 0 and 255
        :param int destination_y:
            The y-coordinate of the destination chip, between 0 and 255
        :param int destination_p:
            The ID of the destination processor, between 0 and 17
        :param int port: The port, between 0 and 65535
        :param int tag: The tag, between 0 and 7
        """
        # pylint: disable=too-many-arguments
        strip_value = 1
        reverse_value = 1

        arg1 = ((reverse_value << 29) | (strip_value << 28) |
                (_IPTAG_SET << 16) | (sdp_port << 13) | (destination_p << 8) |
                tag)
        arg2 = ((destination_x << 24) | (destination_y << 16) | port)

        super().__init__(
            SDPHeader(
                flags=SDPFlag.REPLY_EXPECTED, destination_port=0,
                destination_cpu=0, destination_chip_x=x,
                destination_chip_y=y),
            SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
            argument_1=arg1,
            argument_2=arg2,
            argument_3=0)
Ejemplo n.º 4
0
 def __init__(self, x, y, link, base_address, data, cpu=0):
     """
     :param int x: The x-coordinate of the chip whose neighbour will be
         written to, between 0 and 255
     :param int y: The y-coordinate of the chip whose neighbour will be
         written to, between 0 and 255
     :param int cpu: The CPU core to use, normally 0
         (or if a BMP, the board slot number)
     :param int link: The link number to write to between 0 and 5
         (or if a BMP, the FPGA between 0 and 2)
     :param int base_address: The base_address to start writing to
     :param bytes data: Up to 256 bytes of data to write
     """
     # pylint: disable=too-many-arguments
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=cpu,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_LINK_WRITE),
                      argument_1=base_address,
                      argument_2=len(data),
                      argument_3=link,
                      data=None)
     self._data_to_write = data
Ejemplo n.º 5
0
    def send_output_to_spinnaker(self, value, placement, transceiver):

        # Apply the pre-slice, the connection function and the transform.
        c_value = value[(self._managing_app_outgoing_partition.identifier.
                         transmission_parameter.pre_slice)]

        # locate required transforms and functions
        partition_transmission_function = \
            self._managing_app_outgoing_partition.identifier\
                .transmission_parameter.parameter_function
        partition_transmission_transform = \
            self._managing_app_outgoing_partition.identifier\
                .transmission_parameter.full_transform(slice_out=False)

        # execute function if required
        if partition_transmission_function is not None:
            c_value = partition_transmission_function(c_value)

        # do transform
        c_value = numpy.dot(partition_transmission_transform, c_value)

        # create SCP packet
        # c_value is converted to S16.15
        data = helpful_functions.convert_numpy_array_to_s16_15(c_value)
        packet = SDPMessage(sdp_header=SDPHeader(
            destination_port=constants.SDP_PORTS.SDP_RECEIVER.value,
            destination_cpu=placement.p,
            destination_chip_x=placement.x,
            destination_chip_y=placement.y,
            flags=SDPFlag.REPLY_NOT_EXPECTED),
                            data=bytes(data.data))
        transceiver.send_sdp_message(packet)
        self._n_packets_transmitted += 1
Ejemplo n.º 6
0
 def __init__(self, x, y, p, multicast, point_to_point, fixed_route,
              nearest_neighbour):
     """
     :param x: The x-coordinate of a chip, between 0 and 255
     :type x: int
     :param y: The y-coordinate of a chip, between 0 and 255
     :type y: int
     :param p: \
         The processor running the extra monitor vertex, between 0 and 17
     :type p: int
     :param point_to_point: If point to point should be set
     :type point_to_point: bool
     :param multicast: If multicast should be set
     :type multicast: bool
     :param nearest_neighbour: If nearest neighbour should be set
     :type nearest_neighbour: bool
     :param fixed_route: If fixed route should be set
     :type fixed_route: bool
     """
     # pylint: disable=too-many-arguments
     super(SetReinjectionPacketTypesMessage, self).__init__(
         SDPHeader(
             flags=SDPFlag.REPLY_EXPECTED,
             destination_port=(
                 constants.SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
             destination_cpu=p, destination_chip_x=x,
             destination_chip_y=y),
         SCPRequestHeader(command=ReinjectorSCPCommands.SET_PACKET_TYPES),
         argument_1=int(bool(multicast)),
         argument_2=int(bool(point_to_point)),
         argument_3=int(bool(fixed_route)),
         data=bytearray(struct.pack("<B", nearest_neighbour)))
Ejemplo n.º 7
0
    def __init__(self,
                 x,
                 y,
                 p,
                 run_time,
                 infinite_run,
                 destination_port,
                 expect_response=True):
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        arg3 = 0
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED
            arg3 = 1

        AbstractSCPRequest.__init__(
            self,
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_NEW_RUNTIME_ID_CODE),
            argument_1=run_time,
            argument_2=infinite_run,
            argument_3=arg3)
    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)
        self.assertEqual(
            command,
            SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE.value)
    def __call__(self, txrx, app_id, all_core_subsets):
        # check that the right number of processors are in sync
        processors_completed = txrx.get_core_state_count(
            app_id, CPUState.FINISHED)
        total_processors = len(all_core_subsets)
        left_to_do_cores = total_processors - processors_completed

        progress = ProgressBar(
            left_to_do_cores,
            "Forcing error cores to generate provenance data")

        error_cores = txrx.get_cores_in_state(all_core_subsets,
                                              CPUState.RUN_TIME_EXCEPTION)
        watchdog_cores = txrx.get_cores_in_state(all_core_subsets,
                                                 CPUState.WATCHDOG)
        idle_cores = txrx.get_cores_in_state(all_core_subsets, CPUState.IDLE)

        if (len(error_cores) != 0 or len(watchdog_cores) != 0
                or len(idle_cores) != 0):
            raise ConfigurationException(
                "Some cores have crashed. RTE cores {}, watch-dogged cores {},"
                " idle cores {}".format(error_cores.values(),
                                        watchdog_cores.values(),
                                        idle_cores.values()))

        # check that all cores are in the state FINISHED which shows that
        # the core has received the message and done provenance updating
        attempts = 0
        while processors_completed != total_processors and attempts < 10:
            attempts += 1
            unsuccessful_cores = txrx.get_cores_not_in_state(
                all_core_subsets, CPUState.FINISHED)

            for (x, y, p) in unsuccessful_cores.iterkeys():
                data = struct.pack(
                    "<I", SDP_RUNNING_MESSAGE_CODES.
                    SDP_UPDATE_PROVENCE_REGION_AND_EXIT.value)
                txrx.send_sdp_message(
                    SDPMessage(SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                                         destination_cpu=p,
                                         destination_chip_x=x,
                                         destination_port=SDP_PORTS.
                                         RUNNING_COMMAND_SDP_PORT.value,
                                         destination_chip_y=y),
                               data=data))

            processors_completed = txrx.get_core_state_count(
                app_id, CPUState.FINISHED)

            left_over_now = total_processors - processors_completed
            to_update = left_to_do_cores - left_over_now
            left_to_do_cores = left_over_now
            if to_update != 0:
                progress.update(to_update)
        if attempts >= 10:
            logger.error("Unable to Finish getting provenance data. "
                         "Abandoned after too many retries. "
                         "Board may be left in an unstable state!")

        progress.end()
    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)
        self.assertEqual(command,
                         SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE.value)
 def __init__(self, x, y, p, timeout_mantissa, timeout_exponent):
     """
     :param x: The x-coordinate of a chip, between 0 and 255
     :type x: int
     :param y: The y-coordinate of a chip, between 0 and 255
     :type y: int
     :param p: \
         The processor running the extra monitor vertex, between 0 and 17
     :type p: int
     :param timeout_mantissa: \
         The mantissa of the timeout value, between 0 and 15
     :type timeout_mantissa: int
     :param timeout_exponent: \
         The exponent of the timeout value, between 0 and 15
     :type timeout_exponent: int
     """
     # pylint: disable=too-many-arguments
     super(SetRouterEmergencyTimeoutMessage, self).__init__(
         SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                   destination_port=(
                       SDP_PORTS.EXTRA_MONITOR_CORE_REINJECTION.value),
                   destination_cpu=p,
                   destination_chip_x=x,
                   destination_chip_y=y),
         SCPRequestHeader(
             command=ReinjectorSCPCommands.SET_ROUTER_EMERGENCY_TIMEOUT),
         argument_1=(timeout_mantissa & 0xF) |
         ((timeout_exponent & 0xF) << 4))
    def __init__(self,
                 x,
                 y,
                 p,
                 current_time,
                 run_time,
                 infinite_run,
                 destination_port,
                 expect_response=True):
        # pylint: disable=too-many-arguments
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED

        super(SCPUpdateRuntimeRequest, self).__init__(
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_NEW_RUNTIME_ID_CODE),
            argument_1=run_time,
            argument_2=infinite_run,
            argument_3=current_time,
            data=struct.pack("<B", int(bool(expect_response))))
    def get_data(self, transceiver, placement, extra_monitor_vertices,
                 placements):
        data = struct.pack("<I", 100)
        message = SDPMessage(sdp_header=SDPHeader(
            destination_chip_x=placement.x,
            destination_chip_y=placement.y,
            destination_cpu=placement.p,
            destination_port=2,
            flags=SDPFlag.REPLY_NOT_EXPECTED),
                             data=data)

        # create socket
        connection = UDPConnection(local_host=None, local_port=self.PORT)

        # send
        # set router time out
        extra_monitor_vertices[0].set_router_time_outs(15, 15, transceiver,
                                                       placements,
                                                       extra_monitor_vertices)
        transceiver.send_sdp_message(message=message)

        # receive
        output = None
        finished = False
        first = True
        offset = 0
        while not finished:
            data = connection.receive()
            length_of_data = len(data)
            if first:
                length = struct.unpack_from("<I", data, 0)[0]
                first = False
                output = bytearray(length)
                self._view = memoryview(output)
                self._view[offset:offset + length_of_data - 4] = \
                    data[4:4 + length_of_data - 4]
                offset += length_of_data - 4

            else:
                last_mc_packet = struct.unpack_from("<I", data,
                                                    length_of_data - 4)[0]
                if last_mc_packet == 0xFFFFFFFF:
                    self._view[offset:offset + length_of_data - 4] = \
                        data[0:0 + length_of_data - 4]
                    offset += length_of_data - 4
                    finished = True
                else:
                    self._view[offset:offset + length_of_data] = \
                        data[0:0 + length_of_data]
                    offset += length_of_data

        # hand back
        # set router time out
        extra_monitor_vertices[0].set_router_time_outs(15, 4, transceiver,
                                                       placements,
                                                       extra_monitor_vertices)
        return output
Ejemplo n.º 14
0
 def __init__(self, x, y):
     scp_header = SCPRequestHeader(command=SCPResult.RC_OK)
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     SDPMessage.__init__(self, sdp_header, data=scp_header.bytestring)
    def _retrieve_and_store_data(self, packet):
        """ Following a SpinnakerRequestReadData packet, the data stored\
            during the simulation needs to be read by the host and stored in\
            a data structure, following the specifications of buffering out\
            technique.

        :param packet: SpinnakerRequestReadData packet received from the\
            SpiNNaker system
        :type packet:\
            :py:class:`spinnman.messages.eieio.command_messages.spinnaker_request_read_data.SpinnakerRequestReadData`
        :rtype: None
        """
        x = packet.x
        y = packet.y
        p = packet.p

        # check packet sequence number
        pkt_seq = packet.sequence_no
        last_pkt_seq = self._received_data.last_sequence_no_for_core(x, y, p)
        next_pkt_seq = (last_pkt_seq + 1) % 256
        if pkt_seq != next_pkt_seq:
            # this sequence number is incorrect
            # re-sent last HostDataRead packet sent
            last_packet_sent = self._received_data.last_sent_packet_to_core(
                x, y, p)
            if last_packet_sent is None:
                raise Exception(
                    "{}, {}, {}: Something somewhere went terribly wrong - "
                    "The packet sequence numbers have gone wrong somewhere: "
                    "the packet sent from the board has incorrect sequence "
                    "number, but the host never sent one acknowledge".format(
                        x, y, p))
            self._transceiver.send_sdp_message(last_packet_sent)
            return

        # read data from memory, store it and create data for return ACK packet
        ack_packet = self._assemble_ack_packet(x, y, p, packet, pkt_seq)

        # create SDP header and message
        return_message = SDPMessage(
            SDPHeader(
                destination_port=SDP_PORTS.OUTPUT_BUFFERING_SDP_PORT.value,
                destination_cpu=p,
                destination_chip_x=x,
                destination_chip_y=y,
                flags=SDPFlag.REPLY_NOT_EXPECTED), ack_packet.bytestring)

        # storage of last packet received
        self._received_data.store_last_received_packet_from_core(
            x, y, p, packet)
        self._received_data.update_sequence_no_for_core(x, y, p, pkt_seq)

        # store last sent message and send to the appropriate core
        self._received_data.store_last_sent_packet_to_core(
            x, y, p, return_message)
        self._transceiver.send_sdp_message(return_message)
Ejemplo n.º 16
0
 def __init__(self, x, y, sequence=0):  # pragma: no cover
     scp_header = SCPRequestHeader(command=SCPResult.RC_OK,
                                   sequence=sequence)
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     super().__init__(sdp_header, data=scp_header.bytestring)
Ejemplo n.º 17
0
    def _send_chip_update_provenance_and_exit(txrx, x, y, p):
        cmd = SDP_RUNNING_MESSAGE_CODES.SDP_UPDATE_PROVENCE_REGION_AND_EXIT
        port = SDP_PORTS.RUNNING_COMMAND_SDP_PORT

        txrx.send_sdp_message(
            SDPMessage(SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                                 destination_port=port.value,
                                 destination_cpu=p,
                                 destination_chip_x=x,
                                 destination_chip_y=y),
                       data=_ONE_WORD.pack(cmd.value)))
Ejemplo n.º 18
0
    def read_bytestring(self, data, offset):
        """ Reads a packet from a bytestring of data

        :param bytes data: The bytestring to be read
        :param int offset:
            The offset in the data from which the response should be read
        """
        self._sdp_header = SDPHeader.from_bytestring(data, offset)
        self._scp_response_header = SCPResponseHeader.from_bytestring(
            data, _SCP_HEADER_OFFSET + offset)
        self.read_data_bytestring(data, _SCP_DATA_OFFSET + offset)
Ejemplo n.º 19
0
    def _update_provenance_and_exit(txrx, processor, core_subset):
        byte_data = _ONE_WORD.pack(SDP_RUNNING_MESSAGE_CODES.
                                   SDP_UPDATE_PROVENCE_REGION_AND_EXIT.value)

        txrx.send_sdp_message(
            SDPMessage(sdp_header=SDPHeader(
                flags=SDPFlag.REPLY_NOT_EXPECTED,
                destination_port=SDP_PORTS.RUNNING_COMMAND_SDP_PORT.value,
                destination_cpu=processor,
                destination_chip_x=core_subset.x,
                destination_chip_y=core_subset.y),
                       data=byte_data))
Ejemplo n.º 20
0
 def __init__(self, x, y, version):
     self._scp_header = SCPRequestHeader(command=SCPResult.RC_OK)
     self._version_descriptor = b"BC&MP/Test\0" + version + b"\0"
     self._y = y
     self._x = x
     sdp_header = SDPHeader(flags=SDPFlag.REPLY_NOT_EXPECTED,
                            destination_port=0,
                            destination_cpu=0,
                            destination_chip_x=x,
                            destination_chip_y=y)
     utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
     super(SCPVerMessage, self).__init__(sdp_header)
    def get_data(self, transceiver, placement, extra_monitor_vertices,
                 placements):

        # set router time out
        extra_monitor_vertices[0].set_router_time_outs(15, 15, transceiver,
                                                       placements,
                                                       extra_monitor_vertices)

        # spur off a c code version
        subprocess.call(("host_"))

        data = struct.pack("<I", self.SDP_PACKET_START_SENDING_COMMAND_ID)

        # print("sending to core {}:{}:{}".format(
        #     placement.x, placement.y, placement.p))
        message = SDPMessage(sdp_header=SDPHeader(
            destination_chip_x=placement.x,
            destination_chip_y=placement.y,
            destination_cpu=placement.p,
            destination_port=self.SDP_PACKET_PORT,
            flags=SDPFlag.REPLY_NOT_EXPECTED),
                             data=data)

        # send
        transceiver.send_sdp_message(message=message)

        # receive
        finished = False
        first = True
        seq_num = 1
        seq_nums = set()
        while not finished:
            try:
                data = self._connection.receive(
                    timeout=self.TIMEOUT_PER_RECEIVE_IN_SECONDS)

                first, seq_num, seq_nums, finished = \
                    self._process_data(
                        data, first, seq_num, seq_nums, finished, placement,
                        transceiver)
            except SpinnmanTimeoutException:
                if not finished:
                    finished = self._transmit_missing_seq_nums(
                        seq_nums, transceiver, placement)

        # self._check(seq_nums)
        # set router time out
        extra_monitor_vertices[0].set_router_time_outs(15, 4, transceiver,
                                                       placements,
                                                       extra_monitor_vertices)

        return self._output, self._lost_seq_nums
Ejemplo n.º 22
0
 def _do_receive(self):
     data, address = self._receiver.receive_with_address()
     self._messages.append(data)
     sdp_header = SDPHeader.from_bytestring(data, 2)
     response = None
     if self._responses:
         response = self._responses.popleft()
     else:
         response = _SCPOKMessage(sdp_header.source_chip_x,
                                  sdp_header.source_chip_y)
     if response is not None:
         self._receiver.send_to(
             struct.pack("<2x") + response.bytestring, address)
Ejemplo n.º 23
0
 def __init__(self, x, y):
     """
     :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
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(_IPTAG_INFO << 16),
                      argument_2=_IPTAG_MAX)
    def __init__(self, x, y, p):
        # pylint: disable=too-many-arguments

        super(_ClearIOBUFRequest, self).__init__(
            SDPHeader(
                flags=SDPFlag.REPLY_EXPECTED,
                destination_cpu=p,
                destination_chip_x=x,
                destination_chip_y=y,
                destination_port=SDP_PORTS.RUNNING_COMMAND_SDP_PORT.value),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE),
            argument_3=int(True))
Ejemplo n.º 25
0
    def read_bytestring(self, data, offset):
        """ Reads a packet from a bytestring of data

        :param data: The bytestring to be read
        :type data: str
        :param offset: \
            The offset in the data from which the response should be read
        :type offset: int
        """
        self._sdp_header = SDPHeader.from_bytestring(data, offset)
        self._scp_response_header = SCPResponseHeader.from_bytestring(
            data, _SCP_HEADER_OFFSET + offset)
        self.read_data_bytestring(data, _SCP_DATA_OFFSET + offset)
Ejemplo n.º 26
0
 def __init__(self, app_id):
     """
     :param int app_id: The ID of the application, between 0 and 255
     """
     super().__init__(SDPHeader(
         flags=SDPFlag.REPLY_EXPECTED,
         destination_port=0,
         destination_cpu=0,
         destination_chip_x=self.DEFAULT_DEST_X_COORD,
         destination_chip_y=self.DEFAULT_DEST_Y_COORD),
                      SCPRequestHeader(command=SCPCommand.CMD_NNP),
                      argument_1=(0x3f << 16),
                      argument_2=(5 << 28) | _get_data(app_id, Signal.STOP),
                      argument_3=(1 << 31) + (0x3f << 8))
Ejemplo n.º 27
0
 def __init__(self, x, y, tag_timeout):
     """
     :param int x: The x-coordinate of the chip to run on, between 0 and 255
     :param int y: The y-coordinate of the chip to run on, between 0 and 255
     :param IPTAG_TIME_OUT_WAIT_TIMES tag_timeout: The timeout value
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=_IPTAG_TTO,
                      argument_2=tag_timeout.value)
Ejemplo n.º 28
0
 def _do_receive(self):
     data, address = self._receiver.receive_with_address(10)
     sdp_header = SDPHeader.from_bytestring(data, 2)
     _, sequence = self._SCP_HEADER.unpack_from(data, 10)
     response = None
     if self._responses:
         response = self._responses.popleft()
     else:  # pragma: no cover
         response = SCPOKMessage(sdp_header.source_chip_x,
                                 sdp_header.source_chip_y, sequence)
     if hasattr(response, "set_sequence"):
         response.set_sequence(sequence)
     if response is not None:
         self._receiver.send_to(self._TWO_NUL_BYTES + response.bytestring,
                                address)
 def __request_read_data(self, packet):
     if not self._finished:
         # Send an ACK message to stop the core sending more messages
         ack_message_header = SDPHeader(
             destination_port=(SDP_PORTS.OUTPUT_BUFFERING_SDP_PORT.value),
             destination_cpu=packet.p,
             destination_chip_x=packet.x,
             destination_chip_y=packet.y,
             flags=SDPFlag.REPLY_NOT_EXPECTED)
         ack_message_data = HostDataReadAck(packet.sequence_no)
         ack_message = SDPMessage(ack_message_header,
                                  ack_message_data.bytestring)
         self._transceiver.send_sdp_message(ack_message)
     self._buffering_out_thread_pool.apply_async(
         self._process_buffered_in_packet, args=[packet])
Ejemplo n.º 30
0
 def __init__(self, x, y):
     """
     :param int x: The x-coordinate of the chip, between 0 and 255
     :param int y: The y-coordinate of the chip, between 0 and 255
     :raise SpinnmanInvalidParameterException:
         * If x is out of range
         * If y is out of range
     """
     super().__init__(
         SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                   destination_port=0,
                   destination_cpu=0,
                   destination_chip_x=x,
                   destination_chip_y=y),
         SCPRequestHeader(command=SCPCommand.CMD_RTR))
Ejemplo n.º 31
0
 def __init__(self, x, y, tag):
     """
     :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 int tag: The tag to get details of, between 0 and 7
     :param int tag: The tag, between 0 and 7
     """
     super().__init__(SDPHeader(flags=SDPFlag.REPLY_EXPECTED,
                                destination_port=0,
                                destination_cpu=0,
                                destination_chip_x=x,
                                destination_chip_y=y),
                      SCPRequestHeader(command=SCPCommand.CMD_IPTAG),
                      argument_1=(_IPTAG_GET << 16) | tag,
                      argument_2=1)
Ejemplo n.º 32
0
    def __init__(self, x, y, p, destination_port, expect_response=True):
        # pylint: disable=too-many-arguments
        sdp_flags = SDPFlag.REPLY_NOT_EXPECTED
        if expect_response:
            sdp_flags = SDPFlag.REPLY_EXPECTED

        super(SCPClearIOBUFRequest, self).__init__(
            SDPHeader(flags=sdp_flags,
                      destination_port=destination_port,
                      destination_cpu=p,
                      destination_chip_x=x,
                      destination_chip_y=y),
            SCPRequestHeader(
                command=SDP_RUNNING_MESSAGE_CODES.SDP_CLEAR_IOBUF_CODE),
            argument_3=int(bool(expect_response)))
 def _do_receive(self):
     data, address = self._receiver.receive_with_address()
     self._messages.append(data)
     sdp_header = SDPHeader.from_bytestring(data, 2)
     _result, sequence = struct.unpack_from("<2H", data, 10)
     response = None
     if self._responses:
         response = self._responses.popleft()
         response._data = (
             response._data[:10] + struct.pack("<H", sequence) +
             response._data[12:])
     else:
         response = _SCPOKMessage(
             sdp_header.source_chip_x, sdp_header.source_chip_y,
             sequence)
     if response is not None:
         self._receiver.send_to(
             struct.pack("<2x") + response.bytestring, address)