def _receive_data(self, transceiver, placement): seq_nums = set() lost_seq_nums = list() timeoutcount = 0 finished = False while not finished: try: data = self._connection.receive( timeout=self.TIMEOUT_PER_RECEIVE_IN_SECONDS) timeoutcount = 0 seq_nums, finished = self._process_data( data, seq_nums, finished, placement, transceiver, lost_seq_nums) except SpinnmanTimeoutException: if timeoutcount > TIMEOUT_RETRY_LIMIT: raise SpinnFrontEndException( "Failed to hear from the machine during {} attempts. " "Please try removing firewalls".format(timeoutcount)) timeoutcount += 1 self.__reset_connection() if not finished: finished = self._determine_and_retransmit_missing_seq_nums( seq_nums, transceiver, placement, lost_seq_nums) return lost_seq_nums
def _check_for_success(self, executable_targets, txrx, provenance_file_path, compressor_app_id): """ Goes through the cores checking for cores that have failed to\ compress the routing tables to the level where they fit into the\ router :param txrx: the spinnman interface :type txrx: :py:class:`~spinnman.Transceiver` """ for core_subset in executable_targets.all_core_subsets: x = core_subset.x y = core_subset.y for p in core_subset.processor_ids: # Read the result from USER0 register result = self.__read_user_0(txrx, x, y, p) # The result is 0 if success, otherwise failure if result != 0: self._handle_failure(executable_targets, txrx, provenance_file_path, compressor_app_id) raise SpinnFrontEndException( "The router compressor on {}, {} failed to complete". format(x, y))
def _check_for_success(self, executable_targets, transceiver, provenance_file_path, compressor_app_id): """ goes through the cores checking for cores that have failed to\ compress the routing tables to the level where they fit into the\ router """ for core_subset in executable_targets.all_core_subsets: x = core_subset.x y = core_subset.y for p in core_subset.processor_ids: # Read the result from USER0 register user_0_address = \ transceiver.get_user_0_register_address_from_core(x, y, p) result = struct.unpack( "<I", str(transceiver.read_memory(x, y, user_0_address, 4)))[0] # The result is 0 if success, otherwise failure if result != 0: self._handle_failure(executable_targets, transceiver, provenance_file_path, compressor_app_id) raise SpinnFrontEndException( "The router compressor on {}, {} failed to complete". format(x, y))
def _check_for_success(self, executable_targets, transceiver, register): """ Goes through the cores checking for cores that have failed to\ compress the routing tables to the level where they fit into the\ router :param ExecutableTargets executable_targets: :param int register: number of user register to check """ for core_subset in executable_targets.all_core_subsets: x = core_subset.x y = core_subset.y for p in core_subset.processor_ids: # Read the result from specified register if register == 0: result = transceiver.read_user_0(x, y, p) elif register == 1: result = transceiver.read_user_1(x, y, p) elif register == 2: result = transceiver.read_user_2(x, y, p) else: raise Exception("Incorrect register") # The result is 0 if success, otherwise failure if result != 0: raise SpinnFrontEndException( "The router compressor on {}, {} failed to complete" .format(x, y))
def add_message_to_send(self, message): """ Add a message to send. The message is converted to a sequenced\ message. :param message: The message to be added :type message: ~spinnman.messages.eieio.abstract_messages.AbstractEIEIOMessage """ # If full, raise an exception if self.is_full: raise SpinnFrontEndException("The buffer is full") # Create a sequenced message and update the sequence number self._sequence_lock.acquire() sequenced_message = HostSendSequencedData(self._region, self._sequence_number, message) self._sequence_number = (self._sequence_number + 1) % _N_SEQUENCES self._sequence_lock.release() # Add the sequenced message to the buffers self._buffers_sent.append(sequenced_message)
def _send_initial_messages(self, vertex, region, progress): """ Send the initial set of messages. :param vertex: The vertex to get the keys from :type vertex:\ :py:class:`~spinn_front_end_common.interface.buffer_management.buffer_models.AbstractSendsBuffersFromHost` :param region: The region to get the keys from :type region: int :return: A list of messages :rtype: \ list(:py:class:`~spinnman.messages.eieio.data_messages.EIEIODataMessage`) """ # Get the vertex load details # region_base_address = self._locate_region_address(region, vertex) placement = self._placements.get_placement_of_vertex(vertex) region_base_address = locate_memory_region_for_placement( placement, region, self._transceiver) # Add packets until out of space sent_message = False bytes_to_go = vertex.get_region_buffer_size(region) if bytes_to_go % 2 != 0: raise SpinnFrontEndException( "The buffer region of {} must be divisible by 2".format( vertex)) all_data = b"" if vertex.is_empty(region): sent_message = True else: min_size_of_packet = _MIN_MESSAGE_SIZE while (vertex.is_next_timestamp(region) and bytes_to_go > min_size_of_packet): space_available = min(bytes_to_go, _SDP_MAX_PACKAGE_SIZE) next_message = self._create_message_to_send( space_available, vertex, region) if next_message is None: break # Write the message to the memory data = next_message.bytestring all_data += data sent_message = True # Update the positions bytes_to_go -= len(data) progress.update(len(data)) if not sent_message: raise BufferableRegionTooSmall( "The buffer size {} is too small for any data to be added for" " region {} of vertex {}".format(bytes_to_go, region, vertex)) # If there are no more messages and there is space, add a stop request if (not vertex.is_next_timestamp(region) and bytes_to_go >= EventStopRequest.get_min_packet_length()): data = EventStopRequest().bytestring # logger.debug( # "Writing stop message of {} bytes to {} on {}, {}, {}".format( # len(data), hex(region_base_address), # placement.x, placement.y, placement.p)) all_data += data bytes_to_go -= len(data) progress.update(len(data)) self._sent_messages[vertex] = BuffersSentDeque( region, sent_stop_message=True) # Do the writing all at once for efficiency self._transceiver.write_memory(placement.x, placement.y, region_base_address, all_data)