OpenMP and exceptions: best approach

General OpenMP discussion

OpenMP and exceptions: best approach

Postby shiv4k » Thu Dec 01, 2011 2:14 am


What is the best option to achieve OpenMP and exceptions live together? IE: a "parallel for" which calls several routines and one of them throws an exception. What I want to do is that when one of them throws something, all threads in the group exit the parallel for, and if possible to propagate this exception outside the loop!

Thanks in advance!

Re: OpenMP and exceptions: best approach

Postby MarkB » Fri Feb 17, 2012 10:24 am

OpenMP and exceptions don't mix well! You probably need to set a shared flag (with appropriate synchronisation) instead of throwing the exception. You may also need to schedule the iterations "by hand" so that threads can check the shared flag periodically and exit the loop. Once outside the parallel region, you can then throw an exception based on the flag value.
Posts: 746
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 5 guests