← Back to C-Kernel-Engine Docs Doxygen Source Documentation
 
Loading...
Searching...
No Matches
cpu_features.h
Go to the documentation of this file.
1/**
2 * CPU Feature Detection and Cache-Aware Parameter Tuning
3 *
4 * This module detects CPU cache sizes at runtime and computes optimal
5 * GEMM blocking parameters based on the BLIS/oneDNN methodology.
6 *
7 * Key formulas:
8 * - KC: MR * KC * sizeof(float) fits in L1 (with room for B streaming)
9 * - MC: MC * KC * sizeof(float) fits in L2
10 * - NC: KC * NR fits in L1 for B panel, NC scales with L3
11 */
12
13#ifndef CPU_FEATURES_H
14#define CPU_FEATURES_H
15
16#include <stdint.h>
17#include <stddef.h>
18
19// CPU cache information
20typedef struct {
21 size_t l1d_size; // L1 data cache size in bytes
22 size_t l2_size; // L2 cache size in bytes
23 size_t l3_size; // L3 cache size in bytes
24 size_t l1_line_size; // Cache line size
25 int num_cores; // Number of physical cores
38} CPUInfo;
39
40// GEMM blocking parameters (computed based on cache sizes)
41typedef struct {
42 int MR; // Microkernel rows
43 int NR; // Microkernel cols
44 int MC; // M block size
45 int NC; // N block size
46 int KC; // K block size
48
49// Global CPU info and GEMM params (initialized once at startup)
50extern CPUInfo g_cpu_info;
52extern int g_cpu_initialized;
53
54// Initialize CPU detection (call once at startup)
55void cpu_features_init(void);
56
57// Get current GEMM parameters
58const GEMMParams* get_gemm_params(void);
59
60// Get CPU info
61const CPUInfo* get_cpu_info(void);
62
63// Debug: print CPU info
64void print_cpu_info(void);
65
66#endif // CPU_FEATURES_H
void print_cpu_info(void)
const GEMMParams * get_gemm_params(void)
const CPUInfo * get_cpu_info(void)
CPUInfo g_cpu_info
int g_cpu_initialized
void cpu_features_init(void)
GEMMParams g_gemm_params
int has_amx_int8
size_t l1d_size
int has_amx_bf16
size_t l3_size
int has_avx2
int has_amx_tile
int has_fma
int has_avx
int has_avx512f
int has_avx512_bf16
int has_avx512dq
int num_cores
int has_avx512vl
size_t l2_size
int has_avx512bw
size_t l1_line_size
int has_avx512_vnni