Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)

Race Condition?

CWhit10
Beginner
576 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.

 

0 Kudos
1 Solution
Peter_W_Intel
Employee
576 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.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.


    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
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

# inspxe-cl -version
Intel(R) Inspector XE 2016 (build 423441) Command Line tool
Copyright (C) 2009-2015 Intel Corporation. All rights reserved.

View solution in original post

0 Kudos
2 Replies
Peter_W_Intel
Employee
577 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.
See "https://software.intel.com/en-us/intel-advisor-xe" for details.


    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
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

# inspxe-cl -version
Intel(R) Inspector XE 2016 (build 423441) Command Line tool
Copyright (C) 2009-2015 Intel Corporation. All rights reserved.

0 Kudos
Peter_W_Intel
Employee
575 Views

Forget to attach example C file.

0 Kudos
Reply