This section shows how to use both the er_print command line and the Thread Analyzer GUI to display the following information about each detected data-race:
The unique ID of the data-race.
The virtual address, Vaddr
, associated
with the data-race. If there is more than one virtual address, then the label
Multiple Addresses is displayed in parentheses .
The memory accesses to the virtual address, Vaddr
by
two different threads. The type of the access (read or write) is shown, as
well as the function, offset, and line number in the source code where the
access occurred.
The total number of traces associated with the data-race. Each trace refers to the pair of thread callstacks at the time the two data-race accesses occurred. If you are using the GUI, the two callstacks will be displayed in the Race Details tab when an individual trace is selected. If you are using the er_print utility, the two callstacks will be displayed by the rdetail command.
% cc -xopenmp=noopt omp_prime.c -lm -xinstrument=datarace % collect -r race a.out | sort -n 0 0 0 0 0 0 0 0 0 0 ... 0 0 Creating experiment database test.1.er ... Number of prime numbers between 2 and 3000: 429 2 3 5 7 11 13 17 19 23 29 31 37 41 47 53 59 61 67 71 73 ... 2971 2999 % er_print test.1.er (er_print) races Total Races: 4 Experiment: test.1.er Race #1, Vaddr: 0xffbfeec4 Access 1: Read, main -- MP doall from line 42 [_$d1A42.main] + 0x00000060, line 45 in "omp_prime.c" Access 2: Write, main -- MP doall from line 42 [_$d1A42.main] + 0x0000008C, line 46 in "omp_prime.c" Total Traces: 2 Race #2, Vaddr: 0xffbfeec4 Access 1: Write, main -- MP doall from line 42 [_$d1A42.main] + 0x0000008C, line 46 in "omp_prime.c" Access 2: Write, main -- MP doall from line 42 [_$d1A42.main] + 0x0000008C, line 46 in "omp_prime.c" Total Traces: 1 Race #3, Vaddr: (Multiple Addresses) Access 1: Write, main -- MP doall from line 42 [_$d1A42.main] + 0x0000007C, line 45 in "omp_prime.c" Access 2: Write, main -- MP doall from line 42 [_$d1A42.main] + 0x0000007C, line 45 in "omp_prime.c" Total Traces: 1 Race #4, Vaddr: 0x21418 Access 1: Read, is_prime + 0x00000074, line 18 in "omp_prime.c" Access 2: Write, is_prime + 0x00000114, line 21 in "omp_prime.c" Total Traces: 1 (er_print)
The following screen-shot shows the races that were detected in omp_primes.c as displayed by the Thread Analyzer GUI. The command to invoke the GUI and load the experiment data is tha test.1.er.
There are four data-races in omp_primes.c:
Race number one: A data-race between a read from total on line 45 and a write to total on line 46.
Race number two: A data-race between a write to total on line 46 and another write to total on the same line.
Race number three: A data-race between a write to primes[]
on line 45 and another write to primes[]
on
the same line.
Race number four: A data-race between a read from pflag[]
on line 18 and a write to pflag[]
on
line 21.
% cc pthr_prime.c -lm -mt -xinstrument=datarace . % collect -r on a.out | sort -n Creating experiment database test.2.er ... of type "nfs", which may distort the measured performance. 0 0 0 0 0 0 0 0 0 0 ... 0 0 Creating experiment database test.2.er ... Number of prime numbers between 2 and 3000: 328 751 757 761 773 797 809 811 821 823 827 829 839 853 857 859 877 881 883 887 907 ... 2999 2999 % er_print test.2.er (er_print) races Total Races: 6 Experiment: test.2.er Race #1, Vaddr: 0x218d0 Access 1: Write, work + 0x00000154, line 40 in "pthr_prime.c" Access 2: Write, work + 0x00000154, line 40 in "pthr_prime.c" Total Traces: 3 Race #2, Vaddr: 0x218d0 Access 1: Read, work + 0x000000CC, line 39 in "pthr_prime.c" Access 2: Write, work + 0x00000154, line 40 in "pthr_prime.c" Total Traces: 3 Race #3, Vaddr: 0xffbfeec4 Access 1: Write, main + 0x00000204, line 55 in "pthr_prime.c" Access 2: Read, work + 0x00000024, line 35 in "pthr_prime.c" Total Traces: 2 Race #4, Vaddr: (Multiple Addresses) Access 1: Write, work + 0x00000108, line 39 in "pthr_prime.c" Access 2: Write, work + 0x00000108, line 39 in "pthr_prime.c" Total Traces: 1 Race #5, Vaddr: 0x23bfc Access 1: Write, is_prime + 0x00000210, line 22 in "pthr_prime.c" Access 2: Write, is_prime + 0x00000210, line 22 in "pthr_prime.c" Total Traces: 1 Race #6, Vaddr: 0x247bc Access 1: Write, work + 0x00000108, line 39 in "pthr_prime.c" Access 2: Read, main + 0x00000394, line 65 in "pthr_prime.c" Total Traces: 1 (er_print)
The following screen-shot shows the races detected in pthr_primes.c as displayed by the Thread Analyzer GUI. The command to invoke the GUI and load the experiment data is tha test.2.er.
There are six data-races in pthr_prime.c:
Race number one: A data-race between a write to total on line 40 and another write to total on the same line.
Race number two: A data-race between a read from total on line 39 and a write to total on line 40.
Race number three: A data-race between a write to i on line 55 and a read from i on line 35.
Race number four: A data-race between a write to primes[]
on line 39 and another write to primes[]
the
same line.
Race number five: A data-race between a write to pflag[]
on line 22 and another write to pflag[]
on
the same line
Race number six: A data-race between a write to primes[]
on line 39 and a read from primes[]
on
line 65.
One advantage of the GUI is that it allows you to see, side by side, the two source locations associated with a data-race. For example, select race number six for pthr_prime.c in the Races tab and then click on the Dual Source tab. You will see the following:
The first access for race number six (line 39) is shown in the top Race Source pane, while the second access for that data-race is shown in the bottom pane. Source lines 39 and 65, where the data-race accesses occurred, are highlighted. The default metric (Exclusive Race Accesses metric) is shown to the left of each source line. This metric gives a count of the number of times a data-race access was reported on that line.