def test_sdram(self):
        """
        test that adding a SDRAM resource to a resource container works
        correctly
        """
        const1 = ConstantSDRAM(128)
        self.assertEqual(const1.get_total_sdram(None), 128)
        const2 = ConstantSDRAM(256)
        combo = const1 + const2
        self.assertEqual(combo.get_total_sdram(None), 128+256)
        combo = const1 - const2
        self.assertEqual(combo.get_total_sdram(None), 128-256)
        combo = const2 + const1
        self.assertEqual(combo.get_total_sdram(None), 256+128)
        combo = const2 - const1
        self.assertEqual(combo.get_total_sdram(None), 256-128)

        var1 = VariableSDRAM(124, 8)
        self.assertEqual(var1.get_total_sdram(100), 124 + 8 * 100)
        combo = var1 + const1
        self.assertEqual(combo.get_total_sdram(100), 124 + 8 * 100 + 128)
        combo = var1 - const1
        self.assertEqual(combo.get_total_sdram(100), 124 + 8 * 100 - 128)
        combo = const1 + var1
        self.assertEqual(combo.get_total_sdram(100), 128 + 124 + 8 * 100)
        combo = const1 - var1
        self.assertEqual(combo.get_total_sdram(100), 128 - (124 + 8 * 100))
        var2 = VariableSDRAM(234, 6)
        combo = var2 + var1
        self.assertEqual(combo.get_total_sdram(150), 234 + 124 + (6 + 8) * 150)
        combo = var2 - var1
        self.assertEqual(combo.get_total_sdram(150), 234 - 124 + (6 - 8) * 150)
Exemplo n.º 2
0
    def test_sdram(self):
        """
        test that adding a SDRAM resource to a resource container works
        correctly
        """
        const1 = ConstantSDRAM(128)
        self.assertEqual(const1.get_total_sdram(None), 128)
        const2 = ConstantSDRAM(256)
        combo = const1 + const2
        self.assertEqual(combo.get_total_sdram(None), 128 + 256)
        combo = const1 - const2
        self.assertEqual(combo.get_total_sdram(None), 128 - 256)
        combo = const2 + const1
        self.assertEqual(combo.get_total_sdram(None), 256 + 128)
        combo = const2 - const1
        self.assertEqual(combo.get_total_sdram(None), 256 - 128)

        var1 = VariableSDRAM(124, 8)
        self.assertEqual(var1.get_total_sdram(100), 124 + 8 * 100)
        combo = var1 + const1
        self.assertEqual(combo.get_total_sdram(100), 124 + 8 * 100 + 128)
        combo = var1 - const1
        self.assertEqual(combo.get_total_sdram(100), 124 + 8 * 100 - 128)
        combo = const1 + var1
        self.assertEqual(combo.get_total_sdram(100), 128 + 124 + 8 * 100)
        combo = const1 - var1
        self.assertEqual(combo.get_total_sdram(100), 128 - (124 + 8 * 100))
        var2 = VariableSDRAM(234, 6)
        combo = var2 + var1
        self.assertEqual(combo.get_total_sdram(150), 234 + 124 + (6 + 8) * 150)
        combo = var2 - var1
        self.assertEqual(combo.get_total_sdram(150), 234 - 124 + (6 - 8) * 150)

        multi1 = MultiRegionSDRAM()
        multi1.add_cost(1, 100, 4)
        multi1.add_cost(2, 50, 3)
        multi1.add_cost("overheads", 20)
        multi2 = MultiRegionSDRAM()
        multi2.add_cost(MockEnum.ZERO, 88)
        multi2.add_cost(MockEnum.ONE, 72)
        multi2.add_cost("overheads", 22)

        combo = multi1 + multi2
        self.assertEqual(combo.get_total_sdram(150),
                         100 + 50 + 20 + 88 + 72 + 22 + (4 + 3) * 150)

        multi3 = MultiRegionSDRAM()
        multi3.nest("foo", multi1)
        multi3.nest("bar", multi2)

        multi1.merge(multi2)
        self.assertEqual(len(multi1.regions), 5)
        self.assertEqual(multi1.regions["overheads"], ConstantSDRAM(20 + 22))
        self.assertEqual(multi1.get_total_sdram(150),
                         100 + 50 + 20 + 88 + 72 + 22 + (4 + 3) * 150)
        self.assertEqual(multi1, combo)
        self.assertEqual(multi1, multi3)
        with tempfile.TemporaryFile(mode="w") as target:
            multi3.report(1000, target=target)
    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
