Recep's Code Runs Everywhere
Building a Modern Computer Vision & Machine Learning Engine in C23 from First Principles
-
Read Online
Explore all 16 chapters with native \(\LaTeX\) formulas and C23 source code.
-
Download Monograph
Download the publication-grade PDF monograph compiled from LaTeX sources.
-
Companion Engine
Single-header C23 core engine unifying CV, ML, Autograd, and Vector Search.
-
Interactive Labs
Live 3D WebAssembly visualizers for tensor strides, GEMM tiling, and LSH.
"Modern software engineering has become bloated with heavy runtimes, dynamic dispatch layers, and 2-gigabyte frameworks. This textbook is a return to first principles: understanding the physical reality of silicon, cache lines, and vector execution ports to build ultra-fast, zero-dependency CV and ML engines in pure ISO C23."
[!TIP] New to C or Systems Programming?
Check out the Beginner's Guide: 10-Page Mini E-Book for a gentle, visual introduction designed specifically for non-CS background engineers, scientists, and data practitioners. Takes you from zero to 7,500 Megapixels/sec in 10 short visual pages!
📚 Complete Curriculum & Table of Contents
Part I: Foundations of High-Performance Systems & Modern C23
Bridging the gap between high-level algorithms and bare-metal memory invariants.
| Chapter | Title & Focus | Silicon Focus | Code |
|---|---|---|---|
| Chapter 1 | The Modern C23 Systems Mindset | Standard attributes, <stdbit.h>, hardware POPCNT, 64-byte alignment boundaries |
Code |
| Chapter 2 | Memory Hierarchies, Cache Locality, and Deterministic Arenas | The Memory Wall, 64-byte cache lines, double-ended linear arenas, \(\mathcal{O}(1)\) rewind | Code |
| Chapter 3 | Strided Tensors & Zero-Copy ShapeTracker Views | Generalized stride linear combinations, zero-copy slicing, transposing, and coalescing | Code |
Part II: Core Mathematical & Computational Primitives
Deriving and optimizing foundational numerical kernels from scratch.
| Chapter | Title & Focus | Silicon Focus | Code |
|---|---|---|---|
| Chapter 4 | Matrix Multiplication: From Naive to Cache-Blocked GEMM | The Roofline model, \(B_M \times B_N \times B_K\) 3-level cache blocking, 72 GFLOPS | Code |
| Chapter 5 | Spatial Convolutions & 15-bit Fixed-Point CV | Rank-1 kernel separability theorem, 15-bit fixed-point integer Rec.601 matching OpenCV | Code |
| Chapter 6 | The 25-Op Primitive Reduction & Fusion | The tinygrad taxonomy, fusing letterboxing, normalization, and planar channel layout | Code |
Part III: Classical Machine Learning from First Principles
High-throughput classical ML engines without third-party mathematical runtimes.
| Chapter | Title & Focus | Silicon Focus | Code |
|---|---|---|---|
| Chapter 7 | Continuous Optimization & Cholesky Ridge | Normal equations condition number hazard, Cholesky factorization \(\mathbf{A}=\mathbf{L}\mathbf{L}^T\) | Code |
| Chapter 8 | Support Vector Machines: Pegasos Primal Descent | Soft-margin SVM, dual QP avoidance, primal subgradient stochastic descent in \(\mathcal{O}(D)\) space | Code |
| Chapter 9 | Tabular Ensembles: Flat-Array GBDT Inference | Eliminating pointer-linked trees, branchless flat-array evaluation (\(127\text{ ns}\) latency) | Code |
| Chapter 10 | High-Dimensional Vector Search: HNSW & LSH | Skip-list metric graphs, logarithmic beam routing (\(44\text{k QPS}\)), and two-tier LSH hash tables (\(113\text{k QPS}\)) | Code |
Part IV: Heterogeneous Silicon & Concurrency
Saturating execution pipelines and distributing tasks across multicore CPUs.
| Chapter | Title & Focus | Silicon Focus | Code |
|---|---|---|---|
| Chapter 11 | SIMD Fundamentals: ARM NEON vs. x86 AVX | 128-bit vs 256-bit registers, 4-way independent accumulator unrolling to hide FMA latency | Code |
| Chapter 12 | Dynamic CPU Probing & Zero-Branching HAL | cpuid / OS kernel probing, zero-branching HAL tables, eliminating in-loop branch hazards |
Code |
| Chapter 13 | Concurrency without Runtime Bloat | Zero-runtime thread pools, Chase-Lev deque, eliminating false sharing with 64-byte padding | Code |
Part V: Real-Time Deployment, Edge & The Web
Zero-copy camera capture, WebAssembly compilation, and hardware telemetry.
| Chapter | Title & Focus | Silicon Focus | Code |
|---|---|---|---|
| Chapter 14 | Hardware Video Ingestion & Direct DMA | Linux V4L2 mmap() DMA rings, Apple AVFoundation/IOSurface, SIMD YUYV unpacker |
Code |
| Chapter 15 | Compiling to the Browser: WebAssembly & SIMD128 | Linear memory bridge, W3C wasm_simd128.h, zero-copy Canvas rendering (\(420\text{ FPS}\)) |
Code |
| Chapter 16 | Systems Education: Real-Time Telemetry | Sub-7ns C23 cycle counter telemetry (rcre_prof), dual-layer Arena tracking, Perfetto JSON export |
Code |
Appendices: Real-World Systems & Starter Blueprints
| Appendix | Title & Mission | Practical Focus | Source Directory |
|---|---|---|---|
| Appendix A | RCRE Production Projects Hub | Nine turnkey end-to-end production engines: rcre-lens (visual search), rcre-facex (FACS biomechanics), rcre-mobilenet, rcre-pca, rcre-xgb, rcre-sr, and the project-template starter kit |
Projects |
| Appendix B | Beginner's 10-Page Mini E-Book | High-performance C for the curious mind: gentle visual journey from zero to 7,500 MP/s for non-CS practitioners | E-Book |
🏛️ Pedagogical Pillars
- The First-Principles Equation: Every computational technique begins with its formal mathematical derivation—from the normal equations \(\mathbf{w} = (\mathbf{X}^T\mathbf{X} + \lambda\mathbf{I})^{-1}\mathbf{X}^T\mathbf{y}\) to Euclidean distance invariance \(\|\hat{\mathbf{u}} - \hat{\mathbf{v}}\|_2^2 = 2(1 - \cos\theta)\).
- The Physical Reality: Relate mathematical theory directly to CPU architecture—L1/L2 caches, 64-byte cache lines, memory bus saturation, pipeline latency, and SIMD instruction throughput.
- Pure Zero-Dependency C23: Every implementation is written in idiomatic ISO C23 (
-std=c2x), verified with AddressSanitizer and UndefinedBehaviorSanitizer, and runnable standalone without third-party frameworks. - Universal Hardware Dispatch: Architectural abstraction that adapts dynamically across ARM NEON, x86 AVX2, and WebAssembly SIMD128.
- Interactive Telemetry: Direct integration with in-browser 3D WebAssembly visualizers and nanosecond-resolution hardware profiling.