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))
Пример #2
0
    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()
Пример #3
0
    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 _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))
Пример #5
0
    def generate_data_specification(self, spec, placement, machine_time_step,
                                    time_scale_factor, graph_mapper,
                                    routing_info, tags, n_machine_time_steps):
        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(
            SpikeSourcePoissonMachineVertex.POISSON_SPIKE_SOURCE_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
        ip_tags = tags.get_ip_tags_for_vertex(vertex)
        spec.switch_write_focus(
            SpikeSourcePoissonMachineVertex.POISSON_SPIKE_SOURCE_REGIONS.
            SPIKE_HISTORY_REGION.value)
        recorded_region_sizes = recording_utilities.get_recorded_region_sizes(
            n_machine_time_steps, [
                self._spike_recorder.get_sdram_usage_in_bytes(
                    vertex_slice.n_atoms,
                    self._max_spikes_per_ts(vertex_slice, n_machine_time_steps,
                                            machine_time_step), 1)
            ], 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 parameters
        key = routing_info.get_first_key_from_pre_vertex(
            vertex, constants.SPIKE_PARTITION_ID)
        self._write_poisson_parameters(spec, key, 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,
            n_machine_time_steps, machine_time_step_in_seconds, graph_mapper,
            nengo_graph):

        print "sink at {}".format(placement)

        # reserve the memory region blocks
        self._reserve_memory_regions(spec)

        # fill in system region
        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))

        # fill in recording region
        spec.switch_write_focus(self.DATA_REGIONS.RECORDING.value)
        recorded_region_sizes = recording_utilities.get_recorded_region_sizes(
            self._get_buffered_sdram(self._input_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, iptags))

        # data on slice, aka, input slice size and start point
        spec.switch_write_focus(self.DATA_REGIONS.SLICE_DATA.value)
        spec.write_value(self._input_slice.n_atoms)
        spec.write_array(self._input_slice.lo_atom)

        # add filer region
        spec.switch_write_focus(self.DATA_REGIONS.FILTERS.value)
        filter_to_index_map = filter_region_writer.write_filter_region(
            spec, machine_time_step_in_seconds, self._input_slice,
            self._input_filters)

        # add routing region
        spec.switch_write_focus(self.DATA_REGIONS.FILTER_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.end_specification()
 def _write_recording_region(
         self, spec, ip_tags, n_machine_time_steps, app_vertex,
         time_between_requests, buffer_size_before_receive):
     """
     
     :param spec: 
     :param ip_tags: 
     :param n_machine_time_steps: 
     :param app_vertex: 
     :param time_between_requests: 
     :param buffer_size_before_receive: 
     :return: 
     """
     recorded_region_sizes = recording_utilities.get_recorded_region_sizes(
         app_vertex.get_buffered_sdram(
             self._neuron_slice, n_machine_time_steps),
         app_vertex.maximum_sdram_for_buffering)
     spec.write_array(recording_utilities.get_recording_header_array(
         recorded_region_sizes, time_between_requests,
         buffer_size_before_receive, ip_tags))
    def generate_machine_data_specification(
            self, spec, placement, machine_graph, routing_info, iptags,
            reverse_iptags, machine_time_step, time_scale_factor,
            n_machine_time_steps, current_time_step, graph_mapper):

        # reserve data regions
        self._reverse_memory_regions(spec, self._output_data, machine_graph)

        # add system region
        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))

        # add recording region
        if self._is_recording_output:
            spec.switch_write_focus(self.DATA_REGIONS.RECORDING.value)
            ip_tags = iptags.get_ip_tags_for_vertex(self)
            recorded_region_sizes = \
                recording_utilities.get_recorded_region_sizes(
                    self._get_buffered_sdram(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))

        # add output region
        spec.switch_write_focus(self.DATA_REGIONS.OUTPUT_REGION.value)
        spec.write_array(
            helpful_functions.convert_numpy_array_to_s16_15(self._output_data))

        # add routing region
        spec.switch_write_focus(self.DATA_REGIONS.KEY_REGION.value)
        self._write_key_region(machine_graph, routing_info, spec)

        # add params region
        spec.switch_write_focus(self.DATA_REGIONS.NEURON_REGION.value)
        spec.write_value(self._update_period is not None)
        spec.write_value(self._outgoing_partition_slice.n_atoms)

        # Write the random back off value
        app_vertex = graph_mapper.get_application_vertex(self)
        spec.write_value(
            random.randint(
                0,
                min(app_vertex.n_value_source_machine_vertices,
                    constants.MICROSECONDS_PER_SECOND // machine_time_step)))

        # write time between spikes
        spikes_per_time_step = (
            self._outgoing_partition_slice.n_atoms /
            (constants.MICROSECONDS_PER_SECOND // machine_time_step))
        # avoid a possible division by zero / small number (which may
        # result in a value that doesn't fit in a uint32) by only
        # setting time_between_spikes if spikes_per_timestep is > 1
        time_between_spikes = 0.0
        if spikes_per_time_step > 1:
            time_between_spikes = ((machine_time_step * time_scale_factor) /
                                   (spikes_per_time_step * 2.0))
        spec.write_value(data=int(time_between_spikes))

        # sdp port
        spec.write_value(self.DMA_PORT)
        spec.end_specification()