0
votes

I am writing an c++ application in visual studio 2010. I run my code under performance wizard and it takes nearly 17 seconds. The codes is really suitable to multhreading so I add openmp directives. After that, I run my codes again and it takes also nearly 17 seconds. So, I wonder what that performance wizard does to optimize the code? Does it analyze the code and makes it multithreaded or simple perform compiler optimizations? How that wizard optimize code?

Edit: I enabled compiler options by adding /openmp option. I am using #pragma omp parallel for directive.I added parallel section codes. it has no bottlenecks, loop iterations do not depend on each other.

#pragma omp parallel for
for (int i = START; i < END; i++) {
    solutionList[i] = new Solution(list[i]->solution, direction, i);        
}
1
When you add those OpenMP directives, did you also enable OpenMP support in the compiler options? How about setting the OMP_NUM_THREADS environment variable?Hristo Iliev
Did you put OpenMP worksharing directives (omp for in your case) inside a parallel region? Could you show us some example code that you've applied the OMP directives to? Parallel speedup is highly context specific after all.Hristo Iliev
What is the value of START and what is the value of END? How long does it take to execute the constructor of the Solution class? Did you check the OMP_NUM_THREADS environment, although by default the number of threads is equal to the number of logical CPUs.Hristo Iliev

1 Answers

3
votes

Performance wizard does not optimize your code at all. It measures the execution of your code -- depending on your configuration, by instrumenting the code (making it less efficient but more accurate monitoring). It's a tool you use to decide which areas of your code to examine for optimization -- human optimization of the algorithms, not compiler optimization of the instructions.