Download Sun Studio 12: Thread Analyzer User's Guide
Transcript
2.2 Creating Experiments 827 839 853 859 877 881 883 907 911 ... 2999 2999 2.2 Creating Experiments The Thread Analyzer follows the same "collect-analyze" model that the Sun Studio Performance Analyzer uses. There are three steps involved in using the Thread Analyzer: ■ ■ ■ 2.2.1 “2.2.1 Instrument the Source Code” on page 21 “2.2.2 Create a Data-Race Detection Experiment” on page 22 “2.2.3 Examine the Data-Race Detection Experiment” on page 22 Instrument the Source Code In order to enable data-race detection in a program, the source files must first be compiled with a special compiler option. This special option for the C, C++, and Fortran languages is: -xinstrument=datarace Add the -xinstrument=datarace compiler option to the existing set of options you use to compile your program. You can apply the option to only the source files that you suspect to have data-races. Note – Be sure to specify -g when you compile your program. Do not specify a high level of optimization when compiling your program for race detection. Compile an OpenMP program with -xopenmp=noopt. The information reported, such as line numbers and callstacks, may be incorrect when a high optimization level is used. The following are example commands for instrumenting the source code: ■ ■ cc -xinstrument=datarace -g -mt pthr_prime.c cc -xinstrument=datarace -g -xopenmp=noopt omp_prime.c Chapter 2 • The Data-Race Tutorial 21