mercredi 14 décembre 2016

Performance difference between compilers & OS for pseudo-RNG C++

I need to generate a lot of random numbers for a ray-tracer I'm making. Running a profiler, I determined that on a Release -O2 Visual Studio x64 build the pRNG is taking the most time. Doing tests, I determined that this code:

mt19937 mt(2);
uniform_real_distribution<double> dis;
for(int i = 0; i < 1e6; ++i){
    dis(mt);
}

Runs about 2.5x times slower on both my machine and some friends on msvc compiler than running it on Linux GCC with flags

g++ -std=c++14 -O2 

The performance difference is still significant in Debug builds(no optimizations).
I decided to run it with the MinGW CodeBlocks compiler on Windows and it's only slightly faster, still a significant difference to the Linux counterpart.
What is the reason for these differences? Is it a OS specific issue, compiler specific or am I missing something?




Aucun commentaire:

Enregistrer un commentaire