Division by Integers Using Multiplication - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Division by Integers Using Multiplication

Description:

Division by Invariant Integers using Multiplication. ... The Whole Thing. Activity 0. Activity 1. Activity 2. Activity 3. Activity 4. Questions? ... – PowerPoint PPT presentation

Number of Views:691
Avg rating:3.0/5.0
Slides: 11
Provided by: ccsc1
Category:

less

Transcript and Presenter's Notes

Title: Division by Integers Using Multiplication


1
Division by Integers Using Multiplication
  • Chuck Pheatt
  • Emporia State University

2
A More Precise Title
  • Division by Invariant Integers using
    Multiplication.
  • Reference Granlund, T. and Montgomery, P.L.
    Proceedings of the ACM SIGPLAN '94 Conference on
    Programming Language Design and Implementation
    (PLDI), pages 61--72, Orlando, Florida, June 1994.

3
Unsigned Integer Division
  • Suppose we want to perform an unsigned integer
    division
  • Where
  • 0 lt d lt 2N, d is the divisor and is invariant
  • 0 n lt 2N, n is the dividend and is variable
  • N is the word size

4
Unsigned Integer Division
  • We would like to calculate 1/d using only
    multiplications and shifts. We will use a
    multiplier of the form
  • That is

5
The Unsigned Algorithm
  • From Granlund and Montgomery, given a divisor d
    and dividend n

6
So.
  • Processors generally have very fast integer
    multiply operations (59 cycles signed, 48
    cycles unsigned).
  • The integer division instruction delivers only
    one bit of quotient per cycle (2247 cycles
    signed, 1741 cycles unsigned).

7
So.
  • The cost for invariant integer division
    (per quotient)
  • 1 multiply (4 cycles)
  • 2 adds/subtracts (2 4 8 cycles)
  • 2 shifts (2 4 8 cycles)
  • 20 cycles total

8
The Activities
  • A CS0 activity that introduces the idea of ones
    and twos complement numeric representation and
    using shift operations to replace multiplication
    and division operations.
  • A CS1 activity that has students perform a
    computer performance assessment utilizing the
    generation of random values.
  • A CS2 activity that has students use inline
    assembly language to improve computer algorithm
    performance.
  • A systems programming (assembly language)
    activity where students will use the approach to
    optimize code.
  • A compiler writing course activity where students
    develop a C/C program to create the code
    necessary to implement the algorithm.

9
The Activities
  • The Whole Thing
  • Activity 0
  • Activity 1
  • Activity 2
  • Activity 3
  • Activity 4

10
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com