示例#1
0
    def __init__(self, x, y, app_id, base_address=None):
        """
        :param int x:
            The x-coordinate of the chip to allocate on, between 0 and 255
        :param int y:
            The y-coordinate of the chip to allocate on, between 0 and 255
        :param int app_id: The ID of the application, between 0 and 255
        :param base_address: The start address in SDRAM to which the block
            needs to be deallocated, or none if deallocating via app_id
        :type base_address: int or None
        """

        if base_address is not None:
            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_ALLOC),
                argument_1=(AllocFree.FREE_SDRAM_BY_POINTER.value
                            ),  # @UndefinedVariable
                argument_2=base_address)
            self._read_n_blocks_freed = False
        else:
            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_ALLOC),
                argument_1=(app_id << 8 | AllocFree.FREE_SDRAM_BY_APP_ID.value
                            ))  # @UndefinedVariable
            self._read_n_blocks_freed = True
    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 __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)
示例#4
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]))
 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))
示例#6
0
 def __init__(self, x, y, base_address, size, cpu=0):
     """
     :param int x:
         The x-coordinate of the chip to read from, between 0 and 255
     :param int y:
         The y-coordinate of the chip to read from, between 0 and 255
     :param int base_address:
         The positive base address to start the read from
     :param int size: The number of bytes to read, between 1 and 256
     :raise SpinnmanInvalidParameterException:
         * If the chip coordinates are out of range
         * If the base address is not a positive number
         * If the size is out of range
     """
     # 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_READ),
                      argument_1=base_address,
                      argument_2=size,
                      argument_3=address_length_dtype[(base_address % 4,
                                                       size % 4)].value)
示例#7
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
示例#8
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=(
                       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)))
示例#9
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)
    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 __init__(self, x, y, base_address, data, cpu=0):
     """
     :param int x: The x-coordinate of the chip, between 0 and 255;
         this is not checked due to speed restrictions
     :param int y: The y-coordinate of the chip, between 0 and 255;
         this is not checked due to speed restrictions
     :param int base_address: The base_address to start writing to
         the base address is not checked to see if its not valid
     :param data: between 1 and 256 bytes of data to write;
         this is not checked due to speed restrictions
     :type data: bytearray or bytes
     """
     # pylint: disable=too-many-arguments
     size = len(data)
     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_WRITE),
                      argument_1=base_address,
                      argument_2=size,
                      argument_3=address_length_dtype[(base_address % 4),
                                                      (size % 4)].value,
                      data=None)
     self._data_to_write = data
示例#12
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)
示例#13
0
 def __init__(self,
              boards,
              scp_request_header,
              argument_1=None,
              argument_2=None,
              argument_3=None,
              data=None):
     """
     :param boards: The board or boards to be addressed by this request
     :type boards: int or list(int) or tuple(int)
     :param SCPRequestHeader scp_request_header: The SCP request header
     :param int argument_1: The optional first argument
     :param int argument_2: The optional second argument
     :param int argument_3: The optional third argument
     :param bytes data: The optional data to be sent
     """
     # pylint: disable=too-many-arguments
     sdp_header = SDPHeader(
         flags=SDPFlag.REPLY_EXPECTED,
         destination_port=0,
         destination_cpu=BMPRequest.get_first_board(boards),
         destination_chip_x=0,
         destination_chip_y=0)
     super().__init__(sdp_header, scp_request_header, argument_1,
                      argument_2, argument_3, data)
示例#14
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
    def __init__(self, app_id, x, y, processors, wait=False):
        """
        :param int app_id: The ID of the application to run, between 16 and 255
        :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 list(int) processors:
            The processors on the chip where the executable should be
            started, between 1 and 17
        :param bool wait:
            True if the processors should enter a "wait" state on starting
        """
        # pylint: disable=too-many-arguments
        processor_mask = 0
        if processors is not None:
            for processor in processors:
                processor_mask |= (1 << processor)

        processor_mask |= (app_id << 24)
        if wait:
            processor_mask |= _WAIT_FLAG

        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_AR),
                         argument_1=processor_mask)
 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 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
    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)
 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)
示例#20
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)))
示例#21
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)
示例#22
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))
    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
示例#24
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))
示例#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))
示例#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)
示例#28
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))
示例#29
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)
示例#30
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)))