Skip to content

Commit

Permalink
add some options of parallelism, for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Jul 16, 2024
1 parent 1b9e43d commit 9f8c642
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ authors = ["Leandro Martinez <[email protected]> and contributors"]
version = "0.9.6-DEV"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
2 changes: 2 additions & 0 deletions src/CellListMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ using Setfield: @set!
using LinearAlgebra: cross, diagm, I
using Base.Threads: nthreads, @spawn
using Base: @lock # not exported in 1.6
using Polyester: @batch
using ChunkSplitters: chunks

export Box
export CellList, UpdateCellList!
Expand Down
16 changes: 14 additions & 2 deletions src/CoreComputing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,20 @@ function map_pairwise_parallel!(
output_threaded = [deepcopy(output) for i in 1:nbatches]
end
p = show_progress ? Progress(length(cl.ref), dt=1) : nothing
@sync for ibatch in 1:nbatches
@spawn batch($f, $ibatch, $nbatches, $output_threaded, $box, $cl, $p)
#@sync for ibatch in 1:nbatches
# @spawn batch($f, $ibatch, $nbatches, $output_threaded, $box, $cl, $p)
#end
#Threads.@threads :static for ibatch in 1:nbatches
# batch(f, ibatch, nbatches, output_threaded, box, cl, p)
#end
#@batch for i in eachindex(cl.ref)
# inner_loop!(f, output_threaded[1], i, box, cl)
# #_next!(p)
#end
@sync for (ibatch, inds) in enumerate(chunks(cl.ref; n=nbatches))
@spawn for i in inds
inner_loop!(f, output_threaded[ibatch], i, box, cl)
end
end
return reduce(output, output_threaded)
end
Expand Down

0 comments on commit 9f8c642

Please sign in to comment.