22#ifndef MMGR_MEMORIA_ANULARIS_H
23#define MMGR_MEMORIA_ANULARIS_H
54#ifndef MMGR_RING_WORDS
56#define MMGR_RING_WORDS 40u
66#define MMGR_RING_LOCULI_MAX EMBED_WORD_BITS
78#ifndef MMGR_RING_LOCULI
80#define MMGR_RING_LOCULI 8u
92 "the loculus masks are one machine word; widen them or fall back to a scan past MMGR_RING_LOCULI_MAX");
102#define MMGR_RING_POW2(count_) (((count_) & ((count_) - 1u)) == 0u)
112#define MMGR_RING_WRAP(index_, capacity_) ((index_) & ((capacity_) - 1u))
148#define MemoriaAnularis(name_, pool_) \
149 MMGR_PARS_CLAIMED_ONCE(pool_); \
150 static EMBED_PASS_MEMORY mmgr_ring name_
207EMBED_TABLE_LAYOUT(
MemoriaAnularisNs, init, available, vacant, read_byte, read, peek, consume, put, seg_inflight,
208 seg_next, seg_publish, seg_front, seg_release, seg_at, loculus_ready, loculus_next, loculus_hold,
209 loculus_keepout, loculus_drop, loculus_mark);
EMBED_HOST_DEVICE embed_bool mmgr_anular_read_byte(const AnularisCfg *args)
Takes one byte into args->dst and advances the tail past it.
EMBED_HOST_DEVICE const mmgr_ring_span * mmgr_anular_loculus_keepout(const AnularisCfg *args)
Returns the region loculus args->index retains out.
EMBED_HOST_DEVICE size_t mmgr_anular_available(const AnularisCfg *args)
Returns the bytes ready for a read.
EMBED_HOST_DEVICE embed_bool mmgr_anular_loculus_hold(const AnularisCfg *args)
Takes loculus args->index and records the args->bytes at args->src that it retains out.
EMBED_HOST_DEVICE embed_bool mmgr_anular_put(const AnularisCfg *args)
Writes args->bytes of args->src into the ring, or refuses the whole span.
EMBED_HOST_DEVICE embed_bool mmgr_anular_seg_front(const AnularisCfg *args)
Reports the index of the segment the consumer takes next.
EMBED_HOST_DEVICE void mmgr_anular_peek(const AnularisCfg *args)
Copies args->bytes from args->offset ahead of the tail into args->dst, and leaves the tail alone.
#define MMGR_RING_WORDS
Size of the ring storage a caller declares, counted in size_t units.
EMBED_HOST_DEVICE size_t mmgr_anular_seg_inflight(const AnularisCfg *args)
Returns the segments filled and not yet released.
EMBED_HOST_DEVICE embed_bool mmgr_anular_seg_next(const AnularisCfg *args)
Reports the index of the segment the producer fills next.
EMBED_HOST_DEVICE embed_bool mmgr_anular_init(const AnularisCfg *args)
Lays a fresh ring into args->ring, over the bytes at args->buf.
EMBED_HOST_DEVICE size_t mmgr_anular_vacant(const AnularisCfg *args)
Returns the bytes still free to write.
EMBED_HOST_DEVICE size_t mmgr_anular_read(const AnularisCfg *args)
Takes up to args->bytes into args->dst and advances the tail once at the end.
EMBED_HOST_DEVICE void mmgr_anular_seg_release(const AnularisCfg *args)
Frees the front segment.
EMBED_HOST_DEVICE void mmgr_anular_loculus_drop(const AnularisCfg *args)
Gives loculus args->index back.
EMBED_HOST_DEVICE void mmgr_anular_loculus_mark(const AnularisCfg *args)
Marks loculus args->index free.
EMBED_HOST_DEVICE uint8_t * mmgr_anular_seg_at(const AnularisCfg *args)
Returns the contiguous span of segment args->index.
#define MMGR_RING_LOCULI
Loculi this build reserves, which a build may set before it includes this header.
static const MemoriaAnularisNs anularis
Dispatch table instance named anularis, whose members are the mmgr_anular_ entries.
EMBED_HOST_DEVICE void mmgr_anular_consume(const AnularisCfg *args)
Advances the tail past args->bytes.
EMBED_HOST_DEVICE void mmgr_anular_seg_publish(const AnularisCfg *args)
Makes the filled segment visible to the consumer.
#define MMGR_RING_LOCULI_MAX
Loculi a mask can address, which is one bit per loculus in a machine word.
EMBED_HOST_DEVICE embed_iword mmgr_anular_loculus_next(const AnularisCfg *args)
Returns the index of the lowest set bit of args->mask.
EMBED_HOST_DEVICE embed_word mmgr_anular_loculus_ready(const AnularisCfg *args)
Returns the loculi that are free and not pinned.
The embedded_types headers every module builds on.
Arguments for every mmgr_anular_ entry, each reading only the members it needs.
const size_t segment_bytes
const size_t segment_count
Type of the anularis dispatch table.
embed_bool(*) loculus_hold(const AnularisCfg *args)
embed_bool(*) put(const AnularisCfg *args)
embed_bool(*) seg_next(const AnularisCfg *args)
void(*) loculus_drop(const AnularisCfg *args)
void(*) seg_publish(const AnularisCfg *args)
embed_bool(*) read_byte(const AnularisCfg *args)
size_t(*) seg_inflight(const AnularisCfg *args)
size_t(*) read(const AnularisCfg *args)
embed_word(*) loculus_ready(const AnularisCfg *args)
size_t(*) vacant(const AnularisCfg *args)
size_t(*) available(const AnularisCfg *args)
void(*) seg_release(const AnularisCfg *args)
void(*) consume(const AnularisCfg *args)
void(*) peek(const AnularisCfg *args)
embed_bool(*) seg_front(const AnularisCfg *args)
void(*) loculus_mark(const AnularisCfg *args)
embed_bool(*) init(const AnularisCfg *args)
embed_iword(*) loculus_next(const AnularisCfg *args)
A byte region a pinned loculus retains out: the storage, its extent, and how far a reader got.
Storage a caller declares for one ring, whose contents belong to the implementation.
uint8_t opaque[MMGR_RING_WORDS *sizeof(size_t)]