Specifying optimization flags in mex
28 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
jh2011
il 3 Gen 2018
Commentato: Walter Roberson
il 23 Apr 2020
I know that -O is implemented by default when I use the mex command
mex file.cpp
However, I have two questions related to that
(1) Is -O the same as -O when compile c++ files with g++ (i.e. when I'm not using mex)
(2) How can I implement -O3 without a makefile?
0 Commenti
Risposta accettata
Walter Roberson
il 3 Gen 2018
"(1) Is -O the same as -O when compile c++ files with g++ (i.e. when I'm not using mex)"
Yes. However, -O for mex is treated as -O2 instead of bare -O
"(2) How can I implement -O3 without a makefile?"
Use
mex -v YourFileName.c
and look through the output for COPTIMFLAGS . Copy the flags there changing -O2 to -O3 and insert that into
mex COPTIMFLAGS="THOSE GO HERE" YourFileName.c
for example,
mex -v COPTIMFLAGS="-O3 -fwrapv -DNDEBUG" tt.c
2 Commenti
Walter Roberson
il 23 Apr 2020
There is a series of functions for adjusting various aspects of the toolchain, and it is plausible that you might be able to use the functions to request a copy of the current toolchain, and modify that, and save it, after which there would be a command to activate it. Or perhaps that only applies to MATLAB Compiler or Coder; I am not sure.
There is no simple command along the lines of
mexconfig optimize -O3 %does not exist
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!