コード例 #1
0
    def extract_synaptic_matrix_data_location(self, incoming_key,
                                              master_pop_base_mem_address,
                                              txrx, chip_x, chip_y):
        # locate address of the synaptic block
        pre_x = get_x_from_key(incoming_key)
        pre_y = get_y_from_key(incoming_key)
        pre_p = get_p_from_key(incoming_key)
        table_slot_addr = self._get_table_address_from_coords(
            pre_x, pre_y, pre_p)
        master_table_pop_entry_address = (table_slot_addr +
                                          master_pop_base_mem_address)

        # read in entry
        master_pop_entry = helpful_functions.read_data(
            chip_x, chip_y, master_table_pop_entry_address, 2, "<H", txrx)

        synaptic_block_base_address = master_pop_entry >> 3  # in kilobytes

        # convert synaptic_block_base_address into bytes from kilobytes
        synaptic_block_base_address_offset = synaptic_block_base_address << 10
        max_row_length_index = master_pop_entry & 0x7

        # retrieve the max row length
        max_row_length = ROW_LEN_TABLE_ENTRIES[max_row_length_index]
        return [(max_row_length, synaptic_block_base_address_offset)]
コード例 #2
0
    def extract_synaptic_matrix_data_location(
            self, incoming_key_combo, master_pop_base_mem_address, txrx,
            chip_x, chip_y):

        # get entries in master pop
        n_entries = helpful_functions.read_data(
            chip_x, chip_y, master_pop_base_mem_address, 4, "<I", txrx)
        n_bytes = (n_entries *
                   _MasterPopEntry.MASTER_POP_ENTRY_SIZE_BYTES)

        # read in master pop structure
        full_data = txrx.read_memory(
            chip_x, chip_y, master_pop_base_mem_address + 4, n_bytes)

        # convert into a numpy array
        master_pop_structure = numpy.frombuffer(
            dtype='uint8', buffer=full_data).view(dtype='<u4')

        entries = list()
        for index in range(0, n_bytes / 4, 3):
            key = master_pop_structure[index]
            mask = master_pop_structure[index + 1]
            address_and_row_length = master_pop_structure[index + 2]
            entries.append(_MasterPopEntry(
                key, mask, address_and_row_length >> 8,
                address_and_row_length & 0xFF))

        entry = self._locate_entry(entries, incoming_key_combo)

        max_row_size = entry.row_length
        return max_row_size, entry.address * 4
コード例 #3
0
    def extract_synaptic_matrix_data_location(
            self, incoming_key, master_pop_base_mem_address, txrx, chip_x,
            chip_y):
        """

        :param incoming_key:
        :param master_pop_base_mem_address:
        :param txrx:
        :param chip_x:
        :param chip_y:
        :return:
        """

        # locate address of the synaptic block
        pre_x = get_x_from_key(incoming_key)
        pre_y = get_y_from_key(incoming_key)
        pre_p = get_p_from_key(incoming_key)
        table_slot_addr = self._get_table_address_from_coords(
            pre_x, pre_y, pre_p)
        master_table_pop_entry_address = (table_slot_addr +
                                          master_pop_base_mem_address)

        # read in entry
        master_pop_entry = helpful_functions.read_data(
            chip_x, chip_y, master_table_pop_entry_address, 2, "<H", txrx)

        synaptic_block_base_address = master_pop_entry >> 3  # in kilobytes

        # convert synaptic_block_base_address into bytes from kilobytes
        synaptic_block_base_address_offset = synaptic_block_base_address << 10
        max_row_length_index = master_pop_entry & 0x7

        # retrieve the max row length
        max_row_length = ROW_LEN_TABLE_ENTRIES[max_row_length_index]
        return [(max_row_length, synaptic_block_base_address_offset)]
コード例 #4
0
    def extract_synaptic_matrix_data_location(self, incoming_key_combo,
                                              master_pop_base_mem_address,
                                              txrx, chip_x, chip_y):

        # get entries in master pop
        n_entries = helpful_functions.read_data(chip_x, chip_y,
                                                master_pop_base_mem_address, 4,
                                                "<I", txrx)
        n_bytes = (n_entries * _MasterPopEntry.MASTER_POP_ENTRY_SIZE_BYTES)

        # read in master pop structure
        full_data = txrx.read_memory(chip_x, chip_y,
                                     master_pop_base_mem_address + 4, n_bytes)

        # convert into a numpy array
        master_pop_structure = numpy.frombuffer(
            dtype='uint8', buffer=full_data).view(dtype='<u4')

        entries = list()
        for index in range(0, n_bytes / 4, 3):
            key = master_pop_structure[index]
            mask = master_pop_structure[index + 1]
            address_and_row_length = master_pop_structure[index + 2]
            entries.append(
                _MasterPopEntry(key, mask, address_and_row_length >> 8,
                                address_and_row_length & 0xFF))

        entry = self._locate_entry(entries, incoming_key_combo)

        max_row_size = entry.row_length
        return max_row_size, entry.address * 4
