PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Porting from 32-bit to 64-bit

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Forum Administrator



Joined: 09 Jul 2004
Posts: 61
Location: Lake Oswego, OR

PostPosted: Fri Jul 16, 2004 1:34 pm    Post subject: Porting from 32-bit to 64-bit Reply with quote

I need to port my Fortran and C programs from 32-bits to 64-bits. For those of you that have done this before, any recommendation on what I need to watch out for? Any problems you encountered? Is there a particular methodology I should follow?
Back to top
View user's profile
ElmoSizorbil



Joined: 28 Jul 2004
Posts: 6

PostPosted: Fri Jul 30, 2004 1:12 pm    Post subject: 32 to 64 porting Reply with quote

I've done a lot of this. The first thing to remember is that int *, long* char * and the like are now
64-bit pointers, not 32 bits. "long" is now sizeof(long) == 8. To keep things straight
I define a macro called LONG64 that makes 64 bit (long long for gcc and intel) ints
wherever it is used. (microsoft used __long64 :-)

The next major problem with 32-64 conversions is using casts.
an int* pointer casted to a long * (LONG64 *) pointer can reference a non-8 byte
boundary. This leads to mayhem in the CPU. some boxes will shift for you, some won't.

Lots of system calls have 64 bit variants (fstat64, lseek64, fadvise64_64, timers...)
better use the correct one or you will be limited to 2GB of file/address space.
Be explicit in your integer variable sizes.

One word of caution... when defining a struct, put all your pointers together,
ints together, longs together...

struct foo {
char *bogus;
int * bogus2;
int *anotherone;
}

if you have

struct bad {
int a;
long b;
int c;
long d;
}

and try to walk the pointer to *bad down to each variable, you will find the compiler
MAY have inserted padding for you, and in strange places, or even re-ordered elements
within the struct! if you have to order struct elements, put explicit padding in them.

or, get an alpha running osf1, it has a porting assistant :-) :-)

Elmo
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group