# flame/blis architecture

> Architecture diagram of the GitHub repository flame/blis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flame/blis
- Repository: https://github.com/flame/blis

## Overview

##### Project Type and Purpose
- BLIS is an open-source C99 framework for instantiating high-performance BLAS-like libraries.
- It is not a monolithic service but a layered library and toolchain, with a build system, configurable kernels, API layers, plugin/addon support, test suites, examples, and CI integrations.

##### High-Level Components
- Build System
- configure scripts, makefiles, detection modules (build/, config/, ci/)
- code-generation and header flattening
- Core Framework (“frame”)
- base layer: data types, memory management, threading abstractions
- level-0 to level-3 algorithmic loops
- packing/unpacking infrastructure
- Kernel Implementations
- architecture-generic reference kernels (ref_kernels/)
- architecture-specific optimized kernels (kernels/<arch>/)
- APIs and Compatibility Layers
- object API (examples/oapi/)
- typed API (examples/tapi/)
- BLAS compatibility layer (compat/)
- CBLAS and F2C conversions
- Extensions
- Addons (addon/)
- Plugins (build/plugin/)
- Sandboxes (sandbox/)
- Testing and Examples
- testsuite/, test/ for automated correctness and performance
- examples/ for tutorial code
- CI & Packaging
- .circleci/, .travis.yml, appveyor.yml
- Debian/Gentoo spec files, conda recipes

##### Relationships and Interactions
- Build system invokes detection modules → generates config headers → compiles core framework + selected kernels → links into static/shared libraries.
- API layers sit atop core framework; compatibility layers wrap object/typed calls to core routines.
- Plugins/Addons hook into the control tree via build/plugin scripts and are compiled into the library when enabled.
- Test suite and examples link against the built libraries to verify functionality and performance.
- CI pipelines orchestrate configure, build, test, and packaging.

##### Architectural Patterns
- Layered modular architecture: separation of concerns between build/config, core algorithms, kernels, API surfaces, and tests.
- Plugin/inversion-of-control: control-tree based extensibility for custom operations.
- Code generation and template flattening for managing combinations of datatypes, operations, and architectures.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build System Layer
    subgraph "Build System"
        BuildSystem["Configure & Code-Gen"]:::build
        PlatformConfig["Platform Config & Makefile Templates"]:::build
    end

    %% Core Framework Layer
    subgraph "Core Framework"
        CoreFramework["Core Framework (frame/)"]:::core
        BaseLayer["Base Layer: datatypes, memory, threading"]:::core
        Algorithms["Level-0 to Level-3 Loops"]:::core
        Packing["Packing/Unpacking Infra"]:::core
    end

    %% Kernel Implementations
    subgraph "Kernel Implementations"
        RefKernels["Generic Ref Kernels"]:::generic
        ArchKernels["Arch-Specific Kernels"]:::specific
    end

    %% API and Compatibility
    subgraph "API & Compatibility Layers"
        ObjectAPI["Object API Examples"]:::api
        TypedAPI["Typed API Examples"]:::api
        BLASCompat["BLAS Compatibility Layer"]:::api
    end

    %% Extensions
    subgraph "Extensions"
        Addons["Addons"]:::ext
        Plugins["Plugin Support"]:::ext
        Sandboxes["Sandboxes"]:::ext
    end

    %% Libraries Outcome
    Libraries["Static/Shared Libraries"]:::library

    %% Testing and Examples
    subgraph "Testing & Examples"
        TestSuite["Automated Test Suite"]:::test
        UserTests["User-Level Tests & Benchmarks"]:::test
        Examples["General Examples & Tutorials"]:::test
    end

    %% CI & Packaging
    subgraph "CI & Packaging"
        CI["CI Integrations & Scripts"]:::test
        Packaging["Packaging"]:::test
    end

    %% Relationships
    CI -->|orchestrates| BuildSystem
    BuildSystem -->|"generates config headers"| CoreFramework
    BuildSystem -->|"compiles"| RefKernels
    BuildSystem -->|"compiles"| ArchKernels
    Plugins -->|"integrated via build"| BuildSystem
    Addons -->|"hook into core"| CoreFramework

    CoreFramework --> Libraries
    RefKernels --> Libraries
    ArchKernels --> Libraries

    Libraries --> ObjectAPI
    Libraries --> TypedAPI
    Libraries --> BLASCompat

    ObjectAPI --> Examples
    TypedAPI --> Examples
    BLASCompat --> Examples

    Libraries --> TestSuite
    Examples --> TestSuite
    TestSuite --> UserTests

    CI -->|runs tests| TestSuite
    CI -->|builds packages| Packaging

    %% Click Events
    click BuildSystem "https://github.com/flame/blis/tree/master/build/"
    click PlatformConfig "https://github.com/flame/blis/tree/master/config/"
    click CI "https://github.com/flame/blis/tree/master/ci/"
    click CoreFramework "https://github.com/flame/blis/tree/master/frame/"
    click RefKernels "https://github.com/flame/blis/tree/master/ref_kernels/"
    click ArchKernels "https://github.com/flame/blis/tree/master/kernels/"
    click ObjectAPI "https://github.com/flame/blis/tree/master/examples/oapi/"
    click TypedAPI "https://github.com/flame/blis/tree/master/examples/tapi/"
    click BLASCompat "https://github.com/flame/blis/tree/master/frame/compat/cblas/"
    click Addons "https://github.com/flame/blis/tree/master/addon/"
    click Plugins "https://github.com/flame/blis/tree/master/build/plugin/"
    click Sandboxes "https://github.com/flame/blis/tree/master/sandbox/"
    click Examples "https://github.com/flame/blis/tree/master/examples/"
    click TestSuite "https://github.com/flame/blis/tree/master/testsuite/"
    click UserTests "https://github.com/flame/blis/tree/master/test/"

    %% Styles
    classDef build fill:#cccccc,stroke:#333,stroke-width:1px
    classDef core fill:#a2d5f2,stroke:#333,stroke-width:1px
    classDef generic fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef specific fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef api fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef ext fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef library fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef test fill:#ef9a9a,stroke:#333,stroke-width:1px
```
