def get_static_resources(input_filters, n_routing_keys, hostname, n_provenance_items): """ generates resource calculation so that it can eb called from outside and not instantiated :param input_filters: the input filters going into this vertex :param n_routing_keys: the n keys from the input filters :param hostname: The hostname of the host machine we're running on :param n_provenance_items: n provenance data items :return: A resource container containing the resources used by this vertex for those inputs. """ iptags = list() iptags.append( IPtagResource( ip_address=hostname, port=None, strip_sdp=False, tag=None, traffic_identifier=( SDPTransmitterMachineVertex.IPTAG_TRAFFIC_IDENTIFIER))) return ResourceContainer(sdram=SDRAMResource( fec_constants.SYSTEM_BYTES_REQUIREMENT + helpful_functions.sdram_size_in_bytes_for_filter_region( input_filters) + helpful_functions.sdram_size_in_bytes_for_routing_region( n_routing_keys) + ProvidesProvenanceDataFromMachineImpl.get_provenance_data_size( n_provenance_items) + SDPTransmitterMachineVertex._transmitter_region()), iptags=iptags)
def _allocate_memory_regions(self, spec): spec.reserve_memory_region(self.DATA_REGIONS.SYSTEM.value, fec_constants.SYSTEM_BYTES_REQUIREMENT, label="system region") self.reserve_memory_region(self.DATA_REGIONS.SLICE_DATA.value, self.SLICE_DATA_ITEMS * constants.BYTE_TO_WORD_MULTIPLIER, label="slice data") self.reserve_memory_region(self.DATA_REGIONS.KEYS.value, constants.BYTES_PER_KEY * self._n_keys, label="keys data") self.reserve_memory_region(self.DATA_REGIONS.TRANSFORM.value, self._transform_data.nbytes, label="transform data") self.reserve_memory_region( self.DATA_REGIONS.INPUT_FILTERS.value, helpful_functions.sdram_size_in_bytes_for_filter_region( self._filters), label="input filter data") self.reserve_memory_region( self.DATA_REGIONS.INPUT_ROUTING.value, helpful_functions.sdram_size_in_bytes_for_routing_region( self._n_keys), label="routing data") self.reserve_memory_region(self.DATA_REGIONS.MC_TRANSMISSION.value, (self.MC_TRANSMISSION_REGION_ITEMS * constants.BYTE_TO_WORD_MULTIPLIER), label="mc_transmission data") self.reserve_provenance_data_region(spec)
def _reverse_memory_regions(self, spec, output_data, machine_graph): input_n_keys = len( machine_graph.get_outgoing_edge_partitions_starting_at_vertex( self)) spec.reserve_memory_region(self.DATA_REGIONS.SYSTEM.value, fec_constants.SYSTEM_BYTES_REQUIREMENT, label="system region") spec.reserve_memory_region( self.DATA_REGIONS.KEY_REGION.value, helpful_functions.sdram_size_in_bytes_for_routing_region( input_n_keys), label="routing region") spec.reserve_memory_region(self.DATA_REGIONS.OUTPUT_REGION.value, output_data.nbytes, label="output region") if self._is_recording_output: spec.reserve_memory_region( region=self.DATA_REGIONS.RECORDING.value, size=recording_utilities.get_recording_header_size( self.N_RECORDING_REGIONS), label="recording") spec.reserve_memory_region( region=self.DATA_REGIONS.NEURON_REGION.value, size=self.NEURON_REGION_ITEMS * constants.BYTE_TO_WORD_MULTIPLIER, label="n neurons")
def generate_static_resources(transform_data, n_keys, filters, local_provenance_items): sdram = ( ProvidesProvenanceDataFromMachineImpl.get_provenance_data_size( local_provenance_items) + fec_constants.SYSTEM_BYTES_REQUIREMENT + (InterposerMachineVertex.SLICE_DATA_ITEMS * constants.BYTE_TO_WORD_MULTIPLIER) + (InterposerMachineVertex.MC_TRANSMISSION_REGION_ITEMS * constants.BYTE_TO_WORD_MULTIPLIER) + transform_data.nbytes + (constants.BYTES_PER_KEY * n_keys) + helpful_functions.sdram_size_in_bytes_for_filter_region(filters) + helpful_functions.sdram_size_in_bytes_for_routing_region(n_keys)) return ResourceContainer(sdram=SDRAMResource(sdram))
def _reserve_memory_regions(self, spec): spec.reserve_memory_region( self.DATA_REGIONS.SYSTEM.value, constants.SYSTEM_BYTES_REQUIREMENT, label="system region") spec.reserve_memory_region( self.DATA_REGIONS.SLICE_DATA.value, self.SLICE_DATA_SDRAM_REQUIREMENT, label="slice region") spec.reserve_memory_region( self.DATA_REGIONS.FILTER_ROUTING.value, helpful_functions.sdram_size_in_bytes_for_routing_region( self._input_n_keys), label="routing region") spec.reserve_memory_region( self.DATA_REGIONS.FILTERS.value, helpful_functions.sdram_size_in_bytes_for_filter_region( self._input_filters), label="filter region") spec.reserve_memory_region( region=self.DATA_REGIONS.RECORDING.value, size=recording_utilities.get_recording_header_size( self.N_RECORDING_REGIONS)) self.reserve_provenance_data_region(spec)
def _reserve_memory_regions(self, spec): """ reserve the memory region sizes :param spec: the dsg spec :rtype: None """ spec.reserve_memory_region(self.DATA_REGIONS.SYSTEM.value, fec_constants.SYSTEM_BYTES_REQUIREMENT, label="system region") spec.reserve_memory_region( self.DATA_REGIONS.FILTER.value, helpful_functions.sdram_size_in_bytes_for_filter_region( self._input_n_keys), label="filter region") spec.reserve_memory_region( self.DATA_REGIONS.ROUTING.value, helpful_functions.sdram_size_in_bytes_for_routing_region( self._input_n_keys), label="routing region") spec.reserve_memory_region(self.DATA_REGIONS.TRANSMITTER.value, self._transmitter_region(), label="transmitter region") self.reserve_provenance_data_region(spec)
def resources_required(self, n_machine_time_steps): container = ResourceContainer( sdram=SDRAMResource( constants.SYSTEM_BYTES_REQUIREMENT + ProvidesProvenanceDataFromMachineImpl.get_provenance_data_size( self.N_LOCAL_PROVENANCE_ITEMS) + ValueSinkMachineVertex.SLICE_DATA_SDRAM_REQUIREMENT + helpful_functions.sdram_size_in_bytes_for_filter_region( self._input_filters) + helpful_functions.sdram_size_in_bytes_for_routing_region( self._input_n_keys) + recording_utilities.get_recording_header_size( self.N_RECORDING_REGIONS)), dtcm=DTCMResource(0), cpu_cycles=CPUCyclesPerTickResource(0)) recording_sizes = recording_utilities.get_recording_region_sizes( [self._get_buffered_sdram(self._input_slice, n_machine_time_steps)], self._minimum_buffer_sdram, self._maximum_sdram_for_buffering, self._using_auto_pause_and_resume) container.extend(recording_utilities.get_recording_resources( recording_sizes, self._receive_buffer_host, self._receive_buffer_port)) return container
def _allocate_memory_regions(self, spec, app_vertex): """ :param spec: :param app_vertex: :return: """ # standard system region spec.reserve_memory_region( self.DATA_REGIONS.SYSTEM.value, fec_constants.SYSTEM_BYTES_REQUIREMENT, label="system region") # ensemble / neuron / pop length region n_pop_length_sizes = len(app_vertex.machine_vertex_slices[ app_vertex.core_slice_to_chip_slice[self.neuron_slice]]) spec.reserve_memory_region( self.DATA_REGIONS.ENSEMBLE_PARAMS.value, (self.ENSEMBLE_PARAMS_ITEMS + self.NEURON_PARAMS_ITEMS + (len(self._learnt_encoder_filters) * self.SDRAM_ITEMS_PER_LEARNT_INPUT_VECTOR) + + n_pop_length_sizes) * constants.BYTE_TO_WORD_MULTIPLIER, label="ensemble params") # encoder region spec.reserve_memory_region( region=self.DATA_REGIONS.ENCODER.value, size=self._encoders_with_gain.nbytes, label="encoder region") # reserve bias region spec.reserve_memory_region( region=self.DATA_REGIONS.BIAS.value, size=self._bias_with_di.nbytes, label="encoder region") # reserve gain region spec.reserve_memory_region( region=self.DATA_REGIONS.GAIN.value, size=self._gain.nbytes, label="gain region") # reserve decoders region if self._decoders.nbytes != 0: spec.reserve_memory_region( region=self.DATA_REGIONS.DECODER.value, size=self._decoders.nbytes, label="decoder region") # reserve learnt decoder region if self._learnt_decoders.nbytes != 0: spec.reserve_memory_region( region=self.DATA_REGIONS.LEARNT_DECODER.value, size=self._learnt_decoders.nbytes, label="learnt decoder region") # reserve filter region spec.reserve_memory_region( self.DATA_REGIONS.FILTERS.value, (helpful_functions.sdram_size_in_bytes_for_filter_region( self._input_filters) + helpful_functions.sdram_size_in_bytes_for_filter_region( self._inhibitory_filters) + helpful_functions.sdram_size_in_bytes_for_filter_region( self._modulatory_filters) + helpful_functions.sdram_size_in_bytes_for_filter_region( self._learnt_encoder_filters)), label="filters") # reserve routing region spec.reserve_memory_region( self.DATA_REGIONS.ROUTING.value, (helpful_functions.sdram_size_in_bytes_for_routing_region( app_vertex.input_n_keys) + helpful_functions.sdram_size_in_bytes_for_routing_region( app_vertex.inhibition_n_keys) + helpful_functions.sdram_size_in_bytes_for_routing_region( app_vertex.modulatory_n_keys) + helpful_functions.sdram_size_in_bytes_for_routing_region( app_vertex.learnt_encoders_n_keys)), label="routing") # reserve the key region spec.reserve_memory_region( self.DATA_REGIONS.KEYS.value, ((constants.BYTES_PER_KEY * app_vertex.output_n_keys) + (constants.BYTES_PER_KEY * app_vertex.learnt_output_n_keys)), label="keys region") # reserve the pes region spec.reserve_memory_region( region=self.DATA_REGIONS.PES.value, # pes learning rule region size=((self.PES_REGION_N_ELEMENTS + len( self._local_pes_learning_rules) + self.PES_REGION_SLICED_RULE_N_ELEMENTS) * constants.BYTE_TO_WORD_MULTIPLIER), label="pes region") # reserve the voja region spec.reserve_memory_region( region=self.DATA_REGIONS.VOJA.value, size=((self.VOJA_REGION_N_ELEMENTS + (len(app_vertex.voja_learning_rules) * self.VOJA_REGION_RULE_N_ELEMENT)) * constants.BYTE_TO_WORD_MULTIPLIER), label="voja region") # reserve recording region spec.reserve_memory_region( region=self.DATA_REGIONS.RECORDING.value, size=recording_utilities.get_recording_header_size( len(app_vertex.get_possible_probeable_variables())), label="recording region") # reserve recording_index region possible_recordable = app_vertex.get_possible_probeable_variables() n_elements = self.N_RECORDING_VARIABLE_SIZE + len(possible_recordable) if constants.DECODER_OUTPUT_FLAG not in possible_recordable: n_elements += 1 spec.reserve_memory_region( region=self.DATA_REGIONS.RECORDING_INDEXES.value, size=n_elements * constants.BYTE_TO_WORD_MULTIPLIER, label="recording index region")