This article provides tips and tricks on how to best take advantage of the additional insight into parallel data constructs the Intel Parallel Debugger Extension brings to the Microsoft Visual Studio debug environment. (The Parallel Debugger Extension is part of Intel Parallel Studio.) In doing so it provides a high-level overview of the Intel Parallel Debugger Extension for Microsoft Visual Studio and the key features that enhance the debug experience through enhanced visibility and more in depth understanding of:
- The data shared between multiple threads in Intel C++ Compiler built applications
- The vectorized data streams processed in Single Instruction Multiple Data (SIMD) registers
- The use and dependencies of reentrant function calls
- Active OpenMP tasks lock information and thread team hierarchies
The advent of more and more "multi" and "many" core processors requires extensive use of parallel programming models to best take advantage of the benefits these systems provide to program execution flow and thus to get the best performance out of these systems. Using more and more advanced parallel programming techniques makes it however more and more difficult to keep track of all active threads and their possible data inter-dependencies. The purpose of the Intel Parallel Debugger Extension for Microsoft Visual Studio is to pair the tools Intel provides for developing highly multi-threaded parallel applications with the debug extensions to allow for equally advanced and easily accessible features in the debugger. Advanced parallel programming techniques call for advanced parallel debugging techniques to keep the executions flow and the analysis of runtime problems straight forward and allow for speedy error corrections.
To follow the examples presented in this article, you need:
- Windows XP SP2 or SP3, Window Vista
- Visual Studio 2005 or Visual Studio 2008
- IA-32, Intel 64 architecture or compatible.
The Intel Parallel Debugger Extension, which is part of the Intel Parallel Composer component of the Intel Parallel Studio, consists of a set of features that can be accessed through the Visual Studio Debug pulldown menu (Figure 1). The additional insight provided into the parallel execution of the code to debug is grouped into the following menu entries:
Thread Data Sharing Detection: If an applications has been built using Intel's Debug Runtime Library by using the /debug:parallel and /Qopenmp options with the Intel C++ Compiler, data sharing violations can be detected. It is necessary to set both /Qopenmp and /debug:parallel because the thread data sharing detection feature as well as the function re-entrancy detection rely not only on the debug information instrumentation triggered with /debug:parallel, but also on Intel specific parallel language extensions in the OpenMP runtime library that get activated with the /Qopenmp switch (Figure 2) . The "Enable Detection" menu entry (Figure 3) allows turning thread Data sharing event detection on. An exception is raised when the Debugger Extension detects the sharing of data between different threads.
The Intel Parallel Debugger Extensions monitors this exception and display the data sharing events in a dedicated window (Figure 4).
You can enable data sharing event detection (Figure 3), tell the Debugger Extension to treat such an event as the equivalent of a data breakpoint halting execution, set data sharing filters so only data sharing violations in specific memory regions or data objects, and last but not least you can monitor data sharing events in a dedicated window (Figure 4).
From any of the data sharing events displayed in the Thread Data Sharing Events treeview window you can link back to the associated source code or assembly code via double click at an of the events listed.
A data sharing event that has been detected does not indicate that an actual violation causing faulty program execution occurred. It does however indicate that you may want to have a closer look at these events as more than likely they could point to a potential problem.
If you determined that an event is harmless you may also suppress future reporting by selecting the corresponding context menu entry as in Figure 4.
Re-entrant Function Call Detection
From the Visual Studio Debug pulldown menu you can access a dialog that turns on reentrant function call detection and instructs Visual Studio to break and stop execution when different threads call a function at the same time. Thus it permits to debug and monitor accesses closely so you can decide what measures may need to be taken to ensure consistent execution behavior of your application (Figure 5). Prerequisite for the re-entrant function call detection again is compilation of your code with the Intel C++ Compiler using the /debug:parallel and /Qopenmp options. To enable detection you would select the corresponding debug pulldown menu entry and specify a memory address that can be resolved as belonging to a specific function. Any access timing conflicts between multiple threads to that function will then cause the execution to break.
SSE Registers Window
The Visual Studio debug pulldown menu gives you access to MMX, SSE, SSE2, and SSE3 registers commonly used for data vectorization and single instruction multiple data (SIMD) handling. It displays vectors as rows (or columns) in a table display (Figure 6). Therefore, the SSE Registers Window is a window for displaying expressions, not as single values, but as a vector of values. It thus provides you with ways to change the representation of the data in those registers that makes their use in the debuggee application as well as the actual data mapping to the underlying hardware more transparent.
OpenMP Debugging Support
From the Debug pulldown menu as well as the Intel Parallel Debug Extension icons bar you can access information about OpenMP data structures. The prerequisite for this menu entry to be available and grayed out is to have your application built with the OpenMP runtime library, which means that it requires to be compiled with the compiler option /Qopenmp set.
The OpenMP data structures you can access directly are tasks, task wait lists, task spawn trees, barriers, locks and thread teams (Figure 7).
Serialize Parallel Regions
For OpenMP-based parallel code you can analyze and better understand possible timing issues with parallelized code regions by forcing serial execution.
This let's you determine whether an execution flow correctness issue has been introduced with parallelism, or whether there is a more fundamental coding error that shows up in serial execution as well.
This let's you modify program execution behavior on the fly (Figure 9). It thus provides a very useful feature for basic code correctness checking before investigating an issue further.
.NET Recent Articles
This month's Dr. Dobb's Journal
- March 16-19, 2020: Data Center World Registration is open! Join Us - Data Center World 2020
- Data Center World: The leading conference & expo for Data Center and IT Infrastructure Professionals. Register Today! - Data Center World 2020
- Get Insights: Cisco vs Microsoft & More at EC20 Orlando - Enterprise Connect 2020
Most Recent Premium Content
- November - Mobile Development
- August - Web Development
- May - Testing
- February - Languages
- Open Source
- Windows and .NET programming
- The Design of Messaging Middleware and 10 Tips from Tech Writers
- Parallel Array Operations in Java 8 and Android on x86: Java Native Interface and the Android Native Development Kit
- January - Mobile Development
- February - Parallel Programming
- March - Windows Programming
- April - Programming Languages
- May - Web Development
- June - Database Development
- July - Testing
- August - Debugging and Defect Management
- September - Version Control
- October - DevOps
- November- Really Big Data
- December - Design
- January - C & C++
- February - Parallel Programming
- March - Microsoft Technologies
- April - Mobile Development
- May - Database Programming
- June - Web Development
- July - Security
- August - ALM & Development Tools
- September - Cloud & Web Development
- October - JVM Languages
- November - Testing
- December - DevOps
Dr. Dobb's Journal
Dr. Dobb's Tech Digest