Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Why MEX file is slow on my computer ?

Subject: Why MEX file is slow on my computer ?

From: Louis

Date: 7 Dec, 2010 15:17:21

Message: 1 of 8

Hello,

I have implemented and used some mex files in a desktop, Matlab R2010a, Windows XP 32bit, spec: Intel 2 Duo CPU, 3.06 GHz and 4 GB of RAM. Compiled with Visual Studio 10 ultimate. My code spends 3 sec/frame (well i am doing video processing).

I took the same code and put it on my laptop, Matlab R2010b, Windows 7 32bit, spec: Intel 2 Duo CPU, T9400, 2.53 GHz and 3.00 GB. Compiled with Visual Studio 10 express. The same code spends 28 sec/frame :S...

I do understand there are some differences between the two computers but why this x10 slow down ?

When i "profile" the .m file, it shows that the significant difference occurs in processing the mex files.

What do you think the source of problem ?

Thank you in advance,

Louis

Subject: Why MEX file is slow on my computer ?

From: Jan Simon

Date: 7 Dec, 2010 16:22:20

Message: 2 of 8

Dear Louis,

> I have implemented and used some mex files in a desktop, Matlab R2010a, Windows XP 32bit, spec: Intel 2 Duo CPU, 3.06 GHz and 4 GB of RAM. Compiled with Visual Studio 10 ultimate. My code spends 3 sec/frame (well i am doing video processing).
>
> I took the same code and put it on my laptop, Matlab R2010b, Windows 7 32bit, spec: Intel 2 Duo CPU, T9400, 2.53 GHz and 3.00 GB. Compiled with Visual Studio 10 express. The same code spends 28 sec/frame :S...

You want us to ask hour crystal balls. Ok.
What is different:
1. Matlab 2010a -> Matlab 2010b
  I do noit expect that this causes the Mex to slowdown.
2. WinXP -> Win7
  This can cause a slowdown. Do you use the Windows-API to access the hard disk? Do a Virus-scanner examine all the data you are writing? Is the same scanner installed on both computers?
3. 3.06 GHz -> 2.53 GHz
  Slowdown, of course.
4. VS10 ultimate -> VS10 express
  Slowdown e.g. because the Express version cannot OMP. Do you use OMP-parallelization? What about using the Mex compiled with the Ultimate version on the 2nd computer also?!
5. Do the MEx write to the harddisk? 2-5'' Laptop disks can be much slower than 3.5'' disks.
6. Did you try to find out, where the time is lost inside the Mex?

Kind regards, Jan

Subject: Why MEX file is slow on my computer ?

From: Louis

Date: 7 Dec, 2010 16:24:05

Message: 3 of 8

Hello,

I think the problem is with my matlab or computer. When i do "bench" for my laptop and the desktop, i do see that the desktop has a relative speed of around 90 while laptop shows 24 :S

So in general, the matlab running on the laptop is significantly slower than the desktop.

Do you have any idea how i can increase matlab's speed please?

Thanks

Louis

Subject: Why MEX file is slow on my computer ?

From: Steven_Lord

Date: 7 Dec, 2010 18:03:13

Message: 4 of 8



"Louis " <wlouis@ryerson.ca> wrote in message
news:idln35$od5$1@fred.mathworks.com...
> Hello,
>
> I think the problem is with my matlab or computer. When i do "bench" for
> my laptop and the desktop, i do see that the desktop has a relative speed
> of around 90 while laptop shows 24 :S

What about the individual components that make up the BENCH results? Your
laptop probably, I would guess, has a less powerful graphics card than your
desktop machine; if the 2D and 3D graphics timing values are much worse on
the laptop than on the desktop, but the computational components (LU, FFT,
ODE, and SPARSE) are about the same, then the graphics section of the code
would be the bottleneck.

> So in general, the matlab running on the laptop is significantly slower
> than the desktop.

That's a very broad statement that you have the information to narrow down.

> Do you have any idea how i can increase matlab's speed please?

This is another very broad question -- figure out _what specific piece_ is
slow and then the group may be able to help.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Why MEX file is slow on my computer ?

From: Louis

Date: 7 Dec, 2010 18:23:07

Message: 5 of 8

Thank you Jan and Steven. I do understand that my question was very broad, but I am so sorry as I couldn’t distill my information.

Steven: everything in the laptop's bench is around 10-20 folds slower than the desktop:(

For example:
                  LU FFT ODE Sparse 2-D 3-D
Desptop: 0.07297 0.098262 0.09769 0.21522 0.3826 0.30208
Laptop: 0.2147 0.2782 0.4162 0.7327 1.5501 0.9872


Also, my laptop suppose to be something powerful i.e. Windows 7 index has
processor 6.1
memory 5.5
grpahics 6.3
gaming graphics 6.3
primary hard disk 5.3


I remember that i have once played with the visual memory (before formatting) and its relative speed reached to 80's; however, now, even when i change the visual memory nothing happens.

I am sorry for just giving such vague information, but i can't figure out what is causing the problem.

Thank you again

I look forward to to your input

Subject: Why MEX file is slow on my computer ?

From: Louis

Date: 7 Dec, 2010 18:28:05

Message: 6 of 8

Dear Jan,
Thanks for the information. You draw my attention to several things such as the anti virus, and hard disk speed; i will check them and see if i can figure out something.

Thanks

Louis

Subject: Why MEX file is slow on my computer ?

From: Jan Simon

Date: 7 Dec, 2010 20:01:05

Message: 7 of 8

Dear Louis,

> Steven: everything in the laptop's bench is around 10-20 folds slower than the desktop:(
> LU FFT ODE Sparse 2-D 3-D
> Desptop: 0.07297 0.098262 0.09769 0.21522 0.3826 0.30208
> Laptop: 0.2147 0.2782 0.4162 0.7327 1.5501 0.9872

Hmm. 0.07 to 0.21? this does not look like 10-20 folds slower. I have the impression, that your laptop is 3 to 4 times slower. So this is a speedup of factor 5 just by posting in this newsgroup :-)

The memory access on laptops can be much slower due to energy saving RAM.

My personal advice: Stop digging in the intestines of the laptop. Just be happy that the desktop is surprisingly fast!
It will be more efficient to spend the time for improving your program. An SSE version of the Mex file can save 50% processing time. Squeezing the RAM timings from 3-3-3 to 3-6-3 (or what ever) will usually need more time for debugging than it will save.

Kind regards, Jan

Subject: Why MEX file is slow on my computer ?

From: Louis

Date: 7 Dec, 2010 20:10:23

Message: 8 of 8

Thank you again Jan...
You are correct Sir, i will just stick to the desktop in the time being.

Regards,

Louis

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us