Subject: patch for amd64 asm string functions
To: None <port-amd64@netbsd.org>
From: Blair Sadewitz <blair.sadewitz@gmail.com>
List: port-amd64
Date: 08/04/2007 18:20:31
------=_Part_91149_4505636.1186266031495
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
I'd like to hear opinions on the following:
I've been using the amd64 string functions
(src/common/lib/libc/arch/x86_64/string/) modified by
<fuyuki@hadaly.org> (see netbsd-bugs in January)
for months now without incident (except when troubleshooting to make
sure that it wasn't a problem). I have an EMT64 processor, and after
rebuilding the tree with -mtune=nocona and applying this patch, the
system is noticeably faster. I have confirmed the results he spoke of
in his emails to netbsd-bugs with his memcpy benchmark (see:
<http://www.hadaly.org/fuyuki/>).
Also, when we move to gcc 4.2, we should probably build the tree with
-mtune=generic, which tunes fairly for both AMD and Intel processors.
Until then--according to what I've read on the GCC lists and such--the
best thing to do is use --mtune=nocona, as the performance hit for AMD
processors is negligable (they do, after all, have to compete, and
that means running code optimized for Intel processors). On the other
hand, EMT64 processors pay a substantial price (up to 20% loss in some
benchmarks I've seen) for -mtune=k8 (from -march=k8, our default). I
don't think there's much of a difference between -march=nocona and
-mtune=nocona anyway, especially now that Intel has cloned AMD's
instruction set more faithfully.
The only thing I changed from the author's original patch is adding an
#ifdef _KERNEL...#endif at lines 62 and 81 of memset.S, as the kernel
doesn't do huge memcpy operations AFAIK, and so using the hints there
has virtually no chance of being productive and a substantial chance
of being counterproductive.
Regards,
--Blair
------=_Part_91149_4505636.1186266031495
Content-Type: application/octet-stream; name=amd64-string.diff
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="amd64-string.diff"
SW5kZXg6IGNvbW1vbi9saWIvbGliYy9hcmNoL3g4Nl82NC9zdHJpbmcvYmNvcHkuUwo9PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09ClJDUyBmaWxlOiAvY3Zzcm9vdC9zcmMvY29tbW9uL2xpYi9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