Today I was tracking down the test failure observed in JuliaMath/IntelVectorMath.jl#39 when moving to MKL_jll that occurred on a Mac.
After a while, with some help from @giordano, an MWE is:
# dlopen the libgomp inside CompilerSupportLibraries_jll (libgfortran 5). using Libdl dlopen("/Users/kristoffercarlsson/.julia/artifacts/411c17f069dd12b3f79b19e4647949050a58223c/lib/libgomp.1.dylib") using MKL_jll gamma1(x) = (x = copy(x); ccall((:vdTGamma, libmkl_rt), Cvoid, (Int32, Ptr{Float64}, Ptr{Float64}), length(x), x, x); x); gamma2(x) = (y = similar(x); ccall((:vdTGamma, libmkl_rt), Cvoid, (Int32, Ptr{Float64}, Ptr{Float64}), length(x), x, y); y); INPUT_2 = rand(1000); gamma1(INPUT_2)[1:3] gamma2(INPUT_2)[1:3]
the result from gamma1
and gamma2
should give the same answers, but they don't, as an example
julia> gamma1(INPUT_2)[1:3] 3-element Array{Float64,1}: Inf Inf Inf julia> gamma2(INPUT_2)[1:3] 3-element Array{Float64,1}: 16.209046961478283 6.570129954697695 41.08264424860374
(This doesn't seem to happen 100% of the time but the majority of the times).
This only happens if the length of the input vector is a certain size, cf
julia> gamma1(INPUT_2[1:602])[1:3] # ok 3-element Array{Float64,1}: 1.0650782774656853 1.4718294693439533 1.1884483595544906 julia> gamma2(INPUT_2[1:602])[1:3] # ok 3-element Array{Float64,1}: 1.0650782774656853 1.4718294693439533 1.1884483595544906 julia> gamma1(INPUT_2[1:603])[1:3] # bad 3-element Array{Float64,1}: 0.9663910468243027 0.8856476139287297 0.9213177809196278 julia> gamma2(INPUT_2[1:603])[1:3] # ok 3-element Array{Float64,1}: 1.0650782774656853 1.4718294693439533 1.1884483595544906
The cutoff seems to be when the length of the vector is 603
. My guess is that MKL thinks this is a long enough vector to perhaps enable threading? Also, it is important that libgomp
is loaded before MKL_jll for the bug to occur.
The versions used are:
[e66e0078] CompilerSupportLibraries_jll v0.2.0+1
[856f044c] MKL_jll v2020.0.166+0
and
julia> versioninfo() Julia Version 1.4.0-rc2.0 Commit b99ed72c95 (2020-02-24 16:51 UTC) Platform Info: OS: macOS (x86_64-apple-darwin19.0.0) CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4