Analyzers
Community support for Analyzers (Intel VTune™ Profiler, Intel Advisor, Intel Inspector)
Announcements
4819 Discussions

Race Condition?

Beginner
368 Views

Hi,

I used Inspector XE to run analysis on a matrix multiplication algorithm, where matrix C = A x B.

Matrices A, B, and C are initialized using dynamic memory allocation. Race condition problem was detected at line 80.

```80	    #pragma omp parallel shared (A, B, TEMP) private(i, j)
81	    {
82
83	        #pragma omp for
84	        for (i=0 ; i<N ; i++)
85	        {
86	            for (j=0 ; j<N ; j++)
87	            {
88	                A = i + 1;
89	                B = i + j;
90	            }
91	        }
92          }```

However, the final result (printf result), which is the content of matrix C is correct.

I thought that race condition would cause the final result wrong, but the opposite happened. Why?

Thank you.

1 Solution
Employee
368 Views

I tried to reproduce this problem with your piece of example code (please see my attachment, matrix_multiply.c), but the problem was not found.

Could it be due to different compiler version or inspector version?

# icc -g -openmp matrix_multiply.c -qopt-report -qopt-report-file=stdout -o matrix_multiply -lpthread
Intel(R) Advisor can now assist with vectorization and show optimization
report messages with your source code.

Report from: OpenMP optimizations [openmp]

matrix_multiply.c(12:1-12:1):OMP:Initalzie:  OpenMP DEFINED REGION WAS PARALLELIZED

Report from: OpenMP optimizations [openmp]

matrix_multiply.c(33:1-33:1):OMP:multiply:  OpenMP DEFINED REGION WAS PARALLELIZED

# ./matrix_multiply

# inspxe-cl -c ti3 -- ./matrix_multiply
0 new problem(s) found

# icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.0.109 Build 20150815

# inspxe-cl -version
Intel(R) Inspector XE 2016 (build 423441) Command Line tool

2 Replies
Employee
369 Views

I tried to reproduce this problem with your piece of example code (please see my attachment, matrix_multiply.c), but the problem was not found.

Could it be due to different compiler version or inspector version?

# icc -g -openmp matrix_multiply.c -qopt-report -qopt-report-file=stdout -o matrix_multiply -lpthread
Intel(R) Advisor can now assist with vectorization and show optimization
report messages with your source code.

Report from: OpenMP optimizations [openmp]

matrix_multiply.c(12:1-12:1):OMP:Initalzie:  OpenMP DEFINED REGION WAS PARALLELIZED

Report from: OpenMP optimizations [openmp]

matrix_multiply.c(33:1-33:1):OMP:multiply:  OpenMP DEFINED REGION WAS PARALLELIZED

# ./matrix_multiply

# inspxe-cl -c ti3 -- ./matrix_multiply
0 new problem(s) found

# icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.0.109 Build 20150815