diff --git a/CMakeLists.txt b/CMakeLists.txt index fd17283f77..2c47a14f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,16 @@ else () endif() set (CMAKE_CXX_STANDARD_REQUIRED ON) +# TBB +# There are differences between naming of main intel oneTBB library under Windows and Linux/Mac. +# Under Windows it called `tbb12` (files tbb12.lib/tbb12.dll), but under Linux it called `tbb` (file libtbb.so). +# Therefore, we make here global variable with kernel oneTBB library name: TBB_MAIN_LIBRARY_NAME. +if (WIN32) + set(TBB_MAIN_LIBRARY_NAME "TBB12") +else() + set(TBB_MAIN_LIBRARY_NAME "TBB") +endif() + # macro: include patched file if it exists macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE) if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake") @@ -733,14 +743,14 @@ if (NOT DEFINED ANDROID AND CAN_USE_TBB) add_definitions (-DHAVE_TBB) OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb") else() - OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB") + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_${TBB_MAIN_LIBRARY_NAME}") OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC") OCCT_CHECK_AND_UNSET ("INSTALL_TBB") endif() else() OCCT_CHECK_AND_UNSET ("USE_TBB") - OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB") + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_${TBB_MAIN_LIBRARY_NAME}") OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC") OCCT_CHECK_AND_UNSET ("INSTALL_TBB") endif() diff --git a/adm/cmake/occt_csf.cmake b/adm/cmake/occt_csf.cmake index bee8ba78d9..cd29f49721 100644 --- a/adm/cmake/occt_csf.cmake +++ b/adm/cmake/occt_csf.cmake @@ -12,7 +12,9 @@ endif() # TBB if (USE_TBB) - set (CSF_TBB "tbb tbbmalloc") + set (TBB_MAIN_LIBRARY_NAME_LOWERCASE "") + string (TOLOWER "${TBB_MAIN_LIBRARY_NAME}" TBB_MAIN_LIBRARY_NAME_LOWERCASE) + set (CSF_TBB "${TBB_MAIN_LIBRARY_NAME_LOWERCASE} tbbmalloc") else() set (CSF_TBB) endif() diff --git a/adm/cmake/tbb.cmake b/adm/cmake/tbb.cmake index 670fa4d338..8f52cf809d 100644 --- a/adm/cmake/tbb.cmake +++ b/adm/cmake/tbb.cmake @@ -286,9 +286,9 @@ endmacro() else() # the library directory for using by the executable if (WIN32) - set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR}) + set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_${TBB_MAIN_LIBRARY_NAME}_DLL_DIR}) else() - set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR}) + set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_${TBB_MAIN_LIBRARY_NAME}_LIBRARY_DIR}) endif() endif() #endif() diff --git a/adm/genconfdeps.tcl b/adm/genconfdeps.tcl index 1ffb65afdb..5a787bda1f 100644 --- a/adm/genconfdeps.tcl +++ b/adm/genconfdeps.tcl @@ -759,6 +759,10 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 } set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter"] + set aTbbMainLibName "tbb" + if { "$::tcl_platform(platform)" == "windows" } { + set aTbbMainLibName "tbb12" + } if { "$aTbbLibPath" == "" } { set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ] set aTbbLibPath [wokdep:SearchLib "tbb" "$anArchIter" "$aPath/lib/$aSubDir/$aVcLib"] @@ -775,19 +779,19 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/$aVcLib" } if { "$aTbbLibPath" == "" } { - lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)" + lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}$aTbbMainLibName.${::SYS_LIB_SUFFIX}' not found (Intel TBB)" if { "$::ARCH" == "$anArchIter"} { set isFound "false" } } } if { "$::tcl_platform(platform)" == "windows" } { - set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"] + set aTbbDllPath [wokdep:SearchBin "$aTbbMainLibName.dll" "$anArchIter"] if { "$aTbbDllPath" == "" } { set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ] - set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"] + set aTbbDllPath [wokdep:SearchBin "$aTbbMainLibName.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"] if { "$aTbbDllPath" != "" } { lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/$aVcLib" } else { - lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)" + lappend anErrBin$anArchIter "Error: '$aTbbMainLibName.dll' not found (Intel TBB)" if { "$::ARCH" == "$anArchIter"} { set isFound "false" } } } diff --git a/adm/genproj.tcl b/adm/genproj.tcl index 90ab8d16ae..e34680525e 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -1437,7 +1437,11 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} { set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil" } if { "$::HAVE_TBB" == "true" } { - set aLibsMap(CSF_TBB) "tbb tbbmalloc" + if { "$theOS" == "wnt" } { + set aLibsMap(CSF_TBB) "tbb12 tbbmalloc" + } else { + set aLibsMap(CSF_TBB) "tbb tbbmalloc" + } } if { "$::HAVE_VTK" == "true" } { if { "$theOS" == "wnt" } { diff --git a/adm/qmake/OccToolkit.pri b/adm/qmake/OccToolkit.pri index 3f18edb1cf..658ae9c644 100644 --- a/adm/qmake/OccToolkit.pri +++ b/adm/qmake/OccToolkit.pri @@ -23,7 +23,11 @@ CSF_TclLibs = -ltcl8.6 CSF_TclTkLibs = -ltk8.6 HAVE_FREEIMAGE { CSF_FreeImagePlus = -lfreeimage } else:win32 { CSF_FreeImagePlus = -lwindowscodecs -lole32 } HAVE_FFMPEG { CSF_FFmpeg = -lavcodec -lavformat -lswscale -lavutil } -HAVE_TBB { CSF_TBB = -ltbb -ltbbmalloc } +win32 { + HAVE_TBB { CSF_TBB = -ltbb12 -ltbbmalloc } +} else { + HAVE_TBB { CSF_TBB = -ltbb -ltbbmalloc } +} HAVE_ZLIB { CSF_ZLIB = -lzlib } HAVE_LIBLZMA { CSF_LIBLZMA = -lliblzma } HAVE_DRACO { CSF_Draco = -ldraco } diff --git a/adm/templates/custom.build.bat.in b/adm/templates/custom.build.bat.in index 39ad45085b..0898edd15a 100644 --- a/adm/templates/custom.build.bat.in +++ b/adm/templates/custom.build.bat.in @@ -11,7 +11,7 @@ if /I "%VCVER%" == "@COMPILER@" ( set "FREEIMAGE_DIR=@3RDPARTY_FREEIMAGE_DLL_DIRS@" set "EGL_DIR=@3RDPARTY_EGL_DLL_DIRS@" set "GLES2_DIR=@3RDPARTY_GLES2_DLL_DIRS@" - set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@" + set "TBB_DIR=@3RDPARTY_TBB12_DLL_DIR@" set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@" set "FFMPEG_DIR=@3RDPARTY_FFMPEG_DLL_DIR@" set "OPENVR_DIR=@3RDPARTY_OPENVR_DLL_DIRS@" diff --git a/dox/build/build_3rdparty/building_3rdparty.md b/dox/build/build_3rdparty/building_3rdparty.md index 2eee48c8eb..bc7d892671 100644 --- a/dox/build/build_3rdparty/building_3rdparty.md +++ b/dox/build/build_3rdparty/building_3rdparty.md @@ -128,8 +128,9 @@ You can download its sources from https://freetype.org/ @subsection dev_guides__building_3rdparty_win_3_1 TBB -This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb. -Go to the **Download** page, find the release version you need (e.g. `tbb30_018oss`) and pick the archive for Windows platform. +This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0. +Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Windows platform. +To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-win.zip`) Unpack the downloaded archive of TBB product into the `3rdparty` folder. @@ -304,9 +305,9 @@ Download the necessary archive from https://freetype.org/ and unpack it. @subsection dev_guides__building_3rdparty_linux_3_1 TBB -This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb. -Go to the **Download** page, find the release version you need and pick the archive for Linux platform. -To install, unpack the downloaded archive of TBB product. +This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0. +Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Linux platform. +To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-lin.tgz`). @subsection dev_guides__building_3rdparty_linux_3_3 FreeImage @@ -477,9 +478,9 @@ Download the necessary archive from https://freetype.org/ and unpack it. @subsection dev_guides__building_3rdparty_osx_3_1 TBB -This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb. -Go to the **Download** page, find the release version you need (e.g. `tbb30_018oss`) and pick the archive for Mac OS X platform. -To install, unpack the downloaded archive of TBB product (`tbb30_018oss_osx.tgz`). +This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0. +Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Mac OS X platform. +To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-mac.tgz`). @subsection dev_guides__building_3rdparty_osx_3_3 FreeImage diff --git a/dox/introduction/introduction.md b/dox/introduction/introduction.md index 866ef18100..ed538caf90 100644 --- a/dox/introduction/introduction.md +++ b/dox/introduction/introduction.md @@ -360,7 +360,7 @@ https://dev.opencascade.org/resources/download/3rd-party-components | Component | Where to find | Used for | Purpose | | --------- | ------------- | -------- | -------------------- | | CMake 3.1+ | https://cmake.org/ | Configuration | Build from sources | -| Intel TBB 4.x or later | https://oneapi-src.github.io/oneTBB/ | All | Parallelization of algorithms (alternative to built-in thread pool) | +| Intel oneTBB 2021.5.0 | https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0 | All | Parallelization of algorithms (alternative to built-in thread pool) | | OpenGL 3.3+, OpenGL ES 2.0+ | System | Visualization | Required for using 3D Viewer | | OpenVR 1.10+ | https://github.com/ValveSoftware/openvr | Visualization | VR (Virtual Reality) support in 3D Viewer | | FreeType 2.4+ | https://www.freetype.org/download.html | Visualization | Text rendering in 3D Viewer | @@ -572,7 +572,7 @@ FreeType 2 is released under two open-source licenses: BSD-like FreeType License It is a library that helps you to take advantage of multi-core processor performance without having to be a threading expert. Threading Building Blocks is not just a threads-replacement library. It represents a higher-level, task-based parallelism that abstracts platform details and threading mechanisms for scalability and performance. -TBB version 2017 is available under Apache 2.0 license, while older versions +oneTBB 2021.5.0 is available under Apache 2.0 license, while older versions until 4.4 are available under GPLv2 license with the runtime exception (https://www.threadingbuildingblocks.org). **OpenGL** is an industry standard API for 3D graphics used by OCCT for diff --git a/samples/qt/IESample/IESample.pro b/samples/qt/IESample/IESample.pro index 12f51c7069..fe6da97701 100755 --- a/samples/qt/IESample/IESample.pro +++ b/samples/qt/IESample/IESample.pro @@ -51,7 +51,11 @@ unix { DEFINES += OCC_CONVERT_SIGNALS QT_NO_STL !macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD LIBS += -lfreeimageplus - LIBS += -ltbb -ltbbmalloc + win32 { + LIBS += -ltbb12 -ltbbmalloc + } else { + LIBS += -ltbb -ltbbmalloc + } QMAKE_CXXFLAGS += -std=gnu++11 } diff --git a/src/OSD/OSD_Parallel.hxx b/src/OSD/OSD_Parallel.hxx index 7f24cf039c..8e1e7b620b 100644 --- a/src/OSD/OSD_Parallel.hxx +++ b/src/OSD/OSD_Parallel.hxx @@ -125,10 +125,10 @@ protected: // Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually: using iterator_category = std::forward_iterator_tag; - using value_type = UniversalIterator; + using value_type = IteratorInterface*; using difference_type = ptrdiff_t; - using pointer = UniversalIterator*; - using reference = UniversalIterator&; + using pointer = value_type; + using reference = value_type; UniversalIterator() {} @@ -171,18 +171,8 @@ protected: return aValue; } - const UniversalIterator& operator* () const { return *this; } - UniversalIterator& operator* () { return *this; } - - const UniversalIterator* operator->() const { return this; } - UniversalIterator* operator->() { return this; } - - // type cast to actual iterator - template - const Iterator& DownCast () const - { - return dynamic_cast*>(myPtr.get())->Value(); - } + reference const operator* () const { return myPtr.get(); } + reference operator* () { return myPtr.get(); } private: std::unique_ptr myPtr; @@ -196,7 +186,14 @@ protected: public: virtual ~FunctorInterface() {} - virtual void operator () (UniversalIterator& theIterator) const = 0; + virtual void operator () (IteratorInterface* theIterator) const = 0; + + // type cast to actual iterator + template + static const Iterator& DownCast(IteratorInterface* theIterator) + { + return dynamic_cast*>(theIterator)->Value(); + } }; private: @@ -211,9 +208,9 @@ private: { } - virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE + virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE { - const Iterator& anIt = theIterator.DownCast(); + const Iterator& anIt = DownCast(theIterator); myFunctor(*anIt); } @@ -233,9 +230,9 @@ private: { } - virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE + virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE { - Standard_Integer anIndex = theIterator.DownCast(); + Standard_Integer anIndex = DownCast(theIterator); myFunctor(anIndex); } diff --git a/src/OSD/OSD_Parallel_Threads.cxx b/src/OSD/OSD_Parallel_Threads.cxx index 05066a0066..c36753ea9a 100644 --- a/src/OSD/OSD_Parallel_Threads.cxx +++ b/src/OSD/OSD_Parallel_Threads.cxx @@ -100,7 +100,7 @@ namespace { for (OSD_Parallel::UniversalIterator anIter = myRange.It(); anIter != myRange.End(); anIter = myRange.It()) { - myPerformer (anIter); + myPerformer (*anIter); } }