{"id":5729,"library":"tbb","title":"Intel® oneAPI Threading Building Blocks (oneTBB)","description":"The `tbb` library provides Intel® oneAPI Threading Building Blocks (oneTBB), a C++ template library for parallel programming. The Python package primarily distributes the oneTBB C++ runtime libraries and headers, enabling other Python packages (e.g., NumPy, SciPy) to leverage TBB for parallelization. It is currently at version 2022.3.1 and sees regular updates, typically a few times per year, to introduce new features and address issues.","status":"active","version":"2022.3.1","language":"en","source_language":"en","source_url":"https://github.com/oneapi-src/oneTBB","tags":["parallel-computing","high-performance","c++","intel","runtime","scientific-computing"],"install":[{"cmd":"pip install tbb","lang":"bash","label":"Install the TBB Python package"}],"dependencies":[],"imports":[{"note":"Used to retrieve the installed TBB C++ library version.","symbol":"version_info","correct":"from tbb import version_info"},{"note":"Used to find the path to TBB C++ headers for compilation.","symbol":"include_dir","correct":"from tbb import include_dir"},{"note":"Used to find the path to TBB C++ shared libraries for linking.","symbol":"lib_dir","correct":"from tbb import lib_dir"}],"quickstart":{"code":"import tbb\nimport os\n\n# The 'tbb' Python package primarily provides access to the underlying\n# C++ library paths and version, not direct Python parallel computing APIs.\n# Other Python libraries (e.g., NumPy, SciPy) might be built to use TBB\n# and will detect it automatically if installed.\n\nprint(f\"TBB package version: {tbb.version_info}\")\n\n# Paths useful for C++ projects or Python extensions that link against TBB\nprint(f\"TBB C++ include directory: {tbb.include_dir()}\")\nprint(f\"TBB C++ library directory: {tbb.lib_dir()}\")\n\n# Example of checking if TBB-enabled features are available in another library\n# (Conceptual, 'some_tbb_enabled_lib' is a placeholder)\n# try:\n#     import some_tbb_enabled_lib\n#     if hasattr(some_tbb_enabled_lib, 'is_tbb_enabled') and some_tbb_enabled_lib.is_tbb_enabled():\n#         print(\"A TBB-enabled Python library is detected and can use TBB.\")\n# except ImportError:\n#     print(\"No specific TBB-enabled Python library found for direct usage example.\")","lang":"python","description":"Demonstrates how to import the `tbb` package to retrieve information about the installed Intel oneTBB C++ library, such as its version and file system paths. This is useful for verifying installation or for C++/Python interoperability projects."},"warnings":[{"fix":"Understand that `tbb` is a backend dependency provider. For Python parallelization, consider libraries like `joblib`, `numba`, or native `multiprocessing`.","message":"The `tbb` Python package primarily provides Intel oneTBB C++ runtime libraries and headers. It does not offer direct Python APIs for parallelizing Python code. Users typically interact with libraries like NumPy, SciPy, or scikit-learn, which may be *built against* TBB for their internal parallelization.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update C++ build scripts or environment configurations to use `C_INCLUDE_PATH` and `CPLUS_INCLUDE_PATH` instead of `CPATH` when building against TBB 2022.2.0 or newer.","message":"Environment variable names for C++ include paths changed in oneTBB 2022.2.0. `CPATH` was replaced by `C_INCLUDE_PATH` and `CPLUS_INCLUDE_PATH` to prevent unintended compiler warnings.","severity":"breaking","affected_versions":">=2022.2.0"},{"fix":"Ensure your development environment has a compatible C++ compiler (e.g., GCC, Clang, MSVC) and a build system (e.g., CMake, Make) configured to locate and link against the TBB libraries.","message":"While the `tbb` Python package provides the necessary shared objects and headers, direct C++ development or Python extensions that link against TBB still require a C++ compiler and appropriate build system setup.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When writing or updating C++ code that uses TBB, prefer `oneapi::tbb::` for types and functions. For older code, verify that the TBB version you are linking against provides the necessary `tbb::` aliases.","message":"The primary C++ namespace for TBB migrated from `tbb` to `oneapi::tbb` with the introduction of oneAPI. While aliases often exist for backward compatibility, new C++ code should use the `oneapi::tbb` namespace.","severity":"breaking","affected_versions":"Primarily >=2021.x"},{"fix":"For C++ code, migrate usage from `tbb::task_scheduler_init` to `tbb::task_arena` to leverage improved control and modern best practices for task scheduling.","message":"The `tbb::task_scheduler_init` class has been largely deprecated in modern TBB versions in favor of `tbb::task_arena` for finer-grained control over task execution and thread management.","severity":"deprecated","affected_versions":"Primarily >=2021.x"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}