Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug of MKL on Windows #173

Open
YanWin opened this issue Aug 30, 2024 · 1 comment
Open

Potential bug of MKL on Windows #173

YanWin opened this issue Aug 30, 2024 · 1 comment

Comments

@YanWin
Copy link

YanWin commented Aug 30, 2024

When using MKL on Windows, I get unexpected behavior that looks like a bug as some variables are overwritten, that should not be altered.

I don't get this problem on Linux or if MKL is not loaded.

Below is a minumum example with MKL v0.7.0 and Julia 1.10.5:

function test_error(a,A;mult_A = true)
    C = ones(size(A,2), size(A,2))
    tol = 1e-12
    println("tol init = ",tol)

    # no problem without the loop
    for i = 1:2
        if mult_A
            B = a .* A * C
        else
            # no problem arises without the multiplication of C or a
            B = A
        end
        println("tol = ", tol)
        # no problem arises without this line or adding 1.0
        D = similar(B) .+ 1.0
    end
end

A = ones(100, 5);
a = 1.0

@info "Without loading MKL"
using LinearAlgebra
println(BLAS.get_config())
test_error(a,A);

@info "With MKL"

using MKL
println(BLAS.get_config())
test_error(a, A);
@info "mult_A = false"
println(BLAS.get_config())
test_error(a, A; mult_A = false);

This leads to the following output:

[ Info: Without loading MKL
LBTConfig([ILP64] libopenblas64_.dll)
tol init = 1.0e-12
tol = 1.0e-12
tol = 1.0e-12
[ Info: With MKL
LBTConfig([ILP64] mkl_rt.2.dll, [LP64] mkl_rt.2.dll)
tol init = 1.0e-12
tol = 5.0
tol = 5.0
[ Info: mult_A = false
LBTConfig([ILP64] mkl_rt.2.dll, [LP64] mkl_rt.2.dll)
tol init = 1.0e-12
tol = 1.0e-12
tol = 1.0e-12

Let me know if I can provide any other information.

@ViralBShah
Copy link
Contributor

ViralBShah commented Sep 20, 2024

This feels a bit strange that something so basic in MKL is broken. Try disabling threading to see if it helps:

MKL.set_threading_layer(THREADING_SEQUENTIAL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants