Does MKLDNN has TBB support
Hi @mingfeima,
Currently Intel MKL-DNN cannot be built with TBB. But we are looking into supporting it. No ETA though.
Could you explain why you need TBB and what the use case is? Is it inference only or both inference and training?
@emfomenk TBB is recently introduced into PyTorch as facebook developers consider
- TBB is a more modern interface and has better interaction with C++11
- mkl-blas with TBB has better performance than OpenMP, they quote this
- TBB has msvc support while OpenMP4.0 doesn't so TBB is better for Windows support
however, this is causing great performance drop for CPU, see issue #7903, as a result of resource competition.
Is it possible for TBB and OpenMP to operate peacefully under one process?
Alas OpenMP RT is not aware of TBB run in parallel.
If OpenMP parallel regions are executed not in parallel with TBB threads (i.e. if you have linear model, and Intel MKL-DNN primitives use OpenMP, while all non-MKL-DNN primitives use TBB) -- you should be fine.
There are some techniques how you can make those two runtimes co-exist. In particular it is highly recommended to set KMP_BLOCKTIME environment variable to a small value (0, 1, or ~20). See this doc.
@emfomenk thanks so much on the update, i will try that out.
@mingfeima, it's important to note that the claim that Intel MKL BLAS performance with TBB threading is better than with OpenMP is incorrect. Assuming that a throughput bound function like SGEMM is executed on full system or resources can be statically partitioned (say, threads are pinned to a socket or a few cores) performance with OpenMP will be better. The article you refer to considers very specific scenario when several Intel MKL functions are executed in parallel and OpenMP thread pools spawned from several different threads are competing for compute resources (this is called 'oversubscription'). For that scenario using TBB threading indeed results in better application level performance.
There were bits of useful information posted in Pytorch thread. Copying these here for interested people to find.
The question of OpenMP and TBB threading composability is discussed in details in Scipy proceedings. The core of recommendation for peaceful coexistence between runtimes suggested in the article is the following:
export KMP_BLOCKTIME=1
export KMP_COMPOSABILITY=mode=exclusive
@emfomenk https://software.intel.com/en-us/articles/using-intel-mkl-and-intel-tbb-in-the-same-application
why can they compile mkl with tbb