Execution Speed of mex64 components in linux

6 views (last 30 days)
All, I have written a GUI based application in R2011b which was compiled into a standalone application. It runs fine but its slow running under linux.
I have generated several mex64 components that run under the GUI with the gcc 4.2 compiler in linux and the current Microsoft C SDK under windows 7.
Windows 7 Matlab script function #1 27.11 sec function #2 246.9 sec.
Red Hat Matlab script function #1 33.30 sec function #2 661.81 sec
Red Hat Stand-alone app function #1 33.71 sec function #2 653.17 sec
The same code was used on all platforms. Does the gcc compiler generate non-optimized code compared to the Microsoft SDK? The difference in run times for function #2 is 2.5X... Thanks, Jim

Accepted Answer

Ken Atwell
Ken Atwell on 29 Mar 2012
It certainly seems that the Microsoft compiler has the edge in this situation! Can we assume you are controlling for other variables to the extent reasonable? That is, you are running on comparable computers at similar clock frequencies, etc. If function #2 involves a tight inner loop, even a modest differences in optomizations can have a magnified effect.
Make sure you are using (at least) the -O switch to gcc. Within MATLAB, you can use the -v switch to the mex function to confirm it is being used. You can experiment with more aggressive settings via the "CFLAGS" variable. This Stack Overflow question may give you some ideas.
  1 Comment
Jim hofmann
Jim hofmann on 29 Mar 2012
hi Ken, thanks for answering! yes it has tight inner loops. The hardware is relatively similar, both systems are new servers. Mexopts.sh enables -O only in my environment. Trying COPTIMFLAG='-O2' as an override command in mex and that gave me a 22% improvement, trying the -O3 flag and -ffast-math resulted in 24% improvement. The stack overflow article was a big help. I will continue to experiment as well as profile segments of the code to see if there are any major hangups. thanks and best regards! Jim

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!