Exemplo n.º 4
0
 def resources_required(self):
     fixed = (
         SYSTEM_BYTES_REQUIREMENT +
         recording_utilities.get_recording_header_size(len(Channels)) +
         self.PARAMS_BASE_SIZE + len(self._text))
     variable = len(self._text)
     return ResourceContainer(sdram=VariableSDRAM(fixed, variable))
 def get_sdram_usage(cls, send_buffer_times, recording_enabled,
                     machine_time_step, receive_rate, n_keys):
     """
     :param send_buffer_times: When events will be sent
     :type send_buffer_times:
         ~numpy.ndarray(~numpy.ndarray(numpy.int32)) or
         list(~numpy.ndarray(numpy.int32)) or None
     :param bool recording_enabled: Whether recording is done
     :param int machine_time_step: What the machine timestep is
     :param float receive_rate: What the expected message receive rate is
     :param int n_keys: How many keys are being sent
     :rtype: ~pacman.model.resources.VariableSDRAM
     """
     static_usage = (SYSTEM_BYTES_REQUIREMENT +
                     cls._CONFIGURATION_REGION_SIZE +
                     get_recording_header_size(1) +
                     get_recording_data_constant_size(1) +
                     cls.get_provenance_data_size(0))
     per_timestep = (
         cls._send_buffer_sdram_per_timestep(send_buffer_times, n_keys) +
         cls._recording_sdram_per_timestep(machine_time_step,
                                           recording_enabled, receive_rate,
                                           send_buffer_times, n_keys))
     static_usage += per_timestep
     return VariableSDRAM(static_usage, per_timestep)
 def resources_required(self):
     fixed_sdram = (SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_DATA_SIZE +
                    self.STATE_DATA_SIZE +
                    self.NEIGHBOUR_INITIAL_STATES_SIZE +
                    self.RECORDING_HEADER_SIZE)
     per_timestep_sdram = self.RECORDING_ELEMENT_SIZE
     return ResourceContainer(
         sdram=VariableSDRAM(fixed_sdram, per_timestep_sdram))
Exemplo n.º 7
0
 def resources_required(self):
     if self.group.output_grp:
         resources = ResourceContainer(
             sdram=VariableSDRAM(self._sdram_fixed, self._sdram_variable))
     else:
         resources = ResourceContainer(
             sdram=ConstantSDRAM(self._sdram_fixed))
     return resources
Exemplo n.º 8
0
 def resources_required(self):
     fixed_sdram = (SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_DATA_SIZE +
                    self.STATE_DATA_SIZE +
                    self.NEIGHBOUR_INITIAL_STATES_SIZE +
                    get_recording_header_size(len(Channels)) +
                    get_recording_data_constant_size(len(Channels)))
     per_timestep_sdram = self.RECORDING_ELEMENT_SIZE
     return ResourceContainer(
         sdram=VariableSDRAM(fixed_sdram, per_timestep_sdram))
Exemplo n.º 9
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))
Exemplo n.º 10
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)
 def resources_required(self, app_graph):
     out_edges = app_graph.get_edges_starting_at_vertex(self.app_vertex)
     in_edges = app_graph.get_edges_starting_at_vertex(self.app_vertex)
     return ResourceContainer(sdram=VariableSDRAM(fixed_sdram=(
         SIMULATION_N_BYTES +
         (len(out_edges) * self.SDRAM_PARTITION_BASE_DSG_SIZE) +
         (len(in_edges) * self.SDRAM_PARTITION_BASE_DSG_SIZE) +
         (self.SDRAM_PARTITION_COUNTERS * 2) + SARK_PER_MALLOC_SDRAM_USAGE +
         recording_utilities.get_recording_header_size(len(Channels)) +
         recording_utilities.get_recording_data_constant_size(len(Channels))
     ),
                                                  per_timestep_sdram=self.
                                                  RECORDING_ELEMENT_SIZE))
Exemplo n.º 12
0
 def resources_required(self):
     """
     Reserve resources for data regions
     """
     fixed_sdram = (SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_DATA_SIZE +
                    self.POSITION_DATA_SIZE +
                    self.NEIGHBOUR_KEYS_SIZE +
                    self.VELOCITY_SIZE +
                    self.VERTEX_INDEX_SIZE +
                    recording_utilities.get_recording_header_size(1) +
                    recording_utilities.get_recording_data_constant_size(1))
     per_timestep_sdram = self.RECORDING_ELEMENT_SIZE
     return ResourceContainer(
         sdram=VariableSDRAM(fixed_sdram, per_timestep_sdram))
Exemplo n.º 13
0
    def get_sdram_usage(send_buffer_times, recording_enabled,
                        machine_time_step, receive_rate, n_keys):

        static_usage = (SYSTEM_BYTES_REQUIREMENT +
                        (ReverseIPTagMulticastSourceMachineVertex.
                         _CONFIGURATION_REGION_SIZE) +
                        get_recording_header_size(1) +
                        get_recording_data_constant_size(1) +
                        (ReverseIPTagMulticastSourceMachineVertex.
                         get_provenance_data_size(0)))
        per_timestep = (
            ReverseIPTagMulticastSourceMachineVertex.
            send_buffer_sdram_per_timestep(send_buffer_times, n_keys) +
            ReverseIPTagMulticastSourceMachineVertex.
            recording_sdram_per_timestep(machine_time_step, recording_enabled,
                                         receive_rate, send_buffer_times,
                                         n_keys))
        static_usage += per_timestep
        return VariableSDRAM(static_usage, per_timestep)