How uxlfoundation/onetbb works
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.