-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bug when using MKLSparse following use of MKL #36
Comments
I encountered essentially the same bug. Here is a smaller example that might be helpful:
|
I am seeing similar problems with MKLSparse. However, note that the package seems to be abandoned, as it hasn't been updated in over 2 years: |
I highly suspect that the issue is in MKL. |
I find the culprit, MKL.jl is loading an We load an |
@ViralBShah Is it not possible to still load the interface |
I thought we use the ILP64 by default in MKL. MKL now has the |
Do you know in which version of Intel MKL , the |
IIRC, it was in 2023, but there were some issues where a few symbols got left out. So, I think 2024 is perhaps the safest. In fact, we may want to make 2024 a minimum requirement even in MKL.jl. |
We will drop support for Mac but I think it's fine. It never worked well and required sesuential threading. |
Hi, I also faced a similar issue as the users above today, even though the package was updated recently. MWE:
Note that by construction, matrix Within a project I was working on, MKLSparse also seems to have resulted in Julia crashing in weird ways, as I eventually figured out here. But I couldn't produce an easy MWE for that. My Pkg status:
|
MKL.jl is loading an LP64 interface whereas MKLSparse.jl is loading the ILP64 interface. |
Does it work if you switch MKL.jl to the ILP64 interface? The problem is that MKL.jl only uses the Is it possible to set ILP64 just for the MKLSparse stuff without affecting the BLAS? |
Do these MKL sparse routines give us a clear way of picking which API to call for 32 vs. 64-bit integers? Another possibility may be to default this package to SparseMatrixCSC with 32-bit ints only? |
If we were able to use the C API for MKLSparse, it may stay clear of the issues we are facing with the INTERFACE setting, which probably changes the size of the Fortran INTEGER based on LP64 vs ILP64. Another solution might be to see if we can avoid |
The performance with the C API is worse than Fortran routines last time that I tested. |
My PR didn't work. I closed it. Huh, that is weird that the C routines have worse performance. Can you check that once again? |
@mkrainiuk Any insight you have here might be valuable. |
The only one potential performance change I'd expect is when you compare 32bit integer API vs 64bit integer API, but not Fortran vs C. Could you please clarify what type of APIs you compared? As a side note, I'd highly recommend to use IE spBLAS API instead of deprecated NIST style spBLAS API, since we plan to completely remove it from oneMKL in the future. We have a short KB article about migration here |
@mkrainiuk Thank you. If we are using the LP64 interface of MKL, would the integer that is passed to the sparse API calls have to be 32-bit ints? (Currently this package passes 64-bit ints, and when MKL uses the LP64 interface, we observe the crash). |
Hi @ViralBShah, yes, LP64 interface expect 32bit integers, and this is most likely why you observe the crash, you need to use |
@mkrainiuk The thing I couldn't figure out is if the sparse functions also have the |
oneMKL has _64 API for inspector-executor SpBLAS API
|
@rayegun Do you understand how the Intel sparse BLAS compares to Tim's GraphBLAS? Should people take a look at your GraphBLAS Julia package as well? |
Around JuliaCon I would recommend it yes. It's in fine shape now maybe a little rough on the edges, but I'm about 3/4 of the way through a total rewrite. GraphBLAS is a strict superset of Sparse BLAS with the exception of solvers, and SuiteSparse:GraphBLAS is almost always quite a bit faster than MKL. The real problem I will have solved by JuliaCon is that the GraphBLAS interface is not exactly what SparseBLAS people want. |
@simonp0420 @TobiasHolicki @Leebre |
@mkrainiuk Sorry for not answering earlier. I tested the Fortran API (v1.2.0 of MKLSparse.jl) and the C API (v2.0.0 of MKLSparse.jl) for sparse matrix - vector products with CSC matrices. I don't have any performance regression with the version 2024.2.0 of MKL. 👍 My benchmark is the following code: using BenchmarkTools, SuiteSparseMatrixCollection, MatrixMarket
using SparseArrays, LinearAlgebra, Printf, JLD, Base.Threads
ssmc = ssmc_db(verbose=false)
dataset = ssmc[(ssmc.binary .== false) .& (10000 .≤ ssmc.nrows .≤ 20000) .& (ssmc.numerical_symmetry .== 1.0), :]
# dataset = ssmc[(ssmc.binary .== false) .& (1000 .≤ ssmc.nrows .≤ 10000), :]
paths = fetch_ssmc(dataset, format="MM")
names = dataset[!,:name]
# nb_pbs = length(paths) # 796 matrices...
nb_pbs = 15
benchmark_sparse = true
benchmark_mkl = true
time_sparse = zeros(nb_pbs)
time_mkl = zeros(nb_pbs)
if benchmark_sparse
for i = 1 : nb_pbs
name = dataset[!,:name][i]
path = paths[i]
@printf("SparseArrays -- %3d / %3d -- %s\n", i, nb_pbs, name)
A = Float64.(MatrixMarket.mmread(path * "/$name.mtx"))
n, m = size(A)
x = rand(m)
y = rand(n)
time_sparse[i] = @belapsed for k in 1:1000 mul!($y, $A, $x) end
end
save("time_sparse.jld", "time_sparse", time_sparse)
else
time_sparse = load("time_sparse.jld", "time_sparse")
end
using MKLSparse
if benchmark_mkl
for i = 1 : nb_pbs
name = names[i]
path = paths[i]
@printf("MKLSparse -- %3d / %3d -- %s\n", i, nb_pbs, name)
A = MatrixMarket.mmread(path * "/$name.mtx")
n, m = size(A)
x = rand(m)
y = rand(n)
time_mkl[i] = @belapsed for k in 1:1000 mul!($y, $A, $x) end
end
save("time_mkl.jld", "time_mkl", time_mkl)
else
time_mkl = load("time_mkl.jld", "time_mkl")
end
using PlotlyJS
p = plot([
bar(name="mul! SparseArrays", x=names[1:nb_pbs], y=time_sparse),
bar(name="mul! MKLSparse", x=names[1:nb_pbs], y=time_mkl),
],
)
relayout!(p, barmode="group")
savefig(p, "julia_vs_mkl_eps", format="eps")
savefig(p, "julia_vs_mkl_svg", format="svg") |
When I
use MKLSparse
after a previoususe MKL
, a bug manifests when multiplying a real-valuedSparseMatrixCSC{ComplexF64, Int64}
matrix times aComplexF64
orFloat64
vector. The following output exhibits the bug:The final output should be zero since
b
was computed asQAAQ * fsrc
andQAAQ
has zero imaginary part for each element. Note that the bug does not manifest if I use the two packages in the other order:MKLSparse
first, followed byMKL
.The four files necessary for reproducing this are in this gist. Here is my version info:
and my package status:
The text was updated successfully, but these errors were encountered: