real x / 1.0 /, y / 0.0 / print *, x/y end character string*5, out*20 double precision value external exception_handler i = ieee_handler(’set’, ’all’, exception_handler) string = ’1e310’ print *, ’Input string ’, string, ’ becomes: ’, value print *, ’Value of 1e300 * 1e10 is:’, 1e300 * 1e10 i = ieee_flags(’clear’, ’exception’, ’all’, out) end integer function exception_handler(sig, code, sigcontext) integer sig, code, sigcontext(5) print *, ’*** IEEE exception raised!’ return end |
Runtime output:
Debugging parallelized programs requires some extra effort. The following schemes suggest ways to approach this task.
There are some steps you can try immediately to determine the cause of errors.
Turn off parallelization.
You can do one of the following:
Turn off the parallelization options—Verify that the program works correctly by compiling with -O3 or -O4, but without any parallelization.
Set the number of threads to one and compile with parallelization on—run the program with the environment variable PARALLEL set to 1.
If the problem disappears, then you can assume it was due to using multiple threads.
Check also for out of bounds array references by compiling with -C.
Problems using automatic parallelization with —autopar may indicate that the compiler is parallelizing something it should not.
Turn off -reduction.
If you are using the —reduction option, summation reduction may be occurring and yielding slightly different answers. Try running without this option.
Use fsplit.
If you have many subroutines in your program, use fsplit(1) to break them into separate files. Then compile some files with and without —autopar.
Execute the binary and verify results.
Repeat this process until the problem is narrowed down to one subroutine.
Use -loopinfo.
Check which loops are being parallelized and which loops are not.
Use a dummy subroutine.
Create a dummy subroutine or function that does nothing. Put calls to this subroutine in a few of the loops that are being parallelized. Recompile and execute. Use -loopinfo to see which loops are being parallelized.
Continue this process until you start getting the correct results.
Run loops backward serially.
Replace DO I=1,N with DO I=N,1,-1. Different results point to data dependencies.
Avoid using the loop index.
Replace:
DO I=1,N ... CALL SNUBBER(I) ... ENDDO |
With:
DO I1=1,N I=I1 ... CALL SNUBBER(I) ... ENDDO |