Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7646 Discussions

Parallel lint (/Qdiag-enable:sc-parallel)

Hi, I compiled the factorial program from (see below) with ICC from Parallel Studio 2011 using the options /Qopenmp and /Qdiag-enable:sc-parallel2. According to the manual, the compiler should emit a warning due to a dependency between the loop iterations in the example, but it doesn't. Any ideas why no warning is emitted?

Thanks, Peter

  1. #include
  2. #include"omp.h"
  3. intmain(void)
  4. {
  5. inti;
  6. intfactorial[10];
  7. factorial[0]=1;
  8. #pragmaompparallelfor
  9. for(i=1;i<10;i++){
  10. factorial=i*factorial[i-1];//warning#12246
  11. }
  12. return0;
  13. }

0 Kudos
2 Replies
I can reproduce the issue. I will investigate and get back to you.

There is indeed data dependence in the loop. The reason no dependency is reported is that per OpenMP specification, OpenMP is an assertion-based parallelization model, that is the compiler complies with whatever the user asserts/intends by the use of the OMP pragma so the compiler does not do any dependency checking. That was one of the reasons behind the development of the Intel Inspector XE 2011 available in the Intel Parallel Studio XE. If you run your test case under Intel Parallel Inspector, the inspector will report:

"One or more threads in the application accessed the stack of another thread.
This may indicate one or more bugs in your application. Setting the Intel Inspector XE 2011 to detect data races on stack accesses and running another analysis may help you locate these and other bugs. "

The Intel C++ Compiler Vectorizers will report the data dependency as follows:

> icc -w -vec-report3 -c t.c
t.c(9): (col. 7) remark: loop was not vectorized: existence of vector dependence.
t.c(10): (col. 9) remark: vector dependence: assumed FLOW dependence between factorial line 10 and factorial line 10.