Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Tip for people who optimize their code

  1. Apr 17, 2015 #1
    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 web site for FREE as a student licence 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.
     
  2. jcsd
  3. Apr 17, 2015 #2

    jedishrfu

    Staff: Mentor

    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.
     
  4. Apr 18, 2015 #3
    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::cout << "toto" << std::endl;
    }

    There is no realy 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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Tip for people who optimize their code
  1. MadGraph optimization (Replies: 4)

Loading...