OCCT7 +TBB

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

OCCT7 +TBB

Post by sgrogan »

OCCT7 advertises better multi-threading support. I've been able to compile OCCT7 with TBB support on Win VS2013, and then link FreeCAD against it.
Can we devise a test to see if it's worth it?
Related threads.
viewtopic.php?f=22&t=17042#p134845
viewtopic.php?f=4&t=17501&start=80#p142368
Thanks in advance.
"fight the good fight"
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: OCCT7 +TBB

Post by wandererfan »

sgrogan wrote:Can we devise a test to see if it's worth it?
These files from: https://github.com/WandererFan/FCDraw2T ... anceIssues spend 10-20 seconds per item in the HLR routines and the timing results are already in the log output.

BellowsSaveProjGroup.fcstd
Log: TIMING - ProjItem GO spent: 12805.528 millisecs in HLRBRep_Algo & co
Log: TIMING - ProjItem001 GO spent: 12420.271 millisecs in HLRBRep_Algo & co
Log: TIMING - ProjItem002 GO spent: 12682.243 millisecs in HLRBRep_Algo & co

Bellows_FC017_normandc2.fcstd
Log: TIMING - ProjItem GO spent: 8430.903 millisecs in HLRBRep_Algo & co
Log: TIMING - ProjItem001 GO spent: 18968.696 millisecs in HLRBRep_Algo & co

If HLR uses multithreading they might be useful.

wf

EDIT: fixed url
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: OCCT7 +TBB

Post by triplus »

Here is one test you can try out:

viewtopic.php?t=6197&start=40#p91404
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: OCCT7 +TBB

Post by sgrogan »

wandererfan wrote:If HLR uses multithreading they might be useful.
triplus wrote:Here is one test you can try out:
Thanks guys, maybe a little more help is necessary :?
From DeepSOIC:
"The changes are required, but are minimal (I think). Just need to add "mkFuse.setRunParallel(true);".
From gkv311:
"Intel TBB, optional for several modules.
It is NOT mandatory for activating parallel algorithms in OCCT,
but can be more efficient for this task then built-in OCCT parallelization routines (OSD_Parallel)."
Is there a similar change for HLR?
I think triplus example will test mkFuse if I can find where to appy DeepSoic's change.
"fight the good fight"
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: OCCT7 +TBB

Post by triplus »

Well you can always do the test yourself. Set the number of rows/cols to lets say 200 and after run the macro:

viewtopic.php?t=6197&start=40#p91404

To see if you get intense multi-threading phase (likely meshing) or not when you compare OCCT7 +TBB to just using OCCT7.
Is there a similar change for HLR?
AFAIK no (ATM).
Just need to add "mkFuse.setRunParallel(true);"
For boolean operations indeed this would be needed:
So, for every usage of BRepAlgoAPI you have to explicitly set the parallel mode via BRepAlgoAPI_Algo::SetRunParallel().
https://dev.opencascade.org/index.php?q ... omment-641

And at the bottom of that debate there is a table showing the results. Therefore we would need C++ developer that would add such support to FreeCAD. I am guessing wherever we use:

Code: Select all

BRepAlgoAPI_Cut
BRepAlgoAPI_Fuse
BRepAlgoAPI_Common
BRepAlgoAPI_Section
We would need to enable parallel mode explicitly. Or better it would be used based on the user made setting.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: OCCT7 +TBB

Post by triplus »

I have created a feature request:

issue #002750

There isn't that much places where we use:

Code: Select all

BRepAlgoAPI_Cut
BRepAlgoAPI_Fuse
BRepAlgoAPI_Common
BRepAlgoAPI_Section
Therefore likely one of the core devs will know on how to tackle this. That is where to apply SetRunParallel() if it really is that simple.

P.S. And by doing that to give us some parallel BOA operations in the FreeCAD! ;)

I guess i should have looked for similar feature requests as it was already reported in the past:

issue #002334

Well at least now we know for sure what is the current situation. Meshing (run the above macro for tests): Yes if OCC/OCE + TBB or maybe OCE + OpenMP is used. BOA: No (not due to the lack of such capability in OCC/OCE instead FreeCAD needs to enable such support). :)
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: OCCT7 +TBB

Post by blacey »

sgrogan wrote:OCCT7 advertises better multi-threading support. I've been able to compile OCCT7 with TBB support on Win VS2013, and then link FreeCAD against it.
Can we devise a test to see if it's worth it?
Related threads.
viewtopic.php?f=22&t=17042#p134845
viewtopic.php?f=4&t=17501&start=80#p142368
Thanks in advance.
As a side note, the FreeCAD 0.17 macOS / OS X builds are built with OCCT7 TBB support.
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: OCCT7 +TBB

Post by wandererfan »

sgrogan wrote:Is there a similar change for HLR?
No idea. I'll look into it.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: OCCT7 +TBB

Post by triplus »

I think i figured out where to apply .setRunParallel(true) for Part and PartDesign BOA operations (using FreeCAD 0.17 + OCC 7 + TBB).

I first focused on Part BOA operations. I made some Part geometry and tried to apply BOA operations on it. It doesn't look like there is any multithreading going on in the process.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: OCCT7 +TBB

Post by triplus »

First results. I started focusing on bigger number of geometry involved in single boolean operation. Part Sphere was used in Draft Array. Using Fuse property (Part Fuse) started to make a difference:

PC with 2 core CPU
FreeCAD 0.17 + OCC 7 + TBB
Fuse Draft Array of Spheres (2 x 10)

RunParallel True:
  • 47s
RunParallel False:
  • 1min 23s
Note that there is still some multithreading detected in both cases as TBB is used and therefore likely meshing phase is done in parallel. BOA multi-threading is detected before meshing multi-threading. There is still a phase at the end where no multi-threading is detected.
Post Reply