コード例 #5
0
    def locate_master_pop_table_base_address(self, x, y, p, transceiver,
                                             master_pop_table_region):
        """

        :param x: x coord for the chip to whcih this master pop table is \
        being read
        :type x: int
        :param y: y coord for the chip to whcih this master pop table is \
        being read
        :type y: int
        :param p: p coord for the processor to whcih this master pop table is \
        being read
        :type p: int
        :param transceiver: the transciever object
        :type transceiver: spinnman.transciever.Transciever object
        :param master_pop_table_region: the region to which the master pop\
         resides
         :type master_pop_table_region: int


        :return: the master pop table in some form
        """
        # Get the App Data base address for the core
        # (location where this cores memory starts in
        # sdram and region table)
        app_data_base_address = \
            transceiver.get_cpu_information_from_core(x, y, p).user[0]

        # Get the memory address of the master pop table region
        master_pop_region = master_pop_table_region

        master_region_base_address_address = \
            dsg_utility.get_region_base_address_offset(
                app_data_base_address, master_pop_region)

        master_region_base_address_offset = helpful_functions.read_data(
            x, y, master_region_base_address_address, 4, "<I", transceiver)

        master_region_base_address =\
            master_region_base_address_offset + app_data_base_address

        return master_region_base_address, app_data_base_address
コード例 #6
0
    def locate_master_pop_table_base_address(self, x, y, p, transceiver,
                                             master_pop_table_region):
        """

        :param x: x coord for the chip to whcih this master pop table is \
        being read
        :type x: int
        :param y: y coord for the chip to whcih this master pop table is \
        being read
        :type y: int
        :param p: p coord for the processor to whcih this master pop table is \
        being read
        :type p: int
        :param transceiver: the transciever object
        :type transceiver: spinnman.transciever.Transciever object
        :param master_pop_table_region: the region to which the master pop\
         resides
         :type master_pop_table_region: int


        :return: the master pop table in some form
        """
        # Get the App Data base address for the core
        # (location where this cores memory starts in
        # sdram and region table)
        app_data_base_address = \
            transceiver.get_cpu_information_from_core(x, y, p).user[0]

        # Get the memory address of the master pop table region
        master_pop_region = master_pop_table_region

        master_region_base_address_address = \
            dsg_utility.get_region_base_address_offset(
                app_data_base_address, master_pop_region)

        master_region_base_address_offset = helpful_functions.read_data(
            x, y, master_region_base_address_address, 4, "<I", transceiver)

        master_region_base_address =\
            master_region_base_address_offset + app_data_base_address

        return master_region_base_address, app_data_base_address
コード例 #7
0
    def extract_synaptic_matrix_data_location(
            self, incoming_key, master_pop_base_mem_address, txrx, chip_x,
            chip_y):
        # pylint: disable=too-many-arguments

        # locate address of the synaptic block
        table_slot_addr = self._get_table_address_from_key(incoming_key)
        master_table_pop_entry_address = (
            table_slot_addr + master_pop_base_mem_address)

        # read in entry
        master_pop_entry = helpful_functions.read_data(
            chip_x, chip_y, master_table_pop_entry_address, 2, "<H", txrx)

        synaptic_block_base_address = master_pop_entry >> 3  # in kilobytes

        # convert synaptic_block_base_address into bytes from kilobytes
        synaptic_block_base_address_offset = synaptic_block_base_address << 10
        max_row_length_index = master_pop_entry & 0x7

        # retrieve the max row length
        max_row_length = ROW_LEN_TABLE_ENTRIES[max_row_length_index]
        return [(max_row_length, synaptic_block_base_address_offset)]
