Skip to content

Commit

Permalink
Switch to use Threads.@threads instead of @Spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobadenbaum committed Mar 21, 2021
1 parent fc37895 commit 134151d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/AdaptiveSparseGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,11 @@ function train!(f, fun::AdaptiveSparseGrid{D,N,K,L,T}, children) where {D,N,K,L,
# Evaluate the function and compute the gain for each of the children
# Note: This should be done in parallel, since this is where all of the hard
# work (computing function evaluations) happens
@sync for child in children
Threads.@spawn begin
x = getx(child)
child.fx = T(f(rescale(fun, x)))
ux = evaluate(fun, x)
child.α = T(Tuple(child.fx) .- ux)
end
Threads.@threads for child in children
x = getx(child)
child.fx = T(f(rescale(fun, x)))
ux = evaluate(fun, x)
child.α = T(Tuple(child.fx) .- ux)
end
return
end
Expand Down

2 comments on commit 134151d

@jacobadenbaum
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch = main

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/32474

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" 134151d7cd1e24969e53a55a3845abd2f1cfdc4b
git push origin v0.1.3

Please sign in to comment.