398 void load(
const void* srcDram, uint64_t dstBuffer,
dim_t dimension);
418 void store(uint64_t srcBuffer,
void* dstDram,
dim_t dimension);
511 float dot(uint64_t src1, uint64_t src2,
dim_t dimension);
561 void add(uint64_t src1, uint64_t src2, uint64_t dst,
dim_t dimension);
582 void sub(uint64_t src1, uint64_t src2, uint64_t dst,
dim_t dimension);
601 void mul(uint64_t src1, uint64_t src2, uint64_t dst,
dim_t dimension);
623 void div(uint64_t src1, uint64_t src2, uint64_t dst,
dim_t dimension);
935 uint64_t getNextTag();
938 uint32_t chunksForBytes(uint64_t byteSize)
const;
941 bool tryAllocateChunks(uint32_t count,
const uint32_t* chunks, uint64_t* outBuffers);
948 bool requestFitsEmptyPool(uint32_t count,
const uint32_t* chunks)
const;
953 bool waitAllocateChunks(uint32_t count,
const uint32_t* chunks, uint64_t* outBuffers);
957 void trackAllocation(uint64_t offset, uint32_t chunks);
961 uint32_t untrackAllocation(uint64_t offset);
970 void debugCheckDimFits(
dim_t dimension, uint64_t buffer)
const;
974 volatile int32_t* lock_;
984 uint64_t currentTag_;
Vector Processing Engine Context.
void store(uint64_t srcBuffer, void *dstDram, dim_t dimension)
Store vector data from SRAM buffer to DRAM (synchronous).
void add(uint64_t src1, uint64_t src2, uint64_t dst, dim_t dimension)
Element-wise addition: dst = src1 + src2 (synchronous)
void scalarSub(uint64_t scalar, uint64_t src, uint64_t dst, dim_t dimension)
Subtract each element from a scalar: dst = scalar - src (synchronous)
VpeContext & operator=(VpeContext &&)=delete
DataType getDataType() const
Get the element data type configured for this context.
void freeBuffers(uint32_t count, const uint64_t *buffers)
Free multiple previously allocated buffers in a single atomic operation.
static constexpr uint32_t MAX_TRACKED_BUFFERS
bool isAllZero(uint64_t src, dim_t dimension)
Check if all elements in a vector are zero (synchronous)
float dot(uint64_t src1, uint64_t src2, dim_t dimension)
Compute dot product of two vectors (synchronous)
void scalarAdd(uint64_t scalar, uint64_t src, uint64_t dst, dim_t dimension)
Add a scalar to every element: dst = scalar + src (synchronous)
float subReduce(uint64_t src1, uint64_t src2, dim_t dimension)
Sum of element-wise subtraction: result = Σ(src1[i] - src2[i]) (synchronous)
~VpeContext()
Destructor - automatically frees all allocated buffers.
bool equals(uint64_t src1, uint64_t src2, dim_t dimension)
Check if two vectors are equal element-wise (synchronous)
void scalarXor(uint64_t scalar, uint64_t src, uint64_t dst, dim_t dimension)
Bitwise XOR every element with a scalar mask: dst = scalar ^ src (synchronous)
void mul(uint64_t src1, uint64_t src2, uint64_t dst, dim_t dimension)
Element-wise multiplication: dst = src1 * src2 (synchronous)
bool tryAllocateBuffers(uint32_t count, uint64_t byteSize, uint64_t *outBuffers)
Atomically allocate count equally-sized SRAM buffers (all-or-nothing)
void square(uint64_t src, uint64_t dst, dim_t dimension)
Element-wise square: dst = src * src (synchronous)
VpeContext(VpeIdStrategy strategy=VpeIdStrategy::ByThreadId, DataType dataType=DataType::Fp32)
Constructor with default strategy (ByThreadId) and element type (Fp32)
void fillOne(uint64_t dst, dim_t dimension)
Fill an SRAM buffer with the value one (synchronous).
VpeContext(VpeContext &&)=delete
bool waitAllocateBuffersWithSizes(uint32_t count, const uint64_t *byteSizes, uint64_t *outBuffers)
Allocate count buffers of per-buffer sizes, waiting until they fit (all-or-nothing)
uint64_t bytesForDimension(dim_t dimension) const
Bytes occupied by dimension elements of this context's DataType.
void scalarDiv(uint64_t scalar, uint64_t src, uint64_t dst, dim_t dimension)
Divide a scalar by each element: dst = scalar / src (synchronous)
bool tryAllocateBuffersWithSizes(uint32_t count, const uint64_t *byteSizes, uint64_t *outBuffers)
Atomically allocate count SRAM buffers of per-buffer byte sizes.
void copy(uint64_t src, uint64_t dst, dim_t dimension)
Copy a vector between two SRAM buffers (synchronous).
float scalarDot(uint64_t scalar, uint64_t src, dim_t dimension)
Scalar-weighted sum: result = Σ(scalar * src[i]) (synchronous)
void load(const void *srcDram, uint64_t dstBuffer, dim_t dimension)
Load vector data from DRAM to SRAM buffer (synchronous).
VpeContext & operator=(const VpeContext &)=delete
bool waitAllocateBuffers(uint32_t count, uint64_t byteSize, uint64_t *outBuffers)
Allocate count equally-sized buffers, waiting until they fit (all-or-nothing)
void sub(uint64_t src1, uint64_t src2, uint64_t dst, dim_t dimension)
Element-wise subtraction: dst = src1 - src2 (synchronous)
VpeContext(const VpeContext &)=delete
void scalarMul(uint64_t scalar, uint64_t src, uint64_t dst, dim_t dimension)
Multiply every element by a scalar: dst = scalar * src (synchronous)
void div(uint64_t src1, uint64_t src2, uint64_t dst, dim_t dimension)
Element-wise division: dst = src1 / src2 (synchronous)
float addReduce(uint64_t src1, uint64_t src2, dim_t dimension)
Sum of element-wise addition: result = Σ(src1[i] + src2[i]) (synchronous)
uint64_t allocateBuffer(uint64_t byteSize)
Allocate a buffer in SRAM.
VpeContext(VpeIdStrategy strategy, DataType dataType, volatile uint32_t *lockAddr)
Constructor with an explicit lock address.
float divReduce(uint64_t src1, uint64_t src2, dim_t dimension)
Sum of element-wise division: result = Σ(src1[i] / src2[i]) (synchronous)
void freeBuffer(uint64_t buffer)
Free a previously allocated buffer.
void fillZero(uint64_t dst, dim_t dimension)
Fill an SRAM buffer with the value zero (synchronous).
static void _reset()
[DANGEROUS] Reset the entire SRAM allocator state for the calling thread's execution unit
uint64_t waitAllocateBuffer(uint64_t byteSize)
Allocate a buffer, waiting until it fits.
Dot2Result dot2(uint64_t shared, uint64_t src1, uint64_t src2, dim_t dimension)
Compute two dot products that share one operand in a single fused operation (synchronous).
void bitwiseXor(uint64_t src1, uint64_t src2, uint64_t dst, dim_t dimension)
Element-wise bitwise XOR: dst = src1 ^ src2 (synchronous)
static constexpr uint64_t INVALID_BUFFER
constexpr uint64_t elementSize(DataType dt)
Byte size of one element of the given DataType.
VpeIdStrategy
VPE assignment strategy for load balancing.
uint32_t dim_t
Element count for a vector operation.
DataType
Element data type for VPE operations.
@ ByThreadId
default; spreads concurrent threads in one unit across engines
@ Fp32
32-bit IEEE 754 single-precision float (4 bytes per element)
Main header file for half-precision functionality.
Pair of scalar dot-product results returned by dot2().