ACID - Alpha 21164 Counter Instrumentation Driver  Version 1.0  10/21/97



Overview

--------



ACID provides a way to see what is going on inside of your Alpha 21164 processor.  The Alpha 21164 is capable of counting a number of processor and cache related events.  ACID allows a user to control which events are counted and to access the counts via the NT Performance Monitor (Perfmon).  In addition, ACID provides a Perfmon interface to count PAL (Privileged Architecture Library) calls and events when a debug version of the PAL (included in this package) is installed on your machine.



Requirements

------------



The following are needed to install ACID on your system:



- Alpha 21164 processor (multi-21164 systems are also supported)

- Windows NT 4.0 or later

- Administrator privileges





Installing ACID

---------------



To install ACID, first close any existing ACID or Perfmon windows and uninstall any existing ACID installations (manually stopping an existing ACID driver is not necessary). Then simply run the self-extracting executable "acid-install.exe".  Follow the instructions through the installation process.  When you have successfully completed the installation, the ACID kernel-mode driver should be installed and started, ACID performance counters in Perfmon should be activated, and the Start Menu should contain a ACID item under "Programs".  From this you can run the ACID Counter Selection program or Uninstall ACID.  For this release, the uninstall program is not very robust, so for best results, be sure to close any running ACID or Perfmon windows first.



It is possible that the ACID driver may not start properly during the install.  Simply type 'net start acid' to start the driver after installation the driver is not running.



NOTE: The default behavior is for the ACID driver to automatically start  on boot.  You may want to change this if you don't want ACID on all of the time.





How ACID works

--------------



ACID consists of three parts: a kernel-mode driver which directly accesses the on-chip performance counters on the 21164, a Perfmon DLL which allows Perfmon to receive the data from the kernel-mode driver, and a counter selection Win32 program which allows a user to activate and deactivate performance counters and to select which processor modes are to be measured.



The ACID driver (acid.sys) is responsible for configuring and reading the Alpha 21164 performance counters.  There are 3 performance counters on the chip, and they are accessed and configured via the PMCTR register.  Each performance counter can be set up to count one of up to 24 events.  The possible events are unique to each counter, i.e. a given event may only be counted on a specific counter.  Because there are many more possible events to count than there are counters, ACID uses a time-sharing approach to allow the user to obtain data for more than three events at the same time.  Each clock tick, the driver selects a random event from the list of activated events for each performance counter, and configures each counter to count its selected event.  At the end of the time quantum, the total number of counts is saved and the active quantum counter for the event is incremented by one.  Then the next events are selected and configured and so on.  PAL counters, when the debug PAL is installed, are collected using the "rdcounters" PAL call every time a request to read the current values is sent to the driver.  If the debug PAL is not installed, no counters are visible to the user.



The ACID performance DLL (acid.dll) provides Perfmon with an interface to the ACID driver.  When Perfmon tries to collect performance data from ACID, it calls the DLL data collection function which in turn does a DeviceIoControl call the ACID driver.  The ACID driver will return the latest data, which the DLL is responsible for putting into a format Perfmon can understand.  The DLL is also responsible for scaling the data to appear as if the events being counted were active on the physical performance counters for the entire measurement interval.   In reality they are only active for a fraction of the entire time, depending on how many events are being counted.  This process can lead to inaccuracies, since ACID is estimating how many counts occured during the time quantums when another event was active on the physical counters.  This is especially true if many events are enabled at the same time.



The ACID Counter Selection Utility (acid.exe) allows a user to easily control what events are being counted.  In addition, it allows a user to specify during which processor modes counting should take place.  The choices are All Modes, OS and User, User Only, and PAL only.  Once the desired configuration is selected, the Apply or OK buttons cause the configuration to be sent to the driver.  If the View->Refresh menu option is selected, the current configuration active in the driver will be loaded by the utility.  A user may also Open and Save configurations.  When opening a configuration, the configuration is not sent to the driver until the Apply or OK buttons are pressed.



Using the ACID Counter Selection Utility

----------------------------------------



After ACID has been installed and the ACID driver started, a user can run the ACID Counter Selection Utility from the Start Menu (Do ACID).  The user can select from two views of the counters; 'Raw' and 'Derived'.  The Raw view shows the counted events as they are actually counted on the Alpha 21164 chip.  The Derived view shows the results of expressions using the raw events (such as Icache misses per 1000 instructions).  The Raw and Derived views correspond to the Alpha 21164 (Raw) and Alpha 21164 (Derived) objects which should be visible from Perfmon when the ACID driver is active.



To select a group of counter events, simply move them into the "Active Counters" box.  This will not actually update what is counted by the driver.  Pressing the "Apply" or "OK" buttons will make this happen.  If you'd like to restore the selections to what is currently configured in the driver, use the "Refresh" menu option under "View".  This will query the ACID driver to find out what it is currently counting and update the active and inactive boxes with the appropriate events.



