MSVC 2022/c++20.
After employed c++20 language standard errors of compilation in intel oneTBB occurred.
To get rid of compilation errors proposed moving on actual (2021.5.0) intel oneTBB occ products and occt.
After migration errors of compilation of TKernal and TMath have been occured...
...Error occured if using c++20 standard with new oneTBB 2021.5.0.
The error was:
Error C2672 'tbb::v1::parallel_for_each': no matching overloaded function found TKernel
could be 'void tbb::detail::d2::parallel_for_each(Iterator,Iterator,const Body &)' TKernel
'tbb::detail::d2::parallel_for_each': the associated constraints are not satisfied TKernel
Note, that if we use c++14 or c++17, all ok, error does not occures.
Affected projects: TKernal, TMath
Affected files: src/OSD/OSD_Parallel.hxx, src/OSD/OSD_Parallel_Threads.cxx
Affected classes: class OSD_Parallel, OSD_Parallel::UniversalIterator, OSD_Parallel::FunctorInterface, OSD_Parallel::FunctorWrapperIter, OSD_Parallel:;FunctorWrapperInt.
Additionally, taked into account different names of tbb main library on windows/linux.
On Windows, they are tbb12.lib/tbb12.dll. On Linux, it is libtbb.so.
Therefore, we have to taking into account this fact in all project generator files (cmake and others).
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")
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()
# 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()
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()
}
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"]
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" }
}
}
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" } {
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 }
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@"
@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.
@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
@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
| 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 |
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
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
}
// 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() {}
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 <typename Iterator>
- const Iterator& DownCast () const
- {
- return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(myPtr.get())->Value();
- }
+ reference const operator* () const { return myPtr.get(); }
+ reference operator* () { return myPtr.get(); }
private:
std::unique_ptr<IteratorInterface> myPtr;
public:
virtual ~FunctorInterface() {}
- virtual void operator () (UniversalIterator& theIterator) const = 0;
+ virtual void operator () (IteratorInterface* theIterator) const = 0;
+
+ // type cast to actual iterator
+ template <typename Iterator>
+ static const Iterator& DownCast(IteratorInterface* theIterator)
+ {
+ return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(theIterator)->Value();
+ }
};
private:
{
}
- virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
+ virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
- const Iterator& anIt = theIterator.DownCast<Iterator>();
+ const Iterator& anIt = DownCast<Iterator>(theIterator);
myFunctor(*anIt);
}
{
}
- virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
+ virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
- Standard_Integer anIndex = theIterator.DownCast<Standard_Integer>();
+ Standard_Integer anIndex = DownCast<Standard_Integer>(theIterator);
myFunctor(anIndex);
}
{
for (OSD_Parallel::UniversalIterator anIter = myRange.It(); anIter != myRange.End(); anIter = myRange.It())
{
- myPerformer (anIter);
+ myPerformer (*anIter);
}
}