Commit Graph

164 Commits (c3fc5b1dd799641fbbedfb420358e3dc6f5a4b87)

Author SHA1 Message Date
Sébastien Villemot c3fc5b1dd7
Enable -Wunused-parameter
As a consequence, add many [[maybe_unused]] attributes for legitimate
cases (mainly in virtual functions).
2022-06-24 17:11:48 +02:00
Sébastien Villemot e0c9a287c5
Remove unused StaticModel::copyHelper() 2022-06-24 15:28:42 +02:00
Sébastien Villemot 9bd2973034
Refactor bytecode output around a new BytecodeWriter class and operator<< overloads 2022-06-24 13:10:04 +02:00
Sébastien Villemot 13dc0a1144
Use operator""s to replace some calls to std::string constructor
By the way, remove other unnecessary calls to that constructor.
2022-06-22 12:47:11 +02:00
Sébastien Villemot 83693e4427
Bytecode: stop using unsigned integers where signed ones avoid unnecessary casts 2022-06-20 17:49:31 +02:00
Sébastien Villemot 5cd5676c8e
Bytecode: directly use several enums inside instruction classes 2022-06-20 15:19:08 +02:00
Sébastien Villemot a85730313c
Split CodeInterpreter.hh into two headers
– a generic one: CommonEnums.hh
– and a bytecode-specific one: Bytecode.hh

By the way, rename global constant “near_zero” into “power_deriv_near_zero”,
for clarity.
2022-06-16 17:53:23 +02:00
Sébastien Villemot 49277dbbf2
StaticModel::getDerivID() now throws an exception when arg is not endo or parameter
Previously it would return -1, which is bad practice.
2022-06-08 14:54:09 +02:00
Sébastien Villemot e3bc2d1b9b
Minor simplification 2022-06-08 14:37:59 +02:00
Sébastien Villemot c94dfb848c
C++20 modernization: use initialization within range-based for loop
In particular, use this feature in many loops which feature a special treatment
for the first iteration, using a boolean variable (replacing iterator
manipulation). By the way, also use std::exchange() to simultaneously test the
value of this variable and update it.
2022-06-07 14:35:59 +02:00
Sébastien Villemot 0b5c88109f
Various simplifications 2022-06-07 14:34:30 +02:00
Sébastien Villemot 171cd65566
Fix bytecode compilation of external function nodes 2022-05-20 11:43:02 +02:00
Sébastien Villemot 591b5e5f9e
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.
2022-05-19 14:49:46 +02:00
Sébastien Villemot 0284b249f5
Remove unused “bytecode” argument in {Static,Dynamic}Model::computingPass() 2022-05-19 14:10:22 +02:00
Sébastien Villemot b42ee40b55
C++20 modernization: use contains() method on containers 2022-05-04 17:37:57 +02:00
Sébastien Villemot 54ca5d9cc0
Improve messages during model normalization
– Indicate whether we are trying to normalize the static or dynamic model
– If failed to normalize the static model, suggest to use the “no_static”
  option
– Remove a superfluous error message
2022-04-19 17:11:13 +02:00
Sébastien Villemot 5e8b478ccf
Add check to ensure that column indices in derivative matrices do not overflow
Closes: #89
2022-01-21 14:31:29 +01:00
Sébastien Villemot a492417a5b
Fix typo 2021-12-10 12:44:42 +01:00
MichelJuillard 561bee0790 add NNZderivatives to JSON + use AbstractVector for Julia functions 2021-10-06 17:45:11 +02:00
Sébastien Villemot 90b1235a64
New utility to check if an expression contains an exogenous (possibly deterministic) 2021-07-20 12:10:58 +02:00
Sébastien Villemot 74ef3457b4
Use secure URL for link to GNU licenses 2021-06-09 17:21:00 +02:00
MichelJuillard 9773bafc5b Julia: write definition of get_power_deriv inside generated static/dynamic files 2021-04-26 10:52:18 +00:00
Sébastien Villemot dca294de3a
Julia: refactor the auxiliary variable/series files
— rename the files with camel case
— encapsulate the functions with modules
— change the signature of function <MODFILE>_dynamic_set_series!, by removing
  the output argument and appending the exclamation mark, since this function
  modifies one of its arguments, and for symmetry with the static version

Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:57:33 +02:00
Sébastien Villemot 4354d8a578
Julia: do not overwrite steady state / auxiliary variables/series files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:56:54 +02:00
Sébastien Villemot 4cfc7a563b
Julia: do not overwrite Static/Dynamic files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-22 18:03:47 +02:00
Sébastien Villemot 81b1d02748
Julia: fix typo in StatsFuns package name
Ref. DynareJulia/Dynare.jl#1
2021-04-22 15:48:25 +02:00
Sébastien Villemot 1f17528383
Julia: update dependencies of Static/Dynamic modules
Ref. DynareJulia/Dynare.jl#1
2021-04-19 17:02:46 +02:00
MichelJuillard c2009e2012
fix set_auxiliary_variables.jl 2021-04-01 17:05:13 +02:00
Sébastien Villemot 89e2daf7c7
C++17 modernization: convert the remaining enums to enum classes 2021-02-01 12:05:06 +01:00
Stéphane Adjemian (Charybdis) b8f7b5846b
Fixed flags for temporaries (julia output). 2020-10-21 16:37:13 +02:00
Sébastien Villemot 4560639eb4
Block decomposition: fix evaluation of recursive variables in solved blocks
Ref. dynare#1726
2020-10-06 18:30:34 +02:00
Sébastien Villemot 5979885714
Block decomposition, chain rule derivation: code improvement 2020-10-02 18:31:55 +02:00
Sébastien Villemot d347a92f14
Drop ExprNode::containsExogenous()
Replace it by calls to ExprNode::collectVariables() at the single place where
it was used.
2020-09-29 18:41:31 +02:00
Sébastien Villemot de65e74c8f
use_dll: add the “restrict” C99 keyword to all pointers to double in computation functions
This greatly facilitates the job of the compiler during the optimization pass,
since we promise that the various pointers do not overlap each other. It may
now be possible to reenable some of the optimization flags that were disabled
without sacrificing compilation time, but this needs more investigation.

