Skip to main content

Set the number of threads for OpenBLAS, MKL, OMP, NumExpr, and Accelerate.

Project description

PyPI Build Status CodeCov GitHub Repo stars Documentation

numthreads is a concise, easy-to-use tool designed to set the number of threads for various computing libraries including OpenBLAS, Intel's Math Kernel Library (MKL), OpenMP, NumExpr, and Accelerate. This Python-based utility aids in optimizing the performance of numerical and scientific computing applications by allowing users to efficiently control the threading behavior of these key libraries.

:books: Table of Contents

:sparkles: Features

  • Simple and straightforward command-line interface.
  • Sets thread count for OpenBLAS, MKL, OpenMP, NumExpr, and Accelerate.
  • Context manager support for temporary thread setting in Python code.
  • Cross-platform compatibility (Linux, macOS, Windows).

:package: Installation

To install numthreads, run the following command:

pip install "numthreads"

:rocket: Quick Start

After installing numthreads, you can easily set the number of threads used by supported libraries via the command line. For example, to set the number of threads to 4, run:

numthreads 4

Unix-like Systems (Linux, macOS, WSL)

To apply the settings in your shell:

eval $(numthreads <number_of_threads>)

Windows (PowerShell)

In PowerShell, use:

Invoke-Expression $(numthreads <number_of_threads>)

Using as a Python Module

You can also use numthreads as a Python module:

from numthreads import set_num_threads

set_num_threads(4)

or

from numthreads import num_threads

with num_threads(4):
    # Your code here will run with the specified number of threads
    pass

:question: Getting Help

For more information, or to report issues, please visit numthreads GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numthreads-0.1.0.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

numthreads-0.1.0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page