cycle count for divide

  • Follow


Suppose I want to divide an integer with another integer,
how many cycles does it take in general on PVI and PIII?
I notice that the output of a divide is usually float, does
that mean the divide is only for floats, meaning those
two operands got converted into float?

How expensive is modulo in terms of cycle count?

Cheers,
Jimmy

0
Reply Jimmy 9/6/2004 8:46:29 AM

Jimmy zhang wrote:

> Suppose I want to divide an integer with another integer,
> how many cycles does it take in general on P4 and PIII?

IA-32 Optimization Reference Manual
Appendix C (IA-32 Instruction Latency and Throughput)
ftp://download.intel.com/design/Pentium4/manuals/24896611.pdf

Signed integer division:
Northwood = 56-70 cycles
Prescott  = 66-80 cycles
Pentium M = undisclosed

I don't have the Pentium III latencies.

> I notice that the output of a divide is usually float, does
> that mean the divide is only for floats, meaning those
> two operands got converted into float?

??

Integer division of a by b produces two integers: q (the quotient)
and r (the remainder) such that a = b*q + r and 0 <= r < b

> How expensive is modulo in terms of cycle count?

Modulo 2^n is a simple bit mask operation. Otherwise, see above.

-- 
Regards, Grumble

0
Reply Grumble 9/6/2004 10:41:26 AM


"Jimmy zhang" <jzhang@ximpleware.com> wrote:

>Suppose I want to divide an integer with another integer,
>how many cycles does it take in general on PVI and PIII?
>...
>How expensive is modulo in terms of cycle count?

The integer division instruction produces two results: a quotient and a
remainder.  The modulo operation is, of course, the remainder of a
division.  So, the answer to your second question is exactly the same as
the answer to your first question.
-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

0
Reply Tim 9/7/2004 4:46:29 AM

if the divisor equals 2^x, where x is an integer, does the cycle count
remains the same?


"Grumble" <a@b.c> wrote in message news:chhfbk$c8$1@news-rocq.inria.fr...
> Jimmy zhang wrote:
>
> > Suppose I want to divide an integer with another integer,
> > how many cycles does it take in general on P4 and PIII?
>
> IA-32 Optimization Reference Manual
> Appendix C (IA-32 Instruction Latency and Throughput)
> ftp://download.intel.com/design/Pentium4/manuals/24896611.pdf
>
> Signed integer division:
> Northwood = 56-70 cycles
> Prescott  = 66-80 cycles
> Pentium M = undisclosed
>
> I don't have the Pentium III latencies.
>
> > I notice that the output of a divide is usually float, does
> > that mean the divide is only for floats, meaning those
> > two operands got converted into float?
>
> ??
>
> Integer division of a by b produces two integers: q (the quotient)
> and r (the remainder) such that a = b*q + r and 0 <= r < b
>
> > How expensive is modulo in terms of cycle count?
>
> Modulo 2^n is a simple bit mask operation. Otherwise, see above.
>
> -- 
> Regards, Grumble
>

0
Reply Jimmy 9/8/2004 8:23:42 AM

Jimmy zhang wrote:

> if the divisor equals 2^x, where x is an integer, does the cycle
> count remain the same?

In that case, you should use SHR instead of IDIV.

0
Reply Grumble 9/8/2004 6:58:08 PM

"Jimmy zhang"  <spamtrap@crayne.org> wrote in message news:<NaV_c.6697$vy.1320@attbi_s52>...
> Suppose I want to divide an integer with another integer,
> how many cycles does it take in general on PVI and PIII?
> I notice that the output of a divide is usually float, does
> that mean the divide is only for floats, meaning those
> two operands got converted into float?
> 
> How expensive is modulo in terms of cycle count?


It will depend on a number of factors. Assuming div reg32, m32 I think
it is 3 uops + 20 from microcode (on a netburst architecture) with
about a 50 cycle latency (if the next instruction is dependent). These
are, by necessity, only aproximate values. Agner.org and intel's
netburst documentation has some better details. Div, however, does not
return a float -- it returns 2 unsigned values (not quite the same
thing).

0
Reply spamtrap 9/17/2004 11:10:04 AM

5 Replies
366 Views

(page loaded in 0.07 seconds)

Similiar Articles:













7/23/2012 7:28:50 PM


Reply: