def get_data(self): txrx = self.front_end.transceiver() placement = self.placement n_steps = self.front_end.no_machine_time_steps() # Get the data region base address where results are stored for the # core record_region_base_address = locate_memory_region_for_placement( placement, DataRegions.RESULTS, txrx) # find how many bytes are needed to be read number_of_bytes_to_read = txrx.read_word(placement.x, placement.y, record_region_base_address) expected_bytes = n_steps * self.RECORDING_ELEMENT_SIZE if number_of_bytes_to_read != expected_bytes: raise ConfigurationException( "number of bytes seems wrong; have {} but expected {}".format( number_of_bytes_to_read, expected_bytes)) # read the bytes raw_data = txrx.read_memory( placement.x, placement.y, record_region_base_address + self.RECORDING_HEADER_SIZE, number_of_bytes_to_read) # convert to booleans return [ bool(element) for element in n_word_struct(n_steps).unpack(raw_data) ]
def check_data(data): # check data is correct here ints = n_word_struct(len(data) // 4).unpack(data) start_value = 0 for value in ints: if value != start_value: print("should be getting {}, but got {}".format( start_value, value)) start_value = value + 1 else: start_value += 1
def get_data(self): # for buffering output info is taken form the buffer manager # get raw data, convert to list of booleans raw_data, data_missing = self.get_recording_channel_data( Channels.STATE_LOG) # do check for missing data if data_missing: placement = self.placement print("missing_data from ({}, {}, {}); ".format( placement.x, placement.y, placement.p)) # return the data, converted to list of booleans return [ bool(element) for element in n_word_struct(len(raw_data) // BYTES_PER_WORD).unpack(raw_data)]
def __bitfields(self, placement): """ Reads back the bitfields that have been placed on a vertex. :param ~.Placement placement: The vertex must support AbstractSupportsBitFieldGeneration :returns: sequence of (master population key, num bits, bitfield data) :rtype: iterable(tuple(int,int,list(int))) """ # get bitfield address address = placement.vertex.bit_field_base_address( self.__txrx, placement) # read how many bitfields there are; header of filter_region_t _merged, _redundant, total = _THREE_WORDS.unpack( self.__txrx.read_memory(placement.x, placement.y, address, _THREE_WORDS.size)) address += _THREE_WORDS.size # read in each bitfield for _bit_field_index in range(total): # master pop key, n words and read pointer; filter_info_t master_pop_key, n_words, read_pointer = _THREE_WORDS.unpack( self.__txrx.read_memory(placement.x, placement.y, address, _THREE_WORDS.size)) address += _THREE_WORDS.size # Mask off merged and all_ones flag bits n_words &= self._N_WORDS_MASK # get bitfield words if n_words: bitfield = n_word_struct(n_words).unpack( self.__txrx.read_memory(placement.x, placement.y, read_pointer, n_words * BYTES_PER_WORD)) else: bitfield = [] yield master_pop_key, n_words * _BITS_IN_A_WORD, bitfield