Esempio n. 1
0
    def test_resource_container(self):
        """
        tests that creating multiple resoruce containers doesnt cause issues.
        """
        sdram = SDRAMResource(128 * (2**20))
        dtcm = DTCMResource(128 * (2**20) + 1)
        cpu = CPUCyclesPerTickResource(128 * (2**20) + 2)

        container = ResourceContainer(dtcm, sdram, cpu)
        self.assertEqual(container.sdram.get_value(), 128 * (2**20))
        self.assertEqual(container.dtcm.get_value(), 128 * (2**20) + 1)
        self.assertEqual(container.cpu_cycles.get_value(), 128 * (2**20) + 2)

        sdram = SDRAMResource(128 * (2**19))
        dtcm = DTCMResource(128 * (2**19) + 1)
        cpu = CPUCyclesPerTickResource(128 * (2**19) + 2)

        container = ResourceContainer(dtcm, sdram, cpu)
        self.assertEqual(container.sdram.get_value(), 128 * (2**19))
        self.assertEqual(container.dtcm.get_value(), 128 * (2**19) + 1)
        self.assertEqual(container.cpu_cycles.get_value(), 128 * (2**19) + 2)

        sdram = SDRAMResource(128 * (2**21))
        dtcm = DTCMResource(128 * (2**21) + 1)
        cpu = CPUCyclesPerTickResource(128 * (2**21) + 2)

        container = ResourceContainer(dtcm, sdram, cpu)
        self.assertEqual(container.sdram.get_value(), 128 * (2**21))
        self.assertEqual(container.dtcm.get_value(), 128 * (2**21) + 1)
        self.assertEqual(container.cpu_cycles.get_value(), 128 * (2**21) + 2)
Esempio n. 2
0
 def test_cpu(self):
     """
     test that adding a cpu resource to a resoruce container works
     correctly
     """
     cpu = CPUCyclesPerTickResource(128 * (2**20))
     self.assertEqual(cpu.get_value(), 128 * (2**20))
     cpu = CPUCyclesPerTickResource(128 * (2**19))
     self.assertEqual(cpu.get_value(), 128 * (2**19))
     cpu = CPUCyclesPerTickResource(128 * (2**21))
     self.assertEqual(cpu.get_value(), 128 * (2**21))
Esempio n. 3
0
    def get_resources_used_by_atoms(self, vertex_slice, n_machine_time_steps,
                                    machine_time_step):

        # build resources as i currently know
        container = ResourceContainer(
            sdram=SDRAMResource(self.get_sdram_usage_for_atoms(vertex_slice)),
            dtcm=DTCMResource(self.get_dtcm_usage_for_atoms()),
            cpu_cycles=CPUCyclesPerTickResource(
                self.get_cpu_usage_for_atoms()))

        recording_sizes = recording_utilities.get_recording_region_sizes(
            [
                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),
                    self._N_POPULATION_RECORDING_REGIONS)
            ], n_machine_time_steps, self._minimum_buffer_sdram,
            self._maximum_sdram_for_buffering,
            self._using_auto_pause_and_resume)
        container.extend(
            recording_utilities.get_recording_resources(
                recording_sizes, self._receive_buffer_host,
                self._receive_buffer_port))
        return container
    def get_resources(time_step, time_scale_factor, n_samples_per_recording,
                      sampling_frequency):
        """ Get the resources used by this vertex

        :return: Resource container
        """
        # pylint: disable=too-many-locals
        step_in_microseconds = (time_step * time_scale_factor)
        # The number of sample per step CB believes does not have to be an int
        samples_per_step = (step_in_microseconds / sampling_frequency)
        recording_per_step = (samples_per_step / n_samples_per_recording)
        max_recording_per_step = math.ceil(recording_per_step)
        overflow_recordings = max_recording_per_step - recording_per_step
        system = SYSTEM_BYTES_REQUIREMENT
        config = CONFIG_SIZE_IN_BYTES
        recording = recording_utilities.get_recording_header_size(1)
        recording += recording_utilities.get_recording_data_constant_size(1)
        fixed_sdram = system + config + recording
        with_overflow = (fixed_sdram +
                         overflow_recordings * RECORDING_SIZE_PER_ENTRY)
        per_timestep = recording_per_step * RECORDING_SIZE_PER_ENTRY

        container = ResourceContainer(sdram=VariableSDRAM(
            with_overflow, per_timestep),
                                      cpu_cycles=CPUCyclesPerTickResource(100),
                                      dtcm=DTCMResource(100))
        return container
Esempio n. 5
0
 def get_resources_used_by_atoms(self, vertex_slice):
     return ResourceContainer(
         sdram=SDRAMResource(
             self.get_sdram_usage_for_atoms()),
         dtcm=DTCMResource(self.get_dtcm_usage_for_atoms(vertex_slice)),
         cpu_cycles=CPUCyclesPerTickResource(
             self.get_cpu_usage_for_atoms(vertex_slice)))
Esempio n. 6
0
    def __init__(self,
                 lpg_params,
                 constraints=None,
                 app_vertex=None,
                 label=None):
        """
        :param LivePacketGatherParams lpg_params:
        :param LivePacketGather app_vertex:
        :param str label:
        :param constraints:
        :type constraints:
            iterable(~pacman.model.constraints.AbstractConstraint)
        """
        # inheritance
        super(LivePacketGatherMachineVertex,
              self).__init__(label or lpg_params.label,
                             constraints=constraints,
                             app_vertex=app_vertex)

        self._resources_required = ResourceContainer(
            cpu_cycles=CPUCyclesPerTickResource(self.get_cpu_usage()),
            dtcm=DTCMResource(self.get_dtcm_usage()),
            sdram=ConstantSDRAM(self.get_sdram_usage()),
            iptags=[lpg_params.get_iptag_resource()])

        # app specific data items
        self._lpg_params = lpg_params
Esempio n. 7
0
    def get_resources_used_by_atoms(self, vertex_slice, machine_time_step):
        """
        :param ~pacman.model.graphs.common.Slice vertex_slice:
        :param int machine_time_step:
        """
        # pylint: disable=arguments-differ
        poisson_params_sz = self.get_rates_bytes(vertex_slice)
        other = ConstantSDRAM(
            SYSTEM_BYTES_REQUIREMENT +
            SpikeSourcePoissonMachineVertex.get_provenance_data_size(0) +
            poisson_params_sz + self.tdma_sdram_size_in_bytes +
            recording_utilities.get_recording_header_size(1) +
            recording_utilities.get_recording_data_constant_size(1) +
            profile_utils.get_profile_region_size(self.__n_profile_samples))

        recording = self.get_recording_sdram_usage(vertex_slice,
                                                   machine_time_step)
        # build resources as i currently know
        container = ResourceContainer(sdram=recording + other,
                                      dtcm=DTCMResource(
                                          self.get_dtcm_usage_for_atoms()),
                                      cpu_cycles=CPUCyclesPerTickResource(
                                          self.get_cpu_usage_for_atoms()))

        return container
Esempio n. 8
0
 def get_resources_used_by_atoms(self, vertex_slice, graph):
     out_edges = graph.get_edges_starting_at_vertex(self)
     return ResourceContainer(
         sdram=SDRAMResource(self.get_sdram_usage_for_atoms(out_edges)),
         dtcm=DTCMResource(self.get_dtcm_usage_for_atoms(vertex_slice)),
         cpu_cycles=CPUCyclesPerTickResource(
             self.get_cpu_usage_for_atoms(vertex_slice)))
Esempio n. 9
0
    def __get_neuron_resources(self, vertex_slice):
        """  Gets the resources of the neurons of a slice of atoms from a given
             app vertex.

        :param ~pacman.model.graphs.common.Slice vertex_slice: the slice
        :rtype: ~pacman.model.resources.ResourceContainer
        """
        n_record = len(self._governed_app_vertex.neuron_recordables)
        variable_sdram = self._governed_app_vertex.get_neuron_variable_sdram(
            vertex_slice)
        sdram = MultiRegionSDRAM()
        sdram.merge(self._governed_app_vertex.get_common_constant_sdram(
            n_record, NeuronProvenance.N_ITEMS + NeuronMainProvenance.N_ITEMS,
            PopulationNeuronsMachineVertex.COMMON_REGIONS))
        sdram.merge(self._governed_app_vertex.get_neuron_constant_sdram(
            vertex_slice, PopulationNeuronsMachineVertex.NEURON_REGIONS))
        sdram.add_cost(
            PopulationNeuronsMachineVertex.REGIONS.SDRAM_EDGE_PARAMS.value,
            NEURONS_SDRAM_PARAMS_SIZE)
        sdram.nest(
            len(PopulationNeuronsMachineVertex.REGIONS) + 1, variable_sdram)
        dtcm = self._governed_app_vertex.get_common_dtcm()
        dtcm += self._governed_app_vertex.get_neuron_dtcm(vertex_slice)
        cpu_cycles = self._governed_app_vertex.get_common_cpu()
        cpu_cycles += self._governed_app_vertex.get_neuron_cpu(vertex_slice)

        # set resources required from this object
        container = ResourceContainer(
            sdram=sdram, dtcm=DTCMResource(dtcm),
            cpu_cycles=CPUCyclesPerTickResource(cpu_cycles))

        # return the total resources.
        return container
    def cpu_cost(self, vertex_slice):
        """ returns the cpu cost of the delay extension for a slice of atoms

        :param Slice vertex_slice: slice of atoms
        :rtype: CPUCyclesPerTickResource
        """
        return CPUCyclesPerTickResource(self.ESTIMATED_CPU_CYCLES *
                                        vertex_slice.n_atoms)
 def get_resources_used_by_atoms(self, vertex_slice):  # @UnusedVariable
     return ResourceContainer(
         sdram=ConstantSDRAM(
             LivePacketGatherMachineVertex.get_sdram_usage()),
         dtcm=DTCMResource(LivePacketGatherMachineVertex.get_dtcm_usage()),
         cpu_cycles=CPUCyclesPerTickResource(
             LivePacketGatherMachineVertex.get_cpu_usage()),
         iptags=[self._lpg_params.get_iptag_resource()])
Esempio n. 12
0
 def resources_required(self):
     sdram_required = (constants.SYSTEM_BYTES_REQUIREMENT +
                       self.TRANSMISSION_DATA_SIZE +
                       self.CONFIG_REGION_SIZE)
     resources = ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(45),
                                   dtcm=DTCMResource(100),
                                   sdram=SDRAMResource(sdram_required))
     return resources
Esempio n. 13
0
 def get_resources_used_by_atoms(self, vertex_slice, graph):
     # pylint: disable=arguments-differ
     out_edges = graph.get_edges_starting_at_vertex(self)
     return ResourceContainer(
         sdram=ConstantSDRAM(
             self.get_sdram_usage_for_atoms(out_edges)),
         dtcm=DTCMResource(self.get_dtcm_usage_for_atoms(vertex_slice)),
         cpu_cycles=CPUCyclesPerTickResource(
             self.get_cpu_usage_for_atoms(vertex_slice)))
Esempio n. 14
0
def get_resources_used_by_atoms(lo_atom, hi_atom, vertex_in_edges):
    vertex = Vertex(1, None)
    cpu_cycles = vertex.get_cpu_usage_for_atoms(lo_atom, hi_atom)
    dtcm_requirement = vertex.get_dtcm_usage_for_atoms(lo_atom, hi_atom)
    sdram_requirement = vertex.get_sdram_usage_for_atoms(
        lo_atom, hi_atom, vertex_in_edges)
    return ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(cpu_cycles),
                             dtcm=DTCMResource(dtcm_requirement),
                             sdram=SDRAMResource(sdram_requirement))
Esempio n. 15
0
 def resources_required(self):
     resources = ResourceContainer(sdram=SDRAMResource(
         self._calculate_sdram_requirement()),
                                   dtcm=DTCMResource(0),
                                   cpu_cycles=CPUCyclesPerTickResource(0))
     resources.extend(
         recording_utilities.get_recording_resources(
             [MAX_SIZE_OF_BUFFERED_REGION_ON_CHIP],
             self._receive_buffer_host, self._receive_buffer_port))
     return resources
Esempio n. 16
0
 def test_resource_container(self):
     sdram1 = ConstantSDRAM(128 * (2**20))
     dtcm = DTCMResource(128 * (2**20) + 1)
     cpu = CPUCyclesPerTickResource(128 * (2**20) + 2)
     r1 = ResourceContainer(dtcm, sdram1, cpu)
     self.resource_there_and_back(r1)
     t1 = IPtagResource("1", 2, True)  # Minimal args
     t2 = IPtagResource("1.2.3.4", 2, False, 4, 5)
     r2 = r1 = ResourceContainer(dtcm, sdram1, cpu, iptags=[t1, t2])
     self.resource_there_and_back(r2)
Esempio n. 17
0
def resource_container_from_json(json_dict):
    if json_dict is None:
        return None
    dtcm = DTCMResource(json_dict["dtcm"])
    sdram = VariableSDRAM(json_dict["fixed_sdram"],
                          json_dict["per_timestep_sdram"])
    cpu_cycles = CPUCyclesPerTickResource(json_dict["cpu_cycles"])
    iptags = iptag_resources_from_json(json_dict["iptags"])
    reverse_iptags = iptag_resources_from_json(json_dict["reverse_iptags"])
    return ResourceContainer(dtcm, sdram, cpu_cycles, iptags, reverse_iptags)
Esempio n. 18
0
 def resources_required(self):
     constant_sdram = (
         SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_REGION_N_BYTES +
         recording_utilities.get_recording_header_size(1) +
         recording_utilities.get_recording_data_constant_size(1))
     variable_sdram = self.N_RECORDED_PER_TIMESTEP
     return ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(45),
                              dtcm=DTCMResource(100),
                              sdram=VariableSDRAM(constant_sdram,
                                                  variable_sdram))
Esempio n. 19
0
    def __get_cpu_cost(self, vertex_slice):
        """ get cpu cost for a slice of atoms

        :param Slice vertex_slice: slice of atoms
        :rtype: CPUCyclesPerTickResourcer
        """
        return CPUCyclesPerTickResource(
            self._governed_app_vertex.get_common_cpu() +
            self._governed_app_vertex.get_neuron_cpu(vertex_slice) +
            self._governed_app_vertex.get_synapse_cpu(vertex_slice))
Esempio n. 20
0
 def get_resources_used_by_atoms(self, vertex_slice):
     return ResourceContainer(
         sdram=SDRAMResource(
             LivePacketGatherMachineVertex.get_sdram_usage()),
         dtcm=DTCMResource(LivePacketGatherMachineVertex.get_dtcm_usage()),
         cpu_cycles=CPUCyclesPerTickResource(
             LivePacketGatherMachineVertex.get_cpu_usage()),
         iptags=[IPtagResource(
             ip_address=self._ip_address, port=self._port,
             strip_sdp=self._strip_sdp, tag=self._tag,
             traffic_identifier="LPG_EVENT_STREAM")])
Esempio n. 21
0
 def resources_required(self):
     resources = ResourceContainer(
         cpu_cycles=CPUCyclesPerTickResource(45),
         dtcm=DTCMResource(100),
         sdram=SDRAMResource(constants.SYSTEM_BYTES_REQUIREMENT +
                             self.TRANSMISSION_REGION_N_BYTES))
     resources.extend(
         recording_utilities.get_recording_resources(
             [self._recording_size], self._receive_buffer_host,
             self._receive_buffer_port))
     return resources
    def resources_required(self):
        resources = ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(45),
                                      dtcm=DTCMResource(100),
                                      sdram=SDRAMResource(100))

        resources.extend(
            recording_utilities.get_recording_resources(
                [self._string_data_size], self._receive_buffer_host,
                self._receive_buffer_port))

        return resources
