Commit Graph

3301 Commits (4348f4d57f83aa8f96c3ec23899c33971e847428)

Author SHA1 Message Date
Sébastien Villemot 762243c705
Julia: drop get_power_deriv function from module
The function is now provided separately by Dynare.jl.
2022-11-02 15:49:56 +01:00
Sébastien Villemot 4ae6df494d
JSON: add dynamic_tmp_nbr and static_tmp_nbr
As a consequence, remove the “tmp_nbr” variable from the Julia modules, since
it is now redundant.
2022-11-02 15:49:56 +01:00
Sébastien Villemot 723fc4139b
Implement new sparse model representation in Julia
Ref. dynare#1859
2022-11-02 15:49:56 +01:00
Sébastien Villemot 0278c8577c
Provisions for new sparse representation of dynamic/static files
The new representation is only supported for MATLAB/Octave, C and Julia output
for the time being. Bytecode and JSON are unsupported.

This commit adds new fields in M_.

This is a preliminary step for dynare#1859.
2022-11-02 15:49:56 +01:00
Sébastien Villemot 30853e7360
Block decomposition: improve debugging information for normalization
– print the information only for the final matching (and not the intermediary
  ones that may have failed);
– print the equation name next to its number.
2022-11-02 15:49:56 +01:00
Sébastien Villemot 627dd92c64
Block decomposition: bugfix with temporary terms when mfs=3
In an “evaluate” block, the LHS of a renormalized equation (such as “log(x)=…”)
could be associated to a temporary term that would then be incorrectly
computed: that temporary term would be evaluated *before* (and not after) the
evaluation of the associated variable (“x” in the example).
2022-10-26 17:33:26 +02:00
Sébastien Villemot e153353365 Merge branch 'reset_check_ahead' into 'master'
Occbin: implement simul_reset_check_ahead_period-option

See merge request Dynare/preprocessor!67
2022-10-24 08:32:33 +00:00
Johannes Pfeifer d5cf07fadd Occbin: implement simul_reset_check_ahead_period-option
Related to dynare@3765ef77 (dynare!2094)
2022-10-24 10:30:45 +02:00
Sébastien Villemot 219c8d2a47
Do not error out in stochastic mode if mfs > 0 but “block” option not passed
In that case, the block-DR routines will not be called.
2022-10-18 17:39:14 +02:00
Sébastien Villemot 5a6e276750
Fix comment 2022-10-18 17:39:14 +02:00
Sébastien Villemot 79c8fe61b1
Fix typo 2022-10-18 17:39:14 +02:00
Sébastien Villemot a31ef6069c
Correctly handle diff operator in equation renormalization
Should have no impact though, since diff nodes are already substituted out at
that point. But it’s better to implement it properly, in case we change the
substitution rules later.

By the way, make the computeSubExprContainingVariable method protected.
2022-10-18 17:39:14 +02:00
Sébastien Villemot 9f96db89ba
use_dll: ensure proper cleanup of thread workers threads in case of early exit (e.g. upon failure) 2022-10-17 14:03:27 +02:00
Sébastien Villemot 781e10c24b
Error out if “use_dll” is specified in Julia mode 2022-10-14 15:40:09 +02:00
Sébastien Villemot fd9902e87b
use_dll: rewrite the parallel compilation engine with a fixed number of threads
The previous system would spawn as many threads as there are object files to be
compiled (which could lead to hundreds of threads for large block-decomposed
models). This could pose a memory usage problem (even when not just waiting,
threads require memory for their own stack).
2022-10-14 15:33:52 +02:00
Sébastien Villemot e801f1a862
Fix typo
[skip ci]
2022-10-11 18:15:11 +02:00
Sébastien Villemot 39051aeb30
Make the hack for MATLAB+Windows directory lock work with any recursive directory structure
This simplifes the treatment of the new sparse representation, which creates
several subdirectories in the “+” package folder.
2022-10-11 17:26:47 +02:00
Sébastien Villemot 93054cf692
Various filesystem refactorings
– DataTree::packageDir() now takes a std::string_view, returns a
  std::filesystem::path, and no longer creates that directory
– DataTree::writeToFileIfModified() now takes a std::filesystem::path as
  argument
– Do not call DataTree::writeToFileIfModified() for generating MATLAB/Octave
  files, since it does not work (the directory inside which the file is written
  has been deleted by the preprocessor just before)
– Consistently use DataTree::packageDir() everywhere (for compatibility with
  planner_objective)
2022-10-11 16:28:17 +02:00
Sébastien Villemot 198ff70bce
Simplify strsplit() using std::string_view
By the way:
– improve the semantics by having a consistent treatment of empty substring
  components (previously, only the last one was ignored)
– move it to DataTree to make it more accessible from elsewhere (even though
  ideally it should be in a “utilities” namespace).
2022-10-11 16:23:11 +02:00
Sébastien Villemot 2fb9aa2a60
Minor simplification using argument dependent lookup (ADL) 2022-10-11 11:31:18 +02:00
Sébastien Villemot 5b400b69f0
Use std::filesystem::path::string() when writing paths to std::cout/std::cerr
Otherwise they will be quoted, which is not desirable, especially under
Windows (backslashes will be duplicated).
2022-10-11 11:31:15 +02:00
Sébastien Villemot e0b2583ff9
Streamline informative messages 2022-10-07 18:04:18 +02:00
Sébastien Villemot 3dd40c6c42
use_dll: split generated C file into smaller files that will be compiled in parallel
By the way, factorize the code between the dynamic and static versions.

Ref. #41
2022-10-07 18:04:18 +02:00
Sébastien Villemot dd66459e5f
use_dll: parallelize compilation of multiple object files within single MEX file
In particular, it implements dependency tracking in the thread scheduler, so
that multiple MEX files can share object files.

Ref. #41
2022-10-07 18:04:17 +02:00
Sébastien Villemot 5cf4729ab0
use_dll: dynamically limit the number of concurrently running GCC processes to the number of available logical processors
Ref. #41
2022-10-07 18:04:17 +02:00
Sébastien Villemot 49a530a775
use_dll: allow more flexible output directory in interface of ModelTree::compileMEX() 2022-10-07 18:04:17 +02:00
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