This is not a Qt Programming question, so I have moved your thread to the General Programming section.

There are many explanations I can think of:

1 - g++ is very good at optimizing and parallelizing loops, so OpenMP doesn't add much advantage
2 - g++ has optimized and inlined your simple function.
3 - the OpenMP implementation in g++ has significant overhead which does not result in much performance increase for a small number of evaluations of a simple calculation.
4 - MSVC is not very good at optimizing loops.
5 - MSVC did not inline your function and left it as a function call
6 - MSVC produces slower code so OpenMP has a performance boost
7 - differences in the compilation flags for g++ vs. MSVC gave different degrees of optimization of the non-OpenMP code.

Also, most compilers turn off optimization in debug mode, so using a debug mode build to test performance isn't really valid. Depending on the compiler, optimization can inline function calls, unroll loops, or make other changes so that the release and debug mode versions of the program aren't really the same.

I think you need to first research the compiler flags to make sure your non-OpenMP code is built on as close to an apples-to-apples basis as possible so you really do have the same starting point for comparison. And second, you need to make your test calculation more difficult, so it takes longer to execute and can't be optimized by the compiler, and you need to evaluate it maybe millions of times, not just 20000.

I don't know if it is the case, but because you are accessing a global array in your compute function, there could also be some access control locking that basically defeats the parallelization in g++.