process

  • full name: tenpy.tools.process

  • parent module: tenpy.tools

  • type: module

Functions

load_omp_library([libs, verbose])

Tries to load openMP library.

memory_usage()

Return memory usage of the running python process.

mkl_get_nthreads()

wrapper around MKL get_max_threads.

mkl_set_nthreads(n)

wrapper around MKL set_num_threads.

omp_get_nthreads()

wrapper around OpenMP get_max_threads.

omp_set_nthreads(n)

wrapper around OpenMP set_nthreads.

Module description

Tools to read out total memory usage and get/set the number of threads.

If your python is compiled against MKL (e.g. if you use anaconda as recommended in INSTALL), it will by default use as many threads as CPU cores are available. If you run a job on a cluster, you should limit this to the number of cores you reserved – otherwise your colleagues might get angry… A simple way to achieve this is to set a suitable environment variable before calling your python program, e.g. on the linux bash export OMP_NUM_THREADS=4 for 4 threads. (MKL used OpenMP and thus respects its settings.)

Alternatively, this module provides omp_get_nthreads() and omp_set_nthreads(), which give their best to get and set the number of threads at runtime, while still being failsafe if the shared OpenMP library is not found. In the latter case, you might also try the equivalent mkl_get_nthreads() and mkl_set_nthreads().