[prev in list] [next in list] [prev in thread] [next in thread] 

List:       beowulf
Subject:    RE: [Beowulf] memory allocation on x86_64 returning huge addresses
From:       <daniel.kidger () quadrics ! com>
Date:       2005-02-07 18:18:33
Message-ID: 30062B7EA51A9045B9F605FAAC1B4F62812104 () exch01 ! quadrics ! com
[Download RAW message or body]

Roland,

Sigh!  :-)

malloc can return any address it so wishes. 
Don't forget that this is a *virtual* address and so is not bounded by physical \
memory.

A 64-bit O/s with say 8GB RAM can easily have stack addresses in the window 1TB - \
2TB, and heap address even higher (!)

I guess your real problem is that you are porting a (Fortran) program whose authors \
did not understand that it might ever run on a 64-bit machine. Your code does a \
malloc and then tries to store this in an I4 Fortran Integer. This would only be \
gaurunteed to work on a 32-bit architecture like say a Pentium.

So Solutions?
  1. since this is x86_64 simply run your compile your program with a 32-bit compiler
You can still run under under the 64-bit O/S
  2. Mend your application to store addresses in I8 variables, but keep I4 for other \
stuff if you wish.   3. (dubious) only save the lower 32-bits of the addresses in \
your I4 variables and then when being used add the known offset to yield the original \
64-bit address. The offset is likely to be constant for all variables in your \
programs but ymmv.  4. Port your code away from using malloc() altogether. Recently \
(well make that 15 years), Fortran has had its own dynamic memory allocation- the \
allocate() function.  


Hope this helps,
Daniel.

--------------------------------------------------------------
Dr. Dan Kidger, Quadrics Ltd.      daniel.kidger@quadrics.com
One Bridewell St., Bristol, BS1 2AA, UK         0117 915 5505
----------------------- www.quadrics.com --------------------


> -----Original Message-----
> From: Roland Krause [mailto:rokrau@yahoo.com]
> Sent: 07 February 2005 17:02
> To: beowulf@beowulf.org
> Subject: [Beowulf] memory allocation on x86_64 returning huge 
> addresses
> 
> 
> I am trying to dynamically allocate memory for a Fortran-77 code that
> is supposed to run in I4 R4 mode on an x86_64 running SuSE-9.2 with a
> kernel.org 2.6.9 kernel. The machine has 8GB memory and memory has to
> be allocated in one large chunk. 
> 
> The problem is that malloc returns an address that is way beyond
> 8billion which is not what I had expected.
> 
> Does anybody why Linux gives me an address that is outside 
> the physical
> memory range? 
> 
> Does anybody whether there are any kernel parameter that affect this
> behavior? 
> 
> Any pointers to some good reading about the Linux VM would also be
> appreciated. 
> 
> 
> Regards
> Roland
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - now with 250MB free storage. Learn more.
> http://info.mail.yahoo.com/mail_250
> _______________________________________________
> Beowulf mailing list, Beowulf@beowulf.org
> To change your subscription (digest mode or unsubscribe) 
> visit http://www.beowulf.org/mailman/listinfo/beowulf
> 

_______________________________________________
Beowulf mailing list, Beowulf@beowulf.org
To change your subscription (digest mode or unsubscribe) visit \
http://www.beowulf.org/mailman/listinfo/beowulf


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic