Bug?: Preprocessor substitution of model local variables

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Bug?: Preprocessor substitution of model local variables

Postby cfp » Sat Jul 03, 2010 1:48 pm

The current version of Dynare defines all model local variables in generated c (and m) files, but then never actually uses them, instead substituting in the expression every time the model local variable appears.

Firstly, this makes the C compiler's job a lot harder and will generally result in suboptimal code. It is a lot easier for compilers to optimise out variables than it is for them to create new variables for common expressions.

Secondly, for models with a lot of model local variables, perhaps defined recursively, this results in massive output files, which then crash the compiler. In order to facilitate finding the steady state of my model I created a static version of my model and put in model local variables where ever possible. This results in the current version of Dynare spitting out 350MB C/M files. If the model local variables were actually used rather than being substituted in these files would be more like 350KB...

Tom
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Bug?: Preprocessor substitution of model local variables

Postby cfp » Sun Jul 04, 2010 1:55 am

For anyone else I annoyed by this I attach my own preprocessor written in C# . Consider it released under the GPL.

It is by no means as robust as the Dynare one and it works solely on static model files (with no leads and lags), but this is all you need if you're just trying to find the steady state. The input to it is the macro expanded output of Dynare.

The key thing is that whereas Dynare was making 350MB C files, this is making 89KB ones... Guess which the compiler prefers...
Attachments
Program.cs.txt
The C# pre-processor.
(5.79 KiB) Downloaded 67 times
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Bug?: Preprocessor substitution of model local variables

Postby SébastienVillemot » Thu Aug 19, 2010 1:21 pm

Hi,

Thanks for reporting this problem. This is indeed a bug in the preprocessor, which has been fixed in the unstable version, and will be fixed in the next release.

Best,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests