Example #1
0
    def __init__(self,
                 resources_required,
                 is_recording,
                 minimum_buffer_sdram_usage,
                 buffered_sdram_per_timestep,
                 label,
                 constraints=None,
                 overflow_sdram=0):
        """

        :param resources_required:
        :param is_recording:
        :param minimum_buffer_sdram_usage:
        :param buffered_sdram_per_timestep:
        :param label:
        :param constraints:
        :param overflow_sdram: Extra sdram that may be required if
            buffered_sdram_per_timestep is an average
        :type sampling: bool
        """
        MachineVertex.__init__(self, label, constraints)
        AbstractRecordable.__init__(self)
        self._is_recording = is_recording
        self._resources = resources_required
        self._minimum_buffer_sdram_usage = minimum_buffer_sdram_usage
        self._buffered_sdram_per_timestep = buffered_sdram_per_timestep
        self._overflow_sdram = overflow_sdram
    def __init__(
            self,
            data,
            fs,
            resample_factor,
            data_partition_name="IHCANData",
            acknowledge_partition_name="IHCANDataAck"):  #TODO:add Fs to params

        MachineVertex.__init__(self, label="IHCAN Node", constraints=None)

        self._data = data[0]
        self._data_partition_name = data_partition_name
        self._acknowledge_partition_name = acknowledge_partition_name
        self._fs = fs
        self._data_size = ((len(self._data) * self._DATA_ELEMENT_TYPE.size) +
                           self._DATA_COUNT_TYPE.size)
        self._sdram_usage = (self._N_PARAMETER_BYTES + self._data_size)
        self._resample_factor = resample_factor
        self._fs = fs
        self._num_data_points = 2 * len(
            self._data
        )  # num of points is double previous calculations due to 2 fibre output of IHCAN model
        self._recording_size = (self._num_data_points / self._resample_factor
                                ) * 4  #numpy.ceil(self._num_data_points/32.0)#
        self._placement = list()
Example #3
0
 def __init__(self, resources_required, constraints=None, label=None):
     # Superclasses
     MachineVertex.__init__(self, label,
                            constraints=constraints)
     # ProvidesProvenanceDataFromMachineImpl.__init__(
     #     self, self._BREAKOUT_REGIONS.PROVENANCE.value, 0)
     self._resource_required = resources_required
    def __init__(self, vertex_slice, resources_required, constraints, label,
                 app_vertex, truth_table, input_sequence, rate_on, rate_off,
                 score_delay, stochastic, incoming_spike_buffer_size,
                 simulation_duration_ms, rand_seed):

        # resources required
        self._resources_required = ResourceContainer(
            sdram=ConstantSDRAM(resources_required))

        # **NOTE** n_neurons currently ignored - width and height will be
        # specified as additional parameters, forcing their product to be
        # duplicated in n_neurons seems pointless

        self._label = label

        # Pass in variables
        self._truth_table = truth_table
        self._rate_on = rate_on
        self._rate_off = rate_off
        self._stochastic = stochastic
        self._input_sequence = input_sequence
        self._no_inputs = len(input_sequence)

        self._n_neurons = self._no_inputs
        self._rand_seed = rand_seed

        self._score_delay = score_delay

        # used to define size of recording region
        self._recording_size = int((simulation_duration_ms / 1000.) * 4)

        # Superclasses
        MachineVertex.__init__(self, label, constraints, app_vertex,
                               vertex_slice)
Example #5
0
 def __init__(self, partition_identifier, filter, row_id, constraints=None):
     label = "retina filter for row {}".format(row_id)
     MachineVertex.__init__(self, label, constraints)
     MachineDataSpecableVertex.__init__(self)
     AbstractHasAssociatedBinary.__init__(self)
     AbstractProvidesOutgoingPartitionConstraints.__init__(self)
     self._partition_identifier = partition_identifier
     self._filter = filter
     self._row_id = row_id
 def __init__(self, resources_required, recorded_region_ids, label,
              constraints):
     """
     :param resources_required:
     :param recorded_region_ids:
     :param label:
     :param constraints:
     :type sampling: bool
     """
     MachineVertex.__init__(self, label, constraints)
     AbstractRecordable.__init__(self)
     self.__recorded_region_ids = recorded_region_ids
     self.__resources = resources_required
 def __init__(
         self, resources_required, recorded_region_ids, label, constraints):
     """
     :param resources_required:
     :param recorded_region_ids:
     :param label:
     :param constraints:
     :type sampling: bool
     """
     MachineVertex.__init__(self, label, constraints)
     AbstractRecordable.__init__(self)
     self._recorded_region_ids = recorded_region_ids
     self._resources = resources_required
 def __init__(self,
              resources_required,
              is_recording,
              minimum_buffer_sdram,
              buffered_sdram_per_timestep,
              constraints=None,
              label=None):
     MachineVertex.__init__(self, label, constraints=constraints)
     AbstractRecordable.__init__(self)
     self._is_recording = is_recording
     self._resources = resources_required
     self._minimum_buffer_sdram = minimum_buffer_sdram
     self._buffered_sdram_per_timestep = buffered_sdram_per_timestep
    def __init__(
            self, cf, fs, n_data_points, drnl_index, profile, seq_size,
            synapse_manager, parent, n_buffers_in_sdram_total,
            neuron_recorder, timer_period):
        """ builder of the drnl machine vertex

        :param cf: ????????
        :param fs: sampling freequency of the OME
        :param n_data_points: the number of elements.....
        :param drnl_index:  the index in the list of drnls (used for slices)
        :param profile: bool flag saying if this vertex is set to profile
        :param seq_size: the size of a block
        :param synapse_manager: the synaptic manager
        :param parent: the app vertex
        :param n_buffers_in_sdram_total: the number of buffers in sequence in\
         the sdram edge
        :param neuron_recorder: the recorder for moc
        :param timer_period: the timer period of this core
        """

        MachineVertex.__init__(
            self, label="DRNL Node of {}".format(drnl_index), constraints=None)
        AbstractEarProfiled.__init__(self, profile, self.REGIONS.PROFILE.value)
        AbstractProvidesNKeysForPartition.__init__(self)

        # storage for the synapse manager locations
        self.__on_chip_generatable_offset = None
        self.__on_chip_generatable_size = None

        self._cf = cf
        self._fs = fs
        self._drnl_index = drnl_index
        self._seq_size = seq_size
        self._synapse_manager = synapse_manager
        self._parent = parent
        self._n_buffers_in_sdram_total = n_buffers_in_sdram_total
        self._neuron_recorder = neuron_recorder
        self._timer_period = timer_period

        self._sdram_edge_size = (
            self._n_buffers_in_sdram_total * self._seq_size *
            DataType.FLOAT_64.size)

        self._num_data_points = n_data_points

        # recording size
        self._recording_size_per_sim_time_step = (
            DataType.FLOAT_64.size * self.MOC_BUFFER_SIZE)

        # filter params
        self._filter_params = self._calculate_filter_parameters()
