-
Notifications
You must be signed in to change notification settings - Fork 16
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
@batch
slower than Threads.@threads
#32
Comments
Can you provide a minimal example I can run? |
I'll try, but I expect it to be quite difficult since the tests are based on comparing the results of a fairly complex calculation to those produced by another program in R; I'd have to build tests for much smaller subsets of the calculations. Replacing |
What I'd do from there is store @inbounds Threads.@threads for i in eachindex(tail_length)
tail_length[i] = def_tail_length(post_sample_size, r_eff[i])
ξ[i] = @views ParetoSmooth.do_psis_i!(weights[i,:], tail_length[i])
end A trick for storing things is defining this in your REPL: julia> const ARGS = Ref{Any}() and then (using Main.ARGS[] = copy.((post_sample_size, r_eff, weights))
@inbounds Threads.@threads for i in eachindex(tail_length)
tail_length[i] = def_tail_length(post_sample_size, r_eff[i])
ξ[i] = @views ParetoSmooth.do_psis_i!(weights[i,:], tail_length[i])
end now, calling the function will store those into the |
The tests in the test file should do what you need, in that case; the test folder contains an example log-likelihood array used for testing, as well as the saved results of the same calculations in R. |
I see; how do I get those to you after that? |
If they're big, then there isn't really a convenient way. I'll look at the test suite. |
Yeah, |
Something that might be worth noting is that I tried to parallelize this with FLoops.jl as well, and it complained about "weights" being a boxed variable, which might create data races. I don't know what that means, but it might be useful to you. I figured this was just a problem for FLoops, rather than an inherent feature of the code that would produce data races, since the tests all passed when using |
I don't think that'd be a problem. The first thing I'll look at is if It'll be at least a couple hours before I can look at this. |
Just as an update, I fixed a bug in StrideArraysCore so that it now gets the correct answer, but |
Cool, thanks! That's surprising -- I would have expected it to be, at worst, the same speed. |
@batch
results in incorrect calculations (While Threads.@threads
doesn't)@batch
slower than Threads.@threads
I changed the name of the issue to reflect the updated status. |
Tried to see if replacing
Threads.@threads
with@batch
would improve performance on smaller workloads for a function. This seems to introduce some kind of data race (which wasn't present withThreads.@threads
), which results in manyNaN
values and incorrect results, which were caught by the tests. The relevant loop is here. Not sure what the cause is; thefor
loop is looping over calculations for each data point, and each one of these should be completely independent of the calculations for every other data point.The text was updated successfully, but these errors were encountered: