data.memory.pipelined

Pipelined memory class.


template <
    typename T,
    auto Depth,
    auto Banks,
    template <typename, auto> typename Memory = memory
    >
class pipelined_memory §source

A memory that is physically accessed over multiple clock cycles.

Parameters

  • typename T
    

    The type of data stored in the memory.

  • auto Depth
    

    Total number of elements stored in the memory.

  • auto Banks
    

    Number physical memories that the logical memory comprises.

  • template <typename, auto> typename Memory = memory
    

    Type of underlying memory to use.

Aliases

Methods

  • inline T read(pipelined_memory::addr_t addr) §source
    

    Read one element from the memory.

    Arguments

  • template <auto N>
    inline T[N] read_vec(pipelined_memory::addr_t[N] addresses) §source
    

    Read N elements from the memory.

    Parameters

    • auto N
      

      The number of elements to read.

    Arguments

  • inline void write(pipelined_memory::addr_t addr, T data) §source
    

    Write one value into the memory. Must not be called concurrently with other calls that may write to the memory.

    Arguments

  • template <auto N>
    inline 
    void write_vec(optional<pair<pipelined_memory::addr_t, T>>[N] writes) §source
    

    Write up to N values into the memory. Must not be called concurrently with other calls that may write to the memory. Throughput can be improved by de-duplicating writes to the same address before calling this method.

    Parameters

    • auto N
      

      The maximum number of elements to write.

    Arguments

  • template <auto BankUpdateRate = 1>
    inline 
    pair<T, T> atomically(pipelined_memory::addr_t addr, (T) -> T modify) §source
    

    Atomically read and write the memory. Returns both the old and new value for the specified element. Must not be called concurrently with other calls that may write to the memory. Note that modify may be called multiple times concurrently (one call site per bank).

    Parameters

    • auto BankUpdateRate = 1
      

      If a given thread accesses a given bank, then the next BankUpdateRate-1 threads must not access the same bank. This enables the implementation of modify to be pipelined.

    Arguments

    • pipelined_memory::addr_t addr
      

      Address of the element to read.

    • (T) -> T modify
      

      Function that accepts the value of the element read from the memory and returns a value to write into the memory at the same address.

  • template <auto N, auto BankUpdateRate = 1>
    inline 
    pair<T, T>[N]
    atomically_vec(
        optional<pipelined_memory::addr_t>[N] addresses,
        (T, index_t<N>) -> T modify
        ) §source
    

    Atomically read and write the memory up to N times. Returns both the old and new value for the specified elements. Must not be called concurrently with other calls that may write to the memory. Throughput can be improved by de-duplicating accesses to the same address before calling this method. Note that modify may be called multiple times concurrently (one call site per bank).

    Parameters

    • auto N
      
    • auto BankUpdateRate = 1
      

      If a given thread accesses a given bank, then the next BankUpdateRate-1 threads must not access the same bank. This enables the implementation of modify to be pipelined.

    Arguments

    • optional<pipelined_memory::addr_t>[N] addresses
      

      Addresses of the element to access.

    • (T, index_t<N>) -> T modify
      

      Function that accepts the value of an element read from the memory and an index of an element of the addresses array. This function returns a value to write into the memory at the same address.

  • template <typename Ctx>
    inline 
    Ctx
    bankwise_fold(
        pipelined_memory::addr_t addr,
        Ctx initial,
        (pair<T, Ctx>) -> pair<T, Ctx> combine
        ) §source
    

    Combine and update the set of all elements with a given offset with a bank according to a user-specified function. Must not be called concurrently with other calls that may write to the memory.

    Parameters

    • typename Ctx
      

      Context type passed to and returned from the combine function.

    Arguments

    • pipelined_memory::addr_t addr
      

      Logical address of one element within the memory. All elements that have matching offsets within banks are combined.

    • Ctx initial
      

      Context value passed to the first call to combine.

    • (pair<T, Ctx>) -> pair<T, Ctx> combine
      

      Combination function. Maps a previous value in the memory and the current context to a new value stored in the memory and a new context.

Invariants

  • (0 == (Depth % Banks))
    

    Elements must be evenly distributed among banks.

  • ((0 == (pipelined_memory::ElementsPerBank & (pipelined_memory::ElementsPerBank - 1))) || (Banks == 1))
    

    ElementsPerBank must be a power of 2 if there is more than 1 bank.