CIMFlow LogoCIMFlow

Built-in Functions

Memory, SIMD, and CIM operations in CIM-DSL


Memory Operations

Buffer

Allocate a memory tile with specified shape, type, and location:

buf = Buffer(<4, 8>, int8, __LOCAL__);

Prop

Type

Trans

Transfer data between memory regions:

Trans(src_buffer, dst_buffer);

Load / Save

Access individual elements by index:

val = Load(buf, [row, col]);
Save(buf, [row, col], value);

Shape

Query dimension size at runtime:

n = Shape(vector, 0);  // Get size of dimension 0

Slice

Create a subview of a buffer with explicit offsets, sizes, and steps:

slice = Slice(buf, [offset0, offset1], [size0, size1], [step0, step1]);

Prop

Type

This is an alternative to NumPy-style slicing syntax. Both buf[0:2, 1:3] and Slice(buf, [0, 1], [2, 2], [1, 1]) produce equivalent results.


CIM Operations

CIMSet

Configure active CIM macros using a bitmask:

mask = Buffer(<N_VCOL>, int1, __INPUT_MEMORY__);
CIMSet(mask);

CIMComputeDense

Execute dense matrix-vector multiplication on CIM hardware:

CIMComputeDense(input_buffer, weight_macros);

CIMOutput

Read results from CIM output registers:

CIMOutput(length, offset, output_buffer);

Prop

Type


SIMD Operations

Vector operations via the SIMD function:

SIMD(op_code, src1, src2, dst);
VVADDVector-vector add
VSADDVector-scalar add
VVMULVector-vector multiply
VSMULVector-scalar multiply
VS_SUBVector-scalar subtract
VS_DIVVector-scalar divide
VVMAXElement-wise maximum
VFLOORElement-wise floor
SOFTMAXSoftmax activation
GELUGELU activation
V_EXPElement-wise exponential
VSQRTElement-wise square root
VSETSet all elements to value
REDUCE_SUMSum all elements
REDUCE_MAXFind maximum element

Use with the Reduce function:

Reduce(REDUCE_SUM, src_vector, dst_vector);
QUANTIZEQuantize to lower precision
RESADD_QUANTIZEResidual add + quantize
RESMUL_QUANTIZEResidual multiply + quantize

Utility Functions

Min(a, b)
Returns the minimum of two values
Max(a, b)
Returns the maximum of two values
Print(val)
Debug output to console

SpecialRegSet

Configure special registers for CIM and SIMD operations:

SpecialRegSet(SPECIAL_REG_INPUT_BIT_WIDTH, 8);
SpecialRegSet(SPECIAL_REG_SIMD_OUTPUT_BIT_WIDTH, 32);

Configure bit widths before performing CIM or SIMD operations to ensure correct data handling.

Last updated on