Exemplo n.º 1
0
    def generate_data_specification(self, spec, placement, data_n_steps):
        # Generate the system data region for simulation .c requirements
        # Note that the time step and time scale factor are unused here
        generate_steps_system_data_region(spec, self.DATA_REGIONS.SYSTEM.value,
                                          self)

        # Create the data regions for hello world
        spec.reserve_memory_region(region=self.DATA_REGIONS.PARAMS.value,
                                   size=self.PARAMS_BASE_SIZE +
                                   len(self._text))
        spec.reserve_memory_region(
            region=self.DATA_REGIONS.STRING_DATA.value,
            size=recording_utilities.get_recording_header_size(1),
            label="Recording")

        # write data for the recording
        spec.switch_write_focus(self.DATA_REGIONS.STRING_DATA.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [data_n_steps * len(self._text)]))

        # write the data
        spec.switch_write_focus(self.DATA_REGIONS.PARAMS.value)
        spec.write_value(len(self._text))
        spec.write_array(
            numpy.array(bytearray(self._text, "ascii")).view("uint32"))

        # End-of-Spec:
        spec.end_specification()
    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):
        # Generate the system data region for simulation .c requirements
        generate_system_data_region(spec, self.DATA_REGIONS.SYSTEM.value, self,
                                    machine_time_step, time_scale_factor)

        self.placement = placement

        # Reserve SDRAM space for memory areas:

        # Create the data regions for hello world
        self._reserve_memory_regions(spec)

        # write data for the simulation data item
        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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    def load_data_on_vertices(self, spec, iptags):

        # recording data (output) region
        spec.switch_write_focus(self.DATA_REGIONS.OUTPUT_DATA.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [self._output_data_size], self._time_between_requests,
                self._output_data_size, iptags))

        # input data region
        spec.switch_write_focus(self.DATA_REGIONS.INPUT_DATA.value)

        #write header information - 16bytes of information
        spec.write_array([
            self.state, self.columns, self.rows, self.string_size,
            self.num_string_cols, self.initiate, self.function_id
        ])

        #write the string data entries
        for i in range(0, self.num_string_cols):
            for j in range(0, self.rows):
                spec.write_array(
                    convert_string_to_integer_parcel(
                        self.entries[j][i],  #-> entry converted to integers
                        self.string_size)
                )  #-> number of integers used for string

        #write the integer data entries
        for i in range(self.num_string_cols, self.columns):
            for k in range(0, self.rows):
                spec.write_value(
                    int(self.entries[k]
                        [i]))  #-> those are 32-bit integers by default
Exemplo n.º 6
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 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,
                          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 _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))
Exemplo n.º 10
0
    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, 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_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,
            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()
Exemplo n.º 14
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()
Exemplo n.º 15
0
    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, 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_data_specification(self, spec, placement, routing_info, tags,
                                    placements):

        self._placement.append(placement)

        # Reserve and write the parameters region
        region_size = self._N_PARAMETER_BYTES + self._data_size
        spec.reserve_memory_region(0, region_size)
        spec.switch_write_focus(0)

        # Write the data size in words
        spec.write_value(len(self._data) *
                         (float(self._DATA_ELEMENT_TYPE.size) / 4.0),
                         data_type=self._DATA_COUNT_TYPE)

        # Write the DRNLCoreID
        spec.write_value(0, data_type=self._COREID_TYPE)

        # Write the CoreID
        spec.write_value(placement.p, data_type=self._COREID_TYPE)

        #Write the DRNLAppID
        spec.write_value(0, data_type=self._COREID_TYPE)

        # Write the Acknowledge key
        spec.write_value(0)

        #Write the spike resample factor
        spec.write_value(self._resample_factor, data_type=self._COREID_TYPE)

        #Write the sampling frequency
        spec.write_value(self._fs, data_type=self._COREID_TYPE)

        # Write the data - Arrays must be 32-bit values, so convert
        data = numpy.array(self._data, dtype=self._NUMPY_DATA_ELEMENT_TYPE)
        spec.write_array(data.view(numpy.uint32))

        # Reserve and write the recording regions
        spec.reserve_memory_region(
            1, recording_utilities.get_recording_header_size(1))
        spec.switch_write_focus(1)
        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))

        #        print "IHCAN DRNL placement=",DRNL_placement

        #print "IHCAN placement=",placement.p

        # End the specification
        spec.end_specification()
