comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: reading a text file into a string
Date: Thu, 22 Jul 2004 19:49:34 -0500
Date: 2004-07-22T19:49:34-05:00	[thread overview]
Message-ID: <rOWdnYp1K5bk_Z3cRVn-vA@megapath.net> (raw)
In-Reply-To: OrednWv2_cdw3Z3cRVn-uQ@comcast.com

"Robert I. Eachus" <rieachus@comcast.net> wrote in message
news:OrednWv2_cdw3Z3cRVn-uQ@comcast.com...
> Randy Brukardt wrote:
...
> > Similarly, do you know of *any* compiler for *any* language that
supports
> > 256 byte alignment? I don't, at least on Windows.
>
> You are probably correct with regards to Windows.  I do know of
> compilers that do support such alignments, but only for supercomputers.
>   With the rate at which x86 chips are taking over the supercomputer
> market though, I'll have to check.
>
> But the real reason I posted all this is that Ada compilers for x86,
> including x86 Windows SHOULD support this alignment, even if it is
> relatively painful to do so. (Painful in terms of gaps in the stack, or
> doing the extra effort required when allocating space on the heap.)  The
> case of a String buffer when reading files is a perfect case in point.
> If the buffer is 128 (AMD) or 256 (Intel) byte aligned when reading from
> a memory-mapped file, you will reduce the number of cache line misses
> during the execution of the program.  (If the buffer is in a single
> cache line, then that line will stay resident in L1 cache.  If the
> buffer is distributed over two (Intel) or more (AMD) cache lines, the
> lines that are not referenced every line may get paged out.

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.

Indeed, it would make the most sense to allocate such objects from a storage
pool (with enough extra memory to support the alignment); align the
resulting address, and use an address clause to force the object to use that
memory. That would get the performance benefit in the rare case where it
would help without costing anything to implementors or to users of programs
that don't need the alignment.

                             Randy.






  reply	other threads:[~2004-07-23  0:49 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-15 17:27 reading a text file into a string zork
2004-07-15 17:49 ` Marius Amado Alves
2004-07-15 19:57   ` Nick Roberts
2004-07-15 17:59 ` Marius Amado Alves
2004-07-15 19:18   ` Nick Roberts
2004-07-15 19:18 ` Nick Roberts
2004-07-15 20:02   ` Nick Roberts
2004-07-16  1:23 ` Jeffrey Carter
2004-07-16  2:20 ` Steve
2004-07-16  2:26 ` Steve
2004-07-16 16:16   ` Jeffrey Carter
2004-07-16 17:45     ` Nick Roberts
2004-07-16 21:19   ` Randy Brukardt
2004-07-17  2:27     ` Robert I. Eachus
2004-07-17 11:31       ` Mats Weber
2004-07-17 15:52         ` Robert I. Eachus
2004-07-17 22:38           ` Jeffrey Carter
2004-07-18 13:44             ` zork
2004-07-19  8:07       ` Dale Stanbrough
2004-07-19  8:58         ` Martin Dowie
2004-07-21  0:17           ` Robert I. Eachus
2004-07-21 21:39             ` Randy Brukardt
2004-07-22 22:34               ` Robert I. Eachus
2004-07-23  0:49                 ` Randy Brukardt [this message]
2004-07-23 21:56                   ` Nick Roberts
2004-07-24  0:34                     ` tmoran
2004-07-24  1:16                       ` Nick Roberts
2004-07-24  1:42                     ` Randy Brukardt
2004-07-24 15:14                       ` Nick Roberts
2004-07-26 23:48                         ` Randy Brukardt
2004-07-27 12:08                           ` Nick Roberts
2004-07-27 23:24                             ` Robert I. Eachus
2004-07-29  0:55                               ` Randy Brukardt
2004-07-29  0:53                             ` Randy Brukardt
2004-07-29  7:25                               ` Martin Dowie
2004-07-29 20:08                               ` Robert I. Eachus
2004-07-30  0:14                                 ` tmoran
2004-07-24  2:56                   ` Robert I. Eachus
2004-07-19 11:51       ` Ada2005 (was " Peter Hermann
2004-07-19 12:51         ` Dmitry A. Kazakov
2004-07-19 13:01         ` Nick Roberts
2004-07-19 13:35           ` Martin Dowie
2004-07-19 17:22             ` Nick Roberts
2004-07-19 23:50           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox