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.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

numthreads-0.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file numthreads-0.2.0.tar.gz.

File metadata

  • Download URL: numthreads-0.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for numthreads-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cce220c6f70d106bc780700812cb999d2f8d1f25f92c231ea12ea00df314bb18
MD5 4ac8510f2a1c3d82c1cf5ada32b0aae2
BLAKE2b-256 da870389a27570d149f6bfc5f94aab0a40391fcbebd078b865b7085d2fe7eac5

See more details on using hashes here.

File details

Details for the file numthreads-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: numthreads-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for numthreads-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 908283f323155765ea7cc509d0e77145b1de92412cb7d4c4a1cd4c3ed3351ab9
MD5 027dfcee6c294b5f53d908df1ff52597
BLAKE2b-256 9e83bc6503b53bcb51ac59a212727a6ec235118b4b9435aaf788ef02b07d0c70

See more details on using hashes here.

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