pygsti.tools.mpitools.compute_blas_threads#
- compute_blas_threads(num_ranks, blas_threads_per_rank)#
Return the number of BLAS threads that should be assigned to each MPI rank on the current node, assuming num_ranks in total.
- Parameters:
num_ranks (int) – Total number of MPI ranks launched on this node.
blas_threads_per_rank (int) – Desired thread count. When non-zero, returned as-is. When
0, the value is auto-detected asmax(1, num_physical_cpus // num_ranks).
- Returns:
Thread count per rank (always >= 1).
- Return type:
int
Notes
Auto-detection uses
psutil.cpu_count(logical=False)()when psutil is available, falling back toos.cpu_count(). The result is measured on the machine where this function is called, which may differ from remote HPC compute nodes. Pass an explicit blas_threads_per_rank when targeting a different machine.