Skip to content

Commit

Permalink
Use ChunkSplitters for multithreading (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Dec 4, 2024
1 parent 0efdc25 commit 2fbbd74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Aldo Glielmo <[email protected]>", "Mitja Devetak <m888it
version = "0.2.0"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DynamicSampling = "2083aeaf-6258-5d07-89fc-32cf5060c837"
Expand All @@ -20,6 +21,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"

[compat]
ChunkSplitters = "3"
Dates = "1"
Distributions = "0.25"
DynamicSampling = "0.4"
Expand Down
1 change: 1 addition & 0 deletions src/BeforeIT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module BeforeIT

import Base: length

using ChunkSplitters
using DynamicSampling
using LazyArrays
using LinearAlgebra
Expand Down
7 changes: 4 additions & 3 deletions src/markets/search_and_matching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ function search_and_matching!(model, multi_threading = false)
)
end


if multi_threading
Threads.@threads :static for g in 1:G
loopBody(Threads.threadid(), g)
Threads.@threads for (i, gs) in enumerate(chunks(shuffle(1:G); n=Threads.nthreads()))
for g in gs
loopBody(i, g)
end
end
else
for g in 1:G
Expand Down

0 comments on commit 2fbbd74

Please sign in to comment.