Example #10
0
    def __init__(self, label, constraints, n_samples_per_recording,
                 sampling_frequency):
        """ constructor for idle power monitor c code for machine graphs

        :param label: vertex label
        :param constraints: constraints on this vertex
        :param n_samples_per_recording: how may samples between recording entry
        :type n_samples_per_recording: int
        :param sampling_frequency: how often to sample
        :type sampling_frequency: microseconds
        """
        MachineVertex.__init__(self, label=label, constraints=constraints)
        self._n_samples_per_recording = n_samples_per_recording
        self._sampling_frequency = sampling_frequency
    def __init__(self, resample_factor, seed, n_fibres, ear_index, profile, fs,
                 n_lsr, n_msr, n_hsr, n_buffers_in_sdram_total, seq_size,
                 ihcan_neuron_recorder, ihcan_atom_slice, timer_period):
        """ constructor

        :param resample_factor: resample factor
        :param seed: the seed used for its random number generator in SpiNNaker
        :param n_fibres: how many fibres to simulate
        :param ear_index: which ear its based on
        :param profile: bool flag for profiling
        :param fs: sample freq
        :param n_lsr: number of low freq hair cells
        :param n_msr: number of med freq hair cells
        :param n_hsr: number of high freq hair cells
        :param n_buffers_in_sdram_total: the total number of sdram buffers in \
        the sdram edge
        :param seg_size: the seq size
        :param ihcan_neuron_recorder: recorder for the ihcan recordings
        :param ihcan_atom_slice: the slice of atoms for the ihcan vertex from \
        the global.
        """

        MachineVertex.__init__(self, label="IHCAN Node", constraints=None)
        AbstractProvidesNKeysForPartition.__init__(self)
        AbstractEarProfiled.__init__(self, profile, self.REGIONS.PROFILE.value)
        ProvidesProvenanceDataFromMachineImpl.__init__(self)
        AbstractHasAssociatedBinary.__init__(self)
        AbstractGeneratesDataSpecification.__init__(self)
        AbstractReceiveBuffersToHost.__init__(self)

        self._ihcan_neuron_recorder = ihcan_neuron_recorder
        self._ihcan_recording_atom_slice = ihcan_atom_slice
        self._ear_index = ear_index

        self._re_sample_factor = resample_factor
        self._fs = fs
        self._dt = 1.0 / self._fs
        self._n_atoms = n_fibres
        self._n_buffers_in_sdram_total = n_buffers_in_sdram_total
        self._seq_size = seq_size
        self._timer_period = timer_period

        if n_lsr + n_msr + n_hsr > n_fibres:
            raise Exception(
                self.N_FIBRES_ERROR.format(n_fibres, n_lsr, n_msr, n_hsr))

        self._n_lsr = n_lsr
        self._n_msr = n_msr
        self._n_hsr = n_hsr
        self._seed = seed
    def __init__(self, vertex_slice, resources_required, constraints, label,
                 app_vertex, encoding, time_increment, pole_length, pole_angle,
                 reward_based, force_increments, max_firing_rate,
                 number_of_bins, central, bin_overlap, tau_force,
                 incoming_spike_buffer_size, simulation_duration_ms,
                 rand_seed):

        # Resources required
        self._resource_required = ResourceContainer(
            sdram=ConstantSDRAM(resources_required))

        # **NOTE** n_neurons currently ignored - width and height will be
        # specified as additional parameters, forcing their product to be
        # duplicated in n_neurons seems pointless

        self._label = label

        self._encoding = encoding

        # Pass in variables
        self._pole_length = pole_length
        self._pole_angle = pole_angle

        self._force_increments = force_increments
        # for rate based it's only 1 neuron per metric
        # (position, angle, velocity of both)
        if self._encoding == 0:
            self._n_neurons = 4
        else:
            self._n_neurons = 4 * number_of_bins

        self._time_increment = time_increment
        self._reward_based = reward_based

        self._max_firing_rate = max_firing_rate
        self._number_of_bins = number_of_bins
        self._central = central
        self._rand_seed = rand_seed
        self._bin_overlap = bin_overlap
        self._tau_force = tau_force

        # used to define size of recording region
        self._recording_size = int((simulation_duration_ms / 1000.) * 4)

        # Superclasses
        MachineVertex.__init__(self, label, constraints, app_vertex,
                               vertex_slice)
    def __init__(self, label, state):
        MachineVertex.__init__(self, label)

        config = globals_variables.get_simulator().config
        self._buffer_size_before_receive = None
        if config.getboolean("Buffers", "enable_buffered_recording"):
            self._buffer_size_before_receive = config.getint(
                "Buffers", "buffer_size_before_receive")
        self._time_between_requests = config.getint("Buffers",
                                                    "time_between_requests")
        self._receive_buffer_host = config.get("Buffers",
                                               "receive_buffer_host")
        self._receive_buffer_port = helpful_functions.read_config_int(
            config, "Buffers", "receive_buffer_port")

        # app specific data items
        self._state = state
    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):
        # inheritance
        MachineVertex.__init__(self, 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="LPG_EVENT_STREAM")
            ])

        # 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
Example #15
0
    def __init__(self, vertex, model):
        """
        :param vertex: The MCMC vertex associated with this vertex
        :param model: The model being simulated
        """

        MachineVertex.__init__(self, label="MCMC RF Node", constraints=None)
        self._vertex = vertex
        self._model = model

        vertex.coordinator.register_processor(self)

        # Other parameters need to be added here
        self._n_other_params = 1

        self._n_parameter_bytes = self._n_other_params * 4

        self._sdram_usage = (self._n_parameter_bytes)
Example #16
0
    def __init__(self, label, constraints=None):
        MachineVertex.__init__(self, label=label, constraints=constraints)

        config = globals_variables.get_simulator().config
        self._buffer_size_before_receive = None
        if config.getboolean("Buffers", "enable_buffered_recording"):
            self._buffer_size_before_receive = config.getint(
                "Buffers", "buffer_size_before_receive")
        self._time_between_requests = config.getint("Buffers",
                                                    "time_between_requests")
        self._receive_buffer_host = config.get("Buffers",
                                               "receive_buffer_host")
        self._receive_buffer_port = helpful_functions.read_config_int(
            config, "Buffers", "receive_buffer_port")

        self._string_data_size = 5000

        self.placement = None
Example #17
0
    def __init__(self, coordinator, model,
                 parameter_partition_name="MCMCParameter",
                 result_partition_name="MCMCResultAck",
                 cholesky_partition_name="MCMCCholeskyParameter",
                 cholesky_result_partition_name="MCMCCholeskyResultAck"):
        """

        :param coordinator: The coordinator vertex
        :param model: The model being simulated
        """

        MachineVertex.__init__(self, label="MCMC Node", constraints=None)
        self._coordinator = coordinator
        self._model = model
        self._parameter_partition_name = parameter_partition_name
        self._result_partition_name = result_partition_name
        self._cholesky_partition_name = cholesky_partition_name
        self._cholesky_result_partition_name = cholesky_result_partition_name

        self._coordinator.register_processor(self)

        state = self._get_model_state_array()
        self._recording_size = self._coordinator.n_samples * len(state) * 4

        params = self._get_model_parameters_array()

        # The number of bytes for the parameters
        # (11 * uint32) + (5 * seed array) + (1 * d.o.f.)
        self._n_parameter_bytes = 0
        if (model.get_parameters()[0].data_type is numpy.float64):
            self._n_parameter_bytes = (11 * 4) + (5 * 4) + (1 * 8)
        else:
            self._n_parameter_bytes = (11 * 4) + (5 * 4) + (1 * 4)

        self._sdram_usage = (
            self._n_parameter_bytes + self._recording_size +
            recording_utilities.get_recording_header_size(1) +
            (len(params) * 4)
            )

        self._data_receiver = dict()
        self._cholesky_data_receiver = dict()
Example #18
0
    def __init__(self,
                 label,
                 columns,
                 rows,
                 string_size,
                 num_string_cols,
                 entries,
                 initiate,
                 function_id,
                 state,
                 constraints=None):
        MachineVertex.__init__(self, label=label, constraints=constraints)

        config = globals_variables.get_simulator().config
        self._buffer_size_before_receive = None
        if config.getboolean("Buffers", "enable_buffered_recording"):
            self._buffer_size_before_receive = config.getint(
                "Buffers", "buffer_size_before_receive")
        self._time_between_requests = config.getint("Buffers",
                                                    "time_between_requests")
        self._receive_buffer_host = config.get("Buffers",
                                               "receive_buffer_host")
        self._receive_buffer_port = helpful_functions.read_config_int(
            config, "Buffers", "receive_buffer_port")
        '''
        all the data that will be transfered to the vertex'''
        self.columns = columns
        self.rows = rows
        self.string_size = string_size
        self.num_string_cols = num_string_cols
        self.entries = entries
        self.initiate = initiate
        self.function_id = function_id
        '''
        allocate space for entries and 24 bytes for the 6 integers that make up the header information'''
        self._input_data_size  = (string_size * rows * num_string_cols) + \
                                 (4           * rows * (columns - num_string_cols)) + 28
        self._output_data_size = 10 * 1000

        # app specific elements
        self.placement = None
        self.state = state
    def __init__(self,
                 label,
                 machine_time_step,
                 time_scale_factor,
                 heat_temperature=0,
                 constraints=None):

        config = globals_variables.get_simulator().config
        # resources used by a heat element vertex
        sdram = SDRAMResource(23 +
                              config.getint("Buffers", "minimum_buffer_sdram"))
        self._resources = \
            ResourceContainer(cpu_cycles=CPUCyclesPerTickResource(45),
                              dtcm=DTCMResource(34), sdram=sdram)

        MachineVertex.__init__(self, label=label, constraints=constraints)

        # app specific data items
        self._heat_temperature = heat_temperature
        self._time_between_requests = config.getint("Buffers",
                                                    "time_between_requests")
