request_omp_threading¶
- request_omp_threading(num_threads: int | None = None)[source]¶
A context manager to override the session-wise OMP threading setting on CASA MPI client.
This function improves certain CASAtask/tool call performance on the MPI client by temporarily enabling OpenMP threading while the MPI servers are idle. The feature only takes effect under restricted circumstances to avoid competing with MPI server processes from tier0 or tier1 parallelization.
This function can be used as both a decorator and context manager:
- Example usage as decorator:
@request_omp_threading(4) def do_something():
...
- Example usage as context manager:
- with request_omp_threading(4):
immoments(..)
Note
Use with caution and carefully examine computing resource allocation at the execution point.
The casalog.ompGet/SetNumThreads() API doesn't work as expected on macOS as of CASA ver6.6.1, although runtime env var (i.e. OMP_NUM_THREADS) is respected.