tags:

views:

89

answers:

2

To increase the timeliness of my programs matlab, I got Windows 7 (64bit) and 64bit Matlab. and I've installed on a partition of the hard disk. Unfortunately, I was shocked to see that the execution time of the program is longer with 64bit Matlab. I do not know what's the problem. knowing that I have a core 2 Quad processor and 3GB of RAM.

+2  A: 

Matlab has a built-in profiler, which is a tool that tells you how many times each function is called and how much time it takes to execute. You should use the profiler to find out where the bottle-neck is, i. e. what parts of your program take the most time.

If you do this on both the 32-bit and the 64-bit platforms, you may find out why the 64-bit version is slower.

Dima
I run the same script on both platforms and I get the following execution time: 32 bit: 5 min; 64 bit: 8 min
Is your script reading or writing files to disk? Is it drawing plots? What datatypes is it using (e. g. double, int32, int64)? All of these can contribute to the discrepancy you see. You have to profile, to see where most of the time is spent.
Dima
Since I use exactly the same script .m for both platforms. I think that regardless of the content, Matlab 64bit should be faster.
@bzak - why? 64 bit doesn't necessarily make things faster. It's main purpose is to let you address more memory - there is little advantage on a machine with 3GB of RAM. I wouldn't expect it to be so much slower but I have seen some 64 bit programs run slower. As Dima says - run the profiler...
thrope
@bzak: sorry, but you are absolutely wrong. Many factors influence performance. For example, if your program spends most of its time reading or writing files to disk, wither or not you have a 64-bit CPU may not matter.
Dima
+4  A: 

In general, 64-bit does not make code faster. It just lets you access more memory. Your code will only speed up if it was memory constrained in a 32-bit process. In Matlab, this would usually cause Out Of Memory errors, not slowdowns. And since you only have 3 GB, you probably weren't hitting the 32-bit limit of 4 GB. So you probably shouldn't expect a speedup. A slowdown is surprising, though.

Are you using object-oriented Matlab, especially the old (pre-MCOS) style? There is a known bug in 64-bit Matlab on Windows that increases the overhead of method dispatch. OO code will run slower in 64-bit Matlab than 32-bit Matlab, with the slowdown increasing with the density of method calls. In my codebase (heavily OO), it's about a 2x slowdown. That's about the magnitude you're seeing.

See http://stackoverflow.com/questions/1693429/matlab-oop-is-it-slow-or-am-i-doing-something-wrong/1745686#1745686. (It's discussed tangentially there.)

You can still run 32-bit Matlab on 64-bit Windows. (Though it's not officially supported.) This arrangement does not suffer from the method dispatch slowdown, plus it gets 4 GB of virtual memory instead of the 2 GB it would under a 32-bit OS. (Probably only useful if you have >=4GB RAM.) If the 32-bit does run faster on the exact same machine, you should report it as a bug to MathWorks; the more users that mention it, the more likely it is to get fixed.

Andrew Janke

related questions