# uxlfoundation/onetbb architecture

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

- Interactive diagram: https://gitdiagram.com/uxlfoundation/onetbb
- Repository: https://github.com/uxlfoundation/onetbb

## Overview

##### Major Components
- Core Library Implementation:
- The “src” directory contains the heart of oneTBB’s functionality (task scheduling, work stealing, flow graph support, and concurrency primitives).
- Under “src/tbb”, you see modules for arenas, task scheduling, dynamic linking, cancellation, and other internal details.
- Public API and Headers:
- The “include” directory (especially include/oneapi/tbb) exposes the public interface for client applications. This is where parallel_for, parallel_invoke, flow_graph, and other APIs reside.
- Memory Allocation and Bindings:
- The directories “src/tbbmalloc” and “src/tbbmalloc_proxy” provide memory allocation support specific to TBB.
- The “src/tbbbind” shows binding components that integrate or wrap functionality.
- Build and Integration Frameworks:
- Notice multiple build systems: Bazel (WORKSPACE.bazel, BUILD.bazel, etc.), CMake (CMakeLists.txt, cmake subdirectories), and integration scripts (integration folder for Linux, Mac, Windows). This indicates cross-platform support and multiple build configurations.
- Examples and Documentation:
- The “examples” directory contains many small projects showcasing TBB usage (like graph, parallel_for, task_arena, etc.). These can be treated as client or usage scenarios in the overall ecosystem.
- “doc” is used for autogenerated documentation (with Doxygen configuration files and reStructuredText files) that help guide users.
- Tests and Conformance:
- The “test” directory (with subdirectories for conformance and tbb-specific tests) is vital to capture how the internal modules should behave.
- Additional Bindings and Python Modules:
- The “python” folder suggests Python integration (with a setup.py and some proxy files) and might be depicted to show how oneTBB exposes its functionality to alternate language ecosystems.
- RFCs and Governance:
- The “rfcs” directory shows proposals and experimental changes. This informs architectural evolution and design decisions.

##### Relationships and Interactions
- The Core Library (src and include) is the central piece. It connects to:
- The Memory Allocator modules (tbbmalloc and tbbmalloc_proxy) via internal API calls.
- Task scheduling, flow graph, and parallel algorithms all interoperate inside the core.
- The Build System (cmake, Bazel, integration directories) orchestrates compilation, linking, and deployment across multiple target platforms. This part should be drawn as the “infrastructure” supporting the core modules.
- Integration layers (python, tbbbind) connect the core library with external programming environments.
- Documentation and RFCs provide guidance and design patterns for users and maintainers—they are connected to the core architecture but are non-runtime components.

##### Architectural Patterns and Design Principles
- Modular Design: oneTBB is divided into clear modules (core scheduling, memory allocation, binding/integration) with separate directories emphasizing separation of concerns.
- Extensibility: The “rfcs” folder and numerous configuration files (CMake, Bazel, integration scripts) stress the importance of supporting multiple platforms and evolving API designs.
- Concurrency Abstractions: Illustrate how the library provides logical parallelism using workload abstractions (flow graphs, tasks, parallel loops) rather than raw threads.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Integration"
        buildConfig["Build Configurations"]:::build
        platformIntegration["Platform Integration Scripts"]:::build
    end

    subgraph "Core Abstractions"
        coreImpl["Core Implementation"]:::core
        publicAPI1["Public API (oneapi/tbb)"]:::core
        publicAPI2["Public API (tbb)"]:::core
    end

    subgraph "Memory Management"
        memoryAlloc["Memory Allocator"]:::memory
        memoryProxy["Memory Allocator Proxy"]:::memory
    end

    subgraph "Bindings"
        cppBindings["C++ Bindings"]:::binding
        pythonBindings["Python Bindings"]:::binding
    end

    subgraph "Examples & Tests"
        examples["Examples"]:::example
        tests["Tests & Conformance"]:::example
    end

    subgraph "Documentation & RFCs"
        documentation["Documentation"]:::doc
        rfcs["RFCs & Governance"]:::doc
    end

    %% Build & Integration connects to all major components
    buildConfig --> coreImpl
    buildConfig --> publicAPI1
    buildConfig --> publicAPI2
    buildConfig --> memoryAlloc
    buildConfig --> memoryProxy
    buildConfig --> cppBindings
    buildConfig --> pythonBindings
    buildConfig --> examples
    buildConfig --> tests
    buildConfig --> documentation
    buildConfig --> rfcs

    %% Examples & Tests depend on Core Abstractions
    examples --> coreImpl
    tests --> coreImpl

    %% Bindings layer connects to Core Abstractions
    cppBindings --> coreImpl
    pythonBindings --> coreImpl

    %% Core Abstractions and Memory Management interact
    coreImpl <--> memoryAlloc

    %% Click Events
    click coreImpl "https://github.com/uxlfoundation/onetbb/tree/master/src/tbb"
    click publicAPI1 "https://github.com/uxlfoundation/onetbb/tree/master/include/oneapi/tbb"
    click publicAPI2 "https://github.com/uxlfoundation/onetbb/tree/master/include/tbb"
    click memoryAlloc "https://github.com/uxlfoundation/onetbb/tree/master/src/tbbmalloc"
    click memoryProxy "https://github.com/uxlfoundation/onetbb/tree/master/src/tbbmalloc_proxy"
    click cppBindings "https://github.com/uxlfoundation/onetbb/tree/master/src/tbbbind"
    click pythonBindings "https://github.com/uxlfoundation/onetbb/tree/master/python"
    click buildConfig "https://github.com/uxlfoundation/onetbb/blob/master/CMakeLists.txt"
    click platformIntegration "https://github.com/uxlfoundation/onetbb/tree/master/integration"
    click examples "https://github.com/uxlfoundation/onetbb/tree/master/examples"
    click tests "https://github.com/uxlfoundation/onetbb/tree/master/test"
    click documentation "https://github.com/uxlfoundation/onetbb/tree/master/doc"
    click rfcs "https://github.com/uxlfoundation/onetbb/tree/master/rfcs"

    %% Classes
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef memory fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef binding fill:#FAD7A0,stroke:#B9770E,stroke-width:2px;
    classDef build fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef example fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef doc fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
```
