Parallel Processing and Open Cascade

I need to add parallel processing to my open cascade project. I started this using openMP but I am getting a run time exception. After some searching on the forum I found that openMP support is less in opencascade. Then I thought of adding TBB where I can use multi threading. But I have no idea where should I begin on this.
I would be really grateful if someone can give me an idea, example on how do I use TBB in Opencascade? And can I use OpenMP as well? My application uses stlAPIWriter class.

Thanks a lot.

Roman Lygin's picture

Hi Gishara,

Open CASCADE is quite invariant to a threaded programming model which you use in your application. I have been using TBB and OCC intensively in CAD Exchanger, so they mix just fine. Nothing should prevent you from using OpenMP except that OpenMP has inherent poor composability, and if your code use/can be used in other OpenMP-based algorithms, you may end up oversubscribing a machine, and thus poor performance.

Multi-threading programming brings a lot of specific considerations, so you first need to make yourself quite familiar with them. You should understand these peculiarities (such as data races, deadlocks, etc), their root-causes, how to prevent them, etc. Learn to use developer tools to catch these errors (my favorite one is Intel Parallel Studio XE; of course there is my bias, but I have never seen anything better). Once you are done with that, only then should you bring third-party libraries, including OCC.

As for OCC, you can read a few posts on its use in multi-threaded applications:
http://opencascade.blogspot.com/2009/06/developing-parallel-applications...
http://opencascade.blogspot.com/2009/06/developing-parallel-applications...
http://opencascade.blogspot.com/2009/06/developing-parallel-applications...
http://opencascade.blogspot.com/2009/07/developing-parallel-applications...
http://opencascade.blogspot.com/2009/07/scalability-issues-in-cad-data-e...
http://opencascade.blogspot.com/2010/05/open-cascade-and-multi-threading...

As of 6.5.0, OCC comes with support of integrated TBB – using its memory allocator which is critical for multi-threaded apps and tbb::parallel_for_each in triangulation. See some notes in this post
http://software.intel.com/en-us/blogs/2011/04/04/tbb-adoption-in-cad-tec...

Multi-threading is a nice interesting journey with a lot of new surprises, but you need to do your homework well to turn them into positive ones ;-).

Hope this helps.
Roman

gishara's picture

Thanks a lot for the reply Roman.

I have done parallel processing with openMP at university and this is the first time I am going to do it in real world. I have the basic knowledge and I shall improve it as you have suggested.
I will go through all the stuff provided and try. And will post if I get any problem.

Thanks again.