% 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.