Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

rounding mode mkl 8 and up windows

viktor3
Beginner
1,020 Views
Hello, i'm new on the forum. I hope my posting is at right place. I'm confused about rounding that mkl take by computations. For mkl version 7.1 (and up) on Linux the rounding mode will bee not changed troth the mkl. Does
it apply for mkl on Windows-systems?

Thanks on all
0 Kudos
8 Replies
TimP
Honored Contributor III
1,020 Views
Any MKL functions which modify rounding modes must restore them on exit, regardless of OS. Do you have an example which shows otherwise?
0 Kudos
viktor3
Beginner
1,020 Views
Hello tim18. Thank you for your answer. But this was not my question. For mkl 7.2 ( and up) on linux it applies, that the rounding mode will not be change by mkl, for example, if I multiply two vectors from an outstanding application, for example Matlab. But the mkl 6.0 set the rounding mode to rounding to nearest, multiply the vectors and then set the rounding mode to the previous mode. This is not a bug, because for this version this behavior is specific.
http://www.tacc.utexas.edu/services/userguides/mkl/mkluse.htm
"On input to Intel MKL, precision is set to 80-bit for x87 instructions and rounding is set to "the nearest". On output, user's settings are restored. "

For mkl 7.2 (if I'm not mistaken) for linux the specification provide, that the rounding mode does not bee changed by the mkl. But not the same is valid for the mkl of any Version on Windows platforms. Is this specific, or what can I do?

I use not the mkl self, but the mkl in Matlab. Matlab 2007a and up uses mkl 8.0
and for linux the mkl under Matlab dont change the rounding mode, but not under windows.

Thank you.
0 Kudos
g_f_thomas
Beginner
1,020 Views

Regardless of the OS, MKL can and does change rounding modes and perhaps even precision. In particular, use of an interval arithmetic toolbox on Matlab or MKL's Linear Interval Solver suite do so; it's impossible to do enclosure arithmetic without changing rounding modes on the fly and precision has to be upped because the libraries for intrinsics were not developed with interval arithmetic in mind. The MKL documentation doesn't speak to these details and asking here is unlikely to evoke a response from the forum police.

Gerry

0 Kudos
Shane_S_Intel
Employee
1,020 Views
MKL may indeed change the rounding mode/precison control for internal computations.Prior to any changes, however, the floating-point control state will be saved and then restored prior to leaving the MKL function. I hope this clarification helps.
0 Kudos
viktor3
Beginner
1,020 Views
O.K. thanks for your repluies. That all is known to me. But i'm sure, that for BLAS-operations inner product, matrix-vector and matrix-matrix products the mkl does not change the rounding mode on linux and not so on windows. You can reproduce it, if you set rounding to -infinity and then perform an inner product on two vectors. Then you must set the rounding mode to +infinity and perform the inner product on the two vectors again. You might see, that on linux the two results are different and they are equal on windows. This states, that there ist an ambiguous behaviour.

Thank you
0 Kudos
Shane_S_Intel
Employee
1,020 Views

A few clarifying questions. Do your Windows and Linux systems have identical processors? Is this IA-32 or Intel 64? On HW with both X87 and SSE fp (MXCSR) control words, do you change the rounding mode in both?

Thank you for the additional information.

0 Kudos
viktor3
Beginner
1,020 Views
Yes, it is the same machine, with the two OSs. It is a pentium4 machine. I switch the rounding mode with the fesetround(FE_DOWNWARD or FE_UPWARD) routine from the standard c-header.

Thank You for your time and support for me.
0 Kudos
Shane_S_Intel
Employee
1,020 Views

Interesting, I would have expected similar behavior/results on the two OSs running on the same HW.Maybe theIA-32 default X87 precison controlof extended on Linux and double on Windows is playing a part here, but doubt it.I wonder if fenv.h and the underlying support routines are working as they should? Would it be possible to submit a simple test case at

http://support.intel.com/support/performancetools/libraries/mkl/win/

or provide a simple example here?

Thanks.

0 Kudos
Reply