internal error handling

General OpenMP discussion

internal error handling

Postby bosse » Fri Dec 20, 2013 8:24 am

I have a rather large Fortran code divided into modules which is currently running sequentially but several parts of this can be parallellized. However, I have a problem that I use a global error flag to signal back to a calling routine (often several levels higher) that something has happened and it should take some special action.

This is no problem when run in seauential mode but when several threads are running in parallell and the error flag is raised in one of them all the threads will note this although it only concerns one. I have tried to understand the use of "threadprivate" but much of the discussions there is above my head. The error flag is used in very basic routines and cannot be decleared at the top levels of the program.

Bosse Sundman
bosse
 
Posts: 5
Joined: Fri Apr 01, 2011 12:14 am

Re: internal error handling

Postby MarkB » Mon Jan 06, 2014 10:02 am

Hi Bosse,

Threadprivate is probably the easier solution: if you can be more specific about what is confusing you I may be able to help!

Best wishes,
Mark.
MarkB
 
Posts: 422
Joined: Thu Jan 08, 2009 10:12 am

Re: internal error handling

Postby bosse » Wed Jan 08, 2014 11:37 am

Dear Mark

The problem is that it is not very specific. I am writing a fairly large package and using other free packages for numerics and graphics and there can be many different kinds of errors or exceptions occuring, the simplest may be division by zero or that a matrix inversion goes wrong because the matrix is singluar or more sophisticated that during the calculation of the equilibrium a new phase wants to be stable so I have to redesign the equations to find the minimium. The errors may occur deep down in the code, sometimes in parts of the code I have not written myself, but the upper levels of the code can usually find a way to bypass the error/exception and continue the calculation, the errors are usually not fatal.

It works OK in sequential execution with a single error code but when parallellizing each thread must have its own error code so that the exception in one thread does not distrurb the other. I think threadprivate would be a reasonable solution, what worries me is that I have learned this threadprivate data makes the code significantly slower. But maybe a single variable is not so problematic? There are frequent tests of this variable in to code in order to detect errors/exceptions as early as possible.

Best wishes

Bosse
bosse
 
Posts: 5
Joined: Fri Apr 01, 2011 12:14 am

Re: internal error handling

Postby MarkB » Thu Jan 09, 2014 3:26 am

bosse wrote: I think threadprivate would be a reasonable solution, what worries me is that I have learned this threadprivate data makes the code significantly slower. But maybe a single variable is not so problematic? There are frequent tests of this variable in to code in order to detect errors/exceptions as early as possible.


I think your fears about the impact on performance are unfounded: I see no reason why this should be the case!
MarkB
 
Posts: 422
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 12 guests