Parfor with Dynare

Is dynare compatible with parfor? That is, can one call dynare within a parfor loop?

Dynare itself features parallelization capabilities. But we have never tried to parallelize around Dynare. My hunch would be that it does not work due to the complexity of the underlying codes. But you might try. Any feedback on your experiences is highly appreciated.

I was able to do it. Within parfor, call a function of the iteration index that (i) cds into a distinct, index dependent directory and (ii) runs dynare. That way, dynare is run in the workspace of a function call and files are not rewritten.

Has anyone else been able to do this? The problem I am running into is that parfor does not work well with globals, and dynare uses globals. Alternatively, is there a way to run dynare without globals (M_, oo_) so that I can then figure out how to parallelize it?


Either you follow what Dr. En Ami suggested in doing separate calls to Dynare, which then separates the global variables by using different instances of Dynare.

The second alternative is using Dynare subfunctions directly. Many of them use local instances of the global variables.