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 TThe type of data stored in the memory.
-
auto DepthTotal number of elements stored in the memory.
-
auto BanksNumber physical memories that the logical memory comprises.
-
template <typename, auto> typename Memory = memory
Type of underlying memory to use.
Methods
-
inline T read(pipelined_memory::addr_t addr) §source
Read one element from the memory.
Arguments
-
pipelined_memory::addr_t addr
Address of the element to read.
-
-
template <auto N> inline T[N] read_vec(pipelined_memory::addr_t[N] addresses) §source
Read
Nelements from the memory.Parameters
-
auto NThe number of elements to read.
Arguments
-
pipelined_memory::addr_t[N] addresses
The addresses to read from.
-
-
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
-
pipelined_memory::addr_t addr
Address of the element to write.
-
T dataData to write.
-
-
template <auto N> inline void write_vec(optional<pair<pipelined_memory::addr_t, T>>[N] writes) §source
Write up to
Nvalues 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 NThe maximum number of elements to write.
Arguments
-
optional<pair<pipelined_memory::addr_t, T>>[N] writes
Addresses and corresponding values.
-
-
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
modifymay 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-1threads must not access the same bank. This enables the implementation ofmodifyto be pipelined.
Arguments
-
pipelined_memory::addr_t addr
Address of the element to read.
-
(T) -> T modifyFunction 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
Ntimes. 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 thatmodifymay 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-1threads must not access the same bank. This enables the implementation ofmodifyto 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 CtxContext 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 initialContext 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))
ElementsPerBankmust be a power of 2 if there is more than 1 bank.