Oracle® Solaris Studio 12.4: Thread Analyzer User's Guide

Exit Print View

Updated: December 2014
 
 

Create a Data-Race-Detection Experiment

Use the collect command with the -r race flag to run the program and create a data-race-detection experiment during the execution of the process. For OpenMP programs, make sure that the number of threads used is larger than one. In the tutorial samples, four threads are used.

To create experiments from the binaries that you created by instrumenting the source code:

% collect -r race -o prime_omp_inst.er prime_omp_inst
% collect -r race -o prime_pthr_inst.er prime_pthr_inst

To create experiments from the binaries that you created by using the discover tool:

% collect -r race -o prime_omp_disc.er prime_omp_disc
% collect -r race -o prime_pthr_disc.er prime_pthr_disc

To increase the likelihood of detecting data races, it is recommended that you create several data-race-detection experiments using collect with the -r race flag. Use a different number of threads and different input data for each experiment.

For example, in prime_omp.c, the number of threads is set by the following line:

#define THREADS 4

The number of threads can be changed by changing 4 in the above to some other integer larger than 1, for example 8.

The following line in prime_omp.c limits the program to look for prime numbers between 2 and 3000:

#define N 3000

You can provide different input data by changing the value of N to make the program do more or less work.