Once a set of events has been selected and sent to the driver, the user can then select the same group of corresponding Perfmon counters to see the current values.  If you select an event in Perfmon which is in the "Inactive Counters" box of the selection utility, the result should be zero.  If it isn't please send a bug report detailing your configuration and counter selections.



The "Processor Mode" button group allows the user to select the conditions under which the events will be counted. "All Modes" will count events during any time, while the other selections will enable counting only when the processor mode is in OS or User, User Only, or PAL Only. 



Once you have a selection setup that you would like to use often, you can save the configuration using the "Save" or "Save As" menu options.  You can load the saved configuration later with the "Open" menu.





Getting PAL Counters

--------------------



In production Alpha Windows NT systems, the PAL (Privileged Architecture Library) does not have counters activated, in the interest of performance.  Included in the ACID program files directory is a debug PAL (da221164.pal) which is a special PAL which does enable counting of PAL calls and exceptions handled in the PAL.  If this debug PAL is installed on your system, you will be able to access these counters via Perfmon (assuming the ACID driver is enabled).  



WARNING: The debug PAL packaged here is not standard, has not been officially tested, may not contain the latest enhacements, and will degrade performance to varying degrees depending on the system workload.  DO NOT change the PAL on your Alpha system unless you are well aware of what you are doing and realize that mistakes in installation may leave your system inoperable.



To install the debug PAL, locate the a221164.pal file in the boot partition under \os\winnt*.  Move or copy this file to a safe place, and replace it with the da221164.pal.  Rename da221164.pal to a221164.pal.  Reboot and the PAL counters should be visible.



Other Random Notes

------------------





Known Bugs and Anomalies

------------------------



Some strange things you may notice from time to time:



- Percentages > 100% 



This can happen due to the fact that the two raw counters used to create the percentage are not necessarily measured at the same instant in 		time.  This is most often seen with the %Scache Read/Write Miss counters and some of the %<Instruction Type> counters.  Reducing the number of counters does not necessarily resolve this problem, since the two components of the percentage may be mapped to the same physical counter.



- Counters mysteriously appear in active box after refresh



If you select Conditional Branch Instructions, All Flow Change Instructions, or Jsr-Ret Instructions, the driver may automatically activate other counters.  This is result in the dependency of certain counters on certain other counters.  For example, to collect Conditional Branch Instructions, Branch Mispredicts must be active.    



Frequently Asked Questions

--------------------------



Q: How much overhead does ACID impose?



A: The ACID driver is coded to minimize overhead of the counter switch process and the counter interrupt handling.  The amount of overhead from the driver will depend on what is being counted and how often the counted event occurs.  If the counted event happens frequently, more interrupts will be generated and overhead will increase.  If nothing is being counted, there is a small amount of overhead, usually less than 0.01% of total cycles are consumed.  The ACID Perfmon interface is probably the biggest source of overhead, since this is where data is transferred from kernel to user space, and then reformatted into Perfmon format.  The lower the update frequency in Perfmon, the lower the overhead incurred.



Q: How much accuracy do I lose by enabling more counters?



A: Near perfect accuracy is achieved when only one event is enabled on a physical counter.  When two or more events are enabled, accuracy deteriorates.  How much primarily depends on how consistent the event is over time.  Very infrequent, bursty events are prone to be less accurate, since the event may be "swapped out" during the burst period, and "swapped in" during a lulled period.  The effect would be lower reported counts than actual counts.  Or vice versa.  To get an idea of how much inaccuracy is introduced, enable only the event of interest, take a measurement, and then enable all other events, measure and compare.  A random selection algorithm has been incorporated to avoid problems with regular patterns of behavior that might synchronize in an undesirable way with the event selections. 



Q: Do the counter values include the time ACID is performing counter switching operations?



A: During the small amount of time in which ACID is loading and unloading counter values and configurations, the hardware counters 

are disabled.  Therefore, counts will not include any events that occuring during this time.  This time can be determined by enabling just "Cycles" and seeing how far off the result is from the frequency of the system.  Note that even with only one counter enabled, the counter switch routine is still performed (though no switch takes place).  This may be optimized in the future.





Feedback / Reporting Bugs

-------------------------



Please email any bug reports or suggestions to acid@zso.dec.com.



 

Acknowlegements

---------------



ACID was created by Darren Sawyer at DECwest - Windows NT Systems Group.  Special thanks to Dave Wagner (Alpha consulting, testing, feature creep, human factors, etc.), Jeff Glaum and John Strange (Win32 help), Kim Peterson (PAL counters, counter switch algorithm) and those at DECwest who were brave enough to put early versions of ACID on their machines. 