Exemplo n.º 18
0
    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()
Exemplo n.º 19
0
    def _write_app_memory_regions(self, spec, routing_info, iptags):
        # Get the key, assuming all outgoing edges use the same key
        key = routing_info.get_first_key_from_pre_vertex(self, PARTITION_ID)

        # Write the transmission region
        spec.switch_write_focus(self.DATA_REGIONS.TRANSMISSION.value)
        spec.write_value(int(key is not None))
        spec.write_value(0 if key is None else key)

        # 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]))
    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()
Exemplo n.º 21
0
    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()
Exemplo n.º 22
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()
Exemplo n.º 24
0
    def generate_recording_region(self, spec, region_id, channel_sizes):
        """
        Generate the recording region for the data specification.

        :param ~data_specification.DataSpecificationGenerator spec:
            The data specification being built
        :param int region_id:
            Which region is the recording region.
        :param list(int) sizes:
            The sizes of each of the recording channels.
            The length of the list is the number of recording channels.
        """
        spec.reserve_memory_region(
            region=region_id,
            size=recording_utilities.get_recording_header_size(
                len(channel_sizes)),
            label="Recording")
        spec.switch_write_focus(region_id)
        spec.write_array(
            recording_utilities.get_recording_header_array(channel_sizes))
 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 _write_setup_info(
            self, spec, machine_time_step, time_scale_factor,
            n_machine_time_steps):
        """ Writes the system data as required.

        :param ~data_specification.DataSpecificationGenerator spec:
            the DSG spec writer
        :param int machine_time_step: the machine time step
        :param int time_scale_factor: the time scale factor
        """
        # pylint: disable=too-many-arguments
        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))

        spec.switch_write_focus(region=self._REGIONS.RECORDING)
        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))
Exemplo n.º 27
0
    def write_neuron_recording_region(
            self, spec, neuron_recording_region, vertex_slice,
            data_n_time_steps):
        """ recording data specification

        :param spec: dsg spec
        :param neuron_recording_region: the recording region
        :param vertex_slice: the vertex slice
        :param data_n_time_steps: how many time steps to run this time
        :rtype: None
        """
        spec.switch_write_focus(neuron_recording_region)
        spec.write_array(recording_utilities.get_recording_header_array(
            self._get_buffered_sdram(vertex_slice, data_n_time_steps)))

        # Write the number of variables and bitfields
        n_vars = len(self.__sampling_rates) - len(self.__bitfield_variables)
        spec.write_value(data=n_vars)
        spec.write_value(data=len(self.__bitfield_variables))

        # Write the recording data
        recording_data = self._get_data(vertex_slice)
        spec.write_array(recording_data)
Exemplo n.º 28
0
    def write_neuron_recording_region(self, spec, neuron_recording_region,
                                      vertex_slice, data_n_time_steps):
        """ recording data specification

        :param ~data_specification.DataSpecificationGenerator spec: dsg spec
        :param int neuron_recording_region: the recording region
        :param ~pacman.model.graphs.commmon.Slice vertex_slice:
            the vertex slice
        :param int data_n_time_steps: how many time steps to run this time
        :rtype: None
        """
        spec.switch_write_focus(neuron_recording_region)
        spec.write_array(
            get_recording_header_array(
                self._get_buffered_sdram(vertex_slice, data_n_time_steps)))

        # Write the number of variables and bitfields
        n_vars = len(self.__sampling_rates) - len(self.__bitfield_variables)
        spec.write_value(data=n_vars)
        spec.write_value(data=len(self.__bitfield_variables))

        # Write the recording data
        recording_data = self._get_data(vertex_slice)
        spec.write_array(recording_data)
