Recently I did some refactoring work and verified that the original code and refactored code will produce exactly the same results under Debug mode.
However, if I switch to Release mode. the original code and refactored code will produce slightly different results, the difference is around the scale of 10^-10 ~10^-15. It looks like it's some precision issue. I'm wondering why there's such difference ? Is there anyway to remove this difference ?
Although the difference is small, but maybe because the refactored code needs to be run millions of times, the final results is very different.
I'm using Intel(R) Visual Fortran Compiler 16.0 [Intel(R) 64]
This discussion on StackOverflow, especially the first answer, is also relevant: fortran - MATMUL result not equal with explicit calculation for double precision? - Stack Overflow