OpenMP: The C/C++ Parallel Standard in Numba

Numba integrates OpenMP, a widely adopted directive-based API for shared-memory parallelism in C/C++/Fortran, though it's often disabled in Numba's PyPI binary wheels due to compatibility and portability concerns, requiring a suitable runtime library.

The top 3

  1. OpenMP's 25+ Year Evolution: From Fortran Loops to GPU Offloading: OpenMP, initially for Fortran in 1997 and C/C++ in 1998, unified its specification in 2005. Major milestones include task-based parallelism (v3.0, 2008), accelerator support (v4.0, 2013), and the latest OpenMP 6.0 release in November 2024, significantly expanding its capabilities for heterogeneous systems.
  2. Numba's OpenMP Integration: Key Directives and Runtime Functions: Numba leverages OpenMP as a threading layer for CPU parallelization, especially with `prange` loops. The PyOMP extension allows direct use of OpenMP directives like `parallel` and `for` within Numba-jitted Python functions, along with runtime functions such as `omp_get_thread_num()` and `omp_set_num_threads()`. It also extends to GPU offloading via OpenMP's `target` directive.
  3. OpenMP vs. TBB: Numba's Parallel Backend Choices: Numba offers three threading layers for parallel execution: `omp` (OpenMP), `tbb` (Intel Threading Building Blocks), and `workqueue`. While OpenMP is often simpler for parallelizing independent loops, TBB excels with more complex parallel algorithms and concurrent data structures, especially for load-imbalanced tasks. Numba's OpenMP layer might require specific runtime libraries and faces portability challenges on PyPI binary wheels.

Sources

Open the full topic