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)
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)
def get_router_diagnostics(self, x, y): """ :param int x: :param int y: :rtype: RouterDiagnostics """ self._send_request(ReadMemory(x, y, 0xe1000000, 4), self.__handle_control_register_response) self._send_request(ReadMemory(x, y, 0xe1000014, 4), self.__handle_error_status_response) self._send_request(ReadMemory(x, y, 0xe1000300, 16 * 4), self.__handle_register_response) self._finish() self.check_for_error() return RouterDiagnostics(self._control_register, self._error_status, self._register_values)
def _verify_virtual_to_physical_core_map(self, xy): """ Add this method to _get_virtual_p to verify the mappings. :param tuple(int,int) xy: """ v_to_p = SystemVariableDefinition.virtual_to_physical_core_map self._send_request( ReadMemory(x=xy[0], y=xy[1], base_address=SYSTEM_VARIABLE_BASE_ADDRESS + v_to_p.offset, size=v_to_p.array_size), functools.partial(self._receive_virtual_to_physical_core_map, xy)) self._finish()
def get_cpu_info(self, core_subsets): """ :param ~spinn_machine.CoreSubsets core_subsets: :rtype: list(CPUInfo) """ for core_subset in core_subsets: x = core_subset.x y = core_subset.y for p in core_subset.processor_ids: self._send_request( ReadMemory(x, y, get_vcpu_address(p), CPU_INFO_BYTES), functools.partial(self.__handle_response, x, y, p)) self._finish() self.check_for_error() return self._cpu_info
def get_machine_details(self, boot_x, boot_y, width, height): """ :param int boot_x: :param int boot_y: :param int width: :param int height: :rtype: ~spinn_machine.Machine """ # Get the P2P table - 8 entries are packed into each 32-bit word p2p_column_bytes = P2PTable.get_n_column_bytes(height) self._p2p_column_data = [None] * width for column in range(width): offset = P2PTable.get_column_offset(column) self._send_request( ReadMemory(x=boot_x, y=boot_y, base_address=(ROUTER_REGISTER_P2P_ADDRESS + offset), size=p2p_column_bytes), functools.partial(self.__receive_p2p_data, column)) self._finish() self.check_for_error() p2p_table = P2PTable(width, height, self._p2p_column_data) # Get the chip information for each chip for (x, y) in p2p_table.iterchips(): self._send_request(GetChipInfo(x, y), self._receive_chip_info) self._finish() with suppress(Exception): # Ignore errors, as any error here just means that a chip # is down that wasn't marked as down self.check_for_error() # Warn about unexpected missing chips for (x, y) in p2p_table.iterchips(): if (x, y) not in self._chip_info: logger.warning("Chip {}, {} was expected but didn't reply", x, y) machine = machine_from_size(width, height) self._preprocess_ignore_chips(machine) self._process_ignore_links(machine) self._preprocess_ignore_cores(machine) return self._fill_machine(machine)
def get_routes(self, x, y, base_address): """ :param int x: :param int y: :param int base_address: :rtype: list(~spinn_machine.MulticastRoutingEntry) """ # Create the read requests offset = 0 for _ in range(_N_READS): self._send_request( ReadMemory(x, y, base_address + (offset * 16), UDP_MESSAGE_MAX_SIZE), functools.partial(self.__handle_response, offset)) offset += _ENTRIES_PER_READ self._finish() self.check_for_error() return [entry for entry in self._entries if entry is not None]
def _get_virtual_p(self, xy, p): """ :param tuple(int,int) xy: :param int p: :rtype: int """ if xy not in self._virtual_map: if xy not in self._chip_info: # Chip not part of board so ignore return None p_to_v = SystemVariableDefinition.physical_to_virtual_core_map ba = SYSTEM_VARIABLE_BASE_ADDRESS + p_to_v.offset self._send_request( ReadMemory(x=xy[0], y=xy[1], base_address=ba, size=p_to_v.array_size), functools.partial(self._receive_physical_to_virtual_core_map, xy)) self._finish() if p > 0: self._report_ignore("On chip {} ignoring core {}", xy, p) return p else: virtual_map = self._virtual_map[xy] if 0 - p not in virtual_map: self._report_ignore("On chip {} physical core {} was not used " "so ignore is being discarded.".format( xy, -p)) return None virtual_p = virtual_map[0 - p] if virtual_p == 0: self._report_ignore( "On chip {} physical core {} was used as the monitor " "so will NOT be ignored".format(xy, -p)) return None self._report_ignore( "On chip {} ignoring core {} as it maps to physical " "core {}", xy, 0 - p, virtual_p) return virtual_p
def test(self): self._send_request(ReadMemory(0, 0, 0, 4)) self._finish() self.check_for_error(print_exception=True)
def _request_iobuf_region(self, region): (x, y, p, n, next_address, first_read_size) = region self._send_request( ReadMemory(x, y, next_address, first_read_size), functools.partial(self._handle_first_iobuf_response, x, y, p, n, next_address, first_read_size))
def _request_iobuf_region_tail(self, extra_region): (x, y, p, n, base_address, size, offset) = extra_region self._send_request( ReadMemory(x, y, base_address, size), functools.partial(self._handle_extra_iobuf_response, x, y, p, n, offset))
def _request_iobuf_address(self, iobuf_size, x, y, p): base_address = get_vcpu_address(p) + CPU_IOBUF_ADDRESS_OFFSET self._send_request( ReadMemory(x, y, base_address, 4), functools.partial(self._handle_iobuf_address_response, iobuf_size, x, y, p))
def test_create_new_memory_scp_pkt(self): scp = ReadMemory(0, 0, 0, 256) self.assertEqual(scp.argument_1, 0) self.assertEqual(scp.argument_2, 256) self.assertEqual(scp.argument_3, 2) self.assertEqual(scp.data, None)
def _read_address(self, chip_address, address, size, callback): (x, y) = chip_address self._send_request( ReadMemory(x, y, address, size), callback) self._finish() self.check_for_error()