Question about compiling mex files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about compiling mex files

José Luis García Pallero
Hello:

Which is the best way to tell the mex function to compile using
OpenMP? I have a mex function for Matlab and I can compile it for
Octave without problems using

mex -O3 myfunc.c

If I use

mex -O3 -fopenmp myfunc.c

I obtain no errors nor warnings and the mex function is generated, but
the code not runs in parallel as I can check using the htop utility.

How is the correct way to use OpenMP in mex files in Octave?

Thanks

--
*****************************************
José Luis García Pallero
[hidden email]
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************

Reply | Threaded
Open this post in threaded view
|

Re: Question about compiling mex files

siko1056
On Wed, Jul 18, 2018 at 9:35 PM José Luis García Pallero <[hidden email]> wrote:
Hello:

Which is the best way to tell the mex function to compile using
OpenMP? I have a mex function for Matlab and I can compile it for
Octave without problems using

mex -O3 myfunc.c

If I use

mex -O3 -fopenmp myfunc.c

I obtain no errors nor warnings and the mex function is generated, but
the code not runs in parallel as I can check using the htop utility.

How is the correct way to use OpenMP in mex files in Octave?

Thanks

--
*****************************************
José Luis García Pallero
[hidden email]
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************


The tsa package by Alois Schloegl seems to make use of OpenMP. You can take a look at his Makefile [1] to see what he did.  Somehow "-lgomp" is linked, but I don't know the impact of it.  Additionally, if you run

   mex -v

you can get verbose information of what is done by Octave.

HTH,
Kai