Commit Graph

3375 Commits (faa12910552c82bf5cb92d700bd12817408d22aa)

Author SHA1 Message Date
Sébastien Villemot d9bda244d4
use_dll: refactor MEX compilation so that it happens inside “write” methods 2022-10-07 18:04:17 +02:00
Sébastien Villemot 08a86b67cb
Drop logic for selecting whether to compute derivatives w.r.t. exogenous
We now always compute those derivatives, so no need for an alternate codepath.
2022-10-07 18:04:17 +02:00
Sébastien Villemot 8cac64c1cb
use_dll: fix bug where operator abs() within a .mod file would return an incorrect result
It would compute the *integer* part of the absolute value (calling “abs”
instead of “fabs” from the C source).
2022-10-07 18:04:00 +02:00
Sébastien Villemot 5c33051990
Use std::string_view in a few places where it makes sense 2022-10-04 16:47:16 +02:00
Sébastien Villemot 4c58451d83
Factorize computing pass for block decomposition
Also add “block_decomposed” data member for tracking whether the block
decomposition has been successful.
2022-10-04 16:00:30 +02:00
Sébastien Villemot 6e69eea3cf
Minor tightening of access specifiers 2022-10-04 16:00:30 +02:00
Sébastien Villemot f6053df754
use_dll: compile MEX files in parallel
Currently two threads are used (one for the dynamic MEX, one for the static
MEX). When the sparse representation is implemented, four threads will be used.

Closes: #41
2022-10-04 16:00:30 +02:00
Sébastien Villemot 36fcbf6cfe
Functions that write C files now return the paths to the generated files
This avoids computing those paths two times (the second time when compiling them).
2022-10-04 16:00:30 +02:00
Sébastien Villemot 895a866bb3
Optimization: use move semantics in more places 2022-10-04 16:00:30 +02:00
Sébastien Villemot 6ed033f202
Bugfix: “relative_irf” option passed to “irf_calibration” was also passed to next command 2022-10-04 16:00:30 +02:00
Sébastien Villemot 3d9ac26aa6
Remove all instances of the “map.find(key)->second” pattern
This is unsafe since the find() method can return a past-the-end iterator,
which should be tested for.

Replace most instances by calls to the std::map::at() method (which throws if
the key is unknown), and which is incidentally more readable.
2022-09-27 12:56:16 +02:00
Sébastien Villemot 18037fd29a
Drop code for supporting temporary terms corresponding to model-local variables
Since model-local variables are now substituted out of the model at an early
stage (see cfb41d291c), such temporary terms are
no longer generated.
2022-09-26 17:34:20 +02:00
Sébastien Villemot 64157d9083
Fix bug in ModelTree::writeParamsDerivativesFileHelper()
Elements of params_derivatives could be accessed without them being defined,
thus causing illegal memory read.

Ensure that these elements always exist. By the way, use std::map::at() instead
of std::map::find() to trigger an exception instead of an illegal memory read
in that case.
2022-09-26 17:17:47 +02:00
Sébastien Villemot b403cef871
Put driver output of static block decomposition in a separate function
For symmetry with the dynamic case, and for avoiding a call to “return” in the
middle of StaticModel::writeDriverOutput().
2022-09-21 18:48:35 +02:00
Sébastien Villemot 5b12354dc3
Minor performance improvement in copy constructors/assignments of ModelTree and DynamicModel 2022-09-21 17:37:02 +02:00
Sébastien Villemot 98d4f922ca
Cosmetics 2022-09-20 15:29:19 +02:00
Sébastien Villemot 7f1b4fcc20
Refactor OptionsList class
In particular, use a std::variant to store the values of options. This ensures
that a given option name can have only one value (previously, for a given
option name, it was possible to store several values as long as they were of
different types).
2022-09-20 11:56:43 +02:00
Sébastien Villemot e4449f1c4a
Add comment for special token name for “domain” keyword 2022-09-20 11:56:43 +02:00
Sébastien Villemot 8dcdcf1fd4
Fix check of “domain” option of new estimation prior syntax 2022-09-20 11:56:42 +02:00
Sébastien Villemot 3f674c1af9
Fix bug with “graph_format” option of “identification” and “dynare_sensitivity”
The local value of option was not copied to the top-level “options_” structure,
as it is done for “nograph” and “nodisplay”.
2022-09-20 11:56:42 +02:00
Sébastien Villemot 1088cc4242
Improve informative messages about derivatives and block decomposition
When computing the derivatives or block decomposition of the planner objective,
the epilogue or the original Ramsey model, the preprocessor would talk about
dynamic/static model, which was confusing. It now uses the right terminology.
2022-09-14 17:51:36 +02:00
Sébastien Villemot d67f569035
Always compute block decomposition, even if “block” option was not passed
If block decomposition fails, error out if “block” option was passed, but not
otherwise.

This commit does not modify the generated files.

This is a preliminary step for dynare#1859.
2022-09-13 16:16:00 +02:00
Sébastien Villemot 1aead92cd5
Fix bug in block derivatives w.r.t. exogenous deterministic 2022-09-12 17:38:47 +02:00
Sébastien Villemot 0b5e686c8c
Turn ramsey_FOC_equations_dynamic_model into a local variable instead of a data member 2022-09-09 17:13:21 +02:00
Sébastien Villemot 2fdc8b682e Merge branch 'BGP_space' into 'master'
Add missing whitespace in output of BGP warning

