Strip comments and inline ids onto h*

This commit is contained in:
James Gregory 2013-12-30 15:11:04 +11:00
commit 0f5f617adb
362 changed files with 2519 additions and 6694 deletions

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Pentium Rules</title><!-- HEADER -->
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Pentium Rules</title>
<meta name="chapter" content="20" />
<meta name="pages" content="386-390" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head>
<body>
@ -37,13 +30,12 @@
<p><br /></p>
<h3><a id="Heading4"></a>V-Pipe-Capable Instructions</h3>
<h3 id="Heading4">V-Pipe-Capable Instructions</h3>
<p>Any instruction can go through the U-pipe, and, for practical purposes, the U-pipe is always executing instructions. (The exceptions are when the U-pipe execution unit is waiting for instruction or data bytes after a cache miss, and when a U-pipe instruction finishes before a paired V-pipe instruction, as I&rsquo;ll discuss below.) Only the instructions shown in Table 20.1 can go through the V-pipe. In addition, the V-pipe can execute a separate instruction only when one of the instructions listed in Table 20.2 is executing in the U-pipe; superscalar execution is not possible while any instruction not listed in Table 20.2 is executing in the U-pipe. So, for example, if you use <b>SHR EDX,CL</b>, which takes 4 cycles to execute, no other instructions can execute during those 4 cycles; if, on the other hand, you use <b>SHR EDX,10</b>, it will take 1 cycle to execute in the U-pipe, and another instruction can potentially execute concurrently in the V-pipe. (As you can see, similar instruction sequences can have vastly different performance characteristics on the Pentium.)</p>
<p>Basically, after the current instruction or pair of instructions is finished (that is, once neither the U- nor V-pipe is executing anything), the Pentium sends the next instruction through the U-pipe. If the instruction after the one in the U-pipe is an instruction the V-pipe can handle, if the instruction in the U-pipe is pairable, and if register contention doesn&rsquo;t occur, then the V-pipe starts executing that instruction, as shown in Figure 20.2. Otherwise, the second instruction waits until the first instruction is done, then executes in the U-pipe, possibly pairing with the next instruction in line if all pairing conditions are met.</p>
<hr />
<!-- CODE //-->
<pre>
MOV reg,reg (1 cycle)
mem,reg (1 cycle)
@ -82,7 +74,7 @@ JMP/CALL near (1 cycle if predicted correctly;
3 cycles otherwise)
<sup>&dagger;</sup> Can&rsquo;t execute in V-pipe if address contains a displacement
</pre><!-- END CODE //-->
</pre>
<p><b>Table 20.1 Instructions that can execute in the V-pipe.</b></p>
<hr />
@ -91,7 +83,6 @@ JMP/CALL near (1 cycle if predicted correctly;
<p>Besides, almost all operations can be performed by combinations of pairable instructions. For example, <b>PUSH [<i>mem</i>]</b> is not on either list, but both <b>MOV <i>reg</i>,[<i>mem</i>]</b> and <b>PUSH <i>reg</i></b> are, and those two instructions can be used to push a value stored in memory. In fact, given the proper instruction stream, the discrete instructions can perform this operation effectively in just 1 cycle (taking one-half of each of 2 cycles, for 2*0.5 = 1 cycle total execution time), as shown in Figure 20.3&mdash;a full cycle <i>faster</i> than <b>PUSH [<i>mem</i>]</b>, which takes 2 cycles.</p>
<hr />
<!-- CODE //-->
<pre>
MOV reg,reg (1 cycle)
mem,reg (1 cycle)
@ -128,7 +119,7 @@ ROL/ROR/RCL/RCR reg,1 (1 cycle)
<sup>&dagger;</sup> Can&rsquo;t pair if address contains a displacement
<sup>&dagger;&dagger;</sup> Includes shift-by-1 forms of instructions
</pre><!-- END CODE //-->
</pre>
<p><b>Table 20.2 Instructions that, when executed in the U-pipe, allow V-pipe-executable instructions to execute simultaneously (pair) in the V-pipe.</b></p>
<hr />
@ -141,36 +132,34 @@ ROL/ROR/RCL/RCR reg,1 (1 cycle)
</tr>
</table>
<p><a id="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/20-02.jpg',405,144 )"> --><img src="images/20-02.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/20-02.jpg',405,144)"> --><b>Figure 20.2</b></a>&nbsp;&nbsp;<i>Instruction flow through the two pipes.</i></p>
<p><a id="Fig2"><img src="images/20-02.jpg" /><br />
<b>Figure 20.2</b></a>&nbsp;&nbsp;<i>Instruction flow through the two pipes.</i></p>
<p>One downside of this &ldquo;RISCification&rdquo; (turning complex instructions into simple, RISC-like ones) of Pentium-optimized code is that it makes for substantially larger code. For example,</p><!-- CODE SNIP //-->
<p>One downside of this &ldquo;RISCification&rdquo; (turning complex instructions into simple, RISC-like ones) of Pentium-optimized code is that it makes for substantially larger code. For example,</p>
<pre>
push dword ptr [esi]
</pre><!-- END CODE SNIP //-->
</pre>
<p>is one byte smaller than this sequence:</p><!-- CODE SNIP //-->
<p>is one byte smaller than this sequence:</p>
<pre>
mov eax,[esi]
push eax
</pre><!-- END CODE SNIP //-->
</pre>
<p><a id="Fig3"><!-- </A><A HREF="javascript:displayWindow('images/20-03.jpg',409,210 )"> --><img src="images/20-03.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/20-03.jpg',409,210)"> --><b>Figure 20.3</b></a>&nbsp;&nbsp;<i>Pushing a value from memory effectively in one cycle.</i></p>
<p><a id="Fig3"><img src="images/20-03.jpg" /><br />
<b>Figure 20.3</b></a>&nbsp;&nbsp;<i>Pushing a value from memory effectively in one cycle.</i></p>
<p>A more telling example is the following</p><!-- CODE SNIP //-->
<p>A more telling example is the following</p>
<pre>
add [MemVar],eax
</pre><!-- END CODE SNIP //-->
</pre>
<p>versus the equivalent:</p><!-- CODE SNIP //-->
<p>versus the equivalent:</p>
<pre>
mov edx,[MemVar]
add edx,eax
mov [MemVar],edx
</pre><!-- END CODE SNIP //-->
</pre>
<p>The single complex instruction takes 3 cycles and is 6 bytes long; with proper sequencing, interleaving the simple instructions with other instructions that don&rsquo;t use EDX or <b>Mem Var</b>, the three-instruction sequence can be reduced to 1.5 cycles, but it is <i>14</i> bytes long.</p>
@ -199,10 +188,6 @@ mov [MemVar],edx
<div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</div>
</body>
</html>