threadpoolctl icon indicating copy to clipboard operation
threadpoolctl copied to clipboard

Add support for TBB introspection and set_num_thread

Open ogrisel opened this issue 5 years ago • 4 comments

It's possible to get a CI env with Threading Building Blocks as follows. At the moment threadpoolctl cannot detect TBB loaded by MKL itself loaded by numpy when MKL_THREADING_LAYER=TBB is set:

$ conda create -n numpy-tbb numpy tbb
$ conda activate numpy-tbb
$ MKL_THREADING_LAYER=TBB python -c "import numpy; from pprint import pprint; from threadpoolctl import threadpool_info; pprint(threadpool_info())"
[{'filepath': '/home/ogrisel/miniconda3/envs/mkl-threading-layer/lib/libmkl_rt.so',
  'internal_api': 'mkl',
  'num_threads': 2,
  'prefix': 'libmkl_rt',
  'user_api': 'blas',
  'version': '2019.0.4'}]

ogrisel avatar Oct 22 '19 12:10 ogrisel

The TBB file prefix should probably one of the following (tested under Linux):

$ MKL_THREADING_LAYER="TBB" strace python -c "import numpy" 2>&1 | grep open | grep tbb
openat(AT_FDCWD, "/home/ogrisel/miniconda3/envs/mkl-threading-layer/lib/python3.7/site-packages/mkl/../../../libtbb.so.2", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/home/ogrisel/miniconda3/envs/mkl-threading-layer/lib/python3.7/site-packages/mkl/../../../libmkl_tbb_thread.so", O_RDONLY|O_CLOEXEC) = 4

ogrisel avatar Oct 22 '19 12:10 ogrisel

conda create -n numpy-tbb numpy tbb

tbb should not be needed

jeremiedbb avatar Oct 22 '19 12:10 jeremiedbb

It is needed on my environment, see: https://github.com/ContinuumIO/anaconda-issues/issues/11389

ogrisel avatar Oct 22 '19 12:10 ogrisel

Ah ok. It's weird that I don't need it and you do

jeremiedbb avatar Oct 22 '19 12:10 jeremiedbb