コード例 #8
0
    def _retrieve_synaptic_block(self, placements, transceiver, pre_subvertex,
                                 pre_n_atoms, post_subvertex, routing_infos,
                                 subgraph):
        """
        reads in a synaptic block from a given processor and subvertex on the
        machine.
        """
        post_placement = placements.get_placement_of_subvertex(post_subvertex)
        post_x, post_y, post_p = \
            post_placement.x, post_placement.y, post_placement.p

        # either read in the master pop table or retrieve it from storage
        master_pop_base_mem_address, app_data_base_address = \
            self._master_pop_table_generator.\
            locate_master_pop_table_base_address(
                post_x, post_y, post_p, transceiver,
                constants.POPULATION_BASED_REGIONS.POPULATION_TABLE.value)

        incoming_edges = subgraph.incoming_subedges_from_subvertex(
            post_subvertex)
        incoming_key_combo = None
        for subedge in incoming_edges:
            if subedge.pre_subvertex == pre_subvertex:
                routing_info = \
                    routing_infos.get_subedge_information_from_subedge(subedge)
                keys_and_masks = routing_info.keys_and_masks
                incoming_key_combo = keys_and_masks[0].key
                break

        maxed_row_length, synaptic_block_base_address_offset = \
            self._master_pop_table_generator.\
            extract_synaptic_matrix_data_location(
                incoming_key_combo, master_pop_base_mem_address,
                transceiver, post_x, post_y)

        block = None
        if maxed_row_length > 0:

            # calculate the synaptic block size in words
            synaptic_block_size = (
                pre_n_atoms * 4 *
                (constants.SYNAPTIC_ROW_HEADER_WORDS + maxed_row_length))

            # read in the base address of the synaptic matrix in the app region
            # table
            synapse_region_base_address_location = \
                dsg_utilities.get_region_base_address_offset(
                    app_data_base_address,
                    constants.POPULATION_BASED_REGIONS.SYNAPTIC_MATRIX.value)

            # read in the memory address of the synaptic_region base address
            synapse_region_base_address = helpful_functions.read_data(
                post_x, post_y, synapse_region_base_address_location, 4, "<I",
                transceiver)

            # the base address of the synaptic block in absolute terms is the app
            # base, plus the synaptic matrix base plus the offset
            synaptic_block_base_address = (app_data_base_address +
                                           synapse_region_base_address +
                                           synaptic_block_base_address_offset)

            # read in and return the synaptic block
            block = transceiver.read_memory(post_x, post_y,
                                            synaptic_block_base_address,
                                            synaptic_block_size)

            if len(block) != synaptic_block_size:
                raise exceptions.SynapticBlockReadException(
                    "Not enough data has been read"
                    " (aka, something funkky happened)")
        return block, maxed_row_length
コード例 #9
0
    def _retrieve_synaptic_block(
            self, placements, transceiver, pre_subvertex, pre_n_atoms,
            post_subvertex, routing_infos, subgraph):
        """
        reads in a synaptic block from a given processor and subvertex on the
        machine.
        """
        post_placement = placements.get_placement_of_subvertex(post_subvertex)
        post_x, post_y, post_p = \
            post_placement.x, post_placement.y, post_placement.p

        # either read in the master pop table or retrieve it from storage
        master_pop_base_mem_address, app_data_base_address = \
            self._population_table_type.locate_master_pop_table_base_address(
                post_x, post_y, post_p, transceiver,
                constants.POPULATION_BASED_REGIONS.POPULATION_TABLE.value)

        incoming_edges = subgraph.incoming_subedges_from_subvertex(
            post_subvertex)
        incoming_key_combo = None
        for subedge in incoming_edges:
            if subedge.pre_subvertex == pre_subvertex:
                routing_info = \
                    routing_infos.get_subedge_information_from_subedge(subedge)
                keys_and_masks = routing_info.keys_and_masks
                incoming_key_combo = keys_and_masks[0].key
                break

        maxed_row_length, synaptic_block_base_address_offset = \
            self._population_table_type.extract_synaptic_matrix_data_location(
                incoming_key_combo, master_pop_base_mem_address,
                transceiver, post_x, post_y)

        block = None
        if maxed_row_length > 0:

            # calculate the synaptic block size in words
            synaptic_block_size = (pre_n_atoms * 4 *
                                   (constants.SYNAPTIC_ROW_HEADER_WORDS +
                                    maxed_row_length))

            # read in the base address of the synaptic matrix in the app region
            # table
            synapse_region_base_address_location = \
                dsg_utilities.get_region_base_address_offset(
                    app_data_base_address,
                    constants.POPULATION_BASED_REGIONS.SYNAPTIC_MATRIX.value)

            # read in the memory address of the synaptic_region base address
            synapse_region_base_address = helpful_functions.read_data(
                post_x, post_y, synapse_region_base_address_location, 4,
                "<I", transceiver)

            # the base address of the synaptic block in absolute terms is the
            # app base, plus the synaptic matrix base plus the offset
            synaptic_block_base_address = (app_data_base_address +
                                           synapse_region_base_address +
                                           synaptic_block_base_address_offset)

            # read in and return the synaptic block
            block = transceiver.read_memory(
                post_x, post_y, synaptic_block_base_address,
                synaptic_block_size)

            if len(block) != synaptic_block_size:
                raise exceptions.SynapticBlockReadException(
                    "Not enough data has been read"
                    " (aka, something funkky happened)")
        return block, maxed_row_length