views:

850

answers:

6

I have some matlab code that will only run on 32 bit windows, but I need atleast 6 gb of ram to run it. In my lab the only machine that has 6gb ram is running 64 bit windows, is there some way to run this code on here? I am thinking of emulating a 32 bit windows and running it on that, will that work?

+5  A: 

Your 32 bit application will only be able to address 4 GB when running as a 32 bit process on Windows 64 bit. In order to address more memory you need a 64 bit application.

Brian Rasmussen
actually on 32bit non-Server Windows you only get about 3.3GB accessible.
fuzzy lollipop
I know, but on 64 bit Windows each user process gets the entire 4 GB addressable space.
Brian Rasmussen
It is this way on 32 bit Server too. The CPU can never give more than 4G of memory to a single process in a `flat address space` memory model(which is what every modern OS uses now)... though you can access up to 16G of memory by the 36 bit paging extensions, a single process can still only access 4G at a time. @Brian, even if it does magically give you 4G(which I don't think is technically possible) there is still no way to trivially access 6G of memory
Earlz
@earlz: Not sure I follow you here. When did magic enter the picture? All I said was that a 32 bit user process is able to address 4 GB on 64 bit Windows. A 64 bit user process can access a lot more.
Brian Rasmussen
I've downvoted this answer. I don't disagree with it, nor with much of the additional commentary. But it's not helpful to the OP. If you use Matlab (I write from experience) you don't do fancy memory management. 32-bit Matlab on 32-bit Windows gets no more than 2GB RAM straight out of the box. Yep, you can flick switches to get up to 3GB RAM as @earlz notes below, but we use Matlab 'cos we don't want to waste our time flicking switches and doing clever memory management, we want to get on and compute stuff.
High Performance Mark
@Mark: I am not talking about 32-bit Windows and neither is the OP. The header says 32 bit Matlab on 64 bit Windows. I am simply stating that a 32 bit process such as Matlab will be able to utilize 4 GB of memory when running on Windows 64 bit. There's no need for any fancy memory management. It is just how Windows 64 bit treats 32 bit applications.
Brian Rasmussen
@High Performance Mark: 32 bit processes, in general, get 4GB when emulated on 64 bit. Without "time wasting switch flickery"
peterchen
A: 

64 bit Windows will run 32 bit Windows programs just fine. But the 32 bit programs won't be able to access 6 Gb or memory, so I'm not sure that help you.

John Knoeller
A: 

I'm pretty sure most versions of 32 bit Windows(as in, everything but Server editions) limit a single process to 2GB by default and to 3GB by changing a setting... though it is technically possible to access 16G of RAM from a Pentium Pro(and higher) CPU in 32 bit mode, I don't think anything but Windows Server takes advantage of it

and for your Matlab program to take advantage of it, you'd have to do some interesting multi-process work to manually page between 3G memory banks

Earlz
64GB actually, with PAE.
Ignacio Vazquez-Abrams
+1  A: 

You cannot access 6GB of RAM from a 32-bit application. This leaves you two options:

Either you optimize your code to use less RAM, or you make your Matlab program 64-bit compatible.

For the first option, the fine folks at stackoverflow can help you.

For the second option: No part of Matlab that I'm aware of is 32-bit only - unless you have a 32-bit Matlab version. However, if you have an active maintenance contract, you can download and install the 64-bit version of Matlab. If your code calls mex-functions that are compiled for 32-bit Windows, you can try and recompile them for 64-bit Windows.

Jonas
Yes you can, just not all at once. CreateFileMapping/MapViewOfFile.
Alex
+5  A: 

Hi

I've recently been engaged in moving several of our large Matlab codes from 32-bit Windows XP to 64-bit Windows XP. Unlike one or two of the other answerers here, I think 6GB is a perfectly reasonable memory requirement these days; the largest desktop we use here has dual quad-core processors and 32GB RAM. Some of my scientist colleagues want more, but then they always want more.

I'd go further and advise against trying to rewrite your application to use less RAM; that would be heading in the wrong direction. It will be cheaper and quicker and generate fewer errors if you port your code to the 64-bit machine. To those who would argue for refactoring to use less RAM I would say At what point in the near future will you face up to the realities of the market and recognise that 64-bit computing is here to stay and that RAM is quite cheap, especially compared to the expense of developers time ?

Forget trying to use 6GB RAM on a 32-bit machine; as others have told you, Matlab and Windows won't do it. But, as others have remarked, Matlab is indifferent to the number of bits, so a pure Matlab code which works on a 32-bit release will work on the 64-bit version of the same release. If you move from an older 32-bit release to a newer 64-bit release you may find some Matlab functions have been retired, but you'd have the same issues moving to the newer 32-bit release anyway.

If you have a code which will only run on 32-bit Windows then I suspect you are using MEX files. These will have to be recompiled for execution on a 64-bit machine. Again, be careful to watch out for functionality which has been retired if you are moving between Matlab releases as you port. The other chief gotcha, in my experience, is false assumptions that you might make about the sizes of certain fundamental data types. Neither the Fortran nor the C standards (no C++ experience to speak of) actually specify the size in bytes of default INTEGER (for Fortran) or int (for C -- I think, not much of a C programmer). Pointer sizes are probably only vaguely specified too. What this means is that you may have to either (a) change a lot of variable declarations in your code or (b) use compiler directives/flags to specify default sizes for INTEGERS, REALS, ints and possibly others. (b) is easier, (a) is probably preferable for future maintainability.

Regards

Mark

High Performance Mark
Jeff Atwood argued much the same on his blog a while ago - http://www.codinghorror.com/blog/archives/001198.html. There *will* come a time where it is better to refactor though, it's just deciding where that tipping point is.
Paolo
@Paolo: For me the tipping point is defined by how fast I can get a repacement machine (approved).
peterchen
"I think 6GB is a perfectly reasonable memory requirement these days". Hear hear. I've used MATLAB on a 128 GB, 16-core machine (for data mining on large scientific datasets).
Martin B
A: 

You can not use 6 GB with 32Bit addresses. A 32 Bit address can only contain values from

0 to 0xffffffff (== 4294967295 == 4GB)

Such addresses are used by and are essential for every 32 Bit program, regardless if you explicitly use pointers or not.

(Although there were/are some very exotic exceptions - but those dont apply here).

RED SOFT ADAIR