Borrar filtros
Borrar filtros

Specifying optimization flags in mex

49 visualizaciones (últimos 30 días)
jh2011
jh2011 el 3 de En. de 2018
Comentada: Walter Roberson el 23 de Abr. de 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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de En. de 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 comentarios
Royi Avital
Royi Avital el 23 de Abr. de 2020
Isn't there a dedicated command for Macros?
Walter Roberson
Walter Roberson el 23 de Abr. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by