Skip to contentSkip to conversation

Memory mapped IO vs Port IO

DISCUSSION Andi Kleen 4 participants 8 messages Sep 12, 2003 4 messages not in the archive

lore
Share & tools
lore

Andi Kleen

author
#4 lore raw
In reply to a message not in the archive
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

                             ^^^^^

Something seems to be wrong in your numbers.

Surely the outl in the if () cannot be faster than the pure outl() ?

-Andi

#5 lore raw
Quoted 17 lines · Andi Kleen
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

Quoted 4 lines
                             ^^^^^

Something seems to be wrong in your numbers.

Surely the outl in the if () cannot be faster than the pure outl() ?

Well, they're approximate at best... For outl the branch doesn't seem to matter since it takes forever regardless.

Jesse

author
#6 lore raw
Quoted 18 lines · On Fri, 12 Sep 2003 11:04:29 -0700 [email protected] (Jesse Barnes) wrote:
Quoted 17 lines · Andi Kleen
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

Quoted 7 lines
Quoted 4 lines
                             ^^^^^

Something seems to be wrong in your numbers.

Surely the outl in the if () cannot be faster than the pure outl() ?

Well, they're approximate at best... For outl the branch doesn't seem to matter since it takes forever regardless.

True. Ok for PIO it doesn't matter. I'm surprised the hit is that big for MMIO. What code does the IA64 compiler generate for this? If it was a branch it should have been predicted.

I guess we could use dynamic patching like the alternative() code on i386 does for prefetches etc., but that may be a bit of overkill... Or fix the makefiles that they can easily compile two versions of the driver.

-Andi

#8 lore raw
In reply to Tim Hockin
Quoted 18 lines · Tim Hockin
Quoted 17 lines · Andi Kleen
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

Quoted 6 lines
Quoted 4 lines
                             ^^^^^

Something seems to be wrong in your numbers.

Surely the outl in the if () cannot be faster than the pure outl() ?

Also - a perhaps more useful test is a write followed by a read.

Well, someone else will have to run that test. On Altix, a read() is freakishly expensive, and I'm not really interested in showing everyone how bad it is ;)

Jesse

#7 lore raw
In reply to Andi Kleen
Quoted 17 lines · Andi Kleen
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

Quoted 4 lines
                             ^^^^^

Something seems to be wrong in your numbers.

Surely the outl in the if () cannot be faster than the pure outl() ?

Also - a perhaps more useful test is a write followed by a read.

Signature · 3 lines
Notice that as computers are becoming easier and easier to use,
suddenly there's a big market for "Dummies" books.  Cause and effect,
or merely an ironic juxtaposition of unrelated facts?
author
#9 lore raw
In reply to Jesse Barnes
Quoted 22 lines · On Fri, 12 Sep 2003 11:24:30 -0700 [email protected] (Jesse Barnes) wrote:
Quoted 21 lines · Tim Hockin
Quoted 20 lines · Andi Kleen
Quoted 8 lines · [email protected] (Jesse Barnes) writes:

Ok, Andi asked for benchmarks, so I ran some. Let this should be a lesson on why you shouldn't use port I/O :) I ran these on an SGI Altix w/900 MHz McKinley processors.

Just straight calls to the routines (all of these are based on the average of 100 iterations):
writeq(val, reg) time: 64 cycles
outl(val, reg) time: 2126 cycles

                         ^^^^^
Quoted 6 lines

A simple branch:
if (use_mmio)
writeq(val, reg) time: 132 cycles
else
outl(val, reg) time: 1990 cycles

                             ^^^^^

Something seems to be wrong in your numbers.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Surely the outl in the if () cannot be faster than the pure outl() ?

Also - a perhaps more useful test is a write followed by a read.

Well, someone else will have to run that test. On Altix, a read() is freakishly expensive, and I'm not really interested in showing everyone how bad it is ;)

I guess the read will be very bad everywhere, and the PIO inl even worse.

-Andi

#10 lore raw
In reply to Jesse Barnes
Quoted 5 lines
Quoted 1 line

Also - a perhaps more useful test is a write followed by a read.

Well, someone else will have to run that test. On Altix, a read() is freakishly expensive, and I'm not really interested in showing everyone how bad it is ;)

I find percentile comparisons useful for hiding the embarassement of occasional hardware realities ;-) (ie what's the speed *ratio* between the two types of read).

M.

#11 lore raw
Quoted 9 lines · Martin J. Bligh
Quoted 5 lines
Quoted 1 line

Also - a perhaps more useful test is a write followed by a read.

Well, someone else will have to run that test. On Altix, a read() is freakishly expensive, and I'm not really interested in showing everyone how bad it is ;)

I find percentile comparisons useful for hiding the embarassement of occasional hardware realities ;-) (ie what's the speed *ratio* between the two types of read).

Well, in our case, read() and in() will be pretty close, percentage-wise. The read() in itself is so bad that I think the additional badness of in() will be mostly hidden.

Jesse