-1

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.

bzak
  • 563
  • 1
  • 8
  • 21
  • 2
    what kind of program is it, what toolbox, is it hdd intensive.... not a lot of information here to formulate a decent answer. – rubenvb Aug 25 '10 at 13:42
  • I run the same script on both platforms and I get the following execution time: 32 bit: 5min; 64 bit: 8min – bzak Aug 25 '10 at 15:07

2 Answers2

4

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 Is MATLAB OOP slow or am I doing something wrong?. (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.

Community
  • 1
  • 1
Andrew Janke
  • 23,508
  • 5
  • 56
  • 85
2

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
  • 38,860
  • 14
  • 75
  • 115
  • I run the same script on both platforms and I get the following execution time: 32 bit: 5 min; 64 bit: 8 min – bzak Aug 25 '10 at 15:06
  • 3
    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 Aug 25 '10 at 15:09
  • Since I use exactly the same script .m for both platforms. I think that regardless of the content, Matlab 64bit should be faster. – bzak Aug 25 '10 at 15:15
  • 3
    @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... – robince Aug 25 '10 at 15:19
  • 3
    @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 Aug 25 '10 at 15:23