From 49a530a7750a287711d87bb7575c4f299e336b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Wed, 5 Oct 2022 16:07:22 +0200 Subject: [PATCH] use_dll: allow more flexible output directory in interface of ModelTree::compileMEX() --- src/DynamicModel.cc | 4 ++-- src/ModelTree.cc | 5 ++--- src/ModelTree.hh | 2 +- src/StaticModel.cc | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 1ef6a674..742defe6 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -1074,7 +1074,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const string &mexext, co output.close(); - compileMEX(basename, "dynamic", mexext, { filename }, matlabroot, dynareroot); + compileMEX("+" + basename, "dynamic", mexext, { filename }, matlabroot, dynareroot); } string @@ -1229,7 +1229,7 @@ DynamicModel::writeDynamicBlockCFile(const string &basename, vector<filesystem:: output.close(); per_block_src_files.push_back(filename); - compileMEX(basename, "dynamic", mexext, per_block_src_files, matlabroot, dynareroot); + compileMEX("+" + basename, "dynamic", mexext, per_block_src_files, matlabroot, dynareroot); } void diff --git a/src/ModelTree.cc b/src/ModelTree.cc index e375c684..59172a84 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1619,7 +1619,7 @@ ModelTree::findGccOnMacos(const string &mexext) #endif void -ModelTree::compileMEX(const string &basename, const string &funcname, const string &mexext, const vector<filesystem::path> &src_files, const filesystem::path &matlabroot, const filesystem::path &dynareroot) const +ModelTree::compileMEX(const filesystem::path &output_dir, const string &funcname, const string &mexext, const vector<filesystem::path> &src_files, const filesystem::path &matlabroot, const filesystem::path &dynareroot) const { const string opt_flags = "-O3 -g0 --param ira-max-conflict-table-size=1 -fno-forward-propagate -fno-gcse -fno-dce -fno-dse -fno-tree-fre -fno-tree-pre -fno-tree-cselim -fno-tree-dse -fno-tree-dce -fno-tree-pta -fno-gcse-after-reload"; @@ -1704,8 +1704,7 @@ ModelTree::compileMEX(const string &basename, const string &funcname, const stri } } - filesystem::path mex_dir{"+" + basename}; - filesystem::path binary{mex_dir / (funcname + "." + mexext)}; + filesystem::path binary{output_dir / (funcname + "." + mexext)}; ostringstream cmd; diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 68887054..bc1e7224 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -490,7 +490,7 @@ private: files, those get compiled in separate threads; this could however require implementing a scheduler, so as to not run more threads than there are logical cores. */ - void compileMEX(const string &basename, const string &funcname, const string &mexext, const vector<filesystem::path> &src_files, const filesystem::path &matlabroot, const filesystem::path &dynareroot) const; + void compileMEX(const filesystem::path &output_dir, const string &funcname, const string &mexext, const vector<filesystem::path> &src_files, const filesystem::path &matlabroot, const filesystem::path &dynareroot) const; public: ModelTree(SymbolTable &symbol_table_arg, diff --git a/src/StaticModel.cc b/src/StaticModel.cc index ba1adfa0..2f02ee82 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -713,7 +713,7 @@ StaticModel::writeStaticCFile(const string &basename, const string &mexext, cons output.close(); - compileMEX(basename, "static", mexext, { filename }, matlabroot, dynareroot); + compileMEX("+" + basename, "static", mexext, { filename }, matlabroot, dynareroot); } void @@ -1105,7 +1105,7 @@ StaticModel::writeStaticBlockCFile(const string &basename, vector<filesystem::pa output.close(); per_block_src_files.push_back(filename); - compileMEX(basename, "static", mexext, per_block_src_files, matlabroot, dynareroot); + compileMEX("+" + basename, "static", mexext, per_block_src_files, matlabroot, dynareroot); } void -- GitLab