Bytecode: rename output methods for better consistency
parent
1d838e96ff
commit
2944484442
|
@ -562,9 +562,8 @@ DynamicModel::writeDynamicPerBlockMFiles(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeModelEquationsCode(const string &basename) const
|
DynamicModel::writeDynamicBytecode(const string &basename) const
|
||||||
{
|
{
|
||||||
|
|
||||||
ostringstream tmp_output;
|
ostringstream tmp_output;
|
||||||
ofstream code_file;
|
ofstream code_file;
|
||||||
unsigned int instruction_number = 0;
|
unsigned int instruction_number = 0;
|
||||||
|
@ -590,7 +589,7 @@ DynamicModel::writeModelEquationsCode(const string &basename) const
|
||||||
else
|
else
|
||||||
simulation_type = BlockSimulationType::solveBackwardComplete;
|
simulation_type = BlockSimulationType::solveBackwardComplete;
|
||||||
|
|
||||||
Write_Inf_To_Bin_File(basename + "/model/bytecode/dynamic.bin", u_count_int, file_open, simulation_type == BlockSimulationType::solveTwoBoundariesComplete, symbol_table.endo_nbr());
|
writeBytecodeBinFile(basename + "/model/bytecode/dynamic.bin", u_count_int, file_open, simulation_type == BlockSimulationType::solveTwoBoundariesComplete);
|
||||||
file_open = true;
|
file_open = true;
|
||||||
|
|
||||||
//Temporary variables declaration
|
//Temporary variables declaration
|
||||||
|
@ -808,7 +807,7 @@ DynamicModel::writeModelEquationsCode(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeModelEquationsCode_Block(const string &basename, bool linear_decomposition) const
|
DynamicModel::writeDynamicBlockBytecode(const string &basename, bool linear_decomposition) const
|
||||||
{
|
{
|
||||||
struct Uff_l
|
struct Uff_l
|
||||||
{
|
{
|
||||||
|
@ -871,8 +870,8 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, bool linear_
|
||||||
|| simulation_type == BlockSimulationType::solveBackwardComplete
|
|| simulation_type == BlockSimulationType::solveBackwardComplete
|
||||||
|| simulation_type == BlockSimulationType::solveForwardComplete)
|
|| simulation_type == BlockSimulationType::solveForwardComplete)
|
||||||
{
|
{
|
||||||
Write_Inf_To_Bin_File_Block(basename, block, u_count_int, file_open,
|
writeBlockBytecodeBinFile(basename, block, u_count_int, file_open,
|
||||||
simulation_type == BlockSimulationType::solveTwoBoundariesComplete || simulation_type == BlockSimulationType::solveTwoBoundariesSimple, linear_decomposition);
|
simulation_type == BlockSimulationType::solveTwoBoundariesComplete || simulation_type == BlockSimulationType::solveTwoBoundariesSimple, linear_decomposition);
|
||||||
file_open = true;
|
file_open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,8 +1376,8 @@ DynamicModel::printNonZeroHessianEquations(ostream &output) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::Write_Inf_To_Bin_File_Block(const string &basename, int num,
|
DynamicModel::writeBlockBytecodeBinFile(const string &basename, int num, int &u_count_int,
|
||||||
int &u_count_int, bool &file_open, bool is_two_boundaries, bool linear_decomposition) const
|
bool &file_open, bool is_two_boundaries, bool linear_decomposition) const
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
std::ofstream SaveCode;
|
std::ofstream SaveCode;
|
||||||
|
@ -4636,14 +4635,10 @@ DynamicModel::computeBlockDynJacobianCols()
|
||||||
void
|
void
|
||||||
DynamicModel::writeDynamicFile(const string &basename, bool block, bool linear_decomposition, 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 linear_decomposition, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const
|
||||||
{
|
{
|
||||||
if (block && bytecode)
|
if ((block && bytecode) || linear_decomposition)
|
||||||
writeModelEquationsCode_Block(basename, linear_decomposition);
|
writeDynamicBlockBytecode(basename, linear_decomposition);
|
||||||
else if (!block && bytecode)
|
else if (!block && bytecode)
|
||||||
{
|
writeDynamicBytecode(basename);
|
||||||
if (linear_decomposition)
|
|
||||||
writeModelEquationsCode_Block(basename, linear_decomposition);
|
|
||||||
writeModelEquationsCode(basename);
|
|
||||||
}
|
|
||||||
else if (block && !bytecode)
|
else if (block && !bytecode)
|
||||||
{
|
{
|
||||||
writeDynamicPerBlockMFiles(basename);
|
writeDynamicPerBlockMFiles(basename);
|
||||||
|
|
|
@ -135,10 +135,13 @@ private:
|
||||||
void writeDynamicBlockMFile(const string &basename) const;
|
void writeDynamicBlockMFile(const string &basename) const;
|
||||||
//! Writes the per-block dynamic files of block decomposed model (MATLAB version)
|
//! Writes the per-block dynamic files of block decomposed model (MATLAB version)
|
||||||
void writeDynamicPerBlockMFiles(const string &basename) const;
|
void writeDynamicPerBlockMFiles(const string &basename) const;
|
||||||
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode
|
//! Writes the code of the block-decomposed model in virtual machine bytecode
|
||||||
void writeModelEquationsCode_Block(const string &basename, bool linear_decomposition) const;
|
void writeDynamicBlockBytecode(const string &basename, bool linear_decomposition) const;
|
||||||
//! Writes the code of the model in virtual machine bytecode
|
//! Writes the code of the model in virtual machine bytecode
|
||||||
void writeModelEquationsCode(const string &basename) const;
|
void writeDynamicBytecode(const string &basename) const;
|
||||||
|
//! Adds per-block information for bytecode simulation in a separate .bin file
|
||||||
|
void writeBlockBytecodeBinFile(const string &basename, int num, int &u_count_int, bool &file_open,
|
||||||
|
bool is_two_boundaries, bool linear_decomposition) const;
|
||||||
|
|
||||||
void writeSetAuxiliaryVariables(const string &basename, bool julia) const;
|
void writeSetAuxiliaryVariables(const string &basename, bool julia) const;
|
||||||
void writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType output_type) const;
|
void writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType output_type) const;
|
||||||
|
@ -368,9 +371,6 @@ public:
|
||||||
//! Substitutes pac_expectation operator with expectation based on auxiliary model
|
//! Substitutes pac_expectation operator with expectation based on auxiliary model
|
||||||
void substitutePacExpectation(const string &pac_model_name);
|
void substitutePacExpectation(const string &pac_model_name);
|
||||||
|
|
||||||
//! Adds informations for simulation in a binary file
|
|
||||||
void Write_Inf_To_Bin_File_Block(const string &basename,
|
|
||||||
int num, int &u_count_int, bool &file_open, bool is_two_boundaries, bool linear_decomposition) const;
|
|
||||||
//! Writes dynamic model file
|
//! Writes dynamic model file
|
||||||
void writeDynamicFile(const string &basename, bool block, bool linear_decomposition, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const;
|
void writeDynamicFile(const string &basename, bool block, bool linear_decomposition, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const;
|
||||||
//! Writes file containing parameters derivatives
|
//! Writes file containing parameters derivatives
|
||||||
|
|
|
@ -1509,8 +1509,8 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModelTree::Write_Inf_To_Bin_File(const string &filename,
|
ModelTree::writeBytecodeBinFile(const string &filename, int &u_count_int, bool &file_open,
|
||||||
int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const
|
bool is_two_boundaries) const
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
std::ofstream SaveCode;
|
std::ofstream SaveCode;
|
||||||
|
@ -1534,10 +1534,10 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
|
||||||
int var = symbol_table.getTypeSpecificID(symb);
|
int var = symbol_table.getTypeSpecificID(symb);
|
||||||
int lag = getLagByDerivID(deriv_id);
|
int lag = getLagByDerivID(deriv_id);
|
||||||
SaveCode.write(reinterpret_cast<char *>(&eq), sizeof(eq));
|
SaveCode.write(reinterpret_cast<char *>(&eq), sizeof(eq));
|
||||||
int varr = var + lag * block_mfs;
|
int varr = var + lag * symbol_table.endo_nbr();
|
||||||
SaveCode.write(reinterpret_cast<char *>(&varr), sizeof(varr));
|
SaveCode.write(reinterpret_cast<char *>(&varr), sizeof(varr));
|
||||||
SaveCode.write(reinterpret_cast<char *>(&lag), sizeof(lag));
|
SaveCode.write(reinterpret_cast<char *>(&lag), sizeof(lag));
|
||||||
int u = u_count_int + block_mfs;
|
int u = u_count_int + symbol_table.endo_nbr();
|
||||||
SaveCode.write(reinterpret_cast<char *>(&u), sizeof(u));
|
SaveCode.write(reinterpret_cast<char *>(&u), sizeof(u));
|
||||||
u_count_int++;
|
u_count_int++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,8 +242,8 @@ protected:
|
||||||
void writeJsonTemporaryTerms(const temporary_terms_t &tt, temporary_terms_t &temp_term_union, ostream &output, deriv_node_temp_terms_t &tef_terms, const string &concat) const;
|
void writeJsonTemporaryTerms(const temporary_terms_t &tt, temporary_terms_t &temp_term_union, ostream &output, deriv_node_temp_terms_t &tef_terms, const string &concat) const;
|
||||||
//! Compiles temporary terms
|
//! Compiles temporary terms
|
||||||
void compileTemporaryTerms(ostream &code_file, unsigned int &instruction_number, bool dynamic, bool steady_dynamic, temporary_terms_t &temporary_terms_union, const temporary_terms_idxs_t &temporary_terms_idxs) const;
|
void compileTemporaryTerms(ostream &code_file, unsigned int &instruction_number, bool dynamic, bool steady_dynamic, temporary_terms_t &temporary_terms_union, const temporary_terms_idxs_t &temporary_terms_idxs) const;
|
||||||
//! Adds informations for simulation in a binary file
|
//! Adds information for (non-block) bytecode simulation in a separate .bin file
|
||||||
void Write_Inf_To_Bin_File(const string &filename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const;
|
void writeBytecodeBinFile(const string &filename, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
|
||||||
//! Fixes output when there are more than 32 nested parens, Issue #1201
|
//! Fixes output when there are more than 32 nested parens, Issue #1201
|
||||||
void fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_paren_vars, bool &message_printed) const;
|
void fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_paren_vars, bool &message_printed) const;
|
||||||
//! Tests if string contains more than 32 nested parens, Issue #1201
|
//! Tests if string contains more than 32 nested parens, Issue #1201
|
||||||
|
|
|
@ -279,7 +279,7 @@ StaticModel::writeStaticPerBlockMFiles(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeModelEquationsCode(const string &basename) const
|
StaticModel::writeStaticBytecode(const string &basename) const
|
||||||
{
|
{
|
||||||
ostringstream tmp_output;
|
ostringstream tmp_output;
|
||||||
ofstream code_file;
|
ofstream code_file;
|
||||||
|
@ -298,7 +298,7 @@ StaticModel::writeModelEquationsCode(const string &basename) const
|
||||||
int count_u;
|
int count_u;
|
||||||
int u_count_int = 0;
|
int u_count_int = 0;
|
||||||
|
|
||||||
Write_Inf_To_Bin_File(basename + "/model/bytecode/static.bin", u_count_int, file_open, false, symbol_table.endo_nbr());
|
writeBytecodeBinFile(basename + "/model/bytecode/static.bin", u_count_int, file_open, false);
|
||||||
file_open = true;
|
file_open = true;
|
||||||
|
|
||||||
// Compute the union of temporary terms from residuals and 1st derivatives
|
// Compute the union of temporary terms from residuals and 1st derivatives
|
||||||
|
@ -436,7 +436,7 @@ StaticModel::writeModelEquationsCode(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeModelEquationsCode_Block(const string &basename) const
|
StaticModel::writeStaticBlockBytecode(const string &basename) const
|
||||||
{
|
{
|
||||||
struct Uff_l
|
struct Uff_l
|
||||||
{
|
{
|
||||||
|
@ -497,7 +497,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename) const
|
||||||
|| simulation_type == BlockSimulationType::solveBackwardComplete
|
|| simulation_type == BlockSimulationType::solveBackwardComplete
|
||||||
|| simulation_type == BlockSimulationType::solveForwardComplete)
|
|| simulation_type == BlockSimulationType::solveForwardComplete)
|
||||||
{
|
{
|
||||||
Write_Inf_To_Bin_File_Block(basename, block, u_count_int, file_open);
|
writeBlockBytecodeBinFile(basename, block, u_count_int, file_open);
|
||||||
file_open = true;
|
file_open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,8 +839,8 @@ StaticModel::writeModelEquationsCode_Block(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::Write_Inf_To_Bin_File_Block(const string &basename, int num,
|
StaticModel::writeBlockBytecodeBinFile(const string &basename, int num,
|
||||||
int &u_count_int, bool &file_open) const
|
int &u_count_int, bool &file_open) const
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
std::ofstream SaveCode;
|
std::ofstream SaveCode;
|
||||||
|
@ -1718,9 +1718,9 @@ 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 bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, bool julia) const
|
||||||
{
|
{
|
||||||
if (block && bytecode)
|
if (block && bytecode)
|
||||||
writeModelEquationsCode_Block(basename);
|
writeStaticBlockBytecode(basename);
|
||||||
else if (!block && bytecode)
|
else if (!block && bytecode)
|
||||||
writeModelEquationsCode(basename);
|
writeStaticBytecode(basename);
|
||||||
else if (block && !bytecode)
|
else if (block && !bytecode)
|
||||||
{
|
{
|
||||||
writeStaticPerBlockMFiles(basename);
|
writeStaticPerBlockMFiles(basename);
|
||||||
|
|
|
@ -51,11 +51,15 @@ private:
|
||||||
//! Writes the per-block static files of block decomposed model (MATLAB version)
|
//! Writes the per-block static files of block decomposed model (MATLAB version)
|
||||||
void writeStaticPerBlockMFiles(const string &basename) const;
|
void writeStaticPerBlockMFiles(const string &basename) const;
|
||||||
|
|
||||||
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode
|
//! Writes the code of the block-decomposed model in virtual machine bytecode
|
||||||
void writeModelEquationsCode_Block(const string &basename) const;
|
void writeStaticBlockBytecode(const string &basename) const;
|
||||||
|
|
||||||
//! Writes the code of the model in virtual machine bytecode
|
//! Writes the code of the model in virtual machine bytecode
|
||||||
void writeModelEquationsCode(const string &basename) const;
|
void writeStaticBytecode(const string &basename) const;
|
||||||
|
|
||||||
|
//! Adds per-block information for bytecode simulation in a separate .bin file
|
||||||
|
void writeBlockBytecodeBinFile(const string &basename, int num,
|
||||||
|
int &u_count_int, bool &file_open) const;
|
||||||
|
|
||||||
//! Computes jacobian and prepares for equation normalization
|
//! Computes jacobian and prepares for equation normalization
|
||||||
/*! Using values from initval/endval blocks and parameter initializations:
|
/*! Using values from initval/endval blocks and parameter initializations:
|
||||||
|
@ -130,10 +134,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode);
|
void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode);
|
||||||
|
|
||||||
//! Adds informations for simulation in a binary file for a block decomposed model
|
|
||||||
void Write_Inf_To_Bin_File_Block(const string &basename, int num,
|
|
||||||
int &u_count_int, bool &file_open) const;
|
|
||||||
|
|
||||||
//! Writes static model file
|
//! 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;
|
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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue