next up previous
Next: Multi-way Recursive Method Parallelization Up: Actual Loop Parallelization Previous: Loop Replacement

Exception Handling

In principle, any exception that may be thrown during execution of the parallel loop and that is explicitly handled thereafter can be dealt with by catching such an exception in the run()-method of a loop-worker, storing this exception in an additional field e_x of the loop-worker, and re-throwing a caught exception after the invocation of parloop() generated in the third step (see section 2.3.3) as follows:

tabular358

A single field of type java.lang.Exception can be used if all kinds of exceptions are handled explicitly after the loop, or some different fields in the loop-worker can be used to deal specifically with various types of exceptions. In any case, however, because the order in which iterations of a parallel loop are executed is completely unpredictable, the programmer must be aware that after loop parallelization, no assumptions about which iterations have or have not been executed successfully can be made in any subsequent explicit exception handling. In particular, several exceptions may occur in the different threads of a parallel loop, whereas only one of these exceptions will be re-thrown. Consequently, if the order in which exceptions may be thrown in a loop is essential, parallelization of this loop should be disabled. Otherwise, the mechanism sketched above can be used to transfer an exception that is thrown by a look-worker back to the main thread.



ajcbik@extreme.indiana.edu