How to manage CPU instructions used by Microsoft C runtime libraries?

Is it possible to control which processor instruction sets are used by the MS C runtime library (Visual Studio 2013, 2015)? If I go into disassembly, say, cos (), the code is compared with a pre-calculated set of CPU capabilities, and then performs this function using the "best" features available on the CPU. The problem is that different instruction sets give different results, so the results differ depending on the processor architecture.

As an example, we will build a 64-bit executable file:

std::cout << std::setprecision(20) << cos(-0.61385470201194381) << std:: endl;

On Haswell / Broadwell and later returns 0.81743370050726594 (same as x86). On older processors, 0.81743370050726583 is returned.

The Runtime Library uses the FMA instruction set , if available, executes a different implementation, and produces different results. Please note: this is not affected by the compiler options selected in the application, since the Runtime libraries are provided pre-compiled. Also note that the _controlfp () floating point precision control function cannot control the accuracy of a 64-bit runtime.

Is it possible to control which command sets the runtime library so that the results are more deterministic?

+4
source share
1 answer

, , ?

.

(+, -, *, /, sqrt) IEEE754, . , cos, libm, - . BLAS.

, 2 :

0

Source: https://habr.com/ru/post/1626813/


All Articles