1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
ddzama
92760f930c 0032960: Wrong result of BRepExtrema_DistShapeShape after translation.
Add corresponding test.
2022-09-13 11:05:06 +03:00
ddzama
4b23900a13 0033117: migration to intel oneTBB 2021.5.0 (c++20 ready).
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).
2022-09-13 10:50:34 +03:00
13 changed files with 86 additions and 44 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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" }
}
}

View File

@@ -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" } {

View File

@@ -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 }

View File

@@ -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@"

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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 <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;
@@ -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 <typename Iterator>
static const Iterator& DownCast(IteratorInterface* theIterator)
{
return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(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<Iterator>();
const Iterator& anIt = DownCast<Iterator>(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>();
Standard_Integer anIndex = DownCast<Standard_Integer>(theIterator);
myFunctor(anIndex);
}

View File

@@ -100,7 +100,7 @@ namespace
{
for (OSD_Parallel::UniversalIterator anIter = myRange.It(); anIter != myRange.End(); anIter = myRange.It())
{
myPerformer (anIter);
myPerformer (*anIter);
}
}

View File

@@ -0,0 +1,16 @@
puts "========"
puts "OCC32960: Wrong result of BRepExtrema_DistShapeShape after translation"
puts "========"
# Correct distance is 1.0
restore [locate_data_file bug32960.brep] aShape
explode aShape
set anInfo [distmini d aShape_1 aShape_2]
# Check extrema distance
set absTol 1.0e-7
set relTol 1.0e-7
set aDist_Exp 1.0
set aDist [dval d_val]
checkreal "Distance value check" $aDist $aDist_Exp $absTol $relTol