File acc_f32_core.h¶
FileList > acc_f32 > acc_f32_core.h
Go to the source code of this file
AccF32 component API. More...
#include "clib_common.h"#include "jm_perf.h"#include "dp_state.h"
Classes¶
| Type | Name |
|---|---|
| struct | acc_f32_state_t AccF32 state. |
Public Functions¶
| Type | Name |
|---|---|
| void | acc_f32_add2d (acc_f32_state_t * state, const float * x, size_t x_len) Sum all elements of a (logically) 2-D float array into the accumulator. The array is treated as a flat C-order buffer of x_len floats regardless of the original shape; the caller is responsible for passing the total element count. |
| acc_f32_state_t * | acc_f32_create (float acc) Single-precision floating-point scalar accumulator. Maintains one running sum ( acc ) that persists across calls tostep ,steps ,madd ,add2d , andmadd2d . Useget to read without side-effects ordump to read and atomically zero in a single call. |
| void | acc_f32_destroy (acc_f32_state_t * state) Release all memory owned by an AccF32 instance. Passing NULL is safe; the function is a no-op in that case. After this call the pointer must not be used. |
| float | acc_f32_dump (acc_f32_state_t * state) Return the accumulated sum and atomically reset it to zero. This is the canonical "drain" primitive: read the period total, then start a fresh accumulation interval without a separate reset call. The zero-reset is unconditional and always writes 0.0f. |
| float | acc_f32_get (acc_f32_state_t * state) Return the current accumulated sum without resetting state. Identical to reading the acc property directly; retained as an explicit method so call sites that need the value can be uniform withdump without a conditional. |
| float | acc_f32_get_acc (const acc_f32_state_t * state) Return the current accumulator value without modifying state. Use this when you need to read the running sum mid-accumulation without disturbing it. For a read-and-reset in one call use acc_f32_dump . |
| void | acc_f32_get_state (const acc_f32_state_t * state, void * blob) |
| void | acc_f32_madd (acc_f32_state_t * state, const float * x, size_t x_len, const float * h, size_t h_len) Dot-product accumulate: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . The shorter of the two arrays limits the iteration count; no out-of-bounds access occurs. Typical use: apply a short FIR weight vector to one block of signal samples and fold the result into a running total. |
| void | acc_f32_madd2d (acc_f32_state_t * state, const float * x, size_t x_len, const float * h, size_t h_len) Dot-product accumulate over a flat 2-D buffer: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . Combinesadd2d andmadd semantics — a 2-D signal array is weighted element-wise by a coefficient buffer and the scalar total is folded into the running sum. |
| void | acc_f32_reset (acc_f32_state_t * state) Zero the accumulator, restoring the same state as a fresh AccF32(0.0) — regardless of the value supplied toacc_f32_create . Subsequentget /dump calls return0.0 until new samples are processed. |
| void | acc_f32_set_acc (acc_f32_state_t * state, float acc) Overwrite the accumulator with a new value. Useful for seeding the accumulator to a known baseline before processing a new segment without a full reset . |
| int | acc_f32_set_state (acc_f32_state_t * state, const void * blob) |
| size_t | acc_f32_state_bytes (const acc_f32_state_t * state) |
| JM_FORCEINLINE JM_HOT void | acc_f32_step (acc_f32_state_t * state, float x) Add one sample to the running sum ( acc += x ). This is the hot-path entry point for sample-by-sample processing. For block inputs preferacc_f32_steps to amortise call overhead and allow auto-vectorisation. |
| void | acc_f32_steps (acc_f32_state_t * state, const float * input, size_t n) Add all samples in input to the running sum. Equivalent to callingacc_f32_step for each element, but SIMD-vectorised on platforms that provide it (AVX-512 / AVX2 / SSE2). The loop uses JM_RESTRICT so the compiler can assume no aliasing betweenstate andinput . |
Macros¶
| Type | Name |
|---|---|
| define | ACC_F32_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('A', 'C', 'C', 'F') |
| define | ACC_F32_STATE_VERSION 1u |
Detailed Description¶
Lifecycle: create -> (step / steps / reset)* -> destroy
Example:
acc_f32_state_t *obj = acc_f32_create(0.0f);
acc_f32_step(obj, 1.0f);
float v = acc_f32_get(obj); // v == 1.0
acc_f32_destroy(obj);
Public Functions Documentation¶
function acc_f32_add2d¶
Sum all elements of a (logically) 2-D float array into the accumulator. The array is treated as a flat C-order buffer of x_len floats regardless of the original shape; the caller is responsible for passing the total element count.
Parameters:
stateMust be non-NULL.xInput array (float32, any shape — passed as flat buffer).x_lenNumber of elements inx.
function acc_f32_create¶
Single-precision floating-point scalar accumulator. Maintains one running sum ( acc ) that persists across calls tostep ,steps ,madd ,add2d , andmadd2d . Useget to read without side-effects ordump to read and atomically zero in a single call.
Parameters:
accInitial accumulator value (default: 0.0).
Returns:
Heap-allocated state, or NULL on allocation failure.
Note:
Caller must call acc_f32_destroy() when done.
>>> from doppler.accumulator import AccF32
>>> obj = AccF32(0.0)
>>> obj.get_acc()
0.0
>>> obj.set_acc(5.0)
>>> obj.get_acc()
5.0
>>> obj.reset()
>>> obj.get_acc()
0.0
function acc_f32_destroy¶
Release all memory owned by an AccF32 instance. Passing NULL is safe; the function is a no-op in that case. After this call the pointer must not be used.
function acc_f32_dump¶
Return the accumulated sum and atomically reset it to zero. This is the canonical "drain" primitive: read the period total, then start a fresh accumulation interval without a separate reset call. The zero-reset is unconditional and always writes 0.0f.
Returns:
Value of acc just before the reset (float).
>>> from doppler.accumulator import AccF32
>>> obj = AccF32(0.0)
>>> obj.step(3.0)
>>> obj.step(4.0)
>>> obj.dump()
7.0
>>> obj.get()
0.0
function acc_f32_get¶
Return the current accumulated sum without resetting state. Identical to reading the acc property directly; retained as an explicit method so call sites that need the value can be uniform withdump without a conditional.
Returns:
Current value of acc (float).
>>> from doppler.accumulator import AccF32
>>> obj = AccF32(0.0)
>>> obj.step(2.0)
>>> obj.step(3.0)
>>> obj.get()
5.0
function acc_f32_get_acc¶
Return the current accumulator value without modifying state. Use this when you need to read the running sum mid-accumulation without disturbing it. For a read-and-reset in one call use acc_f32_dump .
Returns:
Current value of acc (float).
>>> from doppler.accumulator import AccF32
>>> obj = AccF32(0.0)
>>> obj.step(4.0)
>>> obj.get_acc()
4.0
function acc_f32_get_state¶
function acc_f32_madd¶
Dot-product accumulate: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . The shorter of the two arrays limits the iteration count; no out-of-bounds access occurs. Typical use: apply a short FIR weight vector to one block of signal samples and fold the result into a running total.
void acc_f32_madd (
acc_f32_state_t * state,
const float * x,
size_t x_len,
const float * h,
size_t h_len
)
Parameters:
stateMust be non-NULL.xSignal samples (float32 array).x_lenNumber of elements inx.hCoefficient / weight array (float32 array).h_lenNumber of elements inh.
function acc_f32_madd2d¶
Dot-product accumulate over a flat 2-D buffer: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . Combinesadd2d andmadd semantics — a 2-D signal array is weighted element-wise by a coefficient buffer and the scalar total is folded into the running sum.
void acc_f32_madd2d (
acc_f32_state_t * state,
const float * x,
size_t x_len,
const float * h,
size_t h_len
)
Parameters:
stateMust be non-NULL.xSignal samples (float32, flat buffer of the 2-D array).x_lenNumber of elements inx.hCoefficient / weight array (float32).h_lenNumber of elements inh.
function acc_f32_reset¶
Zero the accumulator, restoring the same state as a fresh AccF32(0.0) — regardless of the value supplied toacc_f32_create . Subsequentget /dump calls return0.0 until new samples are processed.
>>> from doppler.accumulator import AccF32
>>> obj = AccF32(0.0)
>>> obj.step(7.0)
>>> obj.reset()
>>> obj.get_acc()
0.0
function acc_f32_set_acc¶
Overwrite the accumulator with a new value. Useful for seeding the accumulator to a known baseline before processing a new segment without a full reset .
Parameters:
stateMust be non-NULL.accNew accumulator value.
function acc_f32_set_state¶
function acc_f32_state_bytes¶
function acc_f32_step¶
Add one sample to the running sum ( acc += x ). This is the hot-path entry point for sample-by-sample processing. For block inputs preferacc_f32_steps to amortise call overhead and allow auto-vectorisation.
Parameters:
stateMust be non-NULL.xInput sample (float).
function acc_f32_steps¶
Add all samples in input to the running sum. Equivalent to callingacc_f32_step for each element, but SIMD-vectorised on platforms that provide it (AVX-512 / AVX2 / SSE2). The loop uses JM_RESTRICT so the compiler can assume no aliasing betweenstate andinput .
Parameters:
stateMust be non-NULL.inputInput samples (float32 array).nNumber of elements ininput.
Macro Definition Documentation¶
define ACC_F32_STATE_MAGIC¶
define ACC_F32_STATE_VERSION¶
The documentation for this class was generated from the following file native/inc/acc_f32/acc_f32_core.h