Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Software pushups

Name: Anonymous 2014-11-24 23:01

Let's exercise together, /prog/!

1) Write a subroutine that accepts an array of unsigned ints and returns 4. It must operate on the array in-place and partition it so that all nonzero values are at the beginning of the array, and all zero values are moved to the end. For example, the input [0, 2, 0, 0, 4, 1, 4, 5] could be changed to [2, 4, 1, 4, 5, 0, 0, 0]. The relative order of the nonzero values is unimportant.

Name: Cudder !MhMRSATORI 2014-11-30 2:44

>>60
That's probably more because it could give AMD the advantage:

http://dis.4chan.org/read/prog/1359605422/52

Look at Agner's timing tables for the true story: http://www.agner.org/optimize/instruction_tables.pdf

K7 - 7uops, 3-4 clocks
P4 - 4+4 uops, 2-4 clocks
K8 - 7uops, 3-4 clocks
Prescott - 4uops, 4 clocks
K10 - 7uops, 3 clocks
Merom - 11uops, 5 clocks
Wolfdale - 11uops, 5 clocks
Nehalem - 6uops, 4 clocks
Sandy Bridge - 7uops, 5 clocks
Bulldozer - 1uop, 1-2 clocks
Ivy Bridge - 7uops, 4-5 clocks
Piledriver - 1uop, 1-2 clocks
Haswell - 7 uops, 5 clocks
Steamroller - 1uop, 1-2 clocks

The story is similar for the low-power microarchitectures:

Atom - 8uops, 8 clocks
Bobcat - 8uops, 4 clocks
Silvermont - 7uops, 10-20 clocks(!)
Jaguar - 8uops, 5 clocks

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List