/* kernels_c.c - the same plain C loops, built at -O3 (variants 2 and 5). * The float loop is a reduction; GCC only vectorizes it with * -ffast-math (see Makefile). The INT8 loop vectorizes without it. */ #include "kernels.h" void matvec_f32_c_o3(const float *W, const float *x, float *y, int rows, int cols) { for (int r = 0; r < rows; r++) { const float *w = W + (long)r * cols; float acc = 0.0f; for (int c = 0; c < cols; c++) acc += w[c] * x[c]; y[r] = acc; } } void matvec_i8_c_o3(const int8_t *W, const int8_t *x, int32_t *y, int rows, int cols) { for (int r = 0; r < rows; r++) { const int8_t *w = W + (long)r * cols; int32_t acc = 0; for (int c = 0; c < cols; c++) acc += (int32_t)w[c] * (int32_t)x[c]; y[r] = acc; } }