adding dynare command line option 'fast' in order not to recompile MEX

files if the lists of variables and the equations haven't changed
between two runs of the same model file.
issue#70
Michel Juillard 2015-05-10 20:29:03 +02:00
parent 5b42483e81
commit f020a2cb52
4 changed files with 23 additions and 14 deletions

View File

@ -38,7 +38,7 @@
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, bool no_tmp_terms, bool no_log, bool no_warn,
bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang
bool parallel_test, bool nostrict, bool check_model_changes, FileOutputType output_mode, LanguageOutputType lang
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
@ -49,7 +49,7 @@ usage()
{
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [onlyclearglobals] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]] [nostrict] [output=dynamic|first|second|third] [language=C|C++]"
<< " [-D<variable>[=<value>]] [nostrict] [fast] [output=dynamic|first|second|third] [language=C|C++]"
#if defined(_WIN32) || defined(__CYGWIN32__)
<< " [cygwin] [msvc]"
#endif
@ -97,6 +97,7 @@ main(int argc, char **argv)
bool parallel_slave_open_mode = false;
bool parallel_test = false;
bool nostrict = false;
bool check_model_changes = false;
map<string, string> defines;
FileOutputType output_mode = none;
LanguageOutputType language = matlab;
@ -165,6 +166,8 @@ main(int argc, char **argv)
parallel_test = true;
else if (!strcmp(argv[arg], "nostrict"))
nostrict = true;
else if (!strcmp(argv[arg], "fast"))
check_model_changes = true;
else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "parallel", 8))
{
parallel = true;
@ -285,7 +288,7 @@ main(int argc, char **argv)
// Do the rest
main2(macro_output, basename, debug, clear_all, clear_global, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, output_mode, language
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, check_model_changes, output_mode, language
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc
#endif

View File

@ -27,7 +27,7 @@
void
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear_global, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType language
bool parallel_test, bool nostrict, bool check_model_changes, FileOutputType output_mode, LanguageOutputType language
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
@ -60,11 +60,12 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
if (output_mode != none)
mod_file->writeExternalFiles(basename, output_mode, language);
else
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph, nointeractive, config_file
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
nointeractive, config_file, check_model_changes
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc
, cygwin, msvc
#endif
);
);
delete mod_file;

View File

@ -526,7 +526,8 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output)
}
void
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph,
bool nointeractive, const ConfigFile &config_file, bool check_model_changes
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
@ -650,7 +651,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<< "end" << endl;
bool hasModelChanged = !dynamic_model.isChecksumMatching(basename);
if (!check_model_changes)
hasModelChanged = true;
if (hasModelChanged)
{
// Erase possible remnants of previous runs
@ -700,20 +703,21 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
#endif
// Compile the dynamic MEX file for use_dll option
// When check_model_changes is true, don't force compile if MEX is fresher than source
if (use_dll)
{
#if defined(_WIN32) || defined(__CYGWIN32__)
if (msvc)
// MATLAB/Windows + Microsoft Visual C++
mOutputFile << "dyn_mex('msvc', '" << basename << ", 1)" << endl;
mOutputFile << "dyn_mex('msvc', '" << basename << "', " << !check_model_changes << ")" << endl;
else if (cygwin)
// MATLAB/Windows + Cygwin g++
mOutputFile << "dyn_mex('cygwin', '" << basename << "', 1)" << endl;
mOutputFile << "dyn_mex('cygwin', '" << basename << "', " << !check_model_changes << ")" << endl;
else
mOutputFile << " error('When using the USE_DLL option, you must give either ''cygwin'' or ''msvc'' option to the ''dynare'' command')" << endl;
#else
// other configurations
mOutputFile << "dyn_mex('', '" << basename << "', 1)" << endl;
// other configurations
mOutputFile << "dyn_mex('', '" << basename << "', " << !check_model_changes << ")" << endl;
#endif
}

View File

@ -145,7 +145,8 @@ public:
\param cygwin Should the MEX command of use_dll be adapted for Cygwin?
\param msvc Should the MEX command of use_dll be adapted for MSVC?
*/
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool check_model_changes
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif