mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.51k stars 898 forks source link

MKL_CBWR environment variable does not seem to be respected when running? #1070

Open jaybert opened 8 months ago

jaybert commented 8 months ago

We are trying to resolve some diffs across different systems and I am trying to play around with the MKL_CBWR environment setting but I'm not positive that the environment setting is being effected on the run like it should.

https://www.intel.com/content/www/us/en/developer/articles/technical/introduction-to-the-conditional-numerical-reproducibility-cnr.html

for example,

i set MKL_CBWR=SSE2 or COMPATIBLE, or AVX2,STRICT

and then when I set the env setting MKL_VERBOSE=1 and then run my program,

i still see MKL_VERBOSE DGEMM(......CNR:AUTO...) and the CNR:AUTO never changes

I believe I should see this value change as I change the MKL_CBWR setting but I could be wrong on that.

On a related note, is there a way to change this in code (running the F# version if it matters).

Thanks!

EDIT: i was able to set it by using the MathNet.Numerics.Providers.MKL.LinearAlgebra.MklLinearAlebgraControl.UseNativeMKl(MklConsistency.Compatible) instead of just UseNativeMKL()

One request, would it be possible to expose STRICT setting for MKL_CBWR, so you could do AVX2,STRICT to ensure stronger reproducibility guarantees.