From 591b5e5f9e6c9fbdd20e3d4aa8e361e20bd9d2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Thu, 19 May 2022 14:15:43 +0200 Subject: [PATCH] Always create bytecode output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And, symmetrically, when the “bytecode” option is requested by the user, always create the .m static/dynamic files. The “bytecode” option therefore no longer modifies the preprocessor output. --- src/ComputingTasks.cc | 2 +- src/DynamicModel.cc | 17 ++++++++--------- src/DynamicModel.hh | 4 ++-- src/ModFile.cc | 8 ++++---- src/StaticModel.cc | 17 ++++++++--------- src/StaticModel.hh | 4 ++-- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index d32eda89..bac07b44 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -2438,7 +2438,7 @@ PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename, for (const auto &temporary_terms_derivative : model_tree.getTemporaryTermsDerivatives()) output << temporary_terms_derivative.size() << "; "; output << "];" << endl; - model_tree.writeStaticFile(basename + ".objective", false, false, false, "", {}, {}, false); + model_tree.writeStaticFile(basename + ".objective", false, false, "", {}, {}, false); } void diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 0591d2c2..84244248 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -4536,20 +4536,19 @@ DynamicModel::computeBlockDynJacobianCols() } void -DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const +DynamicModel::writeDynamicFile(const string &basename, bool block, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const { filesystem::path model_dir{basename}; model_dir /= "model"; if (use_dll) filesystem::create_directories(model_dir / "src"); - if (bytecode) - filesystem::create_directories(model_dir / "bytecode"); + filesystem::create_directories(model_dir / "bytecode"); if (block) { - if (bytecode) - writeDynamicBlockBytecode(basename); - else if (use_dll) + writeDynamicBlockBytecode(basename); + + if (use_dll) { writeDynamicPerBlockCFiles(basename); writeDynamicBlockCFile(basename); @@ -4572,9 +4571,9 @@ DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode } else { - if (bytecode) - writeDynamicBytecode(basename); - else if (use_dll) + writeDynamicBytecode(basename); + + if (use_dll) { writeDynamicCFile(basename); compileMEX(basename, "dynamic", mexext, { model_dir / "src" / "dynamic.c" }, diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 3092d796..d808a410 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -400,8 +400,8 @@ public: //! in the trend_component model void updateVarAndTrendModel() const; - //! Writes dynamic model file - void writeDynamicFile(const string &basename, bool block, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const; + //! Writes dynamic model file (+ bytecode) + void writeDynamicFile(const string &basename, bool block, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const; //! Writes file containing parameters derivatives void writeParamsDerivativesFile(const string &basename, bool julia) const; diff --git a/src/ModFile.cc b/src/ModFile.cc index a54a726b..96f7e53b 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -1077,11 +1077,11 @@ ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global, { if (!no_static) { - static_model.writeStaticFile(basename, block, bytecode, use_dll, mexext, matlabroot, dynareroot, false); + static_model.writeStaticFile(basename, block, use_dll, mexext, matlabroot, dynareroot, false); static_model.writeParamsDerivativesFile(basename, false); } - dynamic_model.writeDynamicFile(basename, block, bytecode, use_dll, mexext, matlabroot, dynareroot, false); + dynamic_model.writeDynamicFile(basename, block, use_dll, mexext, matlabroot, dynareroot, false); dynamic_model.writeParamsDerivativesFile(basename, false); @@ -1107,10 +1107,10 @@ ModFile::writeJuliaOutput(const string &basename) const { if (!no_static) { - static_model.writeStaticFile(basename, false, false, false, "", {}, {}, true); + static_model.writeStaticFile(basename, false, false, "", {}, {}, true); static_model.writeParamsDerivativesFile(basename, true); } - dynamic_model.writeDynamicFile(basename, block, bytecode, use_dll, "", {}, {}, true); + dynamic_model.writeDynamicFile(basename, block, use_dll, "", {}, {}, true); dynamic_model.writeParamsDerivativesFile(basename, true); } steady_state_model.writeSteadyStateFile(basename, mod_file_struct.ramsey_model_present, true); diff --git a/src/StaticModel.cc b/src/StaticModel.cc index a26bb32c..3b6320de 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -1785,20 +1785,19 @@ StaticModel::writeStaticJuliaFile(const string &basename) const } void -StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const +StaticModel::writeStaticFile(const string &basename, bool block, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const { filesystem::path model_dir{basename}; model_dir /= "model"; if (use_dll) filesystem::create_directories(model_dir / "src"); - if (bytecode) - filesystem::create_directories(model_dir / "bytecode"); + filesystem::create_directories(model_dir / "bytecode"); if (block) { - if (bytecode) - writeStaticBlockBytecode(basename); - else if (use_dll) + writeStaticBlockBytecode(basename); + + if (use_dll) { writeStaticPerBlockCFiles(basename); writeStaticBlockCFile(basename); @@ -1821,9 +1820,9 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode, } else { - if (bytecode) - writeStaticBytecode(basename); - else if (use_dll) + writeStaticBytecode(basename); + + if (use_dll) { writeStaticCFile(basename); compileMEX(basename, "static", mexext, { model_dir / "src" / "static.c" }, diff --git a/src/StaticModel.hh b/src/StaticModel.hh index ec1b2ff9..c105cec4 100644 --- a/src/StaticModel.hh +++ b/src/StaticModel.hh @@ -136,8 +136,8 @@ public: */ void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block); - //! Writes static model file - void writeStaticFile(const string &basename, bool block, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const; + //! Writes static model file (+ bytecode) + void writeStaticFile(const string &basename, bool block, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const; //! Write JSON Output (used by PlannerObjectiveStatement) void writeJsonOutput(ostream &output) const; -- GitLab