Debugging OpenMP Programs
Debugging OpenMP code is similar to debugging multi-threaded code. The major differences are in the way the OpenMP compiler alters your code. These alterations include:
• Outlining. The compiler pulls the body of a parallel region out of the original routine and places it in an outlined routine. In some cases, the compiler generates multiple outlined routines from a single parallel region. This allows multiple threads to execute the parallel region.
The outlined routine’s name is based on the original routine’s name. In most cases, the compiler adds a numeric suffix.
• The compiler inserts calls to the OpenMP runtime library.
• The compiler splits variables between the original routine and the outlined routine. Normally, shared variables reside in the master thread’s original routine, and private variables reside in the outlined routine.
• The master thread creates threads to share the workload. As the master thread begins to execute a parallel region in the OpenMP code, it creates the worker threads, dispatches them to the outlined routine, and then calls the outlined routine itself.