When in a debugger, you can switch from one thread to another. Each thread has its own program counter so each thread can be in a different place in the code. Example 2 shows a Fortran subroutine PADD(). A breakpoint can be set at the entry point of OpenMP parallel region.
Source listing of the Subroutine PADD() |
12. SUBROUTINE
PADD(A, B, C, N) |
The first call stack below is obtained by breaking at the entry to subroutine PADD using GNU debugger. At this point, the program has not executed any OpenMP regions, and therefore has only one thread. The call stack shows a system run-time __libc_start_main function calling the Fortran main program parallel(), and parallel() calls subroutine padd(). When the program is executed by more than one thread, you can switch from one thread to another. The second and the third call stacks are obtained by breaking at the entry to the parallel region. The call stack of master contains the complete call sequence. At the top of the call stack is _padd__6__par_loop0(). Invocation of a threaded entry point involves a layer of Intel OpenMP library function calls (that is, functions with __kmp prefix). The call stack of the worker thread contains a partial call sequence that begins with a layer of Intel OpenMP library function calls.
ERRATA: GNU debugger sometimes fails to properly unwind the call stack of the immediate caller of Intel OpenMP library function __kmpc_fork_call().
Call Stack Dump of Master Thread upon Entry to Subroutine PADD
Switching from One Thread to Another
Call Stack Dump of Master Thread upon Entry to Parallel Region
Call Stack Dump of Worker Thread upon Entry to Parallel Region
Subroutine PADD() Machine Code Listing |
.globl
padd_ ..B1.19: #
Preds ..B1.15 |