<p dir="auto">(or vice versa).   Right now, this seems to just crash(?) (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="81009305" data-permission-text="Title is private" data-url="https://github.com/JuliaPy/PyCall.jl/issues/148" data-hovercard-type="issue" data-hovercard-url="/JuliaPy/PyCall.jl/issues/148/hovercard" href="https://github.com/JuliaPy/PyCall.jl/issues/148">JuliaPy/PyCall.jl#148</a>).  Can <code class="notranslate">dlopen</code> (i.e. libuv) detect the architecture of a library file and throw an exception?</p>
<p dir="auto">(Would be good to try this outside of PyCall to verify that it really crashes and is not PyCall's fault.  But I think PyCall should throw an error if <code class="notranslate">dlopen</code> does.)</p>
<p dir="auto"><strong>Description</strong></p>
<p dir="auto">When performing an outer product (<code class="notranslate">M .* v</code>) of a sparse matrix by a vector (either dense or sparse), I run out of memory.</p>
<p dir="auto">The matrix in question is <code class="notranslate">3,955,848×3,955,848 SparseMatrixCSC{Float64,Int64} with 31,646,765</code> stored entries. The vector is of length 3,955,848.</p>
<p dir="auto">The result should be another 3,955,848x3,955,848 matrix of 3,955,848 entries, which should fit comfortably in memory. Unfortunately, it seems as though there must be a fair amount of unnecessary allocation happening somewhere.</p>
<p dir="auto"><strong>Version</strong></p>
<p dir="auto">Julia Version 1.0.0<br>
Commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/JuliaLang/julia/commit/5d4eaca0c9fa3d555c79dbacdccb9169fdf64b65/hovercard" href="https://github.com/JuliaLang/julia/commit/5d4eaca0c9fa3d555c79dbacdccb9169fdf64b65"><tt>5d4eaca</tt></a> (2018-08-08 20:58 UTC)<br>
Platform Info:<br>
OS: Linux (x86_64-pc-linux-gnu)<br>
CPU: Intel(R) Core(TM) i5 CPU       M 480  @ 2.67GHz<br>
WORD_SIZE: 64<br>
LIBM: libopenlibm<br>
LLVM: libLLVM-6.0.0 (ORCJIT, westmere)</p>
<p dir="auto"><strong>Error Message</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR: OutOfMemoryError()
Stacktrace:
 [1] _allocres at ./boot.jl:394 [inlined]
 [2] _diffshape_broadcast(::typeof(*), ::SparseMatrixCSC{Float64,Int64}, ::SparseVector{Float64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:189
 [3] _copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:970 [inlined]
 [4] copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:965 [inlined]
 [5] materialize at ./broadcast.jl:724 [inlined]
 [6] broadcast at ./broadcast.jl:702 [inlined]
 [7] copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:1082 [inlined]
 [8] materialize(::Base.Broadcast.Broadcasted{SparseArrays.HigherOrderFns.PromoteToSparse,Nothing,typeof(*),Tuple{SparseMatrixCSC{Float64,Int64},Array{Float64,1}}}) at ./broadcast.jl:724
 [9] top-level scope at none:0"><pre class="notranslate"><code class="notranslate">ERROR: OutOfMemoryError()
Stacktrace:
 [1] _allocres at ./boot.jl:394 [inlined]
 [2] _diffshape_broadcast(::typeof(*), ::SparseMatrixCSC{Float64,Int64}, ::SparseVector{Float64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:189
 [3] _copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:970 [inlined]
 [4] copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:965 [inlined]
 [5] materialize at ./broadcast.jl:724 [inlined]
 [6] broadcast at ./broadcast.jl:702 [inlined]
 [7] copy at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/higherorderfns.jl:1082 [inlined]
 [8] materialize(::Base.Broadcast.Broadcasted{SparseArrays.HigherOrderFns.PromoteToSparse,Nothing,typeof(*),Tuple{SparseMatrixCSC{Float64,Int64},Array{Float64,1}}}) at ./broadcast.jl:724
 [9] top-level scope at none:0
</code></pre></div>
<p dir="auto"><strong>Example Code</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="using SparseArrays

width  = 1636
height = 2418
I      = vec(rand(1:width*height,8*width*height))
J      = vec(rand(1:width*height,8*width*height))
V      = vec(rand(1,8*width*height))
M      = sparse(I,J,V) 
v      = vec(rand(1,width*height))
M.*v #Everything blows up"><pre class="notranslate"><code class="notranslate">using SparseArrays

width  = 1636
height = 2418
I      = vec(rand(1:width*height,8*width*height))
J      = vec(rand(1:width*height,8*width*height))
V      = vec(rand(1,8*width*height))
M      = sparse(I,J,V) 
v      = vec(rand(1,width*height))
M.*v #Everything blows up
</code></pre></div>
<p dir="auto">Note that this works fine for (<code class="notranslate">width=height=100</code>) and returns the expected sparse matrix with the expected number of entries.</p>