Skip to content

Commit 566e01d

Browse files
committed
Try a multithreaded model
1 parent 98b9af0 commit 566e01d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

ad.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ def run_ad(args):
7070

7171
results = {}
7272

73+
if model_key == "multithreaded":
74+
RUN_JULIA_COMMAND = ["julia", "--threads=2", *JULIA_COMMAND[1:]]
75+
else:
76+
RUN_JULIA_COMMAND = JULIA_COMMAND
77+
7378
# Run tests
7479
for adtype in adtypes:
7580
print(f"Running {model_key} with {adtype}...")
7681
try:
77-
output = run_and_capture([*JULIA_COMMAND, "--run", model_key, adtype])
82+
output = run_and_capture([*RUN_JULIA_COMMAND, "--run", model_key, adtype])
7883
result = output.splitlines()[-1]
7984
except sp.CalledProcessError as e:
8085
result = "error"

models.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,11 @@ for n in NS
146146
end
147147
end
148148

149+
@model function multithreaded(x)
150+
Threads.@threads for i in eachindex(x)
151+
x[i] ~ Normal(x, 1)
152+
end
153+
end
154+
add_model!(MODELS, multithreaded([1.5, 2.0, 2.5, 1.5, 2.0, 2.5]))
155+
149156
end # module Models

0 commit comments

Comments
 (0)