Always create bytecode output

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.
master
Sébastien Villemot 2022-05-19 14:15:43 +02:00
parent af88f50d44
commit 591b5e5f9e
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
6 changed files with 25 additions and 27 deletions

View File

@ -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

View File

@ -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" },

View File

@ -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;

View File

@ -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);

View File

@ -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" },

View File

@ -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;