def testSpin2(self): if not Ping.host_is_reachable(self.spalloc): raise unittest.SkipTest(self.spalloc + " appears to be down") spallocAlgo = SpallocAllocator() try: (hostname, version, _, _, _, _, _, m_allocation_controller) = \ spallocAlgo(spalloc_server=self.spalloc, spalloc_user="******", n_chips=20, spalloc_port=self.spin2Port) except (JobDestroyedError): self.skipTest("Skipping as getting Job failed") trans = transceiver.create_transceiver_from_hostname(hostname, 5) trans.ensure_board_is_ready() machine = trans.get_machine_details() m_allocation_controller.close() jsonAlgo = WriteJsonMachine() folder = "spinn2" self._remove_old_json(folder) filename = jsonAlgo(machine, folder) self.json_compare(filename, "spinn2.json") trans.close()
def test_boot_board(self): board_config.set_up_remote_board() trans = transceiver.create_transceiver_from_hostname( board_config.remotehost, board_config.board_version) # self.assertFalse(trans.is_connected()) trans.boot_board() trans.close()
def testSpin2(self): if not Ping.host_is_reachable(self.spalloc): raise unittest.SkipTest(self.spalloc + " appears to be down") spallocAlgo = SpallocAllocator() try: (hostname, version, _, _, _, _, _, m_allocation_controller) = \ spallocAlgo(self.spalloc, "Integration testing ok to kill", 20, self.spin2Port) except (JobDestroyedError): self.skipTest("Skipping as getting Job failed") trans = transceiver.create_transceiver_from_hostname(hostname, 5) trans.ensure_board_is_ready() machine = trans.get_machine_details() m_allocation_controller.close() jsonAlgo = ConvertToJavaMachine() fn = "test_spinn2.json" filename = jsonAlgo(machine, str(fn)) self.json_compare(filename, "spinn2.json") trans.close()
def testSpin4(self): if not Ping.host_is_reachable(self.spin4Host): raise unittest.SkipTest(self.spin4Host + " appears to be down") trans = transceiver.create_transceiver_from_hostname(self.spin4Host, 5) trans.ensure_board_is_ready() machine = trans.get_machine_details() jsonAlgo = ConvertToJavaMachine() fn = "test_spinn4.json" filename = jsonAlgo(machine, str(fn)) self.json_compare(filename, "spinn4.json") # Create a machine with Exception chip = machine.get_chip_at(1, 1) chip._sdram._size = chip._sdram._size - 100 chip._router._n_available_multicast_entries -= 10 chip._virtual = not chip._virtual chip = machine.get_chip_at(1, 2) chip._sdram._size = chip._sdram._size - 101 fn = "test_spinn4_fiddle.json" filename = jsonAlgo(machine, str(fn)) self.json_compare(filename, "spinn4_fiddle.json") trans.close()
def __call__( self, hostname, bmp_details, downed_chips, downed_cores, downed_links, board_version, auto_detect_bmp, enable_reinjection, scamp_connection_data, boot_port_num, reset_machine_on_start_up, max_sdram_size=None, max_core_id=None): """ :param hostname: the hostname or ip address of the spinnaker machine :param bmp_details: the details of the BMP connections :param downed_chips: the chips that are down which SARK thinks are\ alive :param downed_cores: the cores that are down which SARK thinks are\ alive :param board_version: the version of the boards being used within the\ machine (1, 2, 3, 4 or 5) :param auto_detect_bmp: boolean which determines if the BMP should be automatically determined :param enable_reinjection: True if dropped packet reinjection is to be\ enabled :param boot_port_num: the port num used for the boot connection :param scamp_connection_data: the list of scamp connection data or\ None :param max_sdram_size: the maximum SDRAM each chip can say it has (mainly used in debugging purposes) :type max_sdram_size: int or None """ # if the end user gives you scamp data, use it and don't discover them if scamp_connection_data is not None: scamp_connection_data = \ self._sort_out_scamp_connections(scamp_connection_data) # sort out BMP connections into list of strings bmp_connection_data = self._sort_out_bmp_string(bmp_details) txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=bmp_connection_data, version=board_version, ignore_chips=downed_chips, ignore_cores=downed_cores, ignored_links=downed_links, auto_detect_bmp=auto_detect_bmp, boot_port_no=boot_port_num, scamp_connections=scamp_connection_data, max_sdram_size=max_sdram_size, max_core_id=max_core_id) if reset_machine_on_start_up: txrx.power_off_machine() # do auto boot if possible if board_version is None: raise ConfigurationException( "Please set a machine version number in the configuration " "file (spynnaker.cfg or pacman.cfg)") txrx.ensure_board_is_ready( enable_reinjector=enable_reinjection) txrx.discover_scamp_connections() machine = txrx.get_machine_details() return machine, txrx
def __call__( self, hostname, bmp_details, downed_chips, downed_cores, downed_links, board_version, auto_detect_bmp, scamp_connection_data, boot_port_num, reset_machine_on_start_up, max_sdram_size=None, max_core_id=None): """ :param hostname: the hostname or IP address of the SpiNNaker machine :param bmp_details: the details of the BMP connections :param downed_chips: \ the chips that are down which SARK thinks are alive :param downed_cores: \ the cores that are down which SARK thinks are alive :param board_version: the version of the boards being used within the\ machine (1, 2, 3, 4 or 5) :param auto_detect_bmp: \ Whether the BMP should be automatically determined :type auto_detect_bmp: bool :param boot_port_num: the port num used for the boot connection :type boot_port_num: int :param scamp_connection_data: \ the list of SC&MP connection data or None :param max_sdram_size: the maximum SDRAM each chip can say it has\ (mainly used in debugging purposes) :type max_sdram_size: int or None :type reset_machine_on_start_up: bool :return: Connection details and Transceiver """ # pylint: disable=too-many-arguments # if the end user gives you scamp data, use it and don't discover them if scamp_connection_data is not None: scamp_connection_data = [ self._parse_scamp_connection(piece) for piece in scamp_connection_data.split(":")] txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=self._parse_bmp_details(bmp_details), version=board_version, ignore_chips=downed_chips, ignore_cores=downed_cores, ignored_links=downed_links, auto_detect_bmp=auto_detect_bmp, boot_port_no=boot_port_num, scamp_connections=scamp_connection_data, max_sdram_size=max_sdram_size, max_core_id=max_core_id) if reset_machine_on_start_up: txrx.power_off_machine() # do auto boot if possible if board_version is None: raise ConfigurationException( "Please set a machine version number in the configuration " "file (spynnaker.cfg or pacman.cfg)") txrx.ensure_board_is_ready() txrx.discover_scamp_connections() return txrx.get_machine_details(), txrx
def __init__(self, hostname, on_thread_start=None): """ Start a new asynchronous BMP Controller Parameters ---------- hostname : str The hostname/IP of the BMP to connect to. on_thread_start : function() or None *Optional.* A function to be called by the controller's background thread before it starts. This can be used to ensure proper sequencing/handing-over between two AsyncBMPControllers connected to the same machine. """ self._on_thread_start = on_thread_start self._transceiver = create_transceiver_from_hostname( None, 5, bmp_connection_data=[ BMPConnectionData(0, 0, hostname, [0], SCP_SCAMP_PORT) ]) self._hostname = hostname self._stop = False # A lock which must be held when modifying the state of this object self._lock = threading.RLock() # An event fired whenever some new interaction with the BMP is # required. self._requests_pending = threading.Event() # A queue of requests to be done self._requests = deque() self._thread = threading.Thread( target=self._run, name="<BMP control thread for {}>".format(hostname)) self._thread.start()
def _make_transceiver(host, version, bmp_names): """ :param host: Most to use or None to use test config for all params :type host: str or None :param version: Board version to use (None defaults to 5 unless host is 192.168.240.253 (spin 3) :type version: int or None :param bmp: bmp conenction or None to auto detect (if applicable) :type bmp: str or None :rtype: Transceiver """ if host is None: try: from board_test_configuration import BoardTestConfiguration config = BoardTestConfiguration() except ImportError: print("cannot read board test configuration") sys.exit(1) config.set_up_remote_board() host = config.remotehost version = config.board_version bmp_names = config.bmp_names auto_detect_bmp = config.auto_detect_bmp else: if version is None: if host == "192.168.240.253": version = 3 else: version = 5 auto_detect_bmp = False print("talking to SpiNNaker system at {}".format(host)) return create_transceiver_from_hostname(host, version, bmp_connection_data=bmp_names, auto_detect_bmp=auto_detect_bmp)
def __call__( self, hostname, bmp_details, downed_chips, downed_cores, board_version, number_of_boards, width, height, auto_detect_bmp, enable_reinjection, scamp_connection_data, boot_port_num, reset_machine_on_start_up): """ :param hostname: the hostname or ip address of the spinnaker machine :param bmp_details: the details of the BMP connections :param downed_chips: the chips that are down which SARK thinks are\ alive :param downed_cores: the cores that are down which SARK thinks are\ alive :param board_version: the version of the boards being used within the\ machine (1, 2, 3, 4 or 5) :param number_of_boards: the number of boards within the machine :param width: The width of the machine in chips :param height: The height of the machine in chips :param auto_detect_bmp: boolean which determines if the BMP should be automatically determined :param enable_reinjection: True if dropped packet reinjection is to be\ enabled :param boot_port_num: the port num used for the boot connection :param scamp_connection_data: the list of scamp connection data or\ None :return: None """ # if the end user gives you scamp data, use it and dont discover them if scamp_connection_data is not None: scamp_connection_data = \ self._sort_out_scamp_connections(scamp_connection_data) # sort out down chips and down cores if needed ignored_chips, ignored_cores = \ self._sort_out_downed_chips_cores(downed_chips, downed_cores) # sort out BMP connections into list of strings bmp_connection_data = self._sort_out_bmp_string(bmp_details) txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=bmp_connection_data, version=board_version, ignore_chips=ignored_chips, ignore_cores=ignored_cores, number_of_boards=number_of_boards, auto_detect_bmp=auto_detect_bmp, boot_port_no=boot_port_num, scamp_connections=scamp_connection_data) if reset_machine_on_start_up: txrx.power_off_machine() # update number of boards from machine if number_of_boards is None: number_of_boards = txrx.number_of_boards_located # do auto boot if possible if board_version is None: raise exceptions.ConfigurationException( "Please set a machine version number in the configuration " "file (spynnaker.cfg or pacman.cfg)") txrx.ensure_board_is_ready( number_of_boards, width, height, enable_reinjector=enable_reinjection) txrx.discover_scamp_connections() machine = txrx.get_machine_details() return {"machine": machine, "txrx": txrx}
def __call__(self, hostname, bmp_details, downed_chips, downed_cores, downed_links, board_version, auto_detect_bmp, scamp_connection_data, boot_port_num, reset_machine_on_start_up, max_sdram_size=None, max_core_id=None, repair_machine=False, ignore_bad_ethernets=True): """ :param hostname: the hostname or IP address of the SpiNNaker machine :param bmp_details: the details of the BMP connections :param downed_chips: \ the chips that are down which SARK thinks are alive :param downed_cores: \ the cores that are down which SARK thinks are alive :param board_version: the version of the boards being used within the\ machine (1, 2, 3, 4 or 5) :param auto_detect_bmp: \ Whether the BMP should be automatically determined :type auto_detect_bmp: bool :param boot_port_num: the port number used for the boot connection :type boot_port_num: int :param scamp_connection_data: \ the list of SC&MP connection data or None :param max_sdram_size: the maximum SDRAM each chip can say it has\ (mainly used in debugging purposes) :type max_sdram_size: int or None :type reset_machine_on_start_up: bool :param repair_machine: Flag to set the behaviour if a repairable error is found on the machine. If true will create a machine without the problematic bits. (See machine_factory.machine_repair) If False get machine will raise an Exception if a problematic machine is discovered. :type repair_machine: bool :param ignore_bad_ethernets: Flag to say that ip_address information on none ethernet chips should be ignored. None_ethernet chips are defined here as ones that do not report themselves their nearest ethernet. The bad ipaddress is always logged If True the ipaddress is ignored If False the chip with the bad ipaddress is removed. :type ignore_bad_ethernets: bool :return: Connection details and Transceiver :rtype: tuple(:py:class:`~spinnman.Transceiver`,\ :py:class:`~spinn_machine.Machine`) """ # pylint: disable=too-many-arguments # if the end user gives you SCAMP data, use it and don't discover them if scamp_connection_data is not None: scamp_connection_data = [ self._parse_scamp_connection(piece) for piece in scamp_connection_data.split(":") ] txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=self._parse_bmp_details(bmp_details), version=board_version, ignore_chips=downed_chips, ignore_cores=downed_cores, ignored_links=downed_links, auto_detect_bmp=auto_detect_bmp, boot_port_no=boot_port_num, scamp_connections=scamp_connection_data, max_sdram_size=max_sdram_size, max_core_id=max_core_id, repair_machine=repair_machine, ignore_bad_ethernets=ignore_bad_ethernets) if reset_machine_on_start_up: txrx.power_off_machine() # do auto boot if possible if board_version is None: raise ConfigurationException( "Please set a machine version number in the configuration " "file (spynnaker.cfg or pacman.cfg)") txrx.ensure_board_is_ready() txrx.discover_scamp_connections() return txrx.get_machine_details(), txrx
from spinnman.transceiver import create_transceiver_from_hostname import sys if len(sys.argv) < 4: print "{} <machine_name> <x> <y>".format(sys.argv[0]) sys.exit() machine_name = sys.argv[1] x = int(sys.argv[2]) y = int(sys.argv[3]) transceiver = create_transceiver_from_hostname(machine_name, 0, auto_detect_bmp=False) routing_entries = transceiver.get_multicast_routes(x, y) print "Key Mask Links Cores" print "=== ==== ===== =====" for routing_entry in routing_entries: print "0x{:08X} 0x{:08X} {:20s} {}".format( routing_entry.key_combo, routing_entry.mask, list(routing_entry.link_ids), list(routing_entry.processor_ids))
from spinnman.transceiver import create_transceiver_from_hostname import sys if len(sys.argv) < 4: print "{} <machine_name> <x> <y>".format(sys.argv[0]) sys.exit() machine_name = sys.argv[1] x = int(sys.argv[2]) y = int(sys.argv[3]) transceiver = create_transceiver_from_hostname(machine_name, 0, auto_detect_bmp=False) routing_entries = transceiver.get_multicast_routes(x, y) print "Key Mask Links Cores" print "=== ==== ===== =====" for routing_entry in routing_entries: print "0x{:08X} 0x{:08X} {:20s} {}".format( routing_entry.key_combo, routing_entry.mask, list(routing_entry.link_ids), list(routing_entry.processor_ids) )
from spinnman.transceiver import create_transceiver_from_hostname from spinnman.data.file_data_reader import FileDataReader as SpinnmanFileDataReader from spynnaker.pyNN.spynnaker_comms_functions import SpynnakerCommsFunctions import pickle txrx = create_transceiver_from_hostname(hostname="192.168.240.253", discover=False) txrx.ensure_board_is_ready(int(3)) txrx.discover_connections() application_data_file_reader = SpinnmanFileDataReader("192.168.240.253_appData_0_0_1.dat") txrx.write_memory(0, 0, 1879048192, application_data_file_reader, 128) txrx.write_memory(0, 0, 3842011376, 1879048192) application_data_file_reader = SpinnmanFileDataReader("192.168.240.253_appData_0_0_2.dat") txrx.write_memory(0, 0, 1879048320, application_data_file_reader, 116) txrx.write_memory(0, 0, 3842011504, 1879048320) application_data_file_reader = SpinnmanFileDataReader("192.168.240.253_appData_0_0_3.dat") txrx.write_memory(0, 0, 1879048436, application_data_file_reader, 10152) txrx.write_memory(0, 0, 3842011632, 1879048436) application_data_file_reader = SpinnmanFileDataReader("192.168.240.253_appData_0_0_4.dat") txrx.write_memory(0, 0, 1879218592, application_data_file_reader, 128) txrx.write_memory(0, 0, 3842011760, 1879218592) router_table = pickle.load(open("picked_routing_table_for_0_0", "rb")) txrx.load_multicast_routes(router_table.x, router_table.y, router_table.multicast_routing_entries, app_id=30) executable_targets = pickle.load(open("picked_executables_mappings", "rb")) core_subset = executable_targets["/home/micky/src/spinnaker/venv/lib/python2.7/site-packages/spynnaker/pyNN/model_binaries/IF_curr_exp.aplx"] file_reader = SpinnmanFileDataReader("/home/micky/src/spinnaker/venv/lib/python2.7/site-packages/spynnaker/pyNN/model_binaries/IF_curr_exp.aplx")
def __call__(self, hostname, bmp_details, downed_chips, downed_cores, downed_links, board_version, auto_detect_bmp, scamp_connection_data, boot_port_num, reset_machine_on_start_up, max_sdram_size=None, repair_machine=False, ignore_bad_ethernets=True, default_report_directory=None): """ :param str hostname: :param str bmp_details: :param set(tuple(int,int)) downed_chips: :param set(tuple(int,int,int)) downed_cores: :param set(tuple(int,int,int)) downed_links: :param int board_version: :param bool auto_detect_bmp: :param list(~.SocketAddressWithChip) scamp_connection_data: :param int boot_port_num: :param bool reset_machine_on_start_up: :param max_sdram_size: :type max_sdram_size: int or None :param bool repair_machine: :param bool ignore_bad_ethernets: :param str default_report_directory: :rtype: tuple(~spinnman.transceiver.Transceiver, ~spinn_machine.Machine) """ # pylint: disable=too-many-arguments # if the end user gives you SCAMP data, use it and don't discover them if scamp_connection_data is not None: scamp_connection_data = [ self._parse_scamp_connection(piece) for piece in scamp_connection_data.split(":") ] txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=self._parse_bmp_details(bmp_details), version=board_version, ignore_chips=downed_chips, ignore_cores=downed_cores, ignored_links=downed_links, auto_detect_bmp=auto_detect_bmp, boot_port_no=boot_port_num, scamp_connections=scamp_connection_data, max_sdram_size=max_sdram_size, repair_machine=repair_machine, ignore_bad_ethernets=ignore_bad_ethernets, default_report_directory=default_report_directory) if reset_machine_on_start_up: success = txrx.power_off_machine() if success: logger.warning(self.POWER_CYCLE_WARNING) time.sleep(POWER_CYCLE_WAIT_TIME_IN_SECONDS) logger.warning("Power cycle wait complete") else: logger.warning(self.POWER_CYCLE_FAILURE_WARNING) # do auto boot if possible if board_version is None: raise ConfigurationException( "Please set a machine version number in the " "corresponding configuration (cfg) file") txrx.ensure_board_is_ready() txrx.discover_scamp_connections() return txrx.get_machine_details(), txrx
def test_boot_board(self): board_config.set_up_remote_board() with transceiver.create_transceiver_from_hostname( board_config.remotehost, board_config.board_version) as trans: # self.assertFalse(trans.is_connected()) trans.boot_board()
def setup_interfaces( self, hostname, bmp_details, downed_chips, downed_cores, board_version, number_of_boards, width, height, is_virtual, virtual_has_wrap_arounds, auto_detect_bmp=True, enable_reinjection=True, ): """ Set up the interfaces for communicating with the SpiNNaker board :param hostname: the hostname or ip address of the spinnaker machine :param bmp_details: the details of the BMP connections :param downed_chips: the chips that are down which sark thinks are\ alive :param downed_cores: the cores that are down which sark thinks are\ alive :param board_version: the version of the boards being used within the\ machine (1, 2, 3, 4 or 5) :param number_of_boards: the number of boards within the machine :param width: The width of the machine in chips :param height: The height of the machine in chips :param is_virtual: True of the machine is virtual, False otherwise; if\ True, the width and height are used as the machine dimensions :param virtual_has_wrap_arounds: True if the machine is virtual and\ should be created with wrap_arounds :param auto_detect_bmp: boolean which determines if the bmp should be automatically determined :param enable_reinjection: True if dropped packet reinjection is to be\ enabled :return: None """ if not is_virtual: # sort out down chips and down cores if needed ignored_chips, ignored_cores = self._sort_out_downed_chips_cores(downed_chips, downed_cores) # sort out bmp connections into list of strings bmp_connection_data = self._sort_out_bmp_string(bmp_details) self._txrx = create_transceiver_from_hostname( hostname=hostname, bmp_connection_data=bmp_connection_data, version=board_version, ignore_chips=ignored_chips, ignore_cores=ignored_cores, number_of_boards=number_of_boards, auto_detect_bmp=auto_detect_bmp, ) # update number of boards from machine if number_of_boards is None: number_of_boards = self._txrx.number_of_boards_located # do autoboot if possible if board_version is None: raise exceptions.ConfigurationException( "Please set a machine version number in the configuration " "file (spynnaker.cfg or pacman.cfg)" ) self._txrx.ensure_board_is_ready(number_of_boards, width, height, enable_reinjector=enable_reinjection) self._txrx.discover_scamp_connections() self._machine = self._txrx.get_machine_details() if self._reports_states.transciever_report: self._reload_script = ReloadScript( self._app_data_folder, hostname, board_version, bmp_details, downed_chips, downed_cores, number_of_boards, height, width, auto_detect_bmp, enable_reinjection, ) else: self._machine = VirtualMachine(width=width, height=height, with_wrap_arounds=virtual_has_wrap_arounds)
transceiver.write_memory_flood(0x70000000, data=inputdata) data = struct.unpack( "<Q", transceiver.read_memory(0, 0, 0x70000000, 8))[0] data2 = struct.unpack( "<Q", transceiver.read_memory(1, 1, 0x70000000, 8))[0] if data != 123456789123456789 or data2 != 123456789123456789: raise Exception("values are not identical") transceiver.write_memory_flood(0x70000000, data=123456789) data = struct.unpack( "<I", transceiver.read_memory(0, 0, 0x70000000, 4))[0] data2 = struct.unpack( "<I", transceiver.read_memory(1, 1, 0x70000000, 4))[0] if data != 123456789 or data2 != 123456789: raise Exception("values are not identical") with Section("Get Heap"): for heap_element in transceiver.get_heap(0, 0): print(heap_element) transceiver = create_transceiver_from_hostname( board_config.remotehost, board_config.board_version, ignore_cores=down_cores, ignore_chips=down_chips, bmp_connection_data=board_config.bmp_names, auto_detect_bmp=board_config.auto_detect_bmp) try: print_transceiver_tests(transceiver) finally: transceiver.close()