See merge request Dynare/preprocessor!65
2022-09-06 10:11:51 +00:00
Sébastien Villemot 482ec5fb67
macOS: bump to GCC 12 (for compilation and for use_dll) 2022-09-06 11:53:40 +02:00
Johannes Pfeifer da5b36704d Add missing whitespace in output of BGP warning 2022-08-03 10:52:08 +02:00
Sébastien Villemot fc4c9a73c9
Fix comment
[skip ci]
2022-07-27 16:50:08 +02:00
Sébastien Villemot c3cb7ca534
Bytecode: simplify type for storing list of instructions
Incidentally, make BytecodeInstruction an immutable struct, to facilitate
access to opcode in such a list.
2022-07-26 18:26:37 +02:00
Sébastien Villemot 613e0da782
Bytecode: add some comments to FNUMEXPR_
[skip ci]
2022-07-26 14:52:10 +02:00
Sébastien Villemot 21cecee599
Add “fsolve_options” option to “steady” command
Ref. dynare#1856
2022-07-22 13:43:41 +02:00
Sébastien Villemot ad40f1365c
Block decomposition: code factorization 2022-07-21 18:20:35 +02:00
Sébastien Villemot d4c453c422
Block decomposition: (likely) performance improvement in static file in relation to temp terms
Compute temporary terms for derivatives of “evaluate” mode, even though those
derivatives are not computed. This is because the temporary terms may be useful
for subsequent blocks.

By the way, add an explanatory comment for the equivalent code in dynamic file.
2022-07-21 17:31:48 +02:00
Sébastien Villemot a97a41f6c0
Bugfix with temporary terms in block+bytecode
There were actually two distinct bugs, leading to incorrect results in some
corner cases:

– in the “evaluate” mode of the bytecode MEX, the temporary terms of the
  derivatives “evaluate” blocks were not evaluated at runtime; but these
  temporary terms may be needed for residuals of subsequent blocks;

– when the bytecode MEX was only computing residuals of the model (and not 1st
  order derivatives), the temporary terms of the derivatives were not evaluated
  at runtime; but these temporary terms may be needed for residuals of subsequent
  blocks.
2022-07-21 17:22:08 +02:00
Sébastien Villemot 1401c85d6a
Bytecode: drop FCUML instruction
It’s redundant with FBINARY{BinaryOpcode::plus}.
2022-07-20 16:02:24 +02:00
Sébastien Villemot a58109d094
Bytecode: refactor methods for writing .cod and .bin files in the block decomposition case 2022-07-20 16:02:24 +02:00
Sébastien Villemot d598810329
Bytecode: minor simplification using syntax of sizeof operator without parentheses 2022-07-20 14:48:30 +02:00
Sébastien Villemot 50d5b916e2
Remove constructor and accessors for AuxVarInfo
Rather make all data members public and const, and use aggregate-initialization.
2022-07-20 14:48:30 +02:00
Sébastien Villemot f0629555a5
Remove useless constructors (aggregate initialization is enough for those)
By the way, turn those classes into structs since all their members are public.
2022-07-20 14:48:28 +02:00
Sébastien Villemot 83a94aca57
Replace most uses of std::string::compare() by operator==(), for clarity 2022-07-20 11:18:20 +02:00
Sébastien Villemot c0bfc99946
Minor simplification using std::vector::emplace_back() 2022-07-20 11:18:07 +02:00
Sébastien Villemot 435e56369c
Compatibility fixes with GCC 12 2022-07-16 12:46:16 +02:00
Sébastien Villemot 35dc7fcd81
Bytecode: fix treatment of temporary terms (in non-block mode)
The “temporary_terms_union.insert(it)” statement introduced in the previous
commit was in the wrong block.

By the way, replace the “switch” by an “if constexpr”.
2022-07-14 09:17:11 +02:00
Sébastien Villemot ae150d2b1f
Bytecode: refactor routines for creating .cod file in non-block mode 2022-07-13 18:51:01 +02:00
Sébastien Villemot 89debf429a
Factorize code for writing JSON output 2022-07-12 18:04:05 +02:00
Sébastien Villemot 6da24fc763
Fix bug in JSON output for dynamic derivatives w.r.t. parameters
Variable and parameter indices were wrong (offset by 1).
2022-07-12 17:45:00 +02:00
Sébastien Villemot 9e6c01f132
Streamline some function names 2022-07-12 17:04:41 +02:00
Sébastien Villemot a541d23055
Minor simplification 2022-07-12 16:39:17 +02:00
Sébastien Villemot 157c67e04b
New helpers to simplify common operations with derivation IDs 2022-07-12 16:30:45 +02:00
Sébastien Villemot 2013056a2c
Fix bug in JSON output for derivatives w.r.t. parameters
Confusion between a symbol ID and a derivation ID, which could lead to invalid
output or crash.
2022-07-12 16:23:44 +02:00