Debugging a parallel program tends to 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.
You can use the standard debuggers (gdb for Linux* OS and Mac OS* X; the Microsoft Visual Studio* debugger for Windows* OS) although the results may sometimes be harder to interpret. On Windows* OS, the Microsoft Visual Studio IDE is enhanced for Intel® Cilk™ Plus programs when the Intel® Parallel Debugger Extension is installed. On Linux* OS and Mac OS* X, the Intel® Debugger (IDB) provides enhanced support for Intel® Cilk™ Plus.
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 whatif.intel.com website) or Intel® Inspector XE 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.
Copyright © 1996-2011, Intel Corporation. All rights reserved.