From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a3fe2aac201210c0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 22 Jul 2004 19:48:56 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <40f6bf21@dnews.tpgi.com.au> <40fb8c00$1_1@baen1673807.greenlnk.net> Subject: Re: reading a text file into a string Date: Thu, 22 Jul 2004 19:49:34 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-oMwFmlFw1ltzVhXQ0VdkZq/A+00VFTozZw9EiltlaR6HBpSEcRCXpJt7qZyLPvznYT3hCnGR4N1e7ur!i709/iOgKVti8fDhJRm0jKRxR5LGLU5JX68/NH5aldpiguSevJpQwj4s/g3uNUZwMiV2apxoKx57 X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: g2news1.google.com comp.lang.ada:2354 Date: 2004-07-22T19:49:34-05:00 List-Id: "Robert I. Eachus" 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.