Esempio n. 23
0
def get_resourced_machine_vertex(lo_atom, hi_atom, label=None):
    cpu_cycles = 10 * (hi_atom - lo_atom)
    dtcm_requirement = 200 * (hi_atom - lo_atom)
    sdram_requirement = 4000 + 50 * (hi_atom - lo_atom)
    resources = ResourceContainer(
        cpu_cycles=CPUCyclesPerTickResource(cpu_cycles),
        dtcm=DTCMResource(dtcm_requirement),
        sdram=ConstantSDRAM(sdram_requirement))
    return SimpleMachineVertex(resources,
                               label=label,
                               vertex_slice=Slice(lo_atom, hi_atom))
Esempio n. 24
0
    def test_place_vertex_too_big_with_vertex(self):
        cpu_cycles = 1000
        dtcm_requirement = 1000
        sdram_requirement = self.machine.get_chip_at(0, 0).sdram.size * 20
        rc = ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(cpu_cycles),
                               dtcm=DTCMResource(dtcm_requirement),
                               sdram=ConstantSDRAM(sdram_requirement))

        large_machine_vertex = T_MachineVertex(0, 499, rc, "Second vertex")
        self.mach_graph.add_vertex(large_machine_vertex)
        with self.assertRaises(PacmanValueError):
            ConnectiveBasedPlacer()(self.mach_graph, self.machine, 100)
Esempio n. 25
0
    def resources_required(self):
        sim = globals_variables.get_simulator()
        sdram = self.get_sdram_usage(self._send_buffer_times,
                                     self._is_recording, sim.machine_time_step,
                                     self._receive_rate, self._n_keys)

        resources = ResourceContainer(dtcm=DTCMResource(self.get_dtcm_usage()),
                                      sdram=sdram,
                                      cpu_cycles=CPUCyclesPerTickResource(
                                          self.get_cpu_usage()),
                                      reverse_iptags=self._reverse_iptags)
        return resources
Esempio n. 26
0
    def get_resources_used_by_atoms(self, vertex_slice):
        """
        standard method call to get the sdram, cpu and dtcm usage of a
        collection of atoms

        :param vertex_slice: the collection of atoms
        """
        return ResourceContainer(
            sdram=ConstantSDRAM(self.get_sdram_usage_for_atoms(vertex_slice)),
            cpu_cycles=CPUCyclesPerTickResource(
                self.get_cpu_usage_for_atoms(vertex_slice)),
            dtcm=DTCMResource(self.get_dtcm_usage_for_atoms(vertex_slice)))
    def get_resources(n_machine_time_steps, time_step, time_scale_factor,
                      n_samples_per_recording, sampling_frequency):
        """ Get the resources used by this vertex

        :return: Resource container
        """
        # pylint: disable=too-many-locals

        # get config
        config = globals_variables.get_simulator().config

        # get recording params
        minimum_buffer_sdram = config.getint("Buffers", "minimum_buffer_sdram")
        using_auto_pause_and_resume = config.getboolean(
            "Buffers", "use_auto_pause_and_resume")
        receive_buffer_host = config.get("Buffers", "receive_buffer_host")
        receive_buffer_port = read_config_int(config, "Buffers",
                                              "receive_buffer_port")

        # figure recording size for max run
        if not using_auto_pause_and_resume and n_machine_time_steps is None:
            raise Exception(
                "You cannot use the chip power montiors without auto pause "
                "and resume and not allocating a n_machine_time_steps")

        # figure max buffer size
        max_buffer_size = 0
        if config.getboolean("Buffers", "enable_buffered_recording"):
            max_buffer_size = config.getint("Buffers",
                                            "chip_power_monitor_buffer")

        maximum_sdram_for_buffering = [max_buffer_size]

        n_recording_entries = (math.ceil(
            (sampling_frequency / (time_step * time_scale_factor))) /
                               n_samples_per_recording)

        recording_size = (
            ChipPowerMonitorMachineVertex.RECORDING_SIZE_PER_ENTRY *
            n_recording_entries)

        container = ResourceContainer(sdram=SDRAMResource(
            ChipPowerMonitorMachineVertex.sdram_calculation()),
                                      cpu_cycles=CPUCyclesPerTickResource(100),
                                      dtcm=DTCMResource(100))
        recording_sizes = recording_utilities.get_recording_region_sizes(
            [int(recording_size) * n_machine_time_steps], minimum_buffer_sdram,
            maximum_sdram_for_buffering, using_auto_pause_and_resume)
        container.extend(
            recording_utilities.get_recording_resources(
                recording_sizes, receive_buffer_host, receive_buffer_port))
        return container
Esempio n. 28
0
    def test_place_vertex_too_big_with_vertex(self):
        cpu_cycles = 1000
        dtcm_requirement = 1000
        sdram_requirement = self.machine.get_chip_at(0, 0).sdram.size * 20
        rc = ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(cpu_cycles),
                               dtcm=DTCMResource(dtcm_requirement),
                               sdram=ConstantSDRAM(sdram_requirement))

        large_machine_vertex = SimpleMachineVertex(rc,
                                                   vertex_slice=Slice(0, 499),
                                                   label="Second vertex")
        self.mach_graph.add_vertex(large_machine_vertex)
        with self.assertRaises(PacmanValueError):
            radial_placer(self.mach_graph, self.machine, 100)
    def __init__(self,
                 label,
                 use_prefix=False,
                 key_prefix=None,
                 prefix_type=None,
                 message_type=EIEIOType.KEY_32_BIT,
                 right_shift=0,
                 payload_as_time_stamps=True,
                 use_payload_prefix=True,
                 payload_prefix=None,
                 payload_right_shift=0,
                 number_of_packets_sent_per_time_step=0,
                 hostname=None,
                 port=None,
                 strip_sdp=None,
                 board_address=None,
                 tag=None,
                 constraints=None):
        # pylint: disable=too-many-arguments, too-many-locals

        # inheritance
        super(LivePacketGatherMachineVertex,
              self).__init__(label, constraints=constraints)

        self._resources_required = ResourceContainer(
            cpu_cycles=CPUCyclesPerTickResource(self.get_cpu_usage()),
            dtcm=DTCMResource(self.get_dtcm_usage()),
            sdram=SDRAMResource(self.get_sdram_usage()),
            iptags=[
                IPtagResource(ip_address=hostname,
                              port=port,
                              strip_sdp=strip_sdp,
                              tag=tag,
                              traffic_identifier=self.TRAFFIC_IDENTIFIER)
            ])

        # app specific data items
        self._use_prefix = use_prefix
        self._key_prefix = key_prefix
        self._prefix_type = prefix_type
        self._message_type = message_type
        self._right_shift = right_shift
        self._payload_as_time_stamps = payload_as_time_stamps
        self._use_payload_prefix = use_payload_prefix
        self._payload_prefix = payload_prefix
        self._payload_right_shift = payload_right_shift
        self._number_of_packets_sent_per_time_step = \
            number_of_packets_sent_per_time_step
Esempio n. 30
0
    def resources_required(self):
        sdram_required = (constants.SYSTEM_BYTES_REQUIREMENT +
                          self.TRANSMISSION_DATA_SIZE + self.CONFIG_PARAM_SIZE)

        sdram_required += \
            app_constants.MACHINE_STEPS * self.RECORD_BYTES_PER_STEP

        resources = ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(45),
                                      dtcm=DTCMResource(100),
                                      sdram=SDRAMResource(sdram_required))

        # resources.extend(recording_utilities.get_recording_resources(
        #     [app_constants.MACHINE_STEPS * self.RECORD_BYTES_PER_STEP],
        #     self._receive_buffer_host, self._receive_buffer_port))

        return resources
 def test_cpu(self):
     """
     test that adding a CPU resource to a resource container works
     correctly
     """
     cpu = CPUCyclesPerTickResource(128 * (2**20))
     self.assertEqual(cpu.get_value(), 128 * (2**20))
     cpu = CPUCyclesPerTickResource(128 * (2**19))
     self.assertEqual(cpu.get_value(), 128 * (2**19))
     cpu = CPUCyclesPerTickResource(128 * (2**21))
     self.assertEqual(cpu.get_value(), 128 * (2**21))