Example #20
0
    def __init__(self, vertex_slice, resources_required, constraints, label,
                 app_vertex, arms, reward_delay, reward_based, rate_on,
                 rate_off, stochastic, constant_input,
                 incoming_spike_buffer_size, simulation_duration_ms,
                 rand_seed):

        # Resources required
        self._resource_required = ResourceContainer(
            sdram=ConstantSDRAM(resources_required))

        # **NOTE** n_neurons currently ignored - width and height will be
        # specified as additional parameters, forcing their product to be
        # duplicated in n_neurons seems pointless

        self._label = label

        # Pass in variables
        arms_list = []
        for arm in arms:
            arms_list.append(numpy.uint32(arm*0xffffffff))
        self._arms = arms_list

        self._no_arms = len(arms)
        self._n_neurons = self._no_arms
        self._rand_seed = rand_seed

        self._reward_delay = reward_delay
        self._reward_based = reward_based

        self._rate_on = rate_on
        self._rate_off = rate_off
        self._stochastic = stochastic
        self._constant_input = constant_input

        # used to define size of recording region
        self._recording_size = int((simulation_duration_ms / 1000.) * 4)

        # Superclasses
        MachineVertex.__init__(
            self, label, constraints, app_vertex, vertex_slice)
Example #21
0
    def __init__(self,
                 x,
                 y,
                 r,
                 n_particles,
                 batch_size,
                 label,
                 part_id,
                 main_particle,
                 constraints=None):
        MachineVertex.__init__(self, label=label, constraints=constraints)

        AbstractProvidesNKeysForPartition.__init__(self)

        self._x = x
        self._y = y
        self._r = r
        self._n_particles = n_particles
        self._batch_size = batch_size
        self._placement = None
        self._part_id = part_id
        self._main = main_particle
    def __init__(self, vertex_slice, resources_required, constraints, label,
                 app_vertex, x_factor, y_factor, width, height, colour_bits,
                 incoming_spike_buffer_size, simulation_duration_ms, bricking,
                 random_seed):
        # **NOTE** n_neurons currently ignored - width and height will be
        # specified as additional parameters, forcing their product to be
        # duplicated in n_neurons seems pointless

        self._resources_required = ResourceContainer(
            sdram=ConstantSDRAM(resources_required))

        self._label = label
        self._x_factor = x_factor
        self._y_factor = y_factor
        self._width = width / x_factor
        self._height = height / y_factor
        self._colour_bits = colour_bits
        self._width_bits = numpy.uint32(numpy.ceil(numpy.log2(self._width)))
        self._height_bits = numpy.uint32(numpy.ceil(numpy.log2(self._height)))

        self._n_neurons = (
            1 << (self._width_bits + self._height_bits + self._colour_bits))
        self._bricking = bricking
        self._rand_seed = random_seed

        # print self._rand_seed
        # print "# width =", self._width
        # print "# width bits =", self._width_bits
        # print "# height =", self._height
        # print "# height bits =", self._height_bits
        # print "# neurons =", self._n_neurons

        # Define size of recording region
        self._recording_size = int((simulation_duration_ms / 10000.) * 4)

        # Superclasses
        MachineVertex.__init__(self, label, constraints, app_vertex,
                               vertex_slice)
