# openmathlib/openblas architecture

> Architecture diagram of the GitHub repository openmathlib/openblas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openmathlib/openblas
- Repository: https://github.com/openmathlib/openblas

## Overview

OpenBLAS is an optimized BLAS library that also includes LAPACK. A caller uses the CBLAS/BLAS interfaces to request vector, matrix-vector, or matrix-matrix operations; LAPACK interfaces provide higher-level factorizations and solves. Drivers and compute kernels implement the numerical work, with CPU-specific variants supporting optimization across architectures. Runtime components provide threading, memory management, and configuration. The README establishes the product capabilities; source excerpts are incomplete, so implementation links not directly demonstrated are marked unverified.

Main entry points: [`driver/level3`](https://github.com/openmathlib/openblas/tree/develop/driver/level3) (Matrix-matrix operations), [`cblas.h`](https://github.com/openmathlib/openblas/blob/develop/cblas.h) (CBLAS API), [`driver/level2`](https://github.com/openmathlib/openblas/tree/develop/driver/level2) (Matrix-vector operations), [`kernel/generic`](https://github.com/openmathlib/openblas/tree/develop/kernel/generic) (Generic kernels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Numerical interfaces"]
  node_cblas["CBLAS API<br/>[cblas.h]"]
  node_interface_common["Interface contracts<br/>[common_interface.h]"]
  node_level1_api["Level 1 API<br/>[common_level1.h]"]
  node_level2_api["Level 2 API<br/>[common_level2.h]"]
  node_level3_api["Level 3 API<br/>[common_level3.h]"]
  node_lapack_api["LAPACK API<br/>[common_lapack.h]"]
end

subgraph group_compute["Numerical computation"]
  node_level1["Vector operations"]
  node_level2["Matrix-vector operations"]
  node_level3["Matrix-matrix operations"]
  node_lapack["Factorizations and solves"]
  node_lapack_interface["LAPACK wrappers"]
end

subgraph group_platform["Platform optimization"]
  node_generic_kernels["Generic kernels"]
  node_arch_kernels["Architecture kernels"]
  node_cpu_dispatch["CPU dispatch<br/>[dynamic.c]"]
  node_common_config["Core configuration<br/>[common.h]"]
end

subgraph group_runtime["Runtime services"]
  node_threading["Threading runtime<br/>[blas_server.c]"]
  node_memory["Memory management<br/>[memory.c]"]
  node_runtime_controls["Runtime controls"]
end

node_caller(("Application caller"))

node_caller -.->|"calls"| node_cblas
node_cblas -.->|"dispatches"| node_level1
node_cblas -.->|"dispatches"| node_level2
node_cblas -.->|"dispatches"| node_level3
node_lapack_api -.->|"exposes"| node_lapack_interface
node_lapack_interface -.->|"invokes"| node_lapack
node_level1 -.->|"uses kernels"| node_generic_kernels
node_level2 -.->|"uses kernels"| node_generic_kernels
node_level3 -.->|"uses kernels"| node_generic_kernels
node_lapack -.->|"uses operations"| node_level3
node_cpu_dispatch -.->|"selects kernels"| node_arch_kernels
node_common_config -.->|"configures"| node_cpu_dispatch
node_level2 -.->|"parallelizes via"| node_threading
node_level3 -.->|"parallelizes via"| node_threading
node_caller -.->|"configures"| node_runtime_controls
node_level3 -.->|"allocates via"| node_memory

click node_cblas "https://github.com/openmathlib/openblas/blob/develop/cblas.h"
click node_interface_common "https://github.com/openmathlib/openblas/blob/develop/common_interface.h"
click node_level1_api "https://github.com/openmathlib/openblas/blob/develop/common_level1.h"
click node_level2_api "https://github.com/openmathlib/openblas/blob/develop/common_level2.h"
click node_level3_api "https://github.com/openmathlib/openblas/blob/develop/common_level3.h"
click node_lapack_api "https://github.com/openmathlib/openblas/blob/develop/common_lapack.h"
click node_level1 "https://github.com/openmathlib/openblas/tree/develop/interface"
click node_level2 "https://github.com/openmathlib/openblas/tree/develop/driver/level2"
click node_level3 "https://github.com/openmathlib/openblas/tree/develop/driver/level3"
click node_lapack "https://github.com/openmathlib/openblas/tree/develop/lapack"
click node_lapack_interface "https://github.com/openmathlib/openblas/tree/develop/interface/lapack"
click node_generic_kernels "https://github.com/openmathlib/openblas/tree/develop/kernel/generic"
click node_arch_kernels "https://github.com/openmathlib/openblas/tree/develop/kernel/arm64"
click node_cpu_dispatch "https://github.com/openmathlib/openblas/blob/develop/driver/others/dynamic.c"
click node_common_config "https://github.com/openmathlib/openblas/blob/develop/common.h"
click node_threading "https://github.com/openmathlib/openblas/blob/develop/driver/others/blas_server.c"
click node_memory "https://github.com/openmathlib/openblas/blob/develop/driver/others/memory.c"
click node_runtime_controls "https://github.com/openmathlib/openblas/blob/develop/driver/others/openblas_set_num_threads.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cblas,node_interface_common,node_level1_api,node_level2_api,node_level3_api,node_lapack_api toneBlue
class node_level1,node_level2,node_level3,node_lapack,node_lapack_interface toneAmber
class node_generic_kernels,node_arch_kernels,node_cpu_dispatch,node_common_config toneMint
class node_threading,node_memory,node_runtime_controls toneRose
class node_caller toneIndigo
```

## Components

### Numerical interfaces

- [CBLAS API](https://github.com/openmathlib/openblas/blob/develop/cblas.h): `cblas.h`
- [Interface contracts](https://github.com/openmathlib/openblas/blob/develop/common_interface.h): `common_interface.h`
- [Level 1 API](https://github.com/openmathlib/openblas/blob/develop/common_level1.h): `common_level1.h`
- [Level 2 API](https://github.com/openmathlib/openblas/blob/develop/common_level2.h): `common_level2.h`
- [Level 3 API](https://github.com/openmathlib/openblas/blob/develop/common_level3.h): `common_level3.h`
- [LAPACK API](https://github.com/openmathlib/openblas/blob/develop/common_lapack.h): `common_lapack.h`

### Numerical computation

- [Vector operations](https://github.com/openmathlib/openblas/tree/develop/interface): `interface`
- [Matrix-vector operations](https://github.com/openmathlib/openblas/tree/develop/driver/level2): `driver/level2`
- [Matrix-matrix operations](https://github.com/openmathlib/openblas/tree/develop/driver/level3): `driver/level3`
- [Factorizations and solves](https://github.com/openmathlib/openblas/tree/develop/lapack): `lapack`
- [LAPACK wrappers](https://github.com/openmathlib/openblas/tree/develop/interface/lapack): `interface/lapack`

### Platform optimization

- [Generic kernels](https://github.com/openmathlib/openblas/tree/develop/kernel/generic): `kernel/generic`
- [Architecture kernels](https://github.com/openmathlib/openblas/tree/develop/kernel/arm64): `kernel/arm64`
- [CPU dispatch](https://github.com/openmathlib/openblas/blob/develop/driver/others/dynamic.c): `driver/others/dynamic.c`
- [Core configuration](https://github.com/openmathlib/openblas/blob/develop/common.h): `common.h`

### Runtime services

- [Threading runtime](https://github.com/openmathlib/openblas/blob/develop/driver/others/blas_server.c): `driver/others/blas_server.c`
- [Memory management](https://github.com/openmathlib/openblas/blob/develop/driver/others/memory.c): `driver/others/memory.c`
- [Runtime controls](https://github.com/openmathlib/openblas/blob/develop/driver/others/openblas_set_num_threads.c): `driver/others/openblas_set_num_threads.c`

### Other components

- **Application caller**

## Connections

- Application caller → CBLAS API: calls
- CBLAS API → Vector operations: dispatches
- CBLAS API → Matrix-vector operations: dispatches
- CBLAS API → Matrix-matrix operations: dispatches
- LAPACK API → LAPACK wrappers: exposes
- LAPACK wrappers → Factorizations and solves: invokes
- Vector operations → Generic kernels: uses kernels
- Matrix-vector operations → Generic kernels: uses kernels
- Matrix-matrix operations → Generic kernels: uses kernels
- Factorizations and solves → Matrix-matrix operations: uses operations
- CPU dispatch → Architecture kernels: selects kernels
- Core configuration → CPU dispatch: configures
- Matrix-vector operations → Threading runtime: parallelizes via
- Matrix-matrix operations → Threading runtime: parallelizes via
- Application caller → Runtime controls: configures
- Matrix-matrix operations → Memory management: allocates via
