File acc_q8_core.h¶
File List > acc_q8 > acc_q8_core.h
Go to the documentation of this file
#ifndef ACC_Q8_CORE_H
#define ACC_Q8_CORE_H
#include "clib_common.h"
#include "jm_perf.h"
#include "dp_state.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int32_t acc;
} acc_q8_state_t;
acc_q8_state_t *acc_q8_create(int32_t acc);
void acc_q8_destroy(acc_q8_state_t *state);
void acc_q8_reset(acc_q8_state_t *state);
JM_FORCEINLINE JM_HOT void
acc_q8_step(acc_q8_state_t *state, int8_t x)
{
state->acc += (int32_t)x;
}
void acc_q8_steps(
acc_q8_state_t *state,
const int8_t *input,
size_t n);
int32_t acc_q8_get_acc(const acc_q8_state_t *state);
void acc_q8_set_acc(acc_q8_state_t *state, int32_t val);
int32_t acc_q8_get(acc_q8_state_t *state);
int32_t acc_q8_dump(acc_q8_state_t *state);
void acc_q8_madd(acc_q8_state_t *state, const int8_t *a, size_t a_len, const int8_t *b, size_t b_len);
/* ── Serializable state (standard bytes interface; see dp_state.h) ──────────
* Whole-struct POD snapshot (pointer-free); the running 32-bit accumulator resumes exactly into an
* identically-built instance. */
#define ACC_Q8_STATE_MAGIC DP_FOURCC ('A', 'C', 'C', '8')
#define ACC_Q8_STATE_VERSION 1u
size_t acc_q8_state_bytes (const acc_q8_state_t *state);
void acc_q8_get_state (const acc_q8_state_t *state, void *blob);
int acc_q8_set_state (acc_q8_state_t *state, const void *blob);
#ifdef __cplusplus
}
#endif
#endif /* ACC_Q8_CORE_H */