Example #23
0
    def __init__(self,
                 data,
                 fs,
                 n_channels,
                 seq_size,
                 timer_period,
                 profile=False):
        """ constructor for OME vertex

        :param data: the input data
        :param fs: the sampling freq
        :param n_channels: how many channels to process
        :param profile: bool stating if profiling or now
        """

        MachineVertex.__init__(self, label="OME Node", constraints=None)
        AbstractProvidesNKeysForPartition.__init__(self)
        AbstractEarProfiled.__init__(self, profile, self.REGIONS.PROFILE.value)
        AbstractMachineSupportsAutoPauseAndResume.__init__(self)

        self._data = data
        self._fs = fs
        self._n_channels = n_channels
        self._seq_size = seq_size

        # size then list of doubles
        self._data_size = ((len(self._data) * DataType.FLOAT_64.size) +
                           DataType.UINT32.size)

        # write timer period
        self._timer_period = timer_period

        # calculate stapes hpf coefficients
        wn = 1.0 / self._fs * 2.0 * self.MAGIC_TWO

        # noinspection PyTypeChecker
        [self._shb, self._sha] = sig.butter(2, wn, 'high')
Example #24
0
 def __init__(self, resources_required, recorded_region_ids, label,
              constraints, app_vertex, vertex_slice, drop_late_spikes,
              binary_file_name):
     """
     :param ~pacman.model.resources.ResourceContainer resources_required:
     :param iterable(int) recorded_region_ids:
     :param str label:
     :param bool drop_late_spikes: control flag for dropping packets.
     :param list(~pacman.model.constraints.AbstractConstraint) constraints:
     :param AbstractPopulationVertex app_vertex:
         The associated application vertex
     :param ~pacman.model.graphs.common.Slice vertex_slice:
         The slice of the population that this implements
     @param str binary_file_name: binary name to be run for this verte
     """
     MachineVertex.__init__(self, label, constraints, app_vertex,
                            vertex_slice)
     self.__binary_file_name = binary_file_name
     AbstractRecordable.__init__(self)
     self.__recorded_region_ids = recorded_region_ids
     self.__resources = resources_required
     self.__drop_late_spikes = drop_late_spikes
     self.__on_chip_generatable_offset = None
     self.__on_chip_generatable_size = None
    def __init__(self, vertex_slice, resources_required, constraints, label,
                 app_vertex, rate_on, rate_off, pop_size, prob_command,
                 prob_in_change, time_period, stochastic, reward,
                 incoming_spike_buffer_size, simulation_duration_ms,
                 rand_seed):

        # Resources required
        self._resource_required = ResourceContainer(
            sdram=ConstantSDRAM(resources_required))

        # **NOTE** n_neurons currently ignored - width and height will be
        # specified as additional parameters, forcing their product to be
        # duplicated in n_neurons seems pointless

        self._label = label

        # Pass in variables
        self._rate_on = rate_on
        self._rate_off = rate_off
        self._stochastic = stochastic
        self._reward = reward
        self._pop_size = pop_size
        self._prob_command = prob_command
        self._prob_in_change = prob_in_change

        self._n_neurons = pop_size * 4
        self._rand_seed = rand_seed

        self._time_period = time_period

        # used to define size of recording region
        self._recording_size = int((simulation_duration_ms / 1000.) * 4)

        # Superclasses
        MachineVertex.__init__(self, label, constraints, app_vertex,
                               vertex_slice)
    def __init__(
        self,
        n_keys,
        label,
        constraints=None,

        # General input and output parameters
        board_address=None,

        # Live input parameters
        receive_port=None,
        receive_sdp_port=(constants.SDP_PORTS.INPUT_BUFFERING_SDP_PORT.value),
        receive_tag=None,
        receive_rate=10,

        # Key parameters
        virtual_key=None,
        prefix=None,
        prefix_type=None,
        check_keys=False,

        # Send buffer parameters
        send_buffer_times=None,
        send_buffer_partition_id=None,
        send_buffer_max_space=(constants.MAX_SIZE_OF_BUFFERED_REGION_ON_CHIP),
        send_buffer_space_before_notify=640,

        # Buffer notification details
        buffer_notification_ip_address=None,
        buffer_notification_port=None,
        buffer_notification_tag=None,

        # Extra flag for receiving packets without a port
        reserve_reverse_ip_tag=False):
        """

        :param n_keys: The number of keys to be sent via this multicast source
        :param label: The label of this vertex
        :param constraints: Any initial constraints to this vertex
        :param board_address: The IP address of the board on which to place\
                this vertex if receiving data, either buffered or live (by\
                default, any board is chosen)
        :param receive_port: The port on the board that will listen for\
                incoming event packets (default is to disable this feature;\
                set a value to enable it)
        :param receive_sdp_port: The SDP port to listen on for incoming event\
                packets (defaults to 1)
        :param receive_tag: The IP tag to use for receiving live events\
                (uses any by default)
        :param virtual_key: The base multicast key to send received events\
                with (assigned automatically by default)
        :param prefix: The prefix to "or" with generated multicast keys\
                (default is no prefix)
        :param prefix_type: Whether the prefix should apply to the upper or\
                lower half of the multicast keys (default is upper half)
        :param check_keys: True if the keys of received events should be\
                verified before sending (default False)
        :param send_buffer_times: An array of arrays of times at which keys\
                should be sent (one array for each key, default disabled)
        :param send_buffer_max_space: The maximum amount of space to use of\
                the SDRAM on the machine (default is 1MB)
        :param send_buffer_space_before_notify: The amount of space free in\
                the sending buffer before the machine will ask the host for\
                more data (default setting is optimised for most cases)
        :param buffer_notification_ip_address: The IP address of the host\
                that will send new buffers (must be specified if a send buffer\
                is specified)
        :param buffer_notification_port: The port that the host that will\
                send new buffers is listening on (must be specified if a\
                send buffer is specified)
        :param buffer_notification_tag: The IP tag to use to notify the\
                host about space in the buffer (default is to use any tag)
        """
        MachineVertex.__init__(self, label, constraints)
        AbstractReceiveBuffersToHost.__init__(self)

        AbstractProvidesOutgoingPartitionConstraints.__init__(self)

        self._iptags = None
        self._reverse_iptags = None

        # Set up for receiving live packets
        if receive_port is not None or reserve_reverse_ip_tag:
            self._reverse_iptags = [
                ReverseIPtagResource(port=receive_port,
                                     sdp_port=receive_sdp_port,
                                     tag=receive_tag)
            ]
            if board_address is not None:
                self.add_constraint(BoardConstraint(board_address))
        self._receive_rate = receive_rate
        self._receive_sdp_port = receive_sdp_port

        # Work out if buffers are being sent
        self._send_buffer = None
        self._send_buffer_partition_id = send_buffer_partition_id
        if send_buffer_times is None:
            self._send_buffer_times = None
            self._send_buffer_max_space = send_buffer_max_space
            self._send_buffers = None
        else:
            self._send_buffer_max_space = send_buffer_max_space
            self._send_buffer = BufferedSendingRegion(send_buffer_max_space)
            self._send_buffer_times = send_buffer_times

            self._iptags = [
                IPtagResource(ip_address=buffer_notification_ip_address,
                              port=buffer_notification_port,
                              strip_sdp=True,
                              tag=buffer_notification_tag,
                              traffic_identifier=TRAFFIC_IDENTIFIER)
            ]
            if board_address is not None:
                self.add_constraint(BoardConstraint(board_address))
            self._send_buffers = {
                self._REGIONS.SEND_BUFFER.value: self._send_buffer
            }

        # buffered out parameters
        self._send_buffer_space_before_notify = send_buffer_space_before_notify
        if self._send_buffer_space_before_notify > send_buffer_max_space:
            self._send_buffer_space_before_notify = send_buffer_max_space

        # Set up for recording (if requested)
        self._record_buffer_size = 0
        self._buffer_size_before_receive = 0
        self._time_between_triggers = 0
        self._maximum_recording_buffer = 0

        # Set up for buffering
        self._buffer_notification_ip_address = buffer_notification_ip_address
        self._buffer_notification_port = buffer_notification_port
        self._buffer_notification_tag = buffer_notification_tag

        # set flag for checking if in injection mode
        self._in_injection_mode = receive_port is not None

        # Sort out the keys to be used
        self._n_keys = n_keys
        self._virtual_key = virtual_key
        self._mask = None
        self._prefix = prefix
        self._prefix_type = prefix_type
        self._check_keys = check_keys

        # Work out the prefix details
        if self._prefix is not None:
            if self._prefix_type is None:
                self._prefix_type = EIEIOPrefix.UPPER_HALF_WORD
            if self._prefix_type == EIEIOPrefix.UPPER_HALF_WORD:
                self._prefix = prefix << 16

        # If the user has specified a virtual key
        if self._virtual_key is not None:

            # check that virtual key is valid
            if self._virtual_key < 0:
                raise ConfigurationException("Virtual keys must be positive")

            # Get a mask and maximum number of keys for the number of keys
            # requested
            self._mask, max_key = self._calculate_mask(n_keys)

            # Check that the number of keys and the virtual key don't interfere
            if n_keys > max_key:
                raise ConfigurationException(
                    "The mask calculated from the number of keys will "
                    "not work with the virtual key specified")

            if self._prefix is not None:

                # Check that the prefix doesn't change the virtual key in the
                # masked area
                masked_key = (self._virtual_key | self._prefix) & self._mask
                if self._virtual_key != masked_key:
                    raise ConfigurationException(
                        "The number of keys, virtual key and key prefix"
                        " settings don't work together")
            else:

                # If no prefix was generated, generate one
                self._prefix_type = EIEIOPrefix.UPPER_HALF_WORD
                self._prefix = self._virtual_key
 def __init__(self, label=None, constraints=None):
     MachineVertex.__init__(self, label=label, constraints=constraints)
     AbstractProvidesOutgoingPartitionConstraints.__init__(self)
 def __init__(self):
     MachineVertex.__init__(self)
