Skip to content

Commit

Permalink
Jevo chg pmap for distributed computation of interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbus committed May 25, 2024
1 parent aa108e7 commit 0b64d31
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/operators/updaters/updaters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,8 @@ end

function compute_interactions!(matches::Vector{<:AbstractMatch}; batch_size::Int)
@assert length(workers()) > 0 "Jevo must be run with at least one worker process"
# get scores async, this is important because GPU memory fills up if we wait for all
# tasks to finish before collecting
match_batches = [matches[i:min(length(matches),(i+batch_size-1))] for i in 1:batch_size:length(matches)]
score_batches = Vector(undef, length(match_batches))
# send batches of 20 matches to gpu
Threads.@threads for midx in eachindex(match_batches)
score_batches[midx] = fetch(@spawnat(:any, [play(m) for m in match_batches[midx]]))
end
for (mb, sb) in zip(match_batches, score_batches), (match, score) in zip(mb, sb)
scores = pmap(play, matches)
for (match, score) in zip(matches, scores)
@inbounds add_interactions!(score, match)
end
end
Expand Down

0 comments on commit 0b64d31

Please sign in to comment.