Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.6
  • 5.x
  • 6.x
  • aux_vars_fix
  • julia
  • llvm-15
  • master
  • python-codegen
  • rework_pac
  • uop
  • julia-6.2.0
  • julia-6.3.0
  • julia-6.4.0
  • julia-7.0.0
14 results

Target

Select target project
  • normann/preprocessor
  • Dynare/preprocessor
  • FerhatMihoubi/preprocessor
  • MichelJuillard/preprocessor
  • sebastien/preprocessor
  • lnsongxf/preprocessor
  • albop/preprocessor
  • DoraK/preprocessor
  • amg/preprocessor
  • wmutschl/preprocessor
  • JohannesPfeifer/preprocessor
11 results
Select Git revision
  • 4.6
  • 5.x
  • aux_vars_fix
  • dynare_lite
  • julia
  • master
  • pylib
  • rework_pac
  • uop
  • wasm
  • created_preprocessor_repo
  • julia-6.2.0
12 results
Show changes

Commits on Source 209

109 additional commits have been omitted to prevent performance issues.
Showing
with 6136 additions and 4339 deletions
...@@ -11,8 +11,12 @@ BreakInheritanceList: AfterColon ...@@ -11,8 +11,12 @@ BreakInheritanceList: AfterColon
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DeriveLineEnding: false DeriveLineEnding: false
IndentPPDirectives: AfterHash IndentPPDirectives: AfterHash
InsertNewlineAtEOF: true
PackConstructorInitializers: NextLine
PPIndentWidth: 1 PPIndentWidth: 1
PointerAlignment: Left PointerAlignment: Left
# RemoveParentheses: ReturnStatement
# RemoveSemicolon: true
SpaceAfterTemplateKeyword: false SpaceAfterTemplateKeyword: false
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeCpp11BracedList: true SpaceBeforeCpp11BracedList: true
# TODO: add the following check families:
# - bugprone-*
# - cppcoreguidelines-
# NB: as of clang-tidy 16, we get several false positives inside boost, notably this one:
# https://github.com/llvm/llvm-project/issues/40486
Checks: 'performance-*,modernize-*,-modernize-use-trailing-return-type,-clang-diagnostic-unqualified-std-cast-call'
variables: variables:
TERM: linux TERM: linux
MINGW32_BOOST_VERSION: 1.81.0-7 MINGW64_BOOST_VERSION: 1.88.0-2
MINGW64_BOOST_VERSION: 1.81.0-7
WGET_OPTIONS: '--no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error' WGET_OPTIONS: '--no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error'
# To ensure that "false && true" fails, see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25394#note_412609647 # To ensure that "false && true" fails, see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25394#note_412609647
FF_ENABLE_BASH_EXIT_CODE_CHECK: 'true' FF_ENABLE_BASH_EXIT_CODE_CHECK: 'true'
...@@ -9,7 +8,7 @@ variables: ...@@ -9,7 +8,7 @@ variables:
build_linux_x86_64: build_linux_x86_64:
stage: build stage: build
script: script:
- meson setup -D buildtype=release build - meson setup --buildtype=release -Db_lto=true build
- meson compile -C build -v - meson compile -C build -v
artifacts: artifacts:
paths: paths:
...@@ -18,7 +17,7 @@ build_linux_x86_64: ...@@ -18,7 +17,7 @@ build_linux_x86_64:
build_linux_arm64: build_linux_arm64:
stage: build stage: build
script: script:
- meson setup -D buildtype=release --cross-file scripts/linux-arm64-cross.ini build - meson setup --buildtype=release -Db_lto=true --cross-file scripts/linux-arm64-cross.ini build
- meson compile -C build -v - meson compile -C build -v
artifacts: artifacts:
paths: paths:
...@@ -32,7 +31,7 @@ build_windows_x86_64: ...@@ -32,7 +31,7 @@ build_windows_x86_64:
- mkdir -p deps - mkdir -p deps
- tar xf tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst --directory deps - tar xf tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst --directory deps
- echo -e "[properties]\nboost_root = '$(pwd)/deps/mingw64/'" > boost.ini - echo -e "[properties]\nboost_root = '$(pwd)/deps/mingw64/'" > boost.ini
- meson setup -D buildtype=release --cross-file scripts/windows-cross.ini --cross-file boost.ini build - meson setup --buildtype=release -Db_lto=true --cross-file scripts/windows-cross.ini --cross-file boost.ini build
- meson compile -C build -v - meson compile -C build -v
cache: cache:
# This cache is shared between all branches, to save space # This cache is shared between all branches, to save space
...@@ -48,7 +47,7 @@ build_macos_x86_64: ...@@ -48,7 +47,7 @@ build_macos_x86_64:
tags: tags:
- macOS - macOS
script: script:
- arch -x86_64 meson setup -D buildtype=release --native-file scripts/homebrew-native-x86_64.ini build - arch -x86_64 meson setup --buildtype=release -Db_lto=true --native-file scripts/homebrew-native-x86_64.ini build
- arch -x86_64 meson compile -C build -v - arch -x86_64 meson compile -C build -v
artifacts: artifacts:
paths: paths:
...@@ -60,8 +59,28 @@ build_macos_arm64: ...@@ -60,8 +59,28 @@ build_macos_arm64:
- macOS - macOS
script: script:
- export PATH="/opt/homebrew/bin:$PATH" - export PATH="/opt/homebrew/bin:$PATH"
- arch -arm64 meson setup -D buildtype=release --native-file scripts/homebrew-native-arm64.ini build - arch -arm64 meson setup --buildtype=release -Db_lto=true --native-file scripts/homebrew-native-arm64.ini build
- arch -arm64 meson compile -C build -v - arch -arm64 meson compile -C build -v
artifacts: artifacts:
paths: paths:
- build/src/dynare-preprocessor - build/src/dynare-preprocessor
test_clang_format:
stage: test
script:
- meson setup build-clang-format
- ninja -C build-clang-format clang-format-check
needs: []
test_clang_tidy:
stage: test
script:
# Hack needed for meson < 1.6.0 which only looks for unversioned clang-tidy
- mkdir -p ~/.local/bin && ln -s /usr/bin/clang-tidy-19 ~/.local/bin/clang-tidy
- export PATH="$HOME/.local/bin:$PATH"
- meson setup build-clang-tidy
# Generate Flex and Bison files
- meson compile -C build-clang-tidy
- ninja -C build-clang-tidy clang-tidy
needs: []
when: manual
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
\pgfdeclareimage[height=0.8cm]{logo}{dlogo} \pgfdeclareimage[height=0.8cm]{logo}{dlogo}
\institute[Dynare Team]{\pgfuseimage{logo}} \institute[Dynare Team]{\pgfuseimage{logo}}
\date{23 May 2023} \date{31 May 2024}
\AtBeginSection[] \AtBeginSection[]
{ {
...@@ -156,9 +156,9 @@ ...@@ -156,9 +156,9 @@
\item comparison operators: \texttt{< > <= >= == !=} \item comparison operators: \texttt{< > <= >= == !=}
\item logical operators: \verb+&& || !+ \item logical operators: \verb+&& || !+
\item range with unit increment: \texttt{1:4} is equivalent to \item range with unit increment: \texttt{1:4} is equivalent to
real array \texttt{[1, 2, 3, 4]}. (NB: \texttt{[1:4]} is equivalent to an real array \texttt{[1, 2, 3, 4]} \\ (NB: \texttt{[1:4]} is equivalent to an
array containing an array of reals, \textit{i.e.} \texttt{[[1, 2, 3, 4]]}) array containing an array of reals, \textit{i.e.} \texttt{[[1, 2, 3, 4]]})
\item range with user-defined increment: \texttt{4:-1.1:-1} is equivalent to real array \texttt{[4, 2.9, 1.8, 0.7, -0.4]}. \item range with user-defined increment: \\ \texttt{4:-1.1:-1} is equivalent to real array \texttt{[4, 2.9, 1.8, 0.7, -0.4]}
\end{itemize} \end{itemize}
\end{block} \end{block}
...@@ -314,7 +314,7 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}. ...@@ -314,7 +314,7 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}.
\end{frame} \end{frame}
\begin{frame}[fragile=singleslide] \begin{frame}[fragile=singleslide]
\frametitle{Defining macro-variables} \frametitle{Defining macro-variables (1/2)}
The value of a macro-variable can be defined with the \verb+@#define+ The value of a macro-variable can be defined with the \verb+@#define+
directive. directive.
...@@ -335,9 +335,31 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}. ...@@ -335,9 +335,31 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}.
@#define t = ("US" in w) // Equals true @#define t = ("US" in w) // Equals true
\end{verbatim} \end{verbatim}
\end{block} \end{block}
NB: You can define macro variables on the Dynare command line by using the \texttt{-D} option
\end{frame} \end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Defining macro-variables (2/2)}
Macro variables can also be defined on the Dynare command line by using the
\texttt{-D} option, for easily switching between different flavours of a model.
\begin{block}{Example 1}
\begin{verbatim}
dynare myfile.mod -Dx=5
\end{verbatim}
The macro-variable \texttt{x} will be equal to \texttt{5} when running \texttt{myfile.mod}.
\end{block}
\begin{block}{Example 2}
Use single quotes around the \texttt{-D} option when there are spaces or
special characters in the variable definition.
\begin{verbatim}
dynare myfile.mod '-DA=[ i in [1,2,3] when i > 1 ]'
\end{verbatim}
The macro-variable \texttt{A} will be equal to \texttt{[2,3]} when running \texttt{myfile.mod}.
\end{block}
\end{frame}
\begin{frame}[fragile=singleslide] \begin{frame}[fragile=singleslide]
\frametitle{Expression substitution} \frametitle{Expression substitution}
\framesubtitle{Dummy example} \framesubtitle{Dummy example}
...@@ -611,7 +633,7 @@ end; ...@@ -611,7 +633,7 @@ end;
\begin{frame} \begin{frame}
\frametitle{Macro-related command line options} \frametitle{Macro-related command line options}
\begin{itemize} \begin{itemize}
\item \texttt{savemacro}: Useful for debugging or learning purposes, saves the output of the macro processor. If your \texttt{.mod} file is called \texttt{file.mod}, the output is saved to \texttt{file-macroexp.mod}. \item \texttt{savemacro}: Useful for debugging or learning purposes, saves the output of the macro processor. If your \texttt{.mod} file is called \texttt{file.mod}, the output is saved to \texttt{file\_macroexp.mod}.
\item NB: \texttt{savemacro=filename} allows a user-defined file name \item NB: \texttt{savemacro=filename} allows a user-defined file name
\item \texttt{linemacro}: In the output of \texttt{savemacro}, print line numbers where the macro directives were placed. \item \texttt{linemacro}: In the output of \texttt{savemacro}, print line numbers where the macro directives were placed.
\item \texttt{onlymacro}: Stops processing after the macro processing step. \item \texttt{onlymacro}: Stops processing after the macro processing step.
...@@ -866,7 +888,7 @@ rhos = [ 0.8, 0.9, 1]; ...@@ -866,7 +888,7 @@ rhos = [ 0.8, 0.9, 1];
\ccbysa \ccbysa
\column{0.71\textwidth} \column{0.71\textwidth}
\tiny \tiny
Copyright © 2008-2023 Dynare Team \\ Copyright © 2008-2024 Dynare Team \\
License: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative License: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative
Commons Attribution-ShareAlike 4.0} Commons Attribution-ShareAlike 4.0}
\end{columns} \end{columns}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# It is not used when building Dynare as a whole. # It is not used when building Dynare as a whole.
project('dynare-preprocessor', 'cpp', project('dynare-preprocessor', 'cpp',
version : '6-unstable', version : '7-unstable',
# NB: update C++ standard in .clang-format whenever the following is modified # NB: update C++ standard in .clang-format whenever the following is modified
default_options : [ 'cpp_std=gnu++20', 'warning_level=2' ], default_options : [ 'cpp_std=gnu++20', 'warning_level=2' ],
meson_version : '>=0.64.0') meson_version : '>=0.64.0')
......
# Meson native file for compiling under Homebrew / arm64 # Meson native file for compiling under Homebrew / arm64
[binaries] [binaries]
cpp = '/opt/homebrew/bin/g++-13' cpp = '/opt/homebrew/bin/g++-15'
flex = '/opt/homebrew/opt/flex/bin/flex' flex = '/opt/homebrew/opt/flex/bin/flex'
bison = '/opt/homebrew/opt/bison/bin/bison' bison = '/opt/homebrew/opt/bison/bin/bison'
......
# Meson native file for compiling under Homebrew / x86-64 # Meson native file for compiling under Homebrew / x86-64
[binaries] [binaries]
cpp = '/usr/local/bin/g++-13' cpp = '/usr/local/bin/g++-15'
flex = '/usr/local/opt/flex/bin/flex' flex = '/usr/local/opt/flex/bin/flex'
bison = '/usr/local/opt/bison/bin/bison' bison = '/usr/local/opt/bison/bin/bison'
......
# Meson cross file for creating a WebAssembly version of the preprocessor.
#
# Requires emscripten to be installed.
# Was successfully tested with emscripten 3.1.69 installed through emsdk
# tool, as described on: https://emscripten.org/docs/getting_started/downloads.html
# Don’t forget to source script snippet in current shell before running meson.
#
# Compilation creates a .wasm and .js wrapper under <builddir>/src/
#
# Can be run locally with node.js using:
# node dynare-preprocessor.js file.mod
# NB: a version of node.js is shipped with emscripten (under the node/
# subdirectory), but another version should also work.
[binaries]
cpp = 'em++'
[host_machine]
system = 'emscripten'
# Could be changed to wasm64 if 4GB memory constraint is hit
# Some background: https://v8.dev/blog/4gb-wasm-memory
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'
[built-in options]
# Never do a debug build, because otherwise the lack of optimisations can
# overflow the memory capacities.
buildtype = 'release'
# The -fexceptions flag (for both compilation and linking) is needed for an
# unknown reason (C++ compilers are supposed to always add exception support).
# The -Wno-unqualified-std-cast-call flag removes many warnings about “move”
# not being qualified with “std::” namespace.
# The -fexperimental-library flag is needed to get std::jthread support (it was
# supposed to no longer be necessary for LLVM 20, but for some reason we still
# need it).
cpp_args = [ '-fexceptions', '-Wno-unqualified-std-cast-call', '-fexperimental-library' ]
# NODERAWFS=1 is needed for accessing the local filesystem
cpp_link_args = [ '-s', 'NODERAWFS=1', '-fexceptions' ]
[properties]
# It’s necessary to use a different copy of Boost than the one under
# /usr/include, because otherwise GCC headers confuse Clang
boost_root = '/tmp/boost_1_86_0'
/* /*
* Copyright © 2022-2023 Dynare Team * Copyright © 2022-2024 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -17,14 +17,17 @@ ...@@ -17,14 +17,17 @@
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <iostream>
#include <ios>
#include <cstdlib>
#include <algorithm> #include <algorithm>
#include <cstdlib>
#include <ios>
#include <iostream>
#include "Bytecode.hh" #include "Bytecode.hh"
BytecodeWriter::BytecodeWriter(const filesystem::path &filename) namespace Bytecode
{
Writer::Writer(const filesystem::path& filename)
{ {
open(filename, ios::out | ios::binary); open(filename, ios::out | ios::binary);
if (!is_open()) if (!is_open())
...@@ -35,17 +38,16 @@ BytecodeWriter::BytecodeWriter(const filesystem::path &filename) ...@@ -35,17 +38,16 @@ BytecodeWriter::BytecodeWriter(const filesystem::path &filename)
} }
template<> template<>
BytecodeWriter & Writer&
operator<<(BytecodeWriter &code_file, const FCALL_ &instr) operator<<(Writer& code_file, const FCALL& instr)
{ {
code_file.instructions_positions.push_back(code_file.tellp()); code_file.instructions_positions.push_back(code_file.tellp());
auto write_member = [&code_file](const auto &member) auto write_member = [&code_file](const auto& member) {
{
code_file.write(reinterpret_cast<const char*>(&member), sizeof member); code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
}; };
write_member(instr.op_code); write_member(instr.tag);
write_member(instr.nb_output_arguments); write_member(instr.nb_output_arguments);
write_member(instr.nb_input_arguments); write_member(instr.nb_input_arguments);
write_member(instr.indx); write_member(instr.indx);
...@@ -66,23 +68,22 @@ operator<<(BytecodeWriter &code_file, const FCALL_ &instr) ...@@ -66,23 +68,22 @@ operator<<(BytecodeWriter &code_file, const FCALL_ &instr)
} }
template<> template<>
BytecodeWriter & Writer&
operator<<(BytecodeWriter &code_file, const FBEGINBLOCK_ &instr) operator<<(Writer& code_file, const FBEGINBLOCK& instr)
{ {
code_file.instructions_positions.push_back(code_file.tellp()); code_file.instructions_positions.push_back(code_file.tellp());
auto write_member = [&code_file](const auto &member) auto write_member = [&code_file](const auto& member) {
{
code_file.write(reinterpret_cast<const char*>(&member), sizeof member); code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
}; };
write_member(instr.op_code); write_member(instr.tag);
write_member(instr.size); write_member(instr.size);
write_member(instr.type); write_member(instr.type);
for (int i = 0; i < instr.size; i++) for (int i = 0; i < instr.size; i++)
{ {
write_member(instr.variable[i]); write_member(instr.variables[i]);
write_member(instr.equation[i]); write_member(instr.equations[i]);
} }
if (instr.type == BlockSimulationType::solveTwoBoundariesSimple if (instr.type == BlockSimulationType::solveTwoBoundariesSimple
|| instr.type == BlockSimulationType::solveTwoBoundariesComplete || instr.type == BlockSimulationType::solveTwoBoundariesComplete
...@@ -96,8 +97,10 @@ operator<<(BytecodeWriter &code_file, const FBEGINBLOCK_ &instr) ...@@ -96,8 +97,10 @@ operator<<(BytecodeWriter &code_file, const FBEGINBLOCK_ &instr)
write_member(instr.det_exo_size); write_member(instr.det_exo_size);
write_member(instr.exo_size); write_member(instr.exo_size);
for_each_n(instr.det_exogenous.begin(), instr.det_exo_size, write_member); ranges::for_each_n(instr.det_exogenous.begin(), instr.det_exo_size, write_member);
for_each_n(instr.exogenous.begin(), instr.exo_size, write_member); ranges::for_each_n(instr.exogenous.begin(), instr.exo_size, write_member);
return code_file; return code_file;
} }
}
This diff is collapsed.
/* /*
* Copyright © 2007-2022 Dynare Team * Copyright © 2007-2024 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -17,24 +17,30 @@ ...@@ -17,24 +17,30 @@
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef _COMMON_ENUMS_HH #ifndef COMMON_ENUMS_HH
#define _COMMON_ENUMS_HH #define COMMON_ENUMS_HH
//! Enumeration of possible symbol types //! Enumeration of possible symbol types
/*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup command */ /*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup
* command */
enum class SymbolType enum class SymbolType
{ {
endogenous = 0, //!< Endogenous endogenous = 0, // Endogenous (non-heterogeneous)
exogenous = 1, //!< Exogenous exogenous = 1, // Exogenous (non-heterogeneous)
exogenousDet = 2, //!< Exogenous deterministic exogenousDet = 2, // Exogenous deterministic (non-heterogeneous)
parameter = 4, //!< Parameter parameter = 4, // Parameter (non-heterogeneous)
modelLocalVariable = 10, //!< Local variable whose scope is model (pound expression) heterogeneousEndogenous = 5, // Endogenous that is heterogeneous across some dimension
modFileLocalVariable = 11, //!< Local variable whose scope is mod file (model excluded) heterogeneousExogenous = 6, // Exogenous that is heterogeneous across some dimension
externalFunction = 12, //!< External (user-defined) function heterogeneousParameter = 7, // Parameter that is heterogeneous across some dimension
trend = 13, //!< Trend variable modelLocalVariable = 10, // Local variable whose scope is model (pound expression)
statementDeclaredVariable = 14, //!< Local variable assigned within a Statement (see subsample statement for example) modFileLocalVariable = 11, // Local variable whose scope is mod file (model excluded)
externalFunction = 12, // External (user-defined) function
trend = 13, // Trend variable
statementDeclaredVariable
= 14, //!< Local variable assigned within a Statement (see subsample statement for example)
logTrend = 15, //!< Log-trend variable logTrend = 15, //!< Log-trend variable
unusedEndogenous = 16, //!< Type to mark unused endogenous variables when `nostrict` option is passed unusedEndogenous
= 16, //!< Type to mark unused endogenous variables when `nostrict` option is passed
// Value 17 is unused for the time being (but could be reused) // Value 17 is unused for the time being (but could be reused)
...@@ -42,6 +48,13 @@ enum class SymbolType ...@@ -42,6 +48,13 @@ enum class SymbolType
excludedVariable = 19 //!< Variable excluded via model_remove/var_remove/include_eqs/exclude_eqs excludedVariable = 19 //!< Variable excluded via model_remove/var_remove/include_eqs/exclude_eqs
}; };
constexpr bool
isHeterogeneous(SymbolType type)
{
return type == SymbolType::heterogeneousEndogenous || type == SymbolType::heterogeneousExogenous
|| type == SymbolType::heterogeneousParameter;
}
enum class UnaryOpcode enum class UnaryOpcode
{ {
uminus, uminus,
...@@ -66,12 +79,14 @@ enum class UnaryOpcode ...@@ -66,12 +79,14 @@ enum class UnaryOpcode
sign, sign,
steadyState, steadyState,
steadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter steadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
steadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter steadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a
// parameter
expectation, expectation,
erf, erf,
erfc, erfc,
diff, diff,
adl adl,
sum
}; };
enum class BinaryOpcode enum class BinaryOpcode
...@@ -119,8 +134,10 @@ enum class PriorDistributions ...@@ -119,8 +134,10 @@ enum class PriorDistributions
enum class EquationType enum class EquationType
{ {
evaluate, //!< Simple evaluation, normalized variable on left-hand side (written as such by the user) evaluate, //!< Simple evaluation, normalized variable on left-hand side (written as such by the
evaluateRenormalized, //!< Simple evaluation, normalized variable on left-hand side (normalization computed by the preprocessor) //!< user)
evaluateRenormalized, //!< Simple evaluation, normalized variable on left-hand side (normalization
//!< computed by the preprocessor)
solve //!< No simple evaluation of the equation, it has to be solved solve //!< No simple evaluation of the equation, it has to be solved
}; };
...@@ -133,7 +150,8 @@ enum class BlockSimulationType ...@@ -133,7 +150,8 @@ enum class BlockSimulationType
solveTwoBoundariesSimple, //!< Block of one equation, Newton solver needed, forward and backward solveTwoBoundariesSimple, //!< Block of one equation, Newton solver needed, forward and backward
solveForwardComplete, //!< Block of several equations, Newton solver needed, forward solveForwardComplete, //!< Block of several equations, Newton solver needed, forward
solveBackwardComplete, //!< Block of several equations, Newton solver needed, backward solveBackwardComplete, //!< Block of several equations, Newton solver needed, backward
solveTwoBoundariesComplete //!< Block of several equations, Newton solver needed, forward and backwar solveTwoBoundariesComplete //!< Block of several equations, Newton solver needed, forward and
//!< backwar
}; };
enum class PacTargetKind enum class PacTargetKind
...@@ -144,4 +162,4 @@ enum class PacTargetKind ...@@ -144,4 +162,4 @@ enum class PacTargetKind
dd dd
}; };
#endif // _COMMON_ENUMS_HH #endif
This diff is collapsed.
This diff is collapsed.
...@@ -17,57 +17,49 @@ ...@@ -17,57 +17,49 @@
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef _CONFIG_FILE_HH #ifndef CONFIGURATION_HH
#define _CONFIG_FILE_HH #define CONFIGURATION_HH
#include <filesystem>
#include <map> #include <map>
#include <vector> #include <vector>
#include <filesystem>
#include "WarningConsolidation.hh" #include "WarningConsolidation.hh"
using namespace std; using namespace std;
using member_nodes_t = map<string, double>; /* The abstract representation of the configuration.
Merges information from the command-line and from the configuration file. */
class Hook class Configuration
{ {
public: public:
explicit Hook(string global_init_file_arg); Configuration(bool parallel_arg, bool parallel_test_arg, bool parallel_follower_open_mode_arg,
bool parallel_use_psexec_arg, string cluster_name);
private: private:
map<string, string> hooks; using member_nodes_t = map<string, double>;
public:
map<string, string>
get_hooks() const
{
return hooks;
};
};
class Path class Path
{ {
public: public:
explicit Path(vector<string> includepath_arg); explicit Path(vector<string> includepath_arg);
private: [[nodiscard]] map<string, vector<string>>
map<string, vector<string>> paths;
public:
map<string, vector<string>>
get_paths() const get_paths() const
{ {
return paths; return paths;
}; }
private:
map<string, vector<string>> paths;
}; };
class FollowerNode struct FollowerNode
{ {
friend class ConfigFile; FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg,
public: string userName_arg, string password_arg, string remoteDrive_arg,
FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string userName_arg, string remoteDirectory_arg, string programPath_arg, string programConfig_arg,
string password_arg, string remoteDrive_arg, string remoteDirectory_arg, string matlabOctavePath_arg, bool singleCompThread_arg,
string programPath_arg, string programConfig_arg, string matlabOctavePath_arg, bool singleCompThread_arg,
int numberOfThreadsPerJob_arg, string operatingSystem_arg); int numberOfThreadsPerJob_arg, string operatingSystem_arg);
protected:
const string computerName, port; const string computerName, port;
int minCpuNbr, maxCpuNbr; int minCpuNbr, maxCpuNbr;
const string userName, password; const string userName, password;
...@@ -78,55 +70,51 @@ protected: ...@@ -78,55 +70,51 @@ protected:
const string operatingSystem; const string operatingSystem;
}; };
class Cluster struct Cluster
{ {
friend class ConfigFile;
public:
explicit Cluster(member_nodes_t member_nodes_arg); explicit Cluster(member_nodes_t member_nodes_arg);
protected:
member_nodes_t member_nodes; member_nodes_t member_nodes;
}; };
//! The abstract representation of a "config" file
class ConfigFile
{
public:
ConfigFile(bool parallel_arg, bool parallel_test_arg, bool parallel_follower_open_mode_arg,
bool parallel_use_psexec_arg, string cluster_name);
private:
const bool parallel, parallel_test, parallel_follower_open_mode, parallel_use_psexec; const bool parallel, parallel_test, parallel_follower_open_mode, parallel_use_psexec;
const string cluster_name; const string cluster_name;
string firstClusterName; string firstClusterName;
//! Hooks //! Hooks
vector<Hook> hooks; string global_init_file;
//! Paths //! Paths
vector<Path> paths; vector<Path> paths;
//! Cluster Table //! Cluster Table
map<string, Cluster> clusters; map<string, Cluster> clusters;
//! Node Map //! Node Map
map<string, FollowerNode> follower_nodes; map<string, FollowerNode> follower_nodes;
//! Add Hooks
void addHooksConfFileElement(string global_init_file);
//! Add Paths //! Add Paths
void addPathsConfFileElement(vector<string> includepath); void addPathsConfFileElement(vector<string> includepath);
//! Add a FollowerNode or a Cluster object //! Add a FollowerNode or a Cluster object
void addParallelConfFileElement(bool inNode, bool inCluster, const member_nodes_t &member_nodes, const string &name, void addParallelConfFileElement(bool inNode, bool inCluster, const member_nodes_t& member_nodes,
const string &computerName, const string &port, int minCpuNbr, int maxCpuNbr, const string& name, const string& computerName,
const string &userName, const string &password, const string &remoteDrive, const string& port, int minCpuNbr, int maxCpuNbr,
const string &remoteDirectory, const string &programPath, const string &programConfig, const string& userName, const string& password,
const string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob, const string& remoteDrive, const string& remoteDirectory,
const string &operatingSystem); const string& programPath, const string& programConfig,
const string& matlabOctavePath, bool singleCompThread,
int numberOfThreadsPerJob, const string& operatingSystem);
/* Given a filename (e.g. dynare.ini), looks for it in the configuration directory:
– if under Linux or macOS, look into the “dynare” subdirectory of the XDG
configuration directories (following the default values and the precedence order specified in
the XDG specification)
– if under Windows, look into %APPDATA%\dynare\
The returned path will be empty if the file is not found. */
[[nodiscard]] static filesystem::path findConfigFile(const string& filename);
public: public:
//! Parse config file //! Parse config file
void getConfigFileInfo(const filesystem::path &parallel_config_file); void getConfigFileInfo(const filesystem::path& conffile_option, WarningConsolidation& warnings);
//! Check Pass //! Check Pass
void checkPass(WarningConsolidation& warnings) const; void checkPass(WarningConsolidation& warnings) const;
//! Check Pass //! Check Pass
void transformPass(); void transformPass();
//! Get Path Info //! Get Path Info
vector<filesystem::path> getIncludePaths() const; [[nodiscard]] vector<filesystem::path> getIncludePaths() const;
//! Write any hooks //! Write any hooks
void writeHooks(ostream& output) const; void writeHooks(ostream& output) const;
//! Create options_.parallel structure, write options //! Create options_.parallel structure, write options
...@@ -135,4 +123,4 @@ public: ...@@ -135,4 +123,4 @@ public:
void writeEndParallel(ostream& output) const; void writeEndParallel(ostream& output) const;
}; };
#endif // ! CONFIG_FILE_HH #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.