Example #29
0
    def __init__(self, label, state):

        MachineVertex.__init__(self, label)

        # app specific elements
        self._state = state
 def __init__(self, resources_required, label, constraints=None):
     MachineVertex.__init__(
         self, label, constraints=constraints)
     self._resources = resources_required
    def __init__(self,
                 model,
                 data,
                 n_samples,
                 burn_in,
                 thinning,
                 degrees_of_freedom,
                 seed=None,
                 send_timer=1000,
                 receive_timer=1000,
                 window_size=1024,
                 n_sequences=2048,
                 data_partition_name="MCMCData",
                 acknowledge_partition_name="MCMCDataAck",
                 data_tag=1):
        """

        :param model: The model being simulated
        :param data: The data to sample
        :param n_samples: The number of samples to generate
        :param burn_in:\
            no of MCMC transitions to reach apparent equilibrium before\
            generating inference samples
        :param thinning:\
            sampling rate i.e. 5 = 1 sample for 5 generated steps
        :param degrees_of_freedom:\
            The number of degrees of freedom to jump around with
        :param seed: The random seed to use
        """

        MachineVertex.__init__(self, label="MCMC Node", constraints=None)
        self._model = model
        self._data = data
        self._n_samples = n_samples
        self._burn_in = burn_in
        self._thinning = thinning
        self._degrees_of_freedom = degrees_of_freedom
        self._seed = seed
        self._send_timer = send_timer
        self._receive_timer = receive_timer
        self._window_size = window_size
        self._n_sequences = n_sequences
        self._data_partition_name = data_partition_name
        self._acknowledge_partition_name = acknowledge_partition_name
        self._data_tag = data_tag

        # The data type of each data element
        if (self._model.get_parameters()[0].data_type is numpy.float64):
            self._data_element_type = DataType.FLOAT_64
        elif (self._model.get_parameters()[0].data_type is numpy.float32):
            self._data_element_type = DataType.FLOAT_32
        elif (self._model.get_parameters()[0].data_type is DataType.S1615):
            self._data_element_type = DataType.S1615

        # The numpy data type of each data element
        if (self._model.get_parameters()[0].data_type is numpy.float64):
            self._numpy_data_element_type = numpy.float64
        elif (self._model.get_parameters()[0].data_type is numpy.float32):
            self._numpy_data_element_type = numpy.float32
        elif (self._model.get_parameters()[0].data_type is DataType.S1615):
            self._numpy_data_element_type = numpy.uint32

        self._data_size = ((len(self._data) * self._data_element_type.size) +
                           self._DATA_COUNT_TYPE.size)
        self._sdram_usage = (self._N_PARAMETER_BYTES + self._data_size)

        self._mcmc_vertices = list()
        self._mcmc_placements = list()
        self._data_receiver = dict()