From 4313640f80476d7b058bf5c3f4d175ef07270004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 18 Apr 2023 17:26:37 +0200 Subject: [PATCH] Bytecode: allow better compiler optimization of the main evaluation function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the __restrict__ GCC extension on double* pointers, to avoid aliasing. NB: the C “restrict” keyword does not exist in C++. --- mex/sources/bytecode/Evaluate.cc | 2 +- mex/sources/bytecode/Evaluate.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index c271006cf..2fb0e8cdc 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -985,7 +985,7 @@ Evaluate::print_expression(const Evaluate::it_code_type &expr_begin, const optio } void -Evaluate::evaluateBlock(int it_, double *y, const double *ya, int y_size, double *x, int nb_row_x, double *params, const double *steady_y, double *u, int Per_u_, double *T, int T_nrows, map &TEF, map, double> &TEFD, map, double> &TEFDD, double *r, double *g1, double *jacob, double *jacob_exo, double *jacob_exo_det, bool evaluate, bool no_derivatives) +Evaluate::evaluateBlock(int it_, double *__restrict__ y, const double *__restrict__ ya, int y_size, double *__restrict__ x, int nb_row_x, double *__restrict__ params, const double *__restrict__ steady_y, double *__restrict__ u, int Per_u_, double *__restrict__ T, int T_nrows, map &TEF, map, double> &TEFD, map, double> &TEFDD, double *__restrict__ r, double *__restrict__ g1, double *__restrict__ jacob, double *__restrict__ jacob_exo, double *__restrict__ jacob_exo_det, bool evaluate, bool no_derivatives) { auto it_code { currentBlockBeginning() }; int var{0}, lag{0}; diff --git a/mex/sources/bytecode/Evaluate.hh b/mex/sources/bytecode/Evaluate.hh index 46ccb0815..09d5accba 100644 --- a/mex/sources/bytecode/Evaluate.hh +++ b/mex/sources/bytecode/Evaluate.hh @@ -77,7 +77,7 @@ private: protected: BasicSymbolTable &symbol_table; - void evaluateBlock(int it_, double *y, const double *ya, int y_size, double *x, int nb_row_x, double *params, const double *steady_y, double *u, int Per_u_, double *T, int T_nrows, map &TEF, map, double> &TEFD, map, double> &TEFDD, double *r, double *g1, double *jacob, double *jacob_exo, double *jacob_exo_det, bool evaluate, bool no_derivatives); + void evaluateBlock(int it_, double *__restrict__ y, const double *__restrict__ ya, int y_size, double *__restrict__ x, int nb_row_x, double *__restrict__ params, const double *__restrict__ steady_y, double *__restrict__ u, int Per_u_, double *__restrict__ T, int T_nrows, map &TEF, map, double> &TEFD, map, double> &TEFDD, double *__restrict__ r, double *__restrict__ g1, double *__restrict__ jacob, double *__restrict__ jacob_exo, double *__restrict__ jacob_exo_det, bool evaluate, bool no_derivatives); bool steady_state;