News for hackers. Stuff that matters.
Re:The Pentium 4 and the G4e: An Architectural Comparison (2... by duskwuff on Monday September 01, 2014 @06:51PM (#8255001)
For what it's worth, while Intel did win the architecture wars here, the "deep and narrow" pipeline being described here died out with Netburst. The Core microarchitecture that replaced it (which is the predecessor of today's Intel CPUs) used a much more "wide and shallow" pipeline, and benefited greatly from it.
Re:The Pentium 4 and the G4e: An Architectural Comparison (2... by userbinator on Monday September 01, 2014 @07:27PM (#8255090)
Indeed, the P4 was a very odd CPU to program and optimise for - in some ways, it's the "most RISC-like" microarchitecture Intel has attempted. It was far more sensitive to things like instruction alignment and branch prediction than its successors and predecessors, and likely in the pursuit of higher clock frequencies, some instructions (e.g. shifts/rotates) were made several times slower. This meant near-optimal code sequences for the P6 family and often before that would perform horribly on the P4, and vice-versa. It could beat the PIII in "straight-line" execution of simple integer instructions with no branches, but the PIII was faster (even at a lower clock frequency) with more complex and branch-heavy instructions. It's probably the only x86 where a significant speed advantage can be obtained by extreme loop unrolling, a practice that is mostly counterproductive for post-Nehalem.

One of the more amusing P4 oddities is that certain 32-bit add/sub instructions will have a very slightly higher latency if there is a carry/borrow between the two 16-bit halves - it's very difficult to detect (I believe it's ~0.5 cycle), but it's there. This is probably a consequence of pipelining in the ALU itself.

Re:The Pentium 4 and the G4e: An Architectural Comparison (2... by duskwuff on Tuesday September 02, 2014 @02:25AM (#8256073)
> One of the more amusing P4 oddities is that certain 32-bit add/sub instructions will have a very slightly higher latency if there is a carry/borrow between the two 16-bit halves

This kind of data-dependent delay gives crypto people hives, for what it's worth. It's the sort of thing that can make timing attacks possible.

Re:The Pentium 4 and the G4e: An Architectural Comparison (2... by cfallin on Monday September 01, 2014 @08:03PM (#8255157)
> This is probably a consequence of pipelining in the ALU itself.

Yep, the P4 "fast ALU" was double-pumped and did 16-bit chunks of a 32-bit add/sub in adjacent half-cycles [1]. This meant that dependent chains of, e.g., adds could still issue back-to-back, since the first half of a dependent instruction requires only the low 16 bits of its sources. Always struck me as very clever!

[1] http://www.ecs.umass.edu/ece/koren/ece568/papers/Pentium4.pd...