def _get_spike_send_buffer(self, vertex_slice): """ spikeArray is a list with one entry per 'neuron'. The entry for one neuron is a list of times (in ms) when the neuron fires. We need to transpose this 'matrix' and get a list of firing neuron indices for each time tick: List can come in two formats (both now supported): 1) Official PyNN format - single list that is used for all neurons 2) SpiNNaker format - list of lists, one per neuron """ send_buffer = None key = (vertex_slice.lo_atom, vertex_slice.hi_atom) if key not in self._send_buffers: send_buffer = BufferedSendingRegion() if isinstance(self._spike_times[0], list): # This is in SpiNNaker 'list of lists' format: for neuron in range(vertex_slice.lo_atom, vertex_slice.hi_atom + 1): for timeStamp in sorted(self._spike_times[neuron]): time_stamp_in_ticks = int( math.ceil((timeStamp * 1000.0) / self._machine_time_step)) send_buffer.add_key(time_stamp_in_ticks, neuron - vertex_slice.lo_atom) else: # This is in official PyNN format, all neurons use the # same list: neuron_list = range(vertex_slice.n_atoms) for timeStamp in sorted(self._spike_times): time_stamp_in_ticks = int( math.ceil((timeStamp * 1000.0) / self._machine_time_step)) # add to send_buffer collection send_buffer.add_keys(time_stamp_in_ticks, neuron_list) # Update the size total_size = 0 for timestamp in send_buffer.timestamps: n_keys = send_buffer.get_n_keys(timestamp) total_size += BufferManager.get_n_bytes(n_keys) total_size += EventStopRequest.get_min_packet_length() if total_size > self._max_on_chip_memory_usage_for_spikes: total_size = self._max_on_chip_memory_usage_for_spikes send_buffer.buffer_size = total_size self._send_buffers[key] = send_buffer else: send_buffer = self._send_buffers[key] return send_buffer
def _get_spike_send_buffer(self, vertex_slice): """ spikeArray is a list with one entry per 'neuron'. The entry for one neuron is a list of times (in ms) when the neuron fires. We need to transpose this 'matrix' and get a list of firing neuron indices for each time tick: List can come in two formats (both now supported): 1) Official PyNN format - single list that is used for all neurons 2) SpiNNaker format - list of lists, one per neuron """ send_buffer = None key = (vertex_slice.lo_atom, vertex_slice.hi_atom) if key not in self._send_buffers: send_buffer = BufferedSendingRegion() if isinstance(self._spike_times[0], list): # This is in SpiNNaker 'list of lists' format: for neuron in range(vertex_slice.lo_atom, vertex_slice.hi_atom + 1): for timeStamp in sorted(self._spike_times[neuron]): time_stamp_in_ticks = int( math.ceil((timeStamp * 1000.0) / self._machine_time_step)) send_buffer.add_key(time_stamp_in_ticks, neuron - vertex_slice.lo_atom) else: # This is in official PyNN format, all neurons use the # same list: neuron_list = range(vertex_slice.n_atoms) for timeStamp in sorted(self._spike_times): time_stamp_in_ticks = int( math.ceil( (timeStamp * 1000.0) / self._machine_time_step)) # add to send_buffer collection send_buffer.add_keys(time_stamp_in_ticks, neuron_list) # Update the size total_size = 0 for timestamp in send_buffer.timestamps: n_keys = send_buffer.get_n_keys(timestamp) total_size += BufferManager.get_n_bytes(n_keys) total_size += EventStopRequest.get_min_packet_length() if total_size > self._max_on_chip_memory_usage_for_spikes: total_size = self._max_on_chip_memory_usage_for_spikes send_buffer.buffer_size = total_size self._send_buffers[key] = send_buffer else: send_buffer = self._send_buffers[key] return send_buffer