data.buffer.accumulating


template <
    typename T,
    auto Size,
    auto BufferCount,
    auto InputSize = Size,
    template <typename, auto> typename Container = memory,
    bool ResetWithInitialValues = false,
    auto FlitCount = 1
    >
class multi_accumulating_buffer §

An array of buffers, each of which accumulates a given number of entries and returns them once a specified number are enqueued or when a call to enqueue explicitly requests that the buffered values be flushed.

Parameters

  • typename T
    

    Type of values stored in the accumulating buffer.

  • auto Size
    

    Maximum number of elements that can be stored in each buffer.

  • auto BufferCount
    

    The number of buffers.

  • auto InputSize = Size
    

    Maximum number of elements that can be appended to a buffer in one call.

  • template <typename, auto> typename Container = memory
    

    Template used to store buffer metadata and data.

  • bool ResetWithInitialValues = false
    

    Reset the buffer metadata with initial values. If false, then the metadata will be reset with a [[reset]] function.

  • auto FlitCount = 1
    

    Number of calls to the output callback for each Size elements.

Aliases

  • using buffer_index_t = index_t<BufferCount> §
    
  • using input_vec_t = vector<T, InputSize> §
    

Types

  • struct output §
    

    Return type for enqueue.

    Fields

    • count_t<Size> value_count §
      

      The number of valid elements in the output.

    • T[Size] values §
      

      Output values.

    • bool empty §
      

      Flag to indicate whether accumulating_buffer is now empty.

Methods

  • multi_accumulating_buffer::output
    enqueue(
        multi_accumulating_buffer::buffer_index_t buffer_index,
        T[InputSize] values,
        count_t<InputSize> value_count,
        bool flush
        ) §
    

    Write up to InputSize values to a buffer. If there is now a full flit of accumulated data associated with the specified buffer then the return structure will contain that flit. A caller can also explicitly retrieve a partial flit by setting the flush parameter to true. Returns an output in which up to Size values are valid (at most a single flit).

    Arguments

    • multi_accumulating_buffer::buffer_index_t buffer_index
      
    • T[InputSize] values
      

      Values to enqueue.

    • count_t<InputSize> value_count
      

      The number of entries in the values array that are valid. Must be between 0 and InputSize, inclusive.

    • bool flush
      

      If true, return up to Size elements, even if the buffer is not yet full.

  • inline 
    void
    enqueue_with_callback(
        multi_accumulating_buffer::buffer_index_t buffer_index,
        multi_accumulating_buffer::input_vec_t values,
        bool flush,
        ( index_t<FlitCount>, count_t<FlitCount>, vector<T, Size>
        ) -> void output_callback
        ) §
    

    Write up to InputSize values to a buffer. Once FlitCount flits are accumulated for a given buffer then output_callback is called once per accumulated flit.

    Arguments

    • multi_accumulating_buffer::buffer_index_t buffer_index
      

      Which buffer to append to.

    • multi_accumulating_buffer::input_vec_t values
      

      Values to enqueue.

    • bool flush
      

      If true, then call the callback for all buffer values associated with the buffer identified by buffer_index. The caller must ensure that the number of buffered elements + values.size <= FlitCount * Size when true.

    • ( index_t<FlitCount>, count_t<FlitCount>, vector<T, Size>
      ) -> void output_callback
      

      Function which is called once per output flit.

Invariants

  • (InputSize <= Size)
    

    A single call cannot appened more than Size elements.

template <typename T, auto Size, auto InputSize = Size, auto FlitCount = 1>
class accumulating_buffer §

A buffer that accumulates elements into flits (fixed-sized arrays of elements).

Parameters

  • typename T
    

    Type of values stored in the accumulating buffer.

  • auto Size
    

    Maximum number of elements that can be stored in a flit.

  • auto InputSize = Size
    

    Maximum number of elements that can be appended to the buffer in one call.

  • auto FlitCount = 1
    

    Maximum number of flits that can be stored. The output callback is called once for each Size elements.

Aliases

Methods

  • accumulating_buffer::output
    enqueue(T[InputSize] values, count_t<InputSize> value_count, bool flush) §
    

    Write up to InputSize values to the buffer. If there are now full flit of buffered data then the return structure will contain that flit. A caller can also explicitly retrieve a partial flit by setting the flush parameter to true. Returns an output in which up to Size values are valid (at most a single flit).

    Arguments

    • T[InputSize] values
      

      An array of values to enqueue.

    • count_t<InputSize> value_count
      

      The number of entries in the values array that are valid. Must be between 0 and InputSize, inclusive.

    • bool flush
      

      If true, return up to Size elements, even if the buffer is not yet full.

  • inline 
    void
    enqueue_with_callback(
        accumulating_buffer::input_vec_t values,
        bool flush,
        ( index_t<FlitCount>, count_t<FlitCount>, vector<T, Size>
        ) -> void output_callback
        ) §
    

    Write up to InputSize values to the buffer. Once FlitCount flits are accumulated then output_callback is called once per accumulated flit.

    Arguments

    • accumulating_buffer::input_vec_t values
      

      Values to enqueue.

    • bool flush
      

      If true, then call the callback for all buffer values associated with the buffer identified by buffer_index.

    • ( index_t<FlitCount>, count_t<FlitCount>, vector<T, Size>
      ) -> void output_callback
      

      Function which is called once per output flit.

Invariants

  • (InputSize <= Size)
    

    A single call cannot appened more than Size elements.