Execution Speed of mex64 components in linux

조회 수: 3 (최근 30일)
Jim hofmann
Jim hofmann 2012년 3월 28일
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

채택된 답변

Ken Atwell
Ken Atwell 2012년 3월 29일
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
Jim hofmann
Jim hofmann 2012년 3월 29일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by