def _write_setup_info(self, spec, machine_time_step, time_scale_factor, n_machine_time_steps, vertex_slice, ip_tags): """ writes the system data as required :param spec: the dsg spec writer :param machine_time_step: the machine time step :param time_scale_factor: the time scale factor :rtype: None """ spec.switch_write_focus( region=(ChipPowerMonitorMachineVertex.CHIP_POWER_MONITOR_REGIONS. SYSTEM.value)) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus(ChipPowerMonitorMachineVertex. CHIP_POWER_MONITOR_REGIONS.RECORDING.value) recorded_region_sizes = recording_utilities.get_recorded_region_sizes( n_machine_time_steps, [ self._deduce_sdram_requirements_per_timer_tick( machine_time_step, time_scale_factor) ], [self.MAX_BUFFER_SIZE]) spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes, globals_variables.get_simulator().config.getint( "Buffers", "time_between_requests"), None, ip_tags))
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): # Create the data regions for hello world self._reserve_memory_regions(spec, constants.SYSTEM_BYTES_REQUIREMENT) # write data for the simulation data item spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write transmission key spec.switch_write_focus(self.DATA_REGIONS.TRANSMISSION_DATA.value) out_going_routing_key = routing_info.get_first_key_from_pre_vertex( self, app_constants.EDGE_PARTITION_FILTER_TO_PARTICLES) if out_going_routing_key is None: spec.write_value(0) spec.write_value(0) else: spec.write_value(1) spec.write_value(out_going_routing_key) spec.switch_write_focus(self.DATA_REGIONS.CONFIG.value) spec.write_value(self._row_id) spec.write_value(app_constants.RETINA_X_SIZE)
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): self.placement = placement # Setup words + 1 for flags + 1 for recording size setup_size = constants.SYSTEM_BYTES_REQUIREMENT # Reserve SDRAM space for memory areas: self._reserve_memory_regions(spec, setup_size) # set up the SYSTEM partition spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) #load all required data onto the vertex Vertex.load_data_on_vertices(self, spec, iptags) #build all required edges between the vertices Vertex.configure_ring_edges(self, spec, routing_info, machine_graph) # End-of-Spec: spec.end_specification()
def generate_data_specification( self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, routing_info, data_n_time_steps, graph): # pylint: disable=too-many-arguments, arguments-differ self._machine_time_step = machine_time_step vertex = placement.vertex vertex_slice = graph_mapper.get_slice(vertex) spec.comment("\n*** Spec for SpikeSourcePoisson Instance ***\n\n") # Reserve SDRAM space for memory areas: self.reserve_memory_regions(spec, placement, graph_mapper) # write setup data spec.switch_write_focus(_REGIONS.SYSTEM_REGION.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write recording data spec.switch_write_focus(_REGIONS.SPIKE_HISTORY_REGION.value) sdram = self.get_recording_sdram_usage( vertex_slice, machine_time_step) recorded_region_sizes = [sdram.get_total_sdram(data_n_time_steps)] spec.write_array(recording_utilities.get_recording_header_array( recorded_region_sizes)) # write parameters self._write_poisson_parameters( spec, graph, placement, routing_info, vertex_slice, machine_time_step, time_scale_factor) # End-of-Spec: spec.end_specification()
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): self.placement = placement # Setup words + 1 for flags + 1 for recording size setup_size = constants.SYSTEM_BYTES_REQUIREMENT # Reserve SDRAM space for memory areas: # Create the data regions for hello world self._reserve_memory_regions(spec, setup_size) # write data for the simulation data item spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # recording data region spec.switch_write_focus(self.DATA_REGIONS.STRING_DATA.value) spec.write_array( recording_utilities.get_recording_header_array( [self._string_data_size], self._time_between_requests, self._string_data_size + 256, iptags)) # End-of-Spec: spec.end_specification()
def generate_system_data_region( spec, region_id, machine_vertex, machine_time_step, time_scale_factor): """ Generate a system data region for time-based simulations. :param ~data_specification.DataSpecificationGenerator spec: The data specification to write to :param int region_id: The region to write to :param ~pacman.model.graphs.machine.MachineVertex machine_vertex: The machine vertex to write for :param int machine_time_step: The time step of the simulation :param int time_scale_factor: The time scale of the simulation """ # reserve memory regions spec.reserve_memory_region( region=region_id, size=SIMULATION_N_BYTES, label='systemInfo') # simulation .c requirements spec.switch_write_focus(region_id) spec.write_array(get_simulation_header_array( machine_vertex.get_binary_file_name(), machine_time_step, time_scale_factor))
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, application_graph, machine_graph, routing_info, tags, n_machine_time_steps): # pylint: disable=too-many-arguments, arguments-differ vertex = placement.vertex spec.comment("\n*** Spec for block of {} neurons ***\n".format( self._model_name)) vertex_slice = graph_mapper.get_slice(vertex) # Reserve memory regions self._reserve_memory_regions(spec, vertex_slice, vertex) # Declare random number generators and distributions: # TODO add random distribution stuff # self.write_random_distribution_declarations(spec) # Get the key key = routing_info.get_first_key_from_pre_vertex( vertex, constants.SPIKE_PARTITION_ID) # Write the setup region spec.switch_write_focus( constants.POPULATION_BASED_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the recording region spec.switch_write_focus( constants.POPULATION_BASED_REGIONS.RECORDING.value) ip_tags = tags.get_ip_tags_for_vertex(vertex) recorded_region_sizes = recording_utilities.get_recorded_region_sizes( self._get_buffered_sdram(vertex_slice, n_machine_time_steps), self._maximum_sdram_for_buffering) spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes, self._time_between_requests, self._buffer_size_before_receive, ip_tags)) # Write the neuron parameters self._write_neuron_parameters(spec, key, vertex_slice, machine_time_step, time_scale_factor) # write profile data profile_utils.write_profile_region_data( spec, constants.POPULATION_BASED_REGIONS.PROFILING.value, self._n_profile_samples) # allow the synaptic matrix to write its data spec-able data self._synapse_manager.write_data_spec(spec, self, vertex_slice, vertex, placement, machine_graph, application_graph, routing_info, graph_mapper, self._input_type, machine_time_step) # End the writing of this specification: spec.end_specification()
def generate_machine_data_specification( self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): # Setup words + 1 for flags + 1 for recording size setup_size = constants.SYSTEM_BYTES_REQUIREMENT # Reserve SDRAM space for memory areas: # Create the data regions for hello world self._reserve_memory_regions(spec, setup_size) # write data for the simulation data item spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write key local_routing_info = \ routing_info.get_routing_info_from_pre_vertex(self, "TRANSMIT") spec.switch_write_focus(self.DATA_REGIONS.CONFIG.value) first_key = local_routing_info.first_key print("first key is {}".format(first_key)) spec.write_value(first_key) spec.write_value(self._mbs) # End-of-Spec: spec.end_specification()
def generate_machine_data_specification( self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor, machine_time_step_in_seconds, graph_mapper, nengo_graph): print "interposer at {}".format(placement) self._allocate_memory_regions(spec) spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus(self.DATA_REGIONS.SLICE_DATA.value) self._write_slice_data_to_region(spec) spec.switch_write_focus(self.DATA_REGIONS.KEYS.value) self._write_key_data(spec, routing_info) spec.switch_write_focus(self.DATA_REGIONS.INPUT_FILTERS.value) filter_to_index_map = filter_region_writer.write_filter_region( spec, machine_time_step_in_seconds, self._input_slice, self._input_filters) spec.switch_write_focus(self.DATA_REGIONS.INPUT_ROUTING.value) helpful_functions.write_routing_region( spec, routing_info, machine_graph.get_edges_ending_at_vertex(self), filter_to_index_map, self._input_filters, graph_mapper, nengo_graph) spec.switch_write_focus(self.DATA_REGIONS.TRANSFORM.value) spec.write_array( helpful_functions.convert_numpy_array_to_s16_15( self._transform_data)) spec.switch_write_focus(self.DATA_REGIONS.MC_TRANSMISSION.value) self._write_mc_transmission_params(spec, graph_mapper, machine_time_step, time_scale_factor) spec.end_specification()
def generate_data_specification( self, spec, placement, # @UnusedVariable machine_time_step, time_scale_factor, machine_graph, routing_info, tags, first_machine_time_step, n_machine_time_steps): # pylint: disable=too-many-arguments, arguments-differ self._update_virtual_key(routing_info, machine_graph) self._fill_send_buffer( machine_time_step, first_machine_time_step, n_machine_time_steps) # Reserve regions self._reserve_regions(spec) # Write the system region spec.switch_write_focus(self._REGIONS.SYSTEM.value) spec.write_array(get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the additional recording information iptags = tags.get_ip_tags_for_vertex(self) spec.switch_write_focus(self._REGIONS.RECORDING.value) spec.write_array(get_recording_header_array( [self._record_buffer_size], self._time_between_triggers, self._buffer_size_before_receive, iptags, self._buffer_notification_tag)) # Write the configuration information self._write_configuration(spec, iptags) # End spec spec.end_specification()
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, machine_graph, routing_info, tags, first_machine_time_step, n_machine_time_steps): self._update_virtual_key(routing_info, machine_graph) self._fill_send_buffer(machine_time_step, first_machine_time_step, n_machine_time_steps) # Reserve regions self._reserve_regions(spec) # Write the system region spec.switch_write_focus(self._REGIONS.SYSTEM.value) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the additional recording information iptags = tags.get_ip_tags_for_vertex(self) spec.switch_write_focus(self._REGIONS.RECORDING.value) spec.write_array( recording_utilities.get_recording_header_array( [self._record_buffer_size], self._time_between_triggers, self._buffer_size_before_receive, iptags, self._buffer_notification_tag)) # Write the configuration information self._write_configuration(spec, iptags) # End spec spec.end_specification()
def write_setup_info(self, spec, machine_time_step, time_scale_factor): # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus(_DELEXT_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor))
def _write_setup_info(self, spec, machine_time_step, time_scale_factor, n_machine_time_steps, ip_tags): """ Writes the system data as required. :param spec: the DSG spec writer :param machine_time_step: the machine time step :param time_scale_factor: the time scale factor :rtype: None """ # pylint: disable=too-many-arguments spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.SYSTEM.value) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.RECORDING.value) recorded_region_sizes = recording_utilities.get_recorded_region_sizes([ self._deduce_sdram_requirements_per_timer_tick( machine_time_step, time_scale_factor) * n_machine_time_steps ], [self.MAX_BUFFER_SIZE]) spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes, globals_variables.get_simulator().config.getint( "Buffers", "time_between_requests"), None, ip_tags))
def _write_setup_info( self, spec, machine_time_step, time_scale_factor, n_machine_time_steps, ip_tags): """ Writes the system data as required. :param spec: the DSG spec writer :param machine_time_step: the machine time step :param time_scale_factor: the time scale factor :rtype: None """ # pylint: disable=too-many-arguments spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.SYSTEM.value) spec.write_array(get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.RECORDING.value) recorded_region_sizes = recording_utilities.get_recorded_region_sizes( [self._deduce_sdram_requirements_per_timer_tick( machine_time_step, time_scale_factor) * n_machine_time_steps], [self.MAX_BUFFER_SIZE]) spec.write_array(recording_utilities.get_recording_header_array( recorded_region_sizes, globals_variables.get_simulator().config.getint( "Buffers", "time_between_requests"), None, ip_tags))
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): # Setup words + 1 for flags + 1 for recording size setup_size = constants.SYSTEM_BYTES_REQUIREMENT # Create the data regions for hello world self._reserve_memory_regions(spec, setup_size) # write data for the simulation data item spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus(self.DATA_REGIONS.CONFIG.value) base_key = routing_info.get_first_key_for_edge( list(machine_graph.get_edges_ending_at_vertex(self))[0]) spec.write_value(base_key + 1) spec.write_value(base_key + 2) # End-of-Spec: spec.end_specification()
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, routing_info, data_n_time_steps, graph): # pylint: disable=too-many-arguments, arguments-differ self._machine_time_step = machine_time_step vertex = placement.vertex vertex_slice = graph_mapper.get_slice(vertex) spec.comment("\n*** Spec for SpikeSourcePoisson Instance ***\n\n") # Reserve SDRAM space for memory areas: self.reserve_memory_regions(spec, placement, graph_mapper) # write setup data spec.switch_write_focus(_REGIONS.SYSTEM_REGION.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write recording data spec.switch_write_focus(_REGIONS.SPIKE_HISTORY_REGION.value) sdram = self.get_recording_sdram_usage(vertex_slice, machine_time_step) recorded_region_sizes = [sdram.get_total_sdram(data_n_time_steps)] spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes)) # write parameters self._write_poisson_parameters(spec, graph, placement, routing_info, vertex_slice, machine_time_step, time_scale_factor) # End-of-Spec: spec.end_specification()
def _write_common_data_spec(self, spec, rec_regions): """ Write the data specification for the common regions :param ~data_specification.DataSpecificationGenerator spec: The data specification to write to :param list(int) rec_regions: A list of sizes of each recording region (including empty ones) """ # Write the setup region spec.reserve_memory_region(region=self.__regions.system, size=SIMULATION_N_BYTES, label='System') spec.switch_write_focus(self.__regions.system) spec.write_array(get_simulation_header_array(self.__binary_file_name)) # Reserve memory for provenance self.reserve_provenance_data_region(spec) # Write profile data reserve_profile_region(spec, self.__regions.profile, self._app_vertex.n_profile_samples) write_profile_region_data(spec, self.__regions.profile, self._app_vertex.n_profile_samples) # Set up for recording spec.reserve_memory_region(region=self.__regions.recording, size=get_recording_header_size( len(rec_regions)), label="Recording") spec.switch_write_focus(self.__regions.recording) spec.write_array(get_recording_header_array(rec_regions))
def generate_data_specification(self, spec, placement, routing_info): # pylint: disable=too-many-arguments, arguments-differ # reserve regions self.reserve_memory_regions(spec) # Write the setup region spec.comment("\n*** Spec for robot motor control ***\n\n") # handle simulation data spec.switch_write_focus(self._SYSTEM_REGION) spec.write_array( simulation_utilities.get_simulation_header_array( placement.vertex.get_binary_file_name())) # Get the key edge_key = routing_info.get_first_key_from_pre_vertex( placement.vertex, self.MOTOR_PARTITION_ID) if edge_key is None: raise SpynnakerException( "This motor should have one outgoing edge to the robot") # write params to memory spec.switch_write_focus(region=self._PARAMS_REGION) spec.write_value(data=edge_key) spec.write_value(data=self.__speed) spec.write_value(data=self.__sample_time) spec.write_value(data=self.__update_time) spec.write_value(data=self.__delay_time) spec.write_value(data=self.__delta_threshold) spec.write_value(data=int(self.__continue_if_not_different)) # End-of-Spec: spec.end_specification()
def write_setup_info(self, spec, machine_time_step, time_scale_factor): # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus(_DELEXT_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor))
def _write_setup_info(self, spec, machine_time_step, time_scale_factor, n_machine_time_steps): """ Writes the system data as required. :param spec: the DSG spec writer :param machine_time_step: the machine time step :param time_scale_factor: the time scale factor :rtype: None """ # pylint: disable=too-many-arguments spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.SYSTEM.value) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor)) spec.switch_write_focus( region=self.CHIP_POWER_MONITOR_REGIONS.RECORDING.value) recorded_region_sizes = [ self._deduce_sdram_requirements_per_timer_tick( machine_time_step, time_scale_factor) * n_machine_time_steps ] spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes))
def generate_data_specification(self, spec, placement): spec.reserve_memory_region(0, SIMULATION_N_BYTES) spec.switch_write_focus(0) spec.write_array( utils.get_simulation_header_array(self._aplx_file, 1000, time_scale_factor=1)) spec.end_specification()
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, routing_info, data_n_time_steps, graph, first_machine_time_step): """ :param int machine_time_step: :param int time_scale_factor: :param ~pacman.model.routing_info.RoutingInfo routing_info: :param int data_n_time_steps: :param ~pacman.model.graphs.machine.MachineGraph graph: :param int first_machine_time_step: """ # pylint: disable=too-many-arguments, arguments-differ self.__machine_time_step = machine_time_step vertex_slice = placement.vertex.vertex_slice spec.comment("\n*** Spec for SpikeSourcePoisson Instance ***\n\n") # Reserve SDRAM space for memory areas: self.reserve_memory_regions(spec, placement) # write setup data spec.switch_write_focus(_REGIONS.SYSTEM_REGION.value) spec.write_array( simulation_utilities.get_simulation_header_array( placement.vertex.get_binary_file_name(), machine_time_step, time_scale_factor)) # write recording data spec.switch_write_focus(_REGIONS.SPIKE_HISTORY_REGION.value) sdram = self.get_recording_sdram_usage(vertex_slice, machine_time_step) recorded_region_sizes = [sdram.get_total_sdram(data_n_time_steps)] spec.write_array( recording_utilities.get_recording_header_array( recorded_region_sizes)) # write parameters self._write_poisson_parameters(spec, graph, placement, routing_info, vertex_slice, machine_time_step) # write rates self._write_poisson_rates(spec, vertex_slice, machine_time_step, first_machine_time_step) # write profile data profile_utils.write_profile_region_data(spec, _REGIONS.PROFILER_REGION.value, self.__n_profile_samples) # write tdma params spec.switch_write_focus(_REGIONS.TDMA_REGION.value) spec.write_array( self.generate_tdma_data_specification_data( self.vertex_slices.index(vertex_slice))) # End-of-Spec: spec.end_specification()
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, application_graph, machine_graph, routing_info, data_n_time_steps): # pylint: disable=too-many-arguments, arguments-differ vertex = placement.vertex spec.comment("\n*** Spec for block of {} neurons ***\n".format( self.__neuron_impl.model_name)) vertex_slice = graph_mapper.get_slice(vertex) # Reserve memory regions self._reserve_memory_regions(spec, vertex_slice, vertex) # Declare random number generators and distributions: # TODO add random distribution stuff # self.write_random_distribution_declarations(spec) # Get the key key = routing_info.get_first_key_from_pre_vertex( vertex, constants.SPIKE_PARTITION_ID) # Write the setup region spec.switch_write_focus( constants.POPULATION_BASED_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the neuron recording region self._neuron_recorder.write_neuron_recording_region( spec, POPULATION_BASED_REGIONS.NEURON_RECORDING.value, vertex_slice, data_n_time_steps) # Write the neuron parameters self._write_neuron_parameters(spec, key, vertex_slice, machine_time_step, time_scale_factor) # write profile data profile_utils.write_profile_region_data( spec, constants.POPULATION_BASED_REGIONS.PROFILING.value, self.__n_profile_samples) # Get the weight_scale value from the appropriate location weight_scale = self.__neuron_impl.get_global_weight_scale() # allow the synaptic matrix to write its data spec-able data self.__synapse_manager.write_data_spec(spec, self, vertex_slice, vertex, placement, machine_graph, application_graph, routing_info, graph_mapper, weight_scale, machine_time_step) # End the writing of this specification: spec.end_specification()
def _write_setup_info(self, spec, binary_name): """ :param ~data_specification.DataSpecificationGenerator spec: :param str binary_name: the binary name """ # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus(self._DELAY_EXTENSION_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( binary_name))
def _write_setup_info(self, spec, machine_time_step, time_scale_factor): """ Write basic info to the system region """ # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus( region=(LivePacketGatherMachineVertex._LIVE_DATA_GATHER_REGIONS. SYSTEM.value)) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor))
def generate_data_specification( self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, application_graph, machine_graph, routing_info, data_n_time_steps, placements): # pylint: disable=too-many-arguments, arguments-differ vertex = placement.vertex spec.comment("\n*** Spec for block of {} neurons ***\n".format( self._neuron_impl.model_name)) vertex_slice = graph_mapper.get_slice(vertex) # Reserve memory regions self._reserve_memory_regions(spec, vertex_slice, vertex) # Declare random number generators and distributions: # TODO add random distribution stuff # self.write_random_distribution_declarations(spec) # Get the key key = routing_info.get_first_key_from_pre_vertex( vertex, constants.SPIKE_PARTITION_ID) # Write the setup region spec.switch_write_focus( constants.POPULATION_BASED_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the recording region spec.switch_write_focus( constants.POPULATION_BASED_REGIONS.RECORDING.value) spec.write_array(recording_utilities.get_recording_header_array( self._get_buffered_sdram(vertex_slice, data_n_time_steps))) # Write the neuron parameters self._write_neuron_parameters( spec, key, vertex_slice, machine_time_step, time_scale_factor) # write profile data profile_utils.write_profile_region_data( spec, constants.POPULATION_BASED_REGIONS.PROFILING.value, self._n_profile_samples) # Get the weight_scale value from the appropriate location weight_scale = self._neuron_impl.get_global_weight_scale() # allow the synaptic matrix to write its data spec-able data self._synapse_manager.write_data_spec( spec, self, vertex_slice, vertex, placement, machine_graph, application_graph, routing_info, graph_mapper, weight_scale, machine_time_step, placements) # End the writing of this specification: spec.end_specification()
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags): # reserve memory regions spec.reserve_memory_region(region=DataRegions.SYSTEM, size=SIMULATION_N_BYTES, label='systemInfo') # simulation .c requirements spec.switch_write_focus(DataRegions.SYSTEM) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name())) # get counters outgoing_partitions = list( machine_graph.get_sdram_edge_partitions_starting_at_vertex(self)) n_out_sdrams = len(outgoing_partitions) incoming_partitions = list( machine_graph.get_sdram_edge_partitions_ending_at_vertex(self)) n_in_sdrams = len(incoming_partitions) # reserve memory regions spec.reserve_memory_region( region=DataRegions.SDRAM_OUT, size=((n_out_sdrams * self.SDRAM_PARTITION_BASE_DSG_SIZE) + self.SDRAM_PARTITION_COUNTERS), label="sdrams_out") spec.reserve_memory_region( region=DataRegions.SDRAM_IN, size=((n_in_sdrams * self.SDRAM_PARTITION_BASE_DSG_SIZE) + self.SDRAM_PARTITION_COUNTERS), label="sdrams_in") # add outs spec.switch_write_focus(DataRegions.SDRAM_OUT) spec.write_value(n_out_sdrams) for outgoing_partition in outgoing_partitions: spec.write_value( outgoing_partition.get_sdram_base_address_for(self)) spec.write_value( outgoing_partition.get_sdram_size_of_region_for(self)) # add ins spec.switch_write_focus(DataRegions.SDRAM_IN) spec.write_value(n_in_sdrams) for incoming_partition in incoming_partitions: if isinstance(incoming_partition, AbstractSDRAMPartition): spec.write_value( incoming_partition.get_sdram_base_address_for(self)) spec.write_value( incoming_partition.get_sdram_size_of_region_for(self)) spec.end_specification()
def generate_system_data_region( spec, region_id, machine_vertex, machine_time_step, time_scale_factor): # reserve memory regions spec.reserve_memory_region( region=region_id, size=SYSTEM_BYTES_REQUIREMENT, label='systemInfo') # simulation .c requirements spec.switch_write_focus(region_id) spec.write_array(simulation_utilities.get_simulation_header_array( machine_vertex.get_binary_file_name(), machine_time_step, time_scale_factor))
def _write_setup_info(self, spec, machine_time_step, time_scale_factor): """ Write basic info to the system region :param ~.DataSpecificationGenerator spec: :param int machine_time_step: :param int time_scale_factor: """ # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus(region=self._REGIONS.SYSTEM) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor))
def _write_setup_info(self, spec, machine_time_step, time_scale_factor): """ :param ~data_specification.DataSpecificationGenerator spec: :param int machine_time_step: :param int time_scale_factor: """ # Write this to the system region (to be picked up by the simulation): spec.switch_write_focus(_DELEXT_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor))
def generate_data_specification(self, spec, placement, machine_time_step, time_scale_factor, graph_mapper, routing_info, tags, n_machine_time_steps): vertex = placement.vertex vertex_slice = graph_mapper.get_slice(vertex) spec.comment("\n*** Spec for Bandit Instance ***\n\n") spec.comment("\nReserving memory space for data regions:\n\n") # Reserve memory: spec.reserve_memory_region( region=BanditMachineVertex._BANDIT_REGIONS.SYSTEM.value, size=front_end_common_constants.SYSTEM_BYTES_REQUIREMENT, label='setup') spec.reserve_memory_region( region=BanditMachineVertex._BANDIT_REGIONS.BANDIT.value, size=self.BANDIT_REGION_BYTES, label='BanditParams') # vertex.reserve_provenance_data_region(spec) # reserve recording region spec.reserve_memory_region( BanditMachineVertex._BANDIT_REGIONS.RECORDING.value, recording_utilities.get_recording_header_size(1)) # Write setup region spec.comment("\nWriting setup region:\n") spec.switch_write_focus( BanditMachineVertex._BANDIT_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write bandit region containing routing key to transmit with spec.comment("\nWriting bandit region:\n") spec.switch_write_focus( BanditMachineVertex._BANDIT_REGIONS.BANDIT.value) spec.write_value( routing_info.get_first_key_from_pre_vertex( vertex, constants.SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting bandit recording region:\n") spec.switch_write_focus( BanditMachineVertex._BANDIT_REGIONS.RECORDING.value) ip_tags = tags.get_ip_tags_for_vertex(self) or [] spec.write_array( recording_utilities.get_recording_header_array( [self._recording_size], ip_tags=ip_tags)) # End-of-Spec: spec.end_specification()
def generate_data_specification( self, spec, placement, # @UnusedVariable machine_graph, routing_info, tags, machine_time_step, time_scale_factor): # pylint: disable=too-many-arguments, arguments-differ # Setup words + 1 for flags + 1 for recording size setup_size = SYSTEM_BYTES_REQUIREMENT # Create the data regions for hello world DataSpeedUpPacketGatherMachineVertex._reserve_memory_regions( spec, setup_size) # write data for the simulation data item spec.switch_write_focus(_DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # the keys for the special cases if self.TRAFFIC_TYPE == EdgeTrafficType.MULTICAST: base_key = routing_info.get_first_key_for_edge( list(machine_graph.get_edges_ending_at_vertex(self))[0]) new_seq_key = base_key + self.NEW_SEQ_KEY_OFFSET first_data_key = base_key + self.FIRST_DATA_KEY_OFFSET end_flag_key = base_key + self.END_FLAG_KEY_OFFSET else: new_seq_key = self.NEW_SEQ_KEY first_data_key = self.FIRST_DATA_KEY end_flag_key = self.END_FLAG_KEY spec.switch_write_focus(_DATA_REGIONS.CONFIG.value) spec.write_value(new_seq_key) spec.write_value(first_data_key) spec.write_value(end_flag_key) # locate the tag ID for our data and update with port iptags = tags.get_ip_tags_for_vertex(self) iptag = iptags[0] iptag.port = self._connection.local_port spec.write_value(iptag.tag) # End-of-Spec: spec.end_specification()
def generate_machine_data_specification(self, spec, placement, machine_graph, routing_info, iptags, reverse_iptags, machine_time_step, time_scale_factor): """ Generate data :param placement: the placement object for the dsg :param machine_graph: the graph object for this dsg :param routing_info: the routing info object for this dsg :param iptags: the collection of iptags generated by the tag allocator :param reverse_iptags: the collection of reverse iptags generated by\ the tag allocator """ self.placement = placement # Create the data regions self._reserve_memory_regions(spec) # write simulation interface data spec.switch_write_focus(self.DATA_REGIONS.SYSTEM.value) spec.write_array( simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write recording data interface spec.switch_write_focus(self.DATA_REGIONS.RECORDED_DATA.value) spec.write_array( recording_utilities.get_recording_header_array( [self._recording_size], self._time_between_requests, self._buffer_size_before_receive, iptags)) # Get the key, assuming all outgoing edges use the same key has_key = 0 key = routing_info.get_first_key_from_pre_vertex(self, PARTITION_ID) if key is None: key = 0 else: has_key = 1 # Write the transmission region spec.switch_write_focus(self.DATA_REGIONS.TRANSMISSION.value) spec.write_value(has_key) spec.write_value(key) # End-of-Spec: spec.end_specification()
def generate_data_specification( self, spec, placement, # @UnusedVariable machine_time_step, time_scale_factor, machine_graph, routing_info, first_machine_time_step, data_n_time_steps, run_until_timesteps): """ :param int machine_time_step: :param int time_scale_factor: :param ~pacman.model.graphs.machine.MachineGraph machine_graph: :param ~pacman.model.routing_info.RoutingInfo routing_info: :param int first_machine_time_step: :param int data_n_time_steps: :param int run_until_timesteps: """ # pylint: disable=too-many-arguments, arguments-differ self._update_virtual_key(routing_info, machine_graph) self._fill_send_buffer(first_machine_time_step, run_until_timesteps) # Reserve regions self._reserve_regions(spec, data_n_time_steps) # Write the system region spec.switch_write_focus(self._REGIONS.SYSTEM) spec.write_array( get_simulation_header_array(self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Write the additional recording information spec.switch_write_focus(self._REGIONS.RECORDING) recording_size = 0 if self._is_recording: per_timestep = self._recording_sdram_per_timestep( machine_time_step, self._is_recording, self._receive_rate, self._send_buffer_times, self._n_keys) recording_size = per_timestep * data_n_time_steps spec.write_array(get_recording_header_array([recording_size])) # Write the configuration information self._write_configuration(spec, machine_time_step, time_scale_factor) # End spec spec.end_specification()
def generate_data_specification( self, spec, placement, machine_time_step, time_scale_factor): """ :param int machine_time_step: :param int time_scale_factor: """ # pylint: disable=too-many-arguments, arguments-differ timed_commands_size = self.get_timed_commands_bytes() start_resume_commands_size = \ self.get_n_command_bytes(self._commands_at_start_resume) pause_stop_commands_size = \ self.get_n_command_bytes(self._commands_at_pause_stop) # reverse memory regions self._reserve_memory_regions( spec, timed_commands_size, start_resume_commands_size, pause_stop_commands_size, placement.vertex) # Write system region spec.comment("\n*** Spec for multicast source ***\n\n") spec.switch_write_focus( self.DATA_REGIONS.SYSTEM_REGION.value) spec.write_array(get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # write commands spec.switch_write_focus( region=self.DATA_REGIONS.COMMANDS_WITH_ARBITRARY_TIMES.value) # write commands to spec for timed commands self._write_timed_commands(self._timed_commands, spec) # write commands fired off during a start or resume spec.switch_write_focus( region=self.DATA_REGIONS.COMMANDS_AT_START_RESUME.value) self._write_basic_commands(self._commands_at_start_resume, spec) # write commands fired off during a pause or end spec.switch_write_focus( region=self.DATA_REGIONS.COMMANDS_AT_STOP_PAUSE.value) self._write_basic_commands(self._commands_at_pause_stop, spec) # End-of-Spec: spec.end_specification()
def generate_data_specification( self, spec, placement, # @UnusedVariable machine_graph, routing_info, tags, machine_time_step, time_scale_factor): # pylint: disable=too-many-arguments, arguments-differ # Setup words + 1 for flags + 1 for recording size setup_size = SYSTEM_BYTES_REQUIREMENT # Create the data regions for hello world DataSpeedUpPacketGatherMachineVertex._reserve_memory_regions( spec, setup_size) # write data for the simulation data item spec.switch_write_focus(_DATA_REGIONS.SYSTEM.value) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # the keys for the special cases if self.TRAFFIC_TYPE == EdgeTrafficType.MULTICAST: base_key = routing_info.get_first_key_for_edge( list(machine_graph.get_edges_ending_at_vertex(self))[0]) new_seq_key = base_key + self.NEW_SEQ_KEY_OFFSET first_data_key = base_key + self.FIRST_DATA_KEY_OFFSET end_flag_key = base_key + self.END_FLAG_KEY_OFFSET else: new_seq_key = self.NEW_SEQ_KEY first_data_key = self.FIRST_DATA_KEY end_flag_key = self.END_FLAG_KEY spec.switch_write_focus(_DATA_REGIONS.CONFIG.value) spec.write_value(new_seq_key) spec.write_value(first_data_key) spec.write_value(end_flag_key) # locate the tag ID for our data and update with a port # Note: The port doesn't matter as we are going to override this later iptags = tags.get_ip_tags_for_vertex(self) iptag = iptags[0] iptag.port = 10000 spec.write_value(iptag.tag) self._remote_tag = iptag.tag # End-of-Spec: spec.end_specification()
def generate_data_specification( self, spec, placement, routing_info, machine_time_step, time_scale_factor): # pylint: disable=too-many-arguments, arguments-differ # reserve regions self.reserve_memory_regions(spec) # Write the setup region spec.comment("\n*** Spec for robot motor control ***\n\n") # handle simulation data spec.switch_write_focus(self.SYSTEM_REGION) spec.write_array(simulation_utilities.get_simulation_header_array( self.get_binary_file_name(), machine_time_step, time_scale_factor)) # Get the key edge_key = routing_info.get_first_key_from_pre_vertex( placement.vertex, MOTOR_PARTITION_ID) if edge_key is None: raise SpynnakerException( "This motor should have one outgoing edge to the robot") # write params to memory spec.switch_write_focus(region=self.PARAMS_REGION) spec.write_value(data=edge_key) spec.write_value(data=self._speed) spec.write_value(data=self._sample_time) spec.write_value(data=self._update_time) spec.write_value(data=self._delay_time) spec.write_value(data=self._delta_threshold) spec.write_value(data=int(self._continue_if_not_different)) # End-of-Spec: spec.end_specification()