View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

porting to 64-bit

Tom Duvall wrote on Jul 14, 2010

I did succeed in getting a simple task that generates large images to compile and run to generate images of 4 GB. So, then I tried to compile a large package with about 105 tasks and got a number of errors. After fixing the ones that I could figure out, I'm left with a bunch of errors that look like:

libpkg.a(l_to_theta.o): In function `tltota_':
/home/duvall/cedpub1_iraf/travelt/l_to_theta.x:48: relocation truncated to fit: R_X86_64_32 against symbol `mem_' defined in *ABS* section in /tmp/T_x_travelt.e.s9Owzb

After looking at the 'Porting Guide' and studying the code, I'm not sure what is going on. The task in question is reasonably short (90 lines) and so I append it at the end of this message. It's also available at http://sun.stanford.edu/~duvall/Data/l_to_theta.x.
Help!
Thanks.
Tom

# L_TO_THETA: Convert a zonal mode picture (l,t) to real space (t,theta)
# by generating the Legendre polynomials at equal increments of theta.

include <imhdr.h>

procedure t_l_to_theta()
char inname[SZ_FNAME] # Input file name.
char outname[SZ_FNAME] # Output file name.
real dtheta # Increment in colatitude.
real degrees_per_radian# Conversion constant.
int ntheta # Number of output points in theta.
pointer im_in # To input image.
pointer im_out # To output image.
int lmax # Maximum degree.
pointer pl # To array of Legendre polynomials.
int line # Index to input line.
pointer inline # To input line data.
pointer outline # To output line data.
int itheta # Index to theta

real clgetr() # Cl get parameter, real.
int clgeti() # Cl get parameter, int.
pointer immap() # Image open.
pointer imgl2r() # Image get line real.
pointer impl2r() # Image put line real.
real adotr() # Dot product of two vectors, real.
begin
# Cl input.
call clgstr ("input", inname, SZ_FNAME)
call clgstr
# Setup Legendre polynomial image.
im_in = immap (inname, READ_ONLY, 0)
lmax = IM_LEN(im_in,1) - 1
call malloc (pl, (lmax+1)*ntheta, TY_REAL)
call plgen (Memr[pl], lmax+1, ntheta, dtheta)

# Setup output image.
im_out = immap (outname, NEW_COPY, im_in)
IM_LEN(im_out,1) = ntheta

# Do the calculation.
for (line=1; line<=IM_LEN(im_in,2); line=line+1)
{ inline = imgl2r (im_in, line)
outline = impl2r (im_out, line)
for (itheta=0; itheta<ntheta; itheta=itheta+1)
Memr[outline+itheta] = adotr (Memr[inline],
Memr[pl+itheta*(lmax+1)], lmax+1)
}

# Clean up.
call imunmap (im_in)
call imunmap (im_out)
call mfree (pl, TY_REAL)
end
# *********************************************************
procedure plgen (ar, nl, ntheta, dtheta)
int nl # Number of degrees (lmax+1)
int ntheta # Number of colatitude values.
real ar[nl,ntheta] # Output array of coefficients.
real dtheta # Colatitude increment (radians)

int lmax # Maximum degree.
int itheta # Index in the theta direction
real ctheta # Cos(current theta).
real pl_minus_1 # Value of pl in previous iteration.
real pl # Current value of pl.
int l # Index for degree.
begin
lmax = nl - 1

for (itheta=1; itheta<=ntheta; itheta=itheta+1)
{ ctheta = cos (dtheta * (itheta-1))
pl_minus_1 = 1
pl = ctheta
ar[1,itheta] = pl_minus_1
ar[2,itheta] = pl
for (l=1; l<=lmax-1; l=l+1)
{ ar[l+2,itheta] = ((2*l+1)*ctheta*pl - l*pl_minus_1) / (l+1)
pl_minus_1 = pl
pl = ar[l+2,itheta]
ar[l+2,itheta] = ar[l+2,itheta] * sqrt ((2.*l+3)/2)
}
ar[1,itheta] = ar[1,itheta] * sqrt (1/2.)
ar[2,itheta] = ar[2,itheta] * sqrt (3/2.)
}
end

Mike Fitzpatrick wrote on Jul 14, 2010

Hi Tom,

The message was reported a few times before and seems to be somewhat related to the use of AMD machines and/or certain versions of GCC (specificall 4.2 or newer). We don't have a wide variety of 64-bit machines here so I haven't been able to fully test how to build in the most cross-platform manner. In any event....

This appears to be a compiler optimizer bug of some kind, but I haven't tracked down specifically what's getting screwed up or where. In any case, all you should need to do is edit the hlib$mkpkg.inc file and add a "-x" flag to the XFLAGS definition for the linux64 arch, i.e.


  :
$else $ifeq (MACH, linux64) then
$set    XFLAGS          = "-x -c -w -/g -/m64"  # default XC compile flags
   :


If you still see the problem after this let me know (don't forget to remove the existing binaries in the package!).

Cheers,
-Mike

Tom Duvall wrote on Jul 14, 2010

Mike,
Thanks, that fixed the problem. I'm now able to get an executable. Now to test 105 tasks!
Tom

Last post on Jul 14, 2010