opencascade-7.5.0-fix_tbb.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From: kgv <kgv@opencascade.com>
  2. Date: Mon, 29 Nov 2021 18:26:45 +0000 (+0300)
  3. Subject: 0032697: Configuration - fix compilation errors with oneTBB 2021
  4. X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=740833a6a88e481f474783c426b6f6311ed586d3
  5. 0032697: Configuration - fix compilation errors with oneTBB 2021
  6. Removed usage of no more existing tbb::task_scheduler_init and tbb::captured_exception.
  7. ---
  8. diff --git a/src/OSD/OSD_Parallel_TBB.cxx b/src/OSD/OSD_Parallel_TBB.cxx
  9. index 2344a6ca2d..0b9022b576 100644
  10. --- a/src/OSD/OSD_Parallel_TBB.cxx
  11. +++ b/src/OSD/OSD_Parallel_TBB.cxx
  12. @@ -25,7 +25,9 @@ Standard_DISABLE_DEPRECATION_WARNINGS
  13. #include <tbb/parallel_for.h>
  14. #include <tbb/parallel_for_each.h>
  15. #include <tbb/blocked_range.h>
  16. -#include <tbb/task_scheduler_init.h>
  17. +#if TBB_VERSION_MAJOR < 2021
  18. + #include <tbb/task_scheduler_init.h>
  19. +#endif
  20. Standard_ENABLE_DEPRECATION_WARNINGS
  21. //=======================================================================
  22. @@ -38,12 +40,16 @@ void OSD_Parallel::forEachExternal (UniversalIterator& theBegin,
  23. const FunctorInterface& theFunctor,
  24. Standard_Integer theNbItems)
  25. {
  26. +#if TBB_VERSION_MAJOR >= 2021
  27. + // task_scheduler_init is removed,
  28. + // exceptions are captured without proxy tbb::captured_exception object
  29. + (void )theNbItems;
  30. + tbb::parallel_for_each (theBegin, theEnd, theFunctor);
  31. +#else
  32. try
  33. {
  34. const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
  35. - const Standard_Integer aNbThreads = theNbItems > 0 ?
  36. - aThreadPool->NbDefaultThreadsToLaunch() : -1;
  37. -
  38. + const Standard_Integer aNbThreads = theNbItems > 0 ? aThreadPool->NbDefaultThreadsToLaunch() : -1;
  39. tbb::task_scheduler_init aScheduler (aNbThreads);
  40. tbb::parallel_for_each (theBegin, theEnd, theFunctor);
  41. }
  42. @@ -51,6 +57,7 @@ void OSD_Parallel::forEachExternal (UniversalIterator& theBegin,
  43. {
  44. throw Standard_ProgramError (anException.what());
  45. }
  46. +#endif
  47. }
  48. #endif /* HAVE_TBB */