core, gapi: supported build with oneTBB 2021#19384
core, gapi: supported build with oneTBB 2021#19384opencv-pushbot merged 2 commits intoopencv:masterfrom
Conversation
|
Also, if possible, I would like to request to fix old problem with TBB (that is also related to oneAPI updates). Problem that is directly related to oneAPI TBB is that with this TBB version search path needs to be adjusted |
|
@h6197627 , is |
|
@mshabunin , I have OpenCV built with TBB and MKL with TBB so I can't say for sure that TBB linkage is not necessary for -D WITH_TBB=OFF -D MKL_WITH_TBB=ON. It might be that this check is redundant. it is not linked to tbb library (although, when installing TBB threading support component of MKL distribution it installs libtbb.so, so I guess it is not statically linked into libmkl_tbb_thread.so), so it probably uses some sort of runtime dispatch. Considering, static linkage, I am completely not aware of such usage (although libmkl_tbb_thread.a library exists). |
modules/core/src/parallel.cpp
Outdated
| #include "tbb/tbb.h" | ||
| #include "tbb/task.h" | ||
| #if defined(OPENCV_TBB_VERSION_MAJOR) && OPENCV_TBB_VERSION_MAJOR >= 2021 | ||
| #include "tbb/version.h" |
There was a problem hiding this comment.
This can be detected through try_compile() or checking if(EXISTS ...) / TBB_VER_FILE.
There was a problem hiding this comment.
Thank you. Perhaps EXIST check would be the best. I'll update the PR.
There was a problem hiding this comment.
Looks like we don't these conditional includes at all.
tbb/version.h or tbb/tbb_stddef.h is included by tbb/tbb.h or by tbb/task.h:
- latest public release (2021.1): https://github.com/oneapi-src/oneTBB/blame/onetbb_2021/include/oneapi/tbb.h#L71 (
version.h) - 2017+: https://github.com/oneapi-src/oneTBB/blame/2017_U1/include/tbb/task.h#L24 (
tbb_stddef.h) - 2021-beta05 still uses
tbb/stddef.h: https://github.com/oneapi-src/oneTBB/commits/88b4c2782a530db1e66947edd2b24699b67850ab/include/tbb/tbb_stddef.h - 2021-beta08+ uses
version.h: https://github.com/oneapi-src/oneTBB/blame/v2021.1-beta08/include/tbb/tbb.h#L71
P.S. TBB team is not able to work properly with Git history (too many branches are created from clean repo state with lost history)
There was a problem hiding this comment.
Removal of these includes works. Tested even on Ubuntu 14.04 with "TBB (ver 4.2 interface 7000)"
fde32fb to
eaf469b
Compare
|
@alalek , I've updated macros mechanism as you suggested. @h6197627 , I've removed tbb from MKL-TBB dependencies list. Still not sure if it is required, builds with oneAPI without issues ( Please check on your side if possible. |
|
@mshabunin , and 2020.1.217 (which I posted before) does not: |
| #include "gtbbexecutor.hpp" | ||
|
|
||
| #if defined(HAVE_TBB) | ||
| #if defined(HAVE_TBB) && !defined(OPENCV_TBB_USE_VERSION_H) |
There was a problem hiding this comment.
Need to include tbb.h / tbb/task.h and then check TBB_INTERFACE_VERSION < XYZ instead.
Perhaps XYZ should be < 12000, because -DWITH_TBB=ON -DBUILD_TBB=ON uses 2020.2 with interface 11102 and gapi builds succesfully.
BTW, Please add a comment which API is not available.
| set(mkl_lib_list "mkl_intel_${MKL_ARCH_SUFFIX}") | ||
|
|
||
| if(MKL_WITH_TBB) | ||
| list(APPEND mkl_lib_list mkl_tbb_thread tbb) |
There was a problem hiding this comment.
Lets allow to add custom libraries below:
list(APPEND MKL_LIBRARIES ${OPENCV_EXTRA_MKL_LIBRARIES})
eaf469b to
181c9f1
Compare
826c842 to
46b2da4
Compare
|
Validated with:
(
|
|
Wow, thanks folks! |
|
Please back-port the fix for OpenCV v3.x |
|
@dizcza , if you already have cherry-picked commit for 3.4 which you've tested with recent oneTBB, then you can propose it in a PR. It might be faster this way. |
resolves #19358
Build Instruction
Sourcing env.sh is not required.
Notes
tbb::taskinterface being usedTBB_INTERFACE_VERmacro defined in tbb_stddef.h to distinguish between versions, but this file has been removed in favor of new version.hpp file. Thus we had to add our own definitions provided via cmake to be able to include correct header:OPENCV_TBB_VERSION_{MAJOR,MINOR}. These two can be replaced with singleTBB_USE_VERSION_Hdefinition for better clarity and compactness.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.