Skip to content
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

Use ChunkSplitters for multithreading #39

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Tortar marked this conversation as resolved.
Show resolved Hide resolved
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
Loading