At the moment, it is not possible to use @one_by_one in a loop nested within an outer @tasks loop.
In my use case, where I run MCMC chains in parallel, and collect samples after a burn-in phase, it would be convenient to have this feature.
The code I would like to work looks more or less like this
nsamples = 1000
@tasks for c in 1:nchains
x = rand([-1, 1], N)
# burn-in
run_mcmc!(x; nsweeps=100)
# collect samples
while nsamples > 0
run_mcmc!(x, ξ; nsweeps=10)
@one_by_one begin
nsamples -= 1
open(file, "a") do io
writedlm(io, x', ',')
end
end
end
end
for which I get the error
ERROR: LoadError: The @one_by_one macro may only be used inside of a @tasks block.```
Can this limitation be lifted?
Is using a ReentrantLock within the @tasks loop a valid workaround?
At the moment, it is not possible to use
@one_by_onein a loop nested within an outer@tasksloop.In my use case, where I run MCMC chains in parallel, and collect samples after a burn-in phase, it would be convenient to have this feature.
The code I would like to work looks more or less like this
for which I get the error
Can this limitation be lifted?
Is using a
ReentrantLockwithin the@tasksloop a valid workaround?