def _sort_out_downed_chips_cores(downed_chips, downed_cores): """ Translate the down cores and down chips string into a form that \ spinnman can understand :param downed_cores: string representing down cores :type downed_cores: str :param downed_chips: string representing down chips :type: downed_chips: str :return: a list of down cores and down chips in processor and \ core subset format """ ignored_chips = None ignored_cores = None if downed_chips is not None and downed_chips != "None": ignored_chips = CoreSubsets() for downed_chip in downed_chips.split(":"): x, y = downed_chip.split(",") ignored_chips.add_core_subset(CoreSubset(int(x), int(y), [])) if downed_cores is not None and downed_cores != "None": ignored_cores = CoreSubsets() for downed_core in downed_cores.split(":"): x, y, processor_id = downed_core.split(",") ignored_cores.add_processor(int(x), int(y), int(processor_id)) return ignored_chips, ignored_cores
def get_core_subsets(core_infos): """ Convert core information from get_cores_in_state to core_subset objects """ core_subsets = CoreSubsets() for (x, y, p) in core_infos: core_subsets.add_processor(x, y, p) return core_subsets
def spinnaker_based_data_specification_execution(self, write_memory_map_report, dsg_targets, transceiver, dse_app_id, app_id): """ :param write_memory_map_report: :param dsg_targets: :param transceiver: :param dse_app_id: :param app_id: :return: """ # create a progress bar for end users progress_bar = ProgressBar(len(dsg_targets), "Loading data specifications") number_of_cores_used = 0 core_subset = CoreSubsets() for (x, y, p, label) in dsg_targets: core_subset.add_processor(x, y, p) dse_data_struct_address = transceiver.malloc_sdram( x, y, constants.DSE_DATA_STRUCT_SIZE, dse_app_id) data_spec_file_path = dsg_targets[x, y, p, label] data_spec_file_size = os.path.getsize(data_spec_file_path) application_data_file_reader = FileDataReader(data_spec_file_path) base_address = transceiver.malloc_sdram(x, y, data_spec_file_size, dse_app_id) dse_data_struct_data = struct.pack("<4I", base_address, data_spec_file_size, app_id, write_memory_map_report) transceiver.write_memory(x, y, dse_data_struct_address, dse_data_struct_data, len(dse_data_struct_data)) transceiver.write_memory(x, y, base_address, application_data_file_reader, data_spec_file_size) # data spec file is written at specific address (base_address) # this is encapsulated in a structure with four fields: # 1 - data specification base address # 2 - data specification file size # 3 - future application ID # 4 - store data for memory map report (True / False) # If the memory map report is going to be produced, the # address of the structure is returned in user1 user_0_address = transceiver.\ get_user_0_register_address_from_core(x, y, p) transceiver.write_memory(x, y, user_0_address, dse_data_struct_address, 4) progress_bar.update() progress_bar.end() # Execute the DSE on all the cores logger.info("Loading the Data Specification Executor") dse_exec = os.path.join(os.path.dirname(spec_sender.__file__), 'data_specification_executor.aplx') file_reader = FileDataReader(dse_exec) size = os.stat(dse_exec).st_size transceiver.execute_flood(core_subset, file_reader, app_id, size) logger.info( "Waiting for On-chip Data Specification Executor to complete") processors_exited = transceiver.get_core_state_count( dse_app_id, CPUState.FINISHED) while processors_exited < number_of_cores_used: processors_errored = transceiver.get_core_state_count( dse_app_id, CPUState.RUN_TIME_EXCEPTION) if processors_errored > 0: error_cores = helpful_functions.get_cores_in_state( core_subset, CPUState, transceiver) if len(error_cores) > 0: error = helpful_functions.get_core_status_string( error_cores) raise Exception( "Data Specification Execution has failed: {}".format( error)) time.sleep(1) processors_exited = transceiver.get_core_state_count( dse_app_id, CPUState.FINISHED) transceiver.stop_application(dse_app_id) logger.info("On-chip Data Specification Executor completed") return {"LoadedApplicationDataToken": True}
class ExecutableTargets(object): """ Encapsulate the binaries and cores on which to execute them """ def __init__(self): self._targets = dict() self._total_processors = 0 self._all_core_subsets = CoreSubsets() def add_binary(self, binary): """ Add a binary to the list of things to execute :param binary: The binary to add """ if binary not in self._targets: self._targets[binary] = CoreSubsets() else: raise exceptions.ConfigurationException( "Binary {} already added".format(binary)) def has_binary(self, binary): """ Determine if the binary is already in the set :param binary: The binary to find :return: True if the binary exists, false otherwise """ return binary in self._targets def add_subsets(self, binary, subsets): """ Add core subsets to a binary :param binary: the path to the binary needed to be executed :param subsets: the subset of cores that the binary needs to be loaded\ on :return: """ if self.has_binary(binary): self._targets[binary].add_core_subset(subsets) else: self._targets[binary] = subsets for subset in subsets.core_subsets: for p in subset.processor_ids: self._total_processors += 1 self._all_core_subsets.add_processor(subset.x, subset.y, p) def add_processor(self, binary, chip_x, chip_y, chip_p): """ Add a processor to the executable targets :param binary: the binary path for executable :param chip_x: the coordinate on the machine in terms of x for the chip :param chip_y: the coordinate on the machine in terms of y for the chip :param chip_p: the processor id to place this executable on :return: """ if not self.has_binary(binary): self.add_binary(binary) self._targets[binary].add_processor(chip_x, chip_y, chip_p) self._all_core_subsets.add_processor(chip_x, chip_y, chip_p) self._total_processors += 1 def get_cores_for_binary(self, binary): """ Get the cores that a binary is to run on :param binary: The binary to find the cores for """ if self.has_binary(binary): return self._targets[binary] else: return None @property def binaries(self): """ The binaries of the executables """ return self._targets.keys() @property def total_processors(self): """ The total number of cores to be loaded """ return self._total_processors @property def all_core_subsets(self): """ All the core subsets for all the binaries """ return self._all_core_subsets
def test_add_processor_duplicate_processor_different_chip(self): proc_list = [0,1,2,3,5,8,13] cs = CoreSubset(0,0,proc_list) css = CoreSubsets([cs]) css.add_processor(0,1,0)
def test_add_processor_duplicate_processor(self): proc_list = [0,1,2,3,5,8,13] cs = CoreSubset(0,0,proc_list) css = CoreSubsets([cs]) with self.assertRaises(SpinnmanInvalidParameterException): css.add_processor(0,0,0)
from spinnman import constants logging.basicConfig(level=logging.INFO) logging.getLogger("spinnman.transceiver").setLevel(logging.DEBUG) board_config = BoardTestConfiguration() board_config.set_up_remote_board() n_cores = 20 core_subsets = CoreSubsets(core_subsets=[CoreSubset(0, 0, range(1, 11)), CoreSubset(1, 1, range(1, 11))]) app_id = 30 down_cores = CoreSubsets() down_cores.add_processor(0, 0, 5) down_chips = CoreSubsets(core_subsets=[CoreSubset(0, 1, [])]) def print_enums(name, enum_list): string = "" for enum_value in enum_list: string += enum_value.name + "; " print name, string def print_word_as_binary(name, word, start=0, end=32, fields=None): start_fields = set() end_fields = set() if fields is not None: for field in fields: