XArith
xarith API

This is a convenience header that includes all public xarith components. More...

Files

file  version.hpp
 XArith header and linked device library version information.
 

Classes

class  mu::vdma::VpeContext
 Vector Processing Engine Context. More...
 

Typedefs

using mu::vdma::dim_t = uint32_t
 Element count for a vector operation. More...
 

Enumerations

enum class  mu::vdma::DataType : uint64_t { mu::vdma::Fp32 , mu::vdma::Fp16 }
 Element data type for VPE operations. More...
 
enum class  mu::vdma::VpeIdStrategy { mu::vdma::ByThreadId , mu::vdma::ByClusterId }
 VPE assignment strategy for load balancing. More...
 

Functions

constexpr uint64_t mu::vdma::elementSize (DataType dt)
 Byte size of one element of the given DataType. More...
 

Detailed Description

This is a convenience header that includes all public xarith components.

Users can include this single header to get access to all functionality.

The xarith library is a device-side C++ library designed for XCENA's MX1 accelerator device. It works alongside the MU library to build high-performance MU kernels that run on the MX1 device's VPE (Vector Processing Engine). The library provides a high-level interface for Vector Process Engine (VPE) operations, including buffer management, data transfer between DRAM and SRAM, and various vector operations (dot product, arithmetic, reduction, comparison).

The xarith library offers:

See also
mu::vdma::VpeContext for the primary API interface
mu::vdma::VpeIdStrategy for VPE assignment strategies
// Create a context (FP32 by default); choose a VPE assignment strategy
// Atomically reserve SRAM buffers sized for `dimension` elements, waiting
// if the per-VPE pool is momentarily full. Do not hand-roll
// `while (!tryAllocateBuffers(...)) { }` -- a flat-out retry loop starves
// the very buffer holders it is waiting on; this call paces itself.
uint64_t bufs[2];
ctx.waitAllocateBuffers(2, ctx.bytesForDimension(dimension), bufs);
// Load operands from DRAM, then compute their dot product
ctx.load(a, bufs[0], dimension);
ctx.load(b, bufs[1], dimension);
float result = ctx.dot(bufs[0], bufs[1], dimension);
Vector Processing Engine Context.
Definition: vpe_context.hpp:83
@ ByThreadId
default; spreads concurrent threads in one unit across engines
Master include header for the xarith library.

Typedef Documentation

◆ dim_t

using mu::vdma::dim_t = typedef uint32_t

Element count for a vector operation.

The number of elements an operation processes, distinct from the byte sizes and SRAM offsets that buffer management works in (those stay uint64_t). 32 bits is ample: the hardware descriptor carries the dimension in a 16-bit field (max 65535), and the per-VPE SRAM pool (80 KB) bounds a single buffer below that regardless. The alias keeps the choice in one place should the hardware limit ever change.

Definition at line 50 of file vpe_types.hpp.

Enumeration Type Documentation

◆ DataType

enum mu::vdma::DataType : uint64_t
strong

Element data type for VPE operations.

Selects the FP32 or FP16 element layout for buffers and vector operations. FP16 reductions accumulate in FP32, so reduce results (dot(), *Reduce()) are always returned as float.

Enumerator
Fp32 

32-bit IEEE 754 single-precision float (4 bytes per element)

Fp16 

16-bit IEEE 754 half-precision float (2 bytes per element); reductions accumulate in FP32

Definition at line 21 of file vpe_types.hpp.

◆ VpeIdStrategy

VPE assignment strategy for load balancing.

Selects how a context is assigned to a VPE so that concurrent work is distributed across the available engines. Each strategy targets a different parallelization pattern:

ByThreadId (Default):

  • Spreads concurrent threads in the same execution unit across engines
  • Best for: thread-level parallelism within a single unit
  • Use case: multiple threads processing independent vectors together

ByClusterId:

  • Spreads work from different clusters across engines
  • Best for: cluster-level parallelism
  • Use case: multi-cluster workloads that each want a dedicated engine
Note
Choose ByThreadId when parallelizing across threads in one unit. Choose ByClusterId when distributing work across clusters.
See also
VpeContext::VpeContext() for usage examples
Enumerator
ByThreadId 

default; spreads concurrent threads in one unit across engines

ByClusterId 

spreads work from different clusters across engines

Definition at line 76 of file vpe_types.hpp.

Function Documentation

◆ elementSize()

constexpr uint64_t mu::vdma::elementSize ( DataType  dt)
inlineconstexpr

Byte size of one element of the given DataType.

Fp32 → 4 bytes, Fp16 → 2 bytes. Used to compute a buffer's payload size (dimension * elementSize(dataType)).

Definition at line 34 of file vpe_types.hpp.