Is it possible to use an “exception exception” within a parallel region?

Is it good to use a "throw exception" inside a parallel area?

What happens to other threads when one thread throws an exception?

the code:

#pragma omp parallel for
for(int i = 0; i < n; i++)
{
     if(arr[i] < 0)
       throw BadParameter("bad array value");
}
+3
source share
1 answer

A throw executed inside a parallel region should cause execution to resume within the same parallel region, and it should be caught by the same thread that selected the exception.

Otherwise, it will apply to the unhandled exception.

+5
source

All Articles