For the gory details, see:
https://en.cppreference.com/w/c/language/restrict
https://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
2020-09-03 18:09:06 +02:00
Sébastien Villemot c4351166a9
use_dll: remove nb_row_x from static file, it is useless 2020-06-23 18:19:27 +02:00
Sébastien Villemot db8c5439f7
use_dll: higher order derivatives are now returned as sparse matrices by static/dynamic files
Previously they were returned as 3-column matrices. But this was inconsistent
with the M-file mode.
2020-06-23 17:50:50 +02:00
Sébastien Villemot 95bdfcee8c
use_dll: better safeguards on the number of input/output argument to static/dynamic MEX files 2020-06-23 16:30:21 +02:00
Sébastien Villemot fd13c03401
use_dll: use fmax() and fmin() from C99 to compute max and min operators 2020-06-23 15:59:35 +02:00
Sébastien Villemot ad5e196d30
Block decomposition now compatible with 'use_dll' option 2020-06-23 15:13:04 +02:00
Sébastien Villemot 479c2c029f
Block decomposition: move core of the routine for writing per-block files in separate function
This is a preparatory step to allow use_dll with block decomposition.
2020-06-22 14:18:21 +02:00
Sébastien Villemot 7641c2f7ee
Cosmetics 2020-06-22 11:33:16 +02:00
Sébastien Villemot f098329c74
Block decomposition: static and dynamic files are now pure wrappers around the per-block files 2020-06-19 18:45:42 +02:00
Sébastien Villemot 92aff91066
Block decomposition: in per-block files, construct sparse Jacobians more efficiently
Use 3-column format before calling sparse().

Ensure that the 3-column matrix is constructed in column-major order: data
locality will greatly improve performance once we implement use_dll.
2020-06-19 16:42:32 +02:00
Sébastien Villemot 8496979375
Block decomposition: remove useless “y” output for static/dynamic files of solved blocks 2020-06-16 10:38:16 +02:00
Sébastien Villemot b402e35683
In the driver file, provide mapping between model local variables and indices in the temporary terms vector
The structures are M_.model_local_variables_{dynamic,static}_tt_idxs.

Ref. dynare#1722
2020-06-05 17:12:15 +02:00
Sébastien Villemot 90b9b6a1e4
JSON output: write model local variables in parsed model (modfile.json)
Ref. dynare#1723
2020-06-05 16:10:38 +02:00
Sébastien Villemot 7b11898689
use_dll: merge the two generated C source files into a single one
Also, do various other cosmetic/simplification changes.
2020-05-29 16:12:01 +02:00
Sébastien Villemot faa6666abe
Block decomposition: no longer use global variables for temporary terms in the dynamic M-file
Rather use a single vector as in non-block mode.

By the way, change the order of output arguments in static functions, to be
closer to the dynamic ones.
2020-05-26 16:21:11 +02:00
Sébastien Villemot 04b7d4386d
Block decomposition: no longer use global variables for temporary terms in the static M-file
Rather use a single vector as in non-block mode.
2020-05-25 18:35:36 +02:00
Sébastien Villemot a5abbae46a
use_dll: remove workaround for char16_t type
Should no longer be needed now that the minimal MATLAB version is R2014a.
2020-05-25 16:06:17 +02:00