Intel® C++ Compiler 16.0 User and Reference Guide
Debugging a parallel program can be more difficult than debugging a serial program. Use of Intel® Cilk™ Plus is designed to simplify the challenge of parallel debugging as much as possible. Start by debugging the serialization first.
Follow these guidelines to minimize the problem of debugging parallel programs:
If you are converting an existing C/C++ program, debug and test the serial version first.
Once you have a parallel Intel® Cilk™ Plus program, test and debug the serialization. Because both the serial base program and the serialization of the Intel® Cilk™ Plus program are serial C/C++ programs, you can use existing serial debug tools and techniques.
Run with one worker. This can help detect problems occurring in the parallelized code or detect an algorithmic problem.
You can use the standard debuggers (gdb for Linux* and OS X*; the Microsoft Visual Studio* debugger for Windows*) for debugging.
If your program works correctly as a serialization or when run with only one worker, but behaves incorrectly when run with multiple workers, you probably have a data race. You can use Intel® Cilk™ screen race detector (part of the Intel® Cilk™ Plus SDK on the cilkplus.org website) or Intel® Inspector to detect data races. If you detect a data race, do one or more of the following:
Restructure the code to remove the race
Use a reducer
Use a mutual-exclusion lock (such as one of the mutex locks available as part of Intel® Threading Building Blocks), other lock, or atomic operation
It may be simpler to debug programs built without optimizations. Debugging without optimizations turns off inlining, resulting in a more accurate call stack; additionally, the compiler does not attempt to reorder instructions and optimize register usage.