Tip for people who optimize their code

  • Thread starter Thread starter kroni
  • Start date Start date
  • Tags Tags
    Code
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 1K views
kroni
Messages
79
Reaction score
10
Hello everybody.

I am looking question for programming and computer science since 6 months and i see a lot of threat speaking about time consumption and optimization. I just want to say that INTEL COMPILER and INTEL PROFILER are available on intel website for FREE as a student license without trial time.

Intel compiler use inter function optimisation, powerfull optimisation, automatic partial parralélization. I see a mean of 30% time gain. (Don't forget to recompile the libs with it.)

Intel profiler give you a detailled (line by line) time description of your C++ file and give caches miss and if bad prédiction, and a lot of other interesting information.

When the algorithm and the program structure is optimized, you can reduce the time with this tool.
 
Physics news on Phys.org
Thank you for sharing this tip!

I think the optimization threads that you've seen probably have something to do with homework where students are learning the whys of writing a program a certain way. Optimization tools don't always catch all optimizations which look like valid programming.

In my experience there is a kind of time / memory curve that your program falls into. Making use less time means saving data in intermediate structures using more memory. Conversely saving memory may mean recalculating results again which takes more time. The experienced programmer will try to balance these two parameters while trying to keep the program understandable and extendable for the future.
 
I am agree, you have a memory / time curve but micro optimisation done by compiler as register optimisation, SIMD etc have no memory cost but are very effective.
For example this simple code :

double a = 32.0;
for (size_t i = 0; i<1000000; ++i)
{
a = (a+3.0)/2.0;
if (a<3.7 && a>2.1) std::count << "toto" << std::endl;
}

There is no really big optimisation that can be done. But if you compile it in -O0 in G++ and in -O3 (full optimisation) then you will divide the execution time by 100. It's the reason why Intel compiler give better execution time with no effort.