Subject: re: CCL:f77 comp. on DEC alpha

From: "Chuck (aka chazix), 508-493-1399 (DTN 223-1399) 27-Sep-1996 1545 -0400" <[email-masked]>
Date: Fri, 27 Sep 96 16:36:10 EDT

Greetings,

I'm not usually a follower of this forum, but a colleague asked me if I could
respond to Rochus Schmid's inquiry about building deMon for an Alpha system. 
I will assume that the operating system is Digital UNIX.

I wouldn't say unaligned accesses are common when porting Fortran code to the
Alpha architecture, but they can certainly happen.  I can only make rather
general statements about what sort of code contructs cause unaligned accesses.
By default, the compiler assumes that data are stored at addresses that are a
multiple of the size of the data type - for example, INTEGER*4 data is
expected to be at an address that is a multiple of 4.  If this assumption is
broken, unaligned accesses are likely.  I would say that the easiest way for
this to happen in pure Fortran code is a mismatch between the data types of
the formal and actual parameters of a subroutine call - for example, passing a
REAL*4 argument to a subroutine that expects an REAL*8.

I would not assume that the problem is related to the 64-bit nature of the
Alpha architecture, since standard Fortran constructs don't have any notion of
the size of an address (as far as I can think of at the moment).  However, if
there is any use of POINTER types, or any non-Fortran code involved, there are
more possibilities for introducing unaligned accesses.

The statement that the program stops at the time of the unaligned access
puzzles me.  The operating system will "fix up" unaligned accesses so that
the access completes, albeit at a tremendous cost to performance.  It seems
more likely that the unaligned access is just the first symptom of a problem
that eventually results in the halt.  The program may stop so quickly after
the unaligned access that it appears to be simultaneous, but I would expect an
additional message about what actually stops the program - for example,
"signal segmentation fault".

To determine what's causing an unaligned access, one way is to disable the
operating system "fixup", so that the unaligned access will result in the
program being signaled.  The signal can be caught while running the program
under a debugger, or the program can be simply be run and allowed to dump a
core file upon receiving the signal, after which the core file can be examined
with a debugger.  For example, given a program named a.out:

$ uac p sigbus		! make unaligned access cause SIGBUS (see man 1 uac)
$ a.out			! run program
  (core dumped)
$ dbx a.out core	! use debugger to analyze core dump
dbx> where
$ uac p reset		! reset unaligned accesses to being fixed up

Regards,
Chuck Schneider
Digital High Performance Computing Expertise Center, Maynard, Massachusetts