← Back to C-Kernel-Engine Docs Doxygen Source Documentation
 
Loading...
Searching...
No Matches
backend_native.c File Reference
#include "ckernel_engine.h"

Go to the source code of this file.

Functions

CKMathBackend ckernel_backend_native (void)
 
static void ckernel_sgemm_native (int M, int N, int K, const float *A, int lda, const float *B, int ldb, const float *bias, float *C, int ldc)
 

Function Documentation

◆ ckernel_backend_native()

CKMathBackend ckernel_backend_native ( void  )

Obtain the built-in native backend (single-node CPU, C + intrinsics).

Definition at line 39 of file backend_native.c.

40{
43 return b;
44}
static void ckernel_sgemm_native(int M, int N, int K, const float *A, int lda, const float *B, int ldb, const float *bias, float *C, int ldc)
void(* sgemm)(int M, int N, int K, const float *A, int lda, const float *B, int ldb, const float *bias, float *C, int ldc)

References ckernel_sgemm_native(), and CKMathBackend::sgemm.

◆ ckernel_sgemm_native()

static void ckernel_sgemm_native ( int  M,
int  N,
int  K,
const float *  A,
int  lda,
const float *  B,
int  ldb,
const float *  bias,
float *  C,
int  ldc 
)
static

Native GEMM backend that directly reuses the C-Transformer GEMM kernel.

Layout assumptions (identical to C-Transformer/main.c):

  • A: [M x K], row-major, A(i,k) = A[i*K + k]
  • B: [N x K], row-major, B(j,k) = B[j*K + k]
  • C: [M x N], row-major, C(i,j) = C[i*N + j]

This is a straight copy of gemm_blocked_serial with a thin wrapper to match the CKMathBackend.sgemm signature. It is intentionally minimal.

Definition at line 18 of file backend_native.c.

23{
24 /* Honor caller-provided strides so padded matrices still compute correctly. */
25 for (int i = 0; i < M; ++i) {
26 const float *a_row = A + (size_t)i * lda;
27 float *c_row = C + (size_t)i * ldc;
28 for (int j = 0; j < N; ++j) {
29 float sum = bias ? bias[j] : 0.0f;
30 const float *b_row = B + (size_t)j * ldb;
31 for (int k = 0; k < K; ++k) {
32 sum += a_row[k] * b_row[k];
33 }
34 c_row[j] = sum;
35 }
36 }
37}
#define C(color)
Definition show_config.c:39

References C.

Referenced by ckernel_backend_native().