How can I improve performance via a high-level approach when implementing long equations in C++

后端 未结 10 1810
孤街浪徒
孤街浪徒 2021-01-30 19:34

I am developing some engineering simulations. This involves implementing some long equations such as this equation to calculate stress in a rubber like material:



        
10条回答
  •  后悔当初
    2021-01-30 19:55

    As you explicitly asked about high level optimizations, it might be worth trying different C++ compilers. Nowadays, compilers are very complex optimization beasts and CPU vendors might implement very powerful and specific optimizations. But please note, some of them are not free (but there might be a free academic program).

    • GNU compiler collection is free, flexible, and available on many architectures
    • Intel compilers are very fast, very expensive, and may also produce good results for AMD architectures (I believe there is an academic program)
    • Clang compilers are fast, free, and might produce similar results to GCC (some people say they are faster, better, but this might differ for each application case, I suggest to make your own experiences)
    • PGI (Portland Group) is not free as the Intel compilers.
    • PathScale compilers might perform good results on AMD architectures

    I've seen code snippets differ in execution speed by the factor of 2, only by changing the compiler (with full optimizations of course). But be aware of checking the identity of the output. To aggressive optimization might lead to different output, which is something you definitely want to avoid.

    Good Luck!

提交回复
热议问题