Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subject: xlf and Cray pointers



The solution that Craig pointed out solves the problem. The code allocates a huge integer array by

piq = malloc(size)

and for xlf the size has to be passed by value:

piq = malloc(%val(size))

There's another problem with xlf when using certain BLAS functions, more specifically CDOTC, CDOTU, ZDOTC, and ZDOTU. The solution is here:

http://developer.apple.com/hardware/ve/errata.html#fortran_conventions

I simple user the wrapper that is given on the homepage, works very well!

Thanks for your help!

Till


I'm trying to compile and run a Fortran 77 code that uses Cray pointers.
I tested it on Solaris, Linux with Portland and Intel compilers, and
SGI3k. Compiling on my Mac OS X using IBM's xlf works, but I get a
segmentation fault:

Program received signal EXC_BAD_ACCESS, Could not access memory.
0x000266d4 in ordinstep (space=541912) at ordinstep.f:18
18 stfu(i) = cstep0(rlcar(1,rlend(i-1)+1)) * rlins(i)
(gdb)

The arrays that are accessed here have their storrage assigned through
cray pointers. I'm ware of the fact that the xlf is doing byte pointer
arithmetic instead of word arithmetic, but the code does not rely any
specific type of pointer arithmetic.



Can you show us the storage assignment and/or memory allocation lines of
code?

One thing to be aware of with XLF is how you call certain functions. For
instance, if you use malloc, you need to call it as malloc(%val(n)) instead
of the usual malloc(n) many people are accustomed to. XLF passes malloc,
and many other functions, directly to C. Therefore, arguments need to be
passed as values, not address. Other FORTRAN compilers may have wrappers
that take care of this for you, but not XLF.

Here's what the XLF manual gives for an example:

MEMBLK = MALLOC(1024) ! Wrong, passes the address of the constant

MEMBLK = MALLOC(N) ! Wrong, passes the address of the variable

MEMBLK = MALLOC(%VAL(1024)) ! Right, passes the value 1024

MEMBLK = MALLOC(%VAL(N)) ! Right, passes the value of the variable

This is the most often cause of memory allocation and addressing problems I
see with people new to XLF. In fact, it stops some porting efforts dead in
their tracks! So be aware of this, and any other similarly-affected
functions. It should all be documented in the XLF manuals.

Another example is calling the time() function -- it needs to be called as
time(%val(0)) or else you will get bus errors. However, if you call time_()
it works fine -- this function has a wrapper that takes care of the
address/value issue.

Craig


--
---------------------------------
Till Burkert
Dep. of Physics
Uppsala Universitet
http://www.fysik.uu.se/~theomag
---------------------------------
_______________________________________________
fortran-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/fortran-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Subject: xlf and Cray pointers (From: Craig Hunter <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.