The compiler implements a parallel region by enabling the code in the region and putting it into a separate, compiler-created entry point. Although this is different from outlining – the technique employed by other compilers, that is, creating a subroutine, – the same debugging technique can be applied.
The compiler-generated parallel region entry point name is constructed with a concatenation of the following strings:
"__" character
entry point name for the original routine (for example, _parallel)
"_" character
line number of the parallel region
__par_region for OpenMP parallel regions (!$OMP PARALLEL)
__par_loop for OpenMP parallel loops (!$OMP PARALLEL DO),
__par_section for OpenMP parallel sections (!$OMP PARALLEL SECTIONS)
sequence number of the parallel region (for each source file, sequence number starts from zero.)
Example 1 illustrates the debugging of the code with parallel region. Example 1 is produced by this command:
ifort -openmp -g -O0 -S file.f90
Let us consider the code of subroutine parallel in Example 1.
Subroutine PARALLEL() source listing |
1 subroutine parallel 2 integer id,OMP_GET_THREAD_NUM 3 !$OMP PARALLEL PRIVATE(id) 4 id = OMP_GET_THREAD_NUM() 5 !$OMP END PARALLEL 6 end |
The parallel region is at line 3. The compiler created two entry points: parallel_ and ___parallel_3__par_region0. The first entry point corresponds to the subroutine parallel(), while the second entry point corresponds to the OpenMP parallel region at line 3.
Machine Code Listing of the Subroutine parallel() |
.globl parallel_ ..B1.13: #
Preds ..B1.9 |
Debugging the program at this level is just like debugging a program that uses POSIX threads directly. Breakpoints can be set in the threaded code just like any other routine. With GNU debugger, breakpoints can be set to source-level routine names (such as parallel). Breakpoints can also be set to entry point names (such as parallel_ and _parallel__3__par_region0). Note that Intel Fortran Compiler for Linux converted the upper case Fortran subroutine name to the lower case one.