Re: reading a text file into a string

From: Nick Roberts (nick.roberts_at_acm.org)
Date: 07/23/04


Date: Fri, 23 Jul 2004 22:56:06 +0100

On Thu, 22 Jul 2004 19:49:34 -0500, Randy Brukardt <randy@rrsoftware.com>
wrote:

> ...
> That could only be done at run-time, as you couldn't insure anything
> about the alignment of the stack at compile-time. (That's probably
> why GNAT will support only 4 byte alignment, which is about all you
> can guarentee.) So you're asking to make subprogram linkage more
> expensive, to make heap allocation more expensive, and probably to
> use indirect access to statically allocated objects (in order to align
> the starting address). I don't doubt that there are cases where you
> might gain a tiny bit of performance from doing so, but it seems a
> large burden on all of the users to insist on it.

Randy, this is weird. It is a well established technique for highly
optimising compilers to align things for cache efficiency. Good grief
there are whole books on the subject. Not only do they advocate the
possibility of aligning both basic blocks (code) and data objects on
cache-line boundaries, but they advocate that the compiler do it
automatically wherever possible.

It may be that there aren't any highly optimising Ada compilers
(yet ;-) but Robert is suggesting compilers /should/ support this
kind of alignment, so how can you disagree? Do you think all those
computer scientists have got it terribly wrong?

If you think having big 'gaps' is an efficiency concern, I think the
idea is that you fill in the gaps with smaller objects (or basic
blocks). If you are worried about the fact that all stacks and heaps/
pools must be cache-line aligned (32, 64 bytes?), you have missed the
RAM revolution that has been going on for the last two decades ;-)

My cheapo off-the-back-of-a-lorry PC has 1/2 GiB of RAM.

-- 
Nick Roberts


Relevant Pages

  • Re: So how representative is this experience ?
    ... COBOL is different than the other compilers by defaulting to VAX alignment rules. ... Binary fields that are known not to be aligned can be accessed with multiple instructions that don't generate an alignment fault. ... I have several COBOL examples that appear to be much slower on I64 than Alpha all due to alignment faults. ...
    (comp.os.vms)
  • Re: Very Basic question from Newbie
    ... > There could be alignment issues with COMMON and EQUIVALENCE, ... > traditionally COMMON being the cause of alignment problems. ... there happen to be a lot of compilers that violate the standard ...
    (comp.lang.fortran)
  • Re: So how representative is this experience ?
    ... COBOL is different than the other compilers by defaulting to VAX alignment rules. ... Binary fields that are known not to be aligned can be accessed with multiple instructions that don't generate an alignment fault. ... I have several COBOL examples that appear to be much slower on I64 than Alpha all due to alignment faults. ...
    (comp.os.vms)
  • Re: Pointer hell
    ... Alignment requirements are generally referred to as, ... Some compilers don't bother with this kind of stuff, ... The mis-aligned access causes a trap of some kind, ... because the buffer was obtained from callocand ...
    (comp.lang.c)
  • Re: Microcontroller Project
    ... I'd then suggst you take a look at some more modern compilers perhaps. ... When the stack overwrites the ... registers (memory mapped) all sorts of fun things happen. ... When the stack overflows you don't see any allocation errors. ...
    (sci.electronics.design)