I am attempting to parallelize this code
function pdiff(b1::Array{Basic,1}, b2::Basic)
dfdx = Array{Basic}(undef,length(b1))
Threads.@threads for i = 1:length(b1)
a = Basic()
ret = ccall((:basic_diff, libsymengine), Int, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1[i], b2)
dfdx[i] = a
end
return dfdx
end
On my laptop, the same Julia version, but runs on Windows and Intel skylake CPU. I saw an O(n^1/2) improvement with the number of threads, but on my desktop, I saw a decrease in performance with adding cores.
this might be helpful
desktop:
julia> versioninfo()
Julia Version 1.1.1
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
Environment:
JULIA_NUM_THREADS = 44
Any help would be greatly appreciated.
You can see the performance here Parallelization on CPU segfaults on occasion ¡ Issue #166 ¡ symengine/SymEngine.jl ¡ GitHub