Exemplo n.º 29
0
    def generate_machine_data_specification(self, spec, placement,
                                            machine_graph, routing_info,
                                            iptags, reverse_iptags,
                                            machine_time_step,
                                            time_scale_factor):

        #    HAS_KEY = 0, P2P_KEY = 1, FILTER_UPDATE_KEY = 2, OUTPUT_KEY = 3
        #    X_COORD = 0, Y_COORD = 1, RADIUS = 2, P2P_ID = 3, IS_MAIN = 4, N_PARTICLES = 5

        self._placement = placement

        # 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))

        # write transmission key
        spec.switch_write_focus(self.DATA_REGIONS.TRANSMISSION_DATA.value)

        routing_key = routing_info.get_first_key_from_pre_vertex(
            self, app_constants.EDGE_PARTITION_PARTICLE_TO_PARTICLE)
        if routing_key is None:
            raise Exception("Error: the routing key is none!")
        else:
            #HAS_KEY
            spec.write_value(1)
            #P2P_KEY
            spec.write_value(
                routing_info.get_first_key_from_pre_vertex(
                    self, app_constants.EDGE_PARTITION_PARTICLE_TO_PARTICLE))
        if self._main:
            #FILTER_UPDATE_KEY
            spec.write_value(
                routing_info.get_first_key_from_pre_vertex(
                    self, app_constants.EDGE_PARTITION_MAIN_TO_FILTER))
            #OUTPUT_KEY
            spec.write_value(
                routing_info.get_first_key_from_pre_vertex(
                    self, app_constants.EDGE_PARTITION_TARGET_POSITION))
        else:
            spec.write_value(0)
            spec.write_value(0)

        # write config params
        spec.switch_write_focus(self.DATA_REGIONS.CONFIG.value)
        spec.write_value(self._x)
        spec.write_value(self._y)
        spec.write_value(self._r)
        spec.write_value(self._part_id)
        if self._main:
            spec.write_value(1)
        else:
            spec.write_value(0)
        spec.write_value(self._n_particles)
        spec.write_value(self._batch_size)

        #initialise recording region
        spec.switch_write_focus(self.DATA_REGIONS.RECORDING.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [app_constants.MACHINE_STEPS * self.RECORD_BYTES_PER_STEP]))

        # 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,
                                            data_n_time_steps):

        # 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(), machine_time_step,
                time_scale_factor))

        # TODO use get_sdram_edge_partitions_starting_at_vertex
        # 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.reserve_memory_region(
            region=DataRegions.RESULTS,
            size=recording_utilities.get_recording_header_size(len(Channels)))

        # get recorded buffered regions sorted
        spec.switch_write_focus(DataRegions.RESULTS)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [self.RECORDING_ELEMENT_SIZE * data_n_time_steps]))

        spec.end_specification()
    def generate_data_specification(self, spec, placement, routing_info):
        vertex = placement.vertex

        spec.comment("\n*** Spec for Logic Instance ***\n\n")
        spec.comment("\nReserving memory space for data regions:\n\n")

        # Reserve memory:
        spec.reserve_memory_region(
            region=self._LOGIC_REGIONS.SYSTEM.value,
            size=front_end_common_constants.SYSTEM_BYTES_REQUIREMENT,
            label='setup')
        spec.reserve_memory_region(region=self._LOGIC_REGIONS.LOGIC.value,
                                   size=self.LOGIC_REGION_BYTES,
                                   label='LogicParams')
        # reserve recording region
        spec.reserve_memory_region(
            self._LOGIC_REGIONS.RECORDING.value,
            recording_utilities.get_recording_header_size(1))
        spec.reserve_memory_region(region=self._LOGIC_REGIONS.DATA.value,
                                   size=self.BASE_DATA_REGION_BYTES +
                                   (self._no_inputs * 4) +
                                   (len(self._truth_table) * 4),
                                   label='LogicArms')

        # Write setup region
        spec.comment("\nWriting setup region:\n")
        spec.switch_write_focus(self._LOGIC_REGIONS.SYSTEM.value)
        spec.write_array(
            simulation_utilities.get_simulation_header_array(
                vertex.get_binary_file_name()))

        # Write logic region containing routing key to transmit with
        spec.comment("\nWriting logic region:\n")
        spec.switch_write_focus(self._LOGIC_REGIONS.LOGIC.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 logic recording region:\n")
        spec.switch_write_focus(self._LOGIC_REGIONS.RECORDING.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [self._recording_size]))

        # Write logic data
        spec.comment("\nWriting logic data region:\n")
        spec.switch_write_focus(self._LOGIC_REGIONS.DATA.value)
        spec.write_value(self._score_delay, data_type=DataType.UINT32)
        spec.write_value(self._no_inputs, data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[0], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[1], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[2], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[3], data_type=DataType.UINT32)
        spec.write_value(self._rate_on, data_type=DataType.UINT32)
        spec.write_value(self._rate_off, data_type=DataType.UINT32)
        spec.write_value(self._stochastic, data_type=DataType.UINT32)
        # Write the data - Arrays must be 32-bit values, so convert
        data = numpy.array(self._input_sequence, dtype=numpy.uint32)
        spec.write_array(data.view(numpy.uint32))
        data = numpy.array(self._truth_table, dtype=numpy.uint32)
        spec.write_array(data.view(numpy.uint32))

        # End-of-Spec:
        spec.end_specification()
Exemplo n.º 32
0
    def generate_machine_data_specification(self, spec, placement,
                                            machine_graph, routing_info,
                                            iptags, reverse_iptags,
                                            machine_time_step,
                                            time_scale_factor):
        # Generate the system data region for simulation .c requirements
        generate_system_data_region(spec, self.DATA_REGIONS.SYSTEM.value, self,
                                    machine_time_step, time_scale_factor)

        # reserve memory regions
        spec.reserve_memory_region(
            region=self.DATA_REGIONS.TRANSMISSIONS.value,
            size=self.TRANSMISSION_DATA_SIZE,
            label="inputs")
        spec.reserve_memory_region(region=self.DATA_REGIONS.STATE.value,
                                   size=self.STATE_DATA_SIZE,
                                   label="state")
        spec.reserve_memory_region(
            region=self.DATA_REGIONS.NEIGHBOUR_INITIAL_STATES.value,
            size=8,
            label="neighour_states")
        spec.reserve_memory_region(
            region=self.DATA_REGIONS.RESULTS.value,
            size=recording_utilities.get_recording_header_size(1))

        # get recorded buffered regions sorted
        spec.switch_write_focus(self.DATA_REGIONS.RESULTS.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [MAX_SIZE_OF_BUFFERED_REGION_ON_CHIP],
                self._time_between_requests, self._buffer_size_before_receive,
                iptags))

        # check got right number of keys and edges going into me
        partitions = \
            machine_graph.get_outgoing_edge_partitions_starting_at_vertex(self)
        if not is_single(partitions):
            raise ConfigurationException(
                "Can only handle one type of partition.")

        # check for duplicates
        edges = list(machine_graph.get_edges_ending_at_vertex(self))
        if len(edges) != 8:
            raise ConfigurationException(
                "I've not got the right number of connections. I have {} "
                "instead of 8".format(
                    len(machine_graph.incoming_subedges_from_vertex(self))))
        for edge in edges:
            if edge.pre_vertex == self:
                raise ConfigurationException(
                    "I'm connected to myself, this is deemed an error"
                    " please fix.")

        # write key needed to transmit with
        key = routing_info.get_first_key_from_pre_vertex(
            self, self.PARTITION_ID)

        spec.switch_write_focus(region=self.DATA_REGIONS.TRANSMISSIONS.value)
        spec.write_value(0 if key is None else 1)
        spec.write_value(0 if key is None else key)

        # write state value
        spec.switch_write_focus(region=self.DATA_REGIONS.STATE.value)
        spec.write_value(int(bool(self._state)))

        # write neighbours data state
        spec.switch_write_focus(
            region=self.DATA_REGIONS.NEIGHBOUR_INITIAL_STATES.value)
        alive = 0
        dead = 0
        for edge in edges:
            if edge.pre_vertex.state:
                alive += 1
            else:
                dead += 1

        spec.write_value(alive)
        spec.write_value(dead)

        # End-of-Spec:
        spec.end_specification()
    def generate_data_specification(self, spec, placement, routing_info):
        vertex = placement.vertex

        spec.comment("\n*** Spec for Breakout Instance ***\n\n")
        spec.comment("\nReserving memory space for data regions:\n\n")

        # Reserve memory:
        spec.reserve_memory_region(
            region=BreakoutMachineVertex._BREAKOUT_REGIONS.SYSTEM.value,
            size=front_end_common_constants.SYSTEM_BYTES_REQUIREMENT,
            label='setup')
        spec.reserve_memory_region(
            region=BreakoutMachineVertex._BREAKOUT_REGIONS.BREAKOUT.value,
            size=self.BREAKOUT_REGION_BYTES,
            label='BreakoutKey')
        # Reserve recording region
        spec.reserve_memory_region(
            BreakoutMachineVertex._BREAKOUT_REGIONS.RECORDING.value,
            recording_utilities.get_recording_header_size(1))
        spec.reserve_memory_region(
            region=BreakoutMachineVertex._BREAKOUT_REGIONS.PARAMS.value,
            size=self.PARAM_REGION_BYTES,
            label='Parameters')

        # Write setup region
        spec.comment("\nWriting setup region:\n")
        spec.switch_write_focus(
            BreakoutMachineVertex._BREAKOUT_REGIONS.SYSTEM.value)
        spec.write_array(
            simulation_utilities.get_simulation_header_array(
                vertex.get_binary_file_name()))

        # Write breakout region containing routing key to transmit with
        spec.comment("\nWriting breakout region:\n")
        spec.switch_write_focus(
            BreakoutMachineVertex._BREAKOUT_REGIONS.BREAKOUT.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 breakout recording region:\n")
        spec.switch_write_focus(
            BreakoutMachineVertex._BREAKOUT_REGIONS.RECORDING.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [self._recording_size]))

        spec.comment("\nWriting breakout param region:\n")
        spec.switch_write_focus(
            BreakoutMachineVertex._BREAKOUT_REGIONS.PARAMS.value)
        spec.write_value(self._x_factor, data_type=DataType.UINT32)
        spec.write_value(self._y_factor, data_type=DataType.UINT32)
        spec.write_value(self._bricking, data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[0], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[1], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[2], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[3], data_type=DataType.UINT32)

        # End-of-Spec:
        spec.end_specification()
    def generate_data_specification(self, spec, placement, routing_info):
        vertex = placement.vertex

        spec.comment("\n*** Spec for Double Pendulum Instance ***\n\n")
        spec.comment("\nReserving memory space for data regions:\n\n")

        # Reserve memory:
        spec.reserve_memory_region(
            region=self._DOUBLE_PENDULUM_REGIONS.SYSTEM.value,
            size=front_end_common_constants.SYSTEM_BYTES_REQUIREMENT,
            label='setup')
        spec.reserve_memory_region(
            region=self._DOUBLE_PENDULUM_REGIONS.PENDULUM.value,
            size=self.PENDULUM_REGION_BYTES,
            label='PendulumVertex')
        # reserve recording region
        spec.reserve_memory_region(
            self._DOUBLE_PENDULUM_REGIONS.RECORDING.value,
            recording_utilities.get_recording_header_size(1))
        spec.reserve_memory_region(
            region=self._DOUBLE_PENDULUM_REGIONS.DATA.value,
            size=self.DATA_REGION_BYTES,
            label='PendulumData')

        # Write setup region
        spec.comment("\nWriting setup region:\n")
        spec.switch_write_focus(self._DOUBLE_PENDULUM_REGIONS.SYSTEM.value)
        spec.write_array(
            simulation_utilities.get_simulation_header_array(
                vertex.get_binary_file_name()))

        # Write pendulum region containing routing key to transmit with
        spec.comment("\nWriting double pendulum region:\n")
        spec.switch_write_focus(self._DOUBLE_PENDULUM_REGIONS.PENDULUM.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 double pendulum recording region:\n")
        spec.switch_write_focus(self._DOUBLE_PENDULUM_REGIONS.RECORDING.value)
        spec.write_array(
            recording_utilities.get_recording_header_array(
                [self._recording_size]))

        # Write probabilites for arms
        spec.comment("\nWriting double pendulum data region:\n")
        spec.switch_write_focus(self._DOUBLE_PENDULUM_REGIONS.DATA.value)
        spec.write_value(self._encoding, data_type=DataType.UINT32)
        spec.write_value(self._time_increment, data_type=DataType.UINT32)
        spec.write_value(self._pole_length, data_type=DataType.S1615)
        spec.write_value(self._pole_angle, data_type=DataType.S1615)
        spec.write_value(self._pole2_length, data_type=DataType.S1615)
        spec.write_value(self._pole2_angle, data_type=DataType.S1615)
        spec.write_value(self._reward_based, data_type=DataType.UINT32)
        spec.write_value(self._force_increments, data_type=DataType.UINT32)
        spec.write_value(self._max_firing_rate, data_type=DataType.UINT32)
        spec.write_value(self._number_of_bins, data_type=DataType.UINT32)
        spec.write_value(self._central, data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[0], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[1], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[2], data_type=DataType.UINT32)
        spec.write_value(self._rand_seed[3], data_type=DataType.UINT32)
        spec.write_value(self._bin_overlap, data_type=DataType.S1615)
        spec.write_value(self._tau_force, data_type=DataType.S1615)

        # End-of-Spec:
        spec.end_specification()