Skip to content

Commit 6be9496

Browse files
committed
Merge pull request opencv#19384 from mshabunin:support-onetbb
2 parents 900051c + 46b2da4 commit 6be9496

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

3rdparty/tbb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ ocv_install_target(tbb EXPORT OpenCVModules
170170

171171
ocv_install_3rdparty_licenses(tbb "${tbb_src_dir}/LICENSE" "${tbb_src_dir}/README")
172172

173-
ocv_tbb_read_version("${tbb_src_dir}/include")
173+
ocv_tbb_read_version("${tbb_src_dir}/include" tbb)

cmake/OpenCVDetectTBB.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# - "tbb" target exists and added to OPENCV_LINKER_LIBS
2020

2121
function(ocv_tbb_cmake_guess _found)
22-
find_package(TBB QUIET COMPONENTS tbb PATHS "$ENV{TBBROOT}/cmake")
22+
find_package(TBB QUIET COMPONENTS tbb PATHS "$ENV{TBBROOT}/cmake" "$ENV{TBBROOT}/lib/cmake/tbb")
2323
if(TBB_FOUND)
2424
if(NOT TARGET TBB::tbb)
2525
message(WARNING "No TBB::tbb target found!")
@@ -28,11 +28,11 @@ function(ocv_tbb_cmake_guess _found)
2828
get_target_property(_lib TBB::tbb IMPORTED_LOCATION_RELEASE)
2929
message(STATUS "Found TBB (cmake): ${_lib}")
3030
get_target_property(_inc TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
31-
ocv_tbb_read_version("${_inc}")
3231
add_library(tbb INTERFACE IMPORTED)
3332
set_target_properties(tbb PROPERTIES
3433
INTERFACE_LINK_LIBRARIES TBB::tbb
3534
)
35+
ocv_tbb_read_version("${_inc}" tbb)
3636
set(${_found} TRUE PARENT_SCOPE)
3737
endif()
3838
endfunction()
@@ -66,7 +66,6 @@ function(ocv_tbb_env_guess _found)
6666
find_library(TBB_ENV_LIB_DEBUG NAMES "tbb_debug")
6767
if (TBB_ENV_INCLUDE AND (TBB_ENV_LIB OR TBB_ENV_LIB_DEBUG))
6868
ocv_tbb_env_verify()
69-
ocv_tbb_read_version("${TBB_ENV_INCLUDE}")
7069
add_library(tbb UNKNOWN IMPORTED)
7170
set_target_properties(tbb PROPERTIES
7271
IMPORTED_LOCATION "${TBB_ENV_LIB}"
@@ -82,12 +81,14 @@ function(ocv_tbb_env_guess _found)
8281
get_filename_component(_dir "${TBB_ENV_LIB}" DIRECTORY)
8382
set_target_properties(tbb PROPERTIES INTERFACE_LINK_LIBRARIES "-L${_dir}")
8483
endif()
84+
ocv_tbb_read_version("${TBB_ENV_INCLUDE}" tbb)
8585
message(STATUS "Found TBB (env): ${TBB_ENV_LIB}")
8686
set(${_found} TRUE PARENT_SCOPE)
8787
endif()
8888
endfunction()
8989

90-
function(ocv_tbb_read_version _path)
90+
function(ocv_tbb_read_version _path _tgt)
91+
find_file(TBB_VER_FILE oneapi/tbb/version.h "${_path}" NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
9192
find_file(TBB_VER_FILE tbb/tbb_stddef.h "${_path}" NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
9293
ocv_parse_header("${TBB_VER_FILE}" TBB_VERSION_LINES TBB_VERSION_MAJOR TBB_VERSION_MINOR TBB_INTERFACE_VERSION CACHE)
9394
endfunction()

cmake/OpenCVFindMKL.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,10 @@ if(MKL_USE_SINGLE_DYNAMIC_LIBRARY AND NOT (MKL_VERSION_STR VERSION_LESS "10.3.0"
118118

119119
elseif(NOT (MKL_VERSION_STR VERSION_LESS "11.3.0"))
120120

121-
foreach(MKL_ARCH ${MKL_ARCH_LIST})
122-
list(APPEND mkl_lib_find_paths
123-
${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH}
124-
)
125-
endforeach()
126-
127121
set(mkl_lib_list "mkl_intel_${MKL_ARCH_SUFFIX}")
128122

129123
if(MKL_WITH_TBB)
130-
list(APPEND mkl_lib_list mkl_tbb_thread tbb)
124+
list(APPEND mkl_lib_list mkl_tbb_thread)
131125
elseif(MKL_WITH_OPENMP)
132126
if(MSVC)
133127
list(APPEND mkl_lib_list mkl_intel_thread libiomp5md)
@@ -155,6 +149,7 @@ if(NOT MKL_LIBRARIES)
155149
endif()
156150
list(APPEND MKL_LIBRARIES ${${lib_var_name}})
157151
endforeach()
152+
list(APPEND MKL_LIBRARIES ${OPENCV_EXTRA_MKL_LIBRARIES})
158153
endif()
159154

160155
message(STATUS "Found MKL ${MKL_VERSION_STR} at: ${MKL_ROOT_DIR}")

modules/core/src/parallel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
#endif
104104
#include "tbb/tbb.h"
105105
#include "tbb/task.h"
106-
#include "tbb/tbb_stddef.h"
107106
#if TBB_INTERFACE_VERSION >= 8000
108107
#include "tbb/task_arena.h"
109108
#endif

modules/gapi/src/executor/gtbbexecutor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
#include "gtbbexecutor.hpp"
88

9-
#if defined(HAVE_TBB)
9+
#if defined(HAVE_TBB) && (TBB_INTERFACE_VERSION < 12000)
10+
// TODO: TBB task API has been deprecated and removed in 12000
11+
1012
#include "gapi_itt.hpp"
1113

1214
#include <opencv2/gapi/own/assert.hpp>
@@ -442,4 +444,4 @@ std::ostream& cv::gimpl::parallel::operator<<(std::ostream& o, tile_node const&
442444
return o;
443445
}
444446

445-
#endif // HAVE_TBB
447+
#endif // HAVE_TBB && TBB_INTERFACE_VERSION

modules/gapi/src/executor/gtbbexecutor.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
#include <opencv2/cvconfig.h>
1212
#endif
1313

14-
#if defined(HAVE_TBB)
14+
#ifdef HAVE_TBB
15+
#include <tbb/tbb.h>
16+
#include <tbb/task.h>
17+
#if TBB_INTERFACE_VERSION < 12000
18+
// TODO: TBB task API has been deprecated and removed in 12000
1519

1620
#include <atomic>
1721
#include <vector>
@@ -98,6 +102,7 @@ void execute(prio_items_queue_t& q, tbb::task_arena& arena);
98102

99103
}}} // namespace cv::gimpl::parallel
100104

105+
#endif // TBB_INTERFACE_VERSION
101106
#endif // HAVE_TBB
102107

103108
#endif // OPENCV_GAPI_TBB_EXECUTOR_HPP

modules/gapi/test/executor/gtbbexecutor_internal_tests.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
// Deliberately include .cpp file instead of header as we use non exported function (execute)
88
#include <executor/gtbbexecutor.cpp>
99

10-
#if defined(HAVE_TBB)
10+
#ifdef HAVE_TBB
11+
#include <tbb/tbb.h>
12+
#include <tbb/task.h>
13+
#if TBB_INTERFACE_VERSION < 12000
1114

12-
#include "../test_precomp.hpp"
1315
#include <tbb/task_arena.h>
16+
17+
#include "../test_precomp.hpp"
1418
#include <thread>
1519

1620
namespace {
@@ -169,4 +173,6 @@ TEST(TBBExecutor, Dependencies) {
169173
}
170174
}
171175
} // namespace opencv_test
176+
177+
#endif //TBB_INTERFACE_VERSION
172178
#endif //HAVE_TBB

0 commit comments

Comments
 (0)