Esempio n. 1
0
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 test_add_processor(self):
     proc_list = [0,1,2,3,5,8,13]
     cs = CoreSubset(0,0,proc_list)
     css = CoreSubsets()
     css.add_core_subset(cs)
     self.assertIn(cs,css.core_subsets)
     for core_subset in css.core_subsets:
         self.assertIn(core_subset,[cs])
Esempio n. 3
0
    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 _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 _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
Esempio n. 6
0
enable_reinjection = True
iptags.append(IPTag("192.168.240.253", 0, "0.0.0.0", 17896, True))
application_data.append(
    ReloadApplicationData("192.168.240.253_appData_0_0_1.dat", 0, 0, 1,
                          1612972032))
application_data.append(
    ReloadApplicationData("192.168.240.253_appData_0_0_2.dat", 0, 0, 2,
                          1612989276))
reload_routing_table = ReloadRoutingTable()
routing_tables.add_routing_table(
    reload_routing_table.reload("picked_routing_table_for_0_0"))
binaries.add_subsets(
    "C:\\Python27\\lib\\site-packages\\spynnaker\\pyNN\\model_binaries\\IF_curr_exp.aplx",
    CoreSubsets([
        CoreSubset(0, 0, [
            2,
        ]),
    ]))
binaries.add_subsets(
    "C:\\Python27\\lib\\site-packages\\spinn_front_end_common\\common_model_binaries\\reverse_iptag_multicast_source.aplx",
    CoreSubsets([
        CoreSubset(0, 0, [
            1,
        ]),
    ]))
vertex = ReloadBufferedVertex("inputSpikes_On:0:255",
                              [(2, "inputSpikes_On_0_255_2", 1048576)])
buffered_placements.add_placement(Placement(vertex, 0, 0, 1))
buffered_tags.add_ip_tag(IPTag("192.168.240.253", 0, "0.0.0.0", 17896, True),
                         vertex)
Esempio n. 7
0
number_of_boards = 1
height = None
width = None
auto_detect_bmp = False
enable_reinjection = True
iptags.append(
    IPTag("192.168.240.253", 0, "0.0.0.0", 17896, True)) 
application_data.append(ReloadApplicationData(
    "192.168.240.253_appData_0_0_1.dat",
    0, 0, 1, 1612972032))
application_data.append(ReloadApplicationData(
    "192.168.240.253_appData_0_0_2.dat",
    0, 0, 2, 1612987952))
reload_routing_table = ReloadRoutingTable()
routing_tables.add_routing_table(reload_routing_table.reload("picked_routing_table_for_0_0"))
binaries.add_subsets("C:\\Python27\\lib\\site-packages\\spynnaker\\pyNN\\model_binaries\\IF_curr_exp.aplx", CoreSubsets([CoreSubset(0, 0, [2, ]),]))
binaries.add_subsets("C:\\Python27\\lib\\site-packages\\spinn_front_end_common\\common_model_binaries\\reverse_iptag_multicast_source.aplx", CoreSubsets([CoreSubset(0, 0, [1, ]),]))
vertex = ReloadBufferedVertex("inputSpikes_On:0:255", [(2, "inputSpikes_On_0_255_2", 1048576) ])
buffered_placements.add_placement(Placement(vertex, 0, 0, 1))
buffered_tags.add_ip_tag(IPTag("192.168.240.253", 0, "0.0.0.0", 17896, True), vertex) 

reloader = Reload(machine_name, machine_version, reports_states, bmp_details, down_chips, down_cores, number_of_boards, height, width, auto_detect_bmp,enable_reinjection)
if len(socket_addresses) > 0:
    reloader.execute_notification_protocol_read_messages(socket_addresses, None, os.path.join(os.path.dirname(os.path.abspath(__file__)), "input_output_database.db"))
reloader.reload_application_data(application_data)
reloader.reload_routes(routing_tables)
reloader.reload_tags(iptags, reverse_iptags)
reloader.reload_binaries(binaries)
reloader.enable_buffer_manager(buffered_placements, buffered_tags)
reloader.restart(binaries, 4000, 1, turn_off_machine=True)
    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}
Esempio n. 9
0
reload_routing_table = ReloadRoutingTable()
routing_tables.add_routing_table(
    reload_routing_table.reload("picked_routing_table_for_1_0"))
binaries.add_subsets(
    "C:\\Python27\\lib\\site-packages\\spynnaker\\pyNN\\model_binaries\\IF_curr_exp.aplx",
    CoreSubsets([
        CoreSubset(0, 1, [
            1,
            3,
            5,
            7,
        ]),
        CoreSubset(1, 1, [
            1,
            3,
            5,
            7,
            9,
            11,
            13,
            15,
        ]),
        CoreSubset(1, 0, [
            13,
            15,
        ]),
    ]))
binaries.add_subsets(
    "C:\\Python27\\lib\\site-packages\\spynnaker\\pyNN\\model_binaries\\IF_curr_exp_stdp_mad_nearest_pair_multiplicative.aplx",
    CoreSubsets([
        CoreSubset(0, 1, [
            8,
Esempio n. 10
0
 def __init__(self):
     self._targets = dict()
     self._total_processors = 0
     self._all_core_subsets = CoreSubsets()
Esempio n. 11
0
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
Esempio n. 12
0
 def test_add_core_subset_duplicate_core_subset(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_core_subset(cs)
Esempio n. 13
0
 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)
buffered_tags = Tags()
buffered_placements = Placements()

routing_tables = MulticastRoutingTables()
# database params
socket_addresses = list()

reports_states = ReportState(False, False, False, False, False,
                             False, False, False, False, False)
machine_name = "192.168.240.253"
machine_version = 3
bmp_details = "None"
down_chips = "None"
down_cores = "None"
number_of_boards = 1
height = None
width = None
auto_detect_bmp = False
enable_reinjection = True
iptags.append(
    IPTag("192.168.240.253", 0, "0.0.0.0", 17896, True)) 
application_data.append(ReloadApplicationData(
    "192.168.240.253_appData_0_0_1.dat",
    0, 0, 1, 1612972032))
application_data.append(ReloadApplicationData(
    "192.168.240.253_appData_0_0_2.dat",
    0, 0, 2, 1612991232))
reload_routing_table = ReloadRoutingTable()
routing_tables.add_routing_table(reload_routing_table.reload("picked_routing_table_for_0_0"))
binaries.add_subsets("C:\\Python27\\lib\\site-packages\\spynnaker\\pyNN\\model_binaries\\IF_curr_exp.aplx", CoreSubsets([CoreSubset(0, 0, [2, ]),]))
Esempio n. 15
0
from board_test_configuration import BoardTestConfiguration
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: