From: Eric Dumazet <dada1@cosmosbay.com>
To: David Miller <davem@davemloft.net>
Cc: akpm@osdl.org, clameter@sgi.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] SLAB : use a multiply instead of a divide in obj_to_index()
Date: Mon, 04 Dec 2006 23:45:28 +0100 [thread overview]
Message-ID: <4574A508.1090805@cosmosbay.com> (raw)
In-Reply-To: <20061204.135625.48528445.davem@davemloft.net>
David Miller a écrit :
> From: Eric Dumazet <dada1@cosmosbay.com>
> Date: Mon, 04 Dec 2006 22:34:29 +0100
>
>> On a 200 MHz sparcv9 machine, the division takes 64 cycles instead of 1 cycle
>> for a multiply.
>
> For UltraSPARC I and II (which is what this 200mhz guy probably is),
> it's 4 cycle latency for a multiply (32-bit or 64-bit) and 68 cycles
> for a 64-bit divide (32-bit divide is 37 cycles).
I must have Ultra-2 (running Solaris :( )
for (ui = 0 ; ui < 100000000 ; ui++)
val += reciprocal_divide(ui, reciproc);
100000cb0: 83 31 20 00 srl %g4, 0, %g1
100000cb4: 82 48 40 12 mulx %g1, %l2, %g1
100000cb8: 83 30 70 20 srlx %g1, 0x20, %g1
100000cbc: 88 01 20 01 inc %g4
100000cc0: 80 a1 00 05 cmp %g4, %g5
100000cc4: 08 4f ff fb bleu %icc, 100000cb0
100000cc8: b0 06 00 01 add %i0, %g1, %i0
I confirm that this block uses 20 cycles/iteration,
while next one uses 72 cycles/iteration
for (ui = 0 ; ui < 100000000 ; ui++)
val += ui / value;
100000ca8: 83 31 20 00 srl %g4, 0, %g1
100000cac: 82 68 40 11 udivx %g1, %l1, %g1
100000cb0: 88 01 20 01 inc %g4
100000cb4: 80 a1 00 05 cmp %g4, %g5
100000cb8: 08 4f ff fc bleu %icc, 100000ca8
100000cbc: b0 06 00 01 add %i0, %g1, %i0
>
> UltraSPARC-III and IV are worse, 6 cycles for multiply and 40/71
> cycles (32/64-bit) for integer divides.
>
> Niagara is even worse :-) 11 cycle integer multiply and a 72 cycle
> integer divide (regardless of 32-bit or 64-bit).
>
> (more details in gcc/config/sparc/sparc.c:{ultrasparc,ultrasparc3,niagara}_cost).
>
> So this change has tons of merit for sparc64 chips at least :-)
>
> Also, the multiply can parallelize with other operations but it
> seems that integer divide stalls the pipe for most of the duration
> of the calculation. So this makes the divide even worse.
next prev parent reply other threads:[~2006-12-04 22:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-22 21:35 [PATCH] prune_icache_sb Wendy Cheng
2006-11-22 23:36 ` Andrew Morton
2006-11-27 23:52 ` Wendy Cheng
2006-11-28 0:52 ` Andrew Morton
2006-11-28 21:41 ` Wendy Cheng
2006-11-29 0:21 ` Andrew Morton
2006-11-29 6:02 ` Wendy Cheng
2006-11-30 16:05 ` Wendy Cheng
2006-11-30 19:31 ` Nate Diller
2006-12-01 21:23 ` Andrew Morton
2006-12-03 17:49 ` Wendy Cheng
2006-12-03 20:47 ` Andrew Morton
2006-12-04 5:57 ` Wendy Cheng
2006-12-04 6:28 ` Andrew Morton
2006-12-04 16:41 ` [PATCH] SLAB : use a multiply instead of a divide in obj_to_index() Eric Dumazet
2006-12-04 16:55 ` Christoph Lameter
2006-12-04 18:18 ` Eric Dumazet
2006-12-04 19:49 ` Andrew Morton
2006-12-04 19:55 ` Christoph Lameter
2006-12-04 21:34 ` Eric Dumazet
2006-12-04 21:56 ` David Miller
2006-12-04 22:45 ` Eric Dumazet [this message]
2006-12-05 14:42 ` Pavel Machek
2006-12-04 16:51 ` [PATCH] prune_icache_sb Russell Cattelan
2006-12-04 20:46 ` Wendy Cheng
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=4574A508.1090805@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@osdl.org \
--cc=clameter@sgi.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.