From: Matt Randolph <mattr@erols.com>
To: gentoo-amd64@lists.gentoo.org
Subject: Re: [gentoo-amd64] x86_64 optimization patches for glibc.
Date: Sat, 23 Jul 2005 18:15:19 -0400 [thread overview]
Message-ID: <42E2C177.6090001@erols.com> (raw)
In-Reply-To: <42E258A7.5080501@telia.com>
Simon Strandman wrote:
> Hi!
>
> Some binary distros like Mandrake and suse patches their glibcs with
> x86_64 optimized strings and an x86_64 optimized libm to improve
> performance.
>
> I tried extracting those patches from an mandrake SRPM and add them to
> the glibc 2.3.5 ebuild. The x86_64 optimized strings patch built and
> worked perfectly and gave a large speedup as you can see below. But I
> couldn't get glibc to build with the libm patch because of unresolved
> symbols (and I'm no programmer so I have no idea how to fix that).
>
> I found a small C program on a suse mailing-list to measure glibc
> memory copy performance:
> http://lists.suse.com/archive/suse-amd64/2005-Mar/0220.html
>
> With the glibc 2.3.5 currently in gentoo I get:
> isidor ~ # ./memcpy 2200 1000 1048576
> Memory to memory copy rate = 1291.600098 MBytes / sec. Block size =
> 1048576.
>
> But with glibc 2.3.5 + amd64 optimized strings I get:
> isidor ~ # ./memcpy 2200 1000 1048576
> Memory to memory copy rate = 2389.321777 MBytes / sec. Block size =
> 1048576.
>
> That's an improvement of over 1000mb/s! Suse 9.3 also gives about
> 2300mb/s out of the box.
>
> How about adding these patches to gentoo? Perhaps in glibc 2.3.5-r1
> before it leaves package.mask? I'll create a bugreport about it if you
> agree!
>
> This .tar.bz2 contains the glibc directory from my overlay with the
> mandrake patches included in files/mdk, but the libm patches are
> commented out in the ebuild.
> http://snigel.no-ip.com/~nxsty/linux/glibc.tar.bz2
>
There is a bug in the original memcpy.c that will cause a segfault if
you don't pass it any parameters. Here is a fixed version. I've left
everything else alone (except for a spelling correction).
// memcpy.c - Measure how fast we can copy memory
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/* timing function */
#define rdtscll(val) do { \
unsigned int a,d; \
asm volatile("rdtsc" : "=a" (a), "=d" (d)); \
(val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
} while(0)
int main(int argc, char *argv[]) {
int cpu_rate, num_loops, block_size, block_size_lwords, i, j;
unsigned char *send_block_p, *rcv_block_p;
unsigned long start_time, end_time;
float rate;
unsigned long *s_p, *r_p;
if (argc != 4) {
fprintf(stderr,
"Usage: %s <cpu clk rate (MHz)> <num. iterations> <copy block
size>\n",
argv[0] );
return 1;
}
cpu_rate = atoi(argv[1]);
num_loops = atoi(argv[2]);
block_size = atoi(argv[3]);
block_size_lwords = block_size / sizeof(unsigned long);
block_size = sizeof(unsigned long) * block_size_lwords;
send_block_p = malloc(block_size);
rcv_block_p = malloc(block_size);
if ((send_block_p == NULL) || (rcv_block_p == NULL)) {
fprintf(stderr, "Malloc failed to allocate block(s) of size %d.\n",
block_size);
}
// start_time = clock();
rdtscll(start_time);
for (i = 0; i < num_loops; i++) {
memcpy(rcv_block_p, send_block_p, block_size);
// s_p = (unsigned long *) send_block_p;
// r_p = (unsigned long *) rcv_block_p;
//
// for (j = 0 ; j < block_size_lwords; j++) {
// *(r_p++) = *(s_p++);
// }
}
// end_time = clock();
rdtscll(end_time);
rate = (float) (block_size) * (float) (num_loops) /
((float) (end_time - start_time)) *
((float) cpu_rate) * 1.0E6 / 1.0E6;
fprintf(stdout,
"Memory to memory copy rate = %f MBytes / sec. Block size = %d.\n",
rate, block_size);
} /* end main() */
--
"Pluralitas non est ponenda sine necessitate" - W. of O.
--
gentoo-amd64@gentoo.org mailing list
next prev parent reply other threads:[~2005-07-23 22:16 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-23 14:48 [gentoo-amd64] x86_64 optimization patches for glibc Simon Strandman
2005-07-23 16:36 ` Allan Wang
2005-07-23 17:08 ` Simon Strandman
2005-07-23 17:30 ` Allan Wang
2005-07-23 18:11 ` Jared Lindsay
2005-07-23 18:19 ` Allan Wang
2005-07-27 10:09 ` netpython
2005-07-27 16:11 ` [gentoo-amd64] " Duncan
2005-07-23 18:44 ` [gentoo-amd64] " Brian Litzinger
2005-07-25 22:24 ` Luke-Jr
2005-07-25 22:38 ` Olivier Crete
2005-07-26 15:40 ` Luke-Jr
2005-07-26 16:50 ` [gentoo-amd64] " Duncan
2005-07-26 17:02 ` Raffaele BELARDI
2005-07-26 17:49 ` Michael Edwards
2005-07-26 18:42 ` [gentoo-amd64] " Duncan
2005-07-27 0:05 ` [gentoo-amd64] " Sami Samhuri
2005-07-27 2:50 ` Matt Randolph
2005-07-26 2:54 ` [gentoo-amd64] " Brian Litzinger
2005-07-23 16:39 ` Sean Johnson
2005-07-23 22:15 ` Matt Randolph [this message]
2005-07-23 22:36 ` Matt Randolph
2005-07-24 1:47 ` Sean Johnson
2005-07-24 3:36 ` Matt Randolph
2005-07-24 5:36 ` Ian McCulloch
2005-07-24 7:42 ` Jared Lindsay
2005-07-24 14:35 ` Simon Strandman
2005-07-24 18:13 ` Jared Lindsay
2005-07-25 20:08 ` Jeremy Huddleston
2005-07-25 21:34 ` Simon Strandman
2005-07-25 22:00 ` Jared Lindsay
2005-07-31 14:24 ` [gentoo-amd64] " Duncan
2005-07-31 14:56 ` Brian Hall
2005-07-31 16:23 ` [gentoo-amd64] " Duncan
2005-07-31 17:42 ` Ben Skeggs
2005-07-31 18:46 ` Jared Lindsay
2005-07-31 18:52 ` Nuitari
2005-08-01 13:51 ` [gentoo-amd64] " Duncan
2005-07-31 19:21 ` [gentoo-amd64] " Simon Strandman
2005-08-01 9:04 ` Jan Jitse Venselaar
2005-08-01 13:45 ` [gentoo-amd64] " Duncan
2005-08-01 17:03 ` Karol Krizka
2005-08-02 10:21 ` [gentoo-amd64] " Duncan
2005-08-02 19:41 ` Matt Randolph
2005-08-02 23:27 ` [gentoo-amd64] hijacked! :) television (was: x86_64 optimization patches for glibc.) Sami Samhuri
2005-08-04 2:28 ` Luke-Jr
2005-08-05 0:28 ` Sami Samhuri
2005-08-05 7:43 ` Arm Suwarnaratana
2005-08-09 10:29 ` [gentoo-amd64] Re: x86_64 optimization patches for glibc Simon Strandman
2005-07-26 17:40 ` [gentoo-amd64] " ardour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42E2C177.6090001@erols.com \
--to=mattr@erols.com \
--cc=gentoo-amd64@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox