Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
11 KiB

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  6. <meta name="ProgId" content="FrontPage.Editor.Document">
  7. <title>New Page 1</title>
  8. </head>
  9. <body>
  10. <p align="center"><b><font size="5">PMELib 1.0</font></b></p>
  11. <h2>Introduction</h2>
  12. <p><font size="3">&nbsp;&nbsp;&nbsp; This library is an interface to the Performance Monitoring
  13. Events (PME) that are available in the Pentium P5, P6 and P4 processors.&nbsp;
  14. There are 18 counters that let you gather information about what the processor is
  15. going during execution.&nbsp; They are described in these manuals:</font></p>
  16. <blockquote>
  17. <p><a href="http://developer.intel.com/design/pentium4/manuals/253665.htm"><font color="#008000" size="3">IA-32
  18. Intel Architecture Software Developer's Manual Volume 1: Basic Architecture</font></a></p>
  19. <p><a href="http://developer.intel.com/design/pentium4/manuals/253666.htm"><font color="#008000" size="3">IA-32
  20. Intel Architecture Software Developer's Manual Volume 2A: Instruction Set
  21. Reference, A-M</font></a></p>
  22. <p><a href="http://developer.intel.com/design/pentium4/manuals/253667.htm"><font color="#008000" size="3">IA-32
  23. Intel Architecture Software Developer's Manual Volume 2B: Instruction Set
  24. Reference, N-Z</font></a></p>
  25. <p><a href="http://developer.intel.com/design/pentium4/manuals/253668.htm"><font color="#008000" size="3">IA-32
  26. Intel Architecture Software Developer's Manual Volume 3: System Programming
  27. Guide</font></a></p>
  28. <p><font size="3">&nbsp;&nbsp;&nbsp;<font color="#008000" size="3">&nbsp;&nbsp;&nbsp;&nbsp; </font><font size="3" color="#000000">See
  29. chapter 15, Appendix A and Appendix B</font></font></p>
  30. </blockquote>
  31. <p><font size="3">Pentium 4 documentation is available <a href="http://developer.intel.com/design/Pentium4/documentation.htm">here</a></font></p>
  32. <p><font size="3">This library&nbsp; is an extension to the utilities from the Game Developer's
  33. Magazine <a href="http://www.gamasutra.com/features/wyatts_world/19990528/pentium3_08.htm">article</a>
  34. by Robert Wyatt in May 1998.&nbsp; The library is now in a class and included
  35. the Pentium 4 processor.&nbsp; Only Intel is currently supported and
  36. tested.&nbsp;&nbsp;</font></p>
  37. <p>&nbsp;</p>
  38. <p><font size="3">Send feedback to <a href="mailto:[email protected]">[email protected]</a></font></p>
  39. <p>&nbsp;</p>
  40. <p>&nbsp;</p>
  41. <h2><b>Installation</b></h2>
  42. <p><font size="3">&nbsp;&nbsp;&nbsp; Window NT and Windows XP are supported and tested.&nbsp;
  43. Win98 may work, however.</font></p>
  44. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;</font></p>
  45. <p><font size="3">&nbsp;&nbsp;&nbsp; You need to install a driver, set some registry settings
  46. and reboot.&nbsp; If you installed the GDPerf.sys from the GD magazine article,
  47. you can skip the installation step. It uses the same driver.&nbsp; Let me know
  48. if you have problems.</font></p>
  49. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In the <i>Installation</i>
  50. directory</font></p>
  51. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; copy
  52. GDPerf.sys to the window driver directory</font></p>
  53. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  54. copy GDPerf.sys <a href="file:///C:/windows/system32/drivers">C:\windows\system32\drivers</a></font></p>
  55. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  56. there is a batch file as an example</font></p>
  57. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Run the
  58. PMELib.reg file to set the registry settings</font></p>
  59. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reboot</font></p>
  60. <p>&nbsp;</p>
  61. <h2><b>Configuring PMELib</b><font size="3">&nbsp;</font></h2>
  62. <p><font size="3">For P5 and P6 processors (anything before Pentium 4), You use the same
  63. interfaces that are described in the Game Developer article.&nbsp; They have
  64. just been incorporated in to the PMELib as is.</font></p>
  65. <p><font size="3"><font color="#000000">In the Pentium 4, are 18 performance
  66. monitoring counters and more than 40 Events Modes that can be captured.&nbsp;
  67. Each Mode has a bit mask that indicates which tests to perform.&nbsp; These are
  68. described in Appendix A of </font><font color="#008000" size="3"><a href="http://developer.intel.com/design/pentium4/manuals/253668.htm">IA-32
  69. Intel Architecture Software Developer's Manual Volume 3: System Programming
  70. Guide</a>&nbsp;&nbsp;</font><font size="3" color="#000000"> Each of these event
  71. mode has a class dedicated to it.&nbsp; The event modes are listed below.</font></font></p>
  72. <blockquote>
  73. <p><font size="3">Set PerfTest2 for an example.</font></p>
  74. <p><font size="3"><b>Step 1) Choose an Event Mode class</b></font></p>
  75. <p><font size="3">&nbsp;&nbsp;&nbsp; Example:</font></p>
  76. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  77. Event_branch_retired event;</font></p>
  78. <p>&nbsp;</p>
  79. <p><font size="3"><b>Step 2)&nbsp; Set the Event Mask for the selected Event
  80. Mode</b></font></p>
  81. <p><font size="3">&nbsp;&nbsp;&nbsp; Example:</font></p>
  82. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; event.eventMask-&gt;MMNP = 1;</font></p>
  83. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; event.eventMask-&gt;MMTP = 1;</font></p>
  84. <p>&nbsp;</p>
  85. <p><b><font size="3">Step 3)&nbsp; Set the privilege level to capture data
  86. from with the <i>SetCaptureMode</i> method</font></b></p>
  87. <blockquote>
  88. <p><font size="3">OS_Only, <font COLOR="#008000">// ring 0, driver&nbsp;
  89. level only
  90. </font></font></p>
  91. <p><font size="3">USR_Only, <font COLOR="#008000">// app level, privilege
  92. levels&nbsp; 1 2 and 3
  93. </font></font></p>
  94. <p><font size="3">OS_and_USR, <font COLOR="#008000">// all levels 0, 1, 2
  95. and 3
  96. </font>
  97. </font></p>
  98. </blockquote>
  99. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Optionally, you
  100. can enable tagging in the <i>SetCaptureMode</i> method.</font></p>
  101. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Example:</font></p>
  102. <p><font size="3"><font COLOR="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  103. </font>SetCaptureMode(OS_and_USR, TagEnable, 34);</font></p>
  104. <p>&nbsp;</p>
  105. <p><font size="3"><b>Step 4) Optional Configuration</b></font></p>
  106. <p><font size="3">&nbsp;&nbsp;&nbsp;<b>&nbsp;&nbsp;&nbsp;&nbsp; </b>At this
  107. point you can configure Tagging, Filtering, Overflow and Cascading
  108. options.&nbsp; You can also select one of the legal counters for the selected
  109. Event Mode.</font></p>
  110. <p><font size="3"><b>Step 5) Set the process priority to high</b></font></p>
  111. <blockquote>
  112. <p><font size="3">This reduces the noise from other processes interfering.&nbsp; If you
  113. have an infinite loop in you code and you have these set, you may hang and
  114. need to reboot</font></p>
  115. <p><font size="3">Example:</font></p>
  116. <p><font size="3">&nbsp;&nbsp;&nbsp; PME * pme = PME::Instance();</font></p>
  117. <p><font size="3">&nbsp;&nbsp;&nbsp; pme-&gt;SetProcessPriority(ProcessPriorityHigh);</font></p>
  118. <font SIZE="2">
  119. <p>&nbsp;</p>
  120. </blockquote>
  121. </font>
  122. <p><font size="3"><b>Step 6) Start using the counters</b></font></p>
  123. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Each Event Mode
  124. counter has the follow ability:</font></p>
  125. <blockquote>
  126. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stop</font></p>
  127. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start</font></p>
  128. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Clear - set to
  129. 0</font></p>
  130. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Read</font></p>
  131. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write - write a
  132. 64 bit counter value</font></p>
  133. </blockquote>
  134. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></p>
  135. <p><font size="3"><b>Step 7) Set the process priority to normal</b></font></p>
  136. <p><font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pme-&gt;SetProcessPriority(ProcessPriorityNormal);</font></p>
  137. <h2>&nbsp;</h2>
  138. </blockquote>
  139. <h2><font size="3"><b>Event Modes:</b></font></h2>
  140. <blockquote>
  141. <blockquote>
  142. <p><font size="3">Event_TC_deliver_mode</font></p>
  143. <p><font size="3">Event_BPU_fetch_request</font></p>
  144. <p><font size="3">Event_ITLB_reference</font></p>
  145. <p><font size="3">Event_memory_cancel</font></p>
  146. <p><font size="3">Event_memory_complete</font></p>
  147. <p><font size="3">Event_load_port_replay</font></p>
  148. <p><font size="3">Event_store_port_replay</font></p>
  149. <p><font size="3">Event_MOB_load_replay</font></p>
  150. <p><font size="3">Event_page_walk_type</font></p>
  151. <p><font size="3">Event_BSQ_cache_reference</font></p>
  152. <p><font size="3">Event_IOQ_allocation</font></p>
  153. <p><font size="3">Event_IOQ_active_entries</font></p>
  154. <p><font size="3">Event_FSB_data_activity</font></p>
  155. <p><font size="3">Event_BSQ_allocation</font></p>
  156. <p><font size="3">Event_BSQ_active_entries</font></p>
  157. <p><font size="3">Event_SSE_input_assist</font></p>
  158. <p><font size="3">Event_packed_SP_uop</font></p>
  159. <p><font size="3">Event_packed_DP_uop</font></p>
  160. <p><font size="3">Event_scalar_SP_uop</font></p>
  161. <p><font size="3">Event_scalar_DP_uop</font></p>
  162. <p><font size="3">Event_64bit_MMX_uop</font></p>
  163. <p><font size="3">Event_128bit_MMX_uop</font></p>
  164. <p><font size="3">Event_x87_FP_uop</font></p>
  165. <p><font size="3">Event_x87_SIMD_moves_uop</font></p>
  166. <p><font size="3">Event_TC_misc</font></p>
  167. <p><font size="3">Event_global_power_events</font></p>
  168. <p><font size="3">Event_tc_ms_xfer</font></p>
  169. <p><font size="3">Event_uop_queue_writes</font></p>
  170. <p><font size="3">Event_retired_mispred_branch_type</font></p>
  171. <p><font size="3">Event_retired_branch_type</font></p>
  172. <p><font size="3">Event_resource_stall</font></p>
  173. <p><font size="3">Event_WC_Buffer</font></p>
  174. <p><font size="3">Event_b2b_cycles</font></p>
  175. <p><font size="3">Event_bnr</font></p>
  176. <p><font size="3">Event_snoop</font></p>
  177. <p><font size="3">Event_response</font></p>
  178. <p><font size="3">Event_front_end_event</font></p>
  179. <p><font size="3">Event_execution_event</font></p>
  180. <p><font size="3">Event_replay_event</font></p>
  181. <p><font size="3">Event_instr_retired</font></p>
  182. <p><font size="3">Event_uops_retired</font></p>
  183. <p><font size="3">Event_uop_type</font></p>
  184. <p><font size="3">Event_branch_retired</font></p>
  185. <p><font size="3">Event_mispred_branch_retired</font></p>
  186. <p><font size="3">Event_x87_assist</font></p>
  187. <p><font size="3">Event_machine_clear</font></p>
  188. </blockquote>
  189. </blockquote>
  190. <h2><b>Credits</b></h2>
  191. <p><a href="http://www.gamasutra.com/features/wyatts_world/19990528/pentium3_08.htm"><font color="#008000" size="3">http://www.gamasutra.com/features/wyatts_world/19990528/pentium3_08.htm</font></a></p>
  192. <p><font color="#008000" size="3">Used some tables from <a href="http://user.it.uu.se/~mikpe/">Mikael Pettersson's</a>&nbsp;
  193. <a href="http://user.it.uu.se/~mikpe/linux/perfctr/">pertctf</a>
  194. </font>
  195. </p>
  196. <p align="left"><font color="#008000" size="3">Used the detect code from<a href="http://yotov.org">
  197. Kamen Yotov's</a>&nbsp; <a href="http://iss.cs.cornell.edu/ia32.htm">ia32lib library</a></font></p>
  198. <p>&nbsp;</p>
  199. <p>&nbsp;</p>
  200. </body>
  201. </html>