Abstract:
A computer process transforms a &#34;general purpose&#34; central processing unit (hereinafter &#34;CPU&#34;) into one of a number of possible &#34;special purpose&#34; CPUs by changing operation of circuitry in the CPU. Changing operation of CPU circuitry as described herein &#34;fine tunes&#34; behavior of the CPU, e.g. provides resources and environment most suitable for execution of a specific application program, or even a portion of an application program. The computer process performs the steps of: checking whether the CPU has a tunable unit, waiting for a triggering event indicating a need for fine tuning, reading one or more statistics on the performance of the CPU, comparing the read statistics with corresponding predetermined statistics, determining a multi-valued parameter signal depending on the comparison, driving the determined parameter signal to the tunable unit and changing operation of circuitry in the tunable unit depending on the received parameter signal, thereby to fine tune operation of the tunable unit and the CPU.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application is related to and incorporates by reference herein in their entirety the following commonly owned, concurrently filed, copending U.S. Patent Applications: 
     1. &#34;A Port For Fine Tuning A Central Processing Unit&#34; by Sherman Lee and David G. Kyle, Ser. No. 08/710,337 filed Sept. 16, 1996; and 
     2. &#34;A Method For Identifying And Correcting Errors In A Central Processing Unit&#34; by Sherman Lee and David G. Kyle, Ser. No. 08/710,336 filed Sept. 16. 1996. 
    
    
     CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application is related to and incorporates by reference herein in their entirety the following commonly owned, concurrently filed, copending U.S. Patent Applications: 
     1. &#34;A Port For Fine Tuning A Central Processing Unit&#34; by Sherman Lee and David G. Kyle, Ser. No. 08/710,337 filed Sept. 16, 1996; and 
     2. &#34;A Method For Identifying And Correcting Errors In A Central Processing Unit&#34; by Sherman Lee and David G. Kyle, Ser. No. 08/710,336 filed Sept. 16. 1996. 
     FIELD OF THE INVENTION 
     This invention relates to a method for monitoring and controlling the performance of a central processing unit (CPU). In particular, this invention relates to a method for evaluating performance statistics of the CPU and changing operation of circuitry in the CPU depending on the evaluation. 
     BACKGROUND OF THE INVENTION 
     A conventional microprocessor, such as INTEL&#39;S P6, is a &#34;general purpose&#34; microprocessor that has a predetermined configuration. The predetermined configuration is a result of design trade-offs between running certain types of application programs faster than other types. The application programs are typically diverse, such as spread sheet applications, word processing applications and video game applications. 
     Such application programs may be drawn from commercial benchmarks of the type described in &#34;The Complete x86,&#34; Chapter 20, MicroDesign Resources, 1994 that is incorporated by reference herein in its entirety. Designers of central processing units (CPUs) may use an 80-20 rule in optimizing the CPU for running 20% of the most common application programs (e.g. programs known to be used 80% of the time). Thus the rest of the application programs run less than optimally on such &#34;general purpose&#34; microprocessors. 
     For example, an article &#34;P6 stirs up software issues&#34;, by Alexander Wolfe, Electronic Engineering Times, Oct. 30, 1995, page 22 states: &#34;a 133-MHz P6 running Windows 3.1 runs 10 to 20% slower than a Pentium&#34;. The article also cites an INTEL warning that &#34;programs that intermix . . . use of 8-, 16- and 32-bit registers can result in partial pipeline stalls, which slow performance.&#34; According to Wolfe, &#34;Intel is providing special optimizing compilers and a software performance aide called the Visualized Tuning Tool (V Tune) .&#34; However, such tools fail to improve the performance of application programs (such as 16m-bit code) that predate (e.g. were sold before) the P6. Therefore, to use INTEL&#39;s P6 a user must discard such preexisting software and buy a whole new generation of 32-bit software at a considerable expense. 
     Conventional microprocessors, such as INTEL&#39;s PENTIUM™ have one or more on-chip caches with &#34;modes&#34;, such as a &#34;cache disabled&#34; (CD) mode and a &#34;not write thru&#34; (NW) mode. The PENTIUM&#39;s modes are described in &#34;Pentium™ Processor User&#39;s Manual&#34; (see in particular Volume 1, Chapter 3) available from Intel Corporation, Literature Sales, PO Box 7641, Mt. Prospect, Ill. 60056-7641 that is incorporated by reference herein in its entirety. For example, setting a bit CD to 0 in register CR0 of the PENTIUM™, results in disabling a cache in the PENTIUM™ (see Table 3-2 of the above-incorporated manual). Moreover, Intel states that &#34;the cache must be flushed after being disabled . . . &#34; 
     SUMMARY 
     A computer process in accordance with the invention transforms a &#34;general purpose&#34; central processing unit (hereinafter &#34;CPU&#34;) into one of a number of possible &#34;special purpose&#34; CPUs by changing operation of circuitry in the CPU. The CPU has one or more functional units (hereinafter &#34;tunable units&#34;) that operate differently depending on one or more parameters. The functional units parameters (also called &#34;multi-valued parameters&#34;) can have one of a number (e.g. 4) of different values selectable from a predetermined range (e.g. programming model sizes of 8 bit, 16 bit, 32 bit and 64 bit). In one embodiment, the computer process changes one or more parameters of one or more functional units, thereby to change operation of circuitry internal to the functional units in response to the changed parameter. 
     Changing operation of CPU&#39;s internal circuitry as described herein &#34;fine tunes&#34; behavior of the CPU, e.g. provides resources and environment most suitable for execution of a specific application program, or even a portion of an application program. The multi-valued parameters of this invention allow the computer process to change the internal circuitry&#39;s behavior gradually unlike prior art operating systems that, for example, completely enable or completely disable the use of a microprocessor&#39;s on-chip cache. 
     In one embodiment, the computer process performs the steps of: checking whether the CPU has a tunable unit, waiting for a triggering event indicating a need for fine tuning, reading one or more statistics on the performance of the CPU, comparing the read statistics with corresponding predetermined statistics, determining a parameter signal depending on the comparison, driving the parameter signal to the tunable unit and changing operation of circuitry in the tunable unit depending on the parameter signal, thereby to fine tune operation of the tunable unit. 
     In addition to the above-described steps, a computer process may include other steps such as entering a critical section (e.g. by disabling interrupts and serializing execution) prior to the &#34;circuitry operation changing&#34; step and leaving the critical section after the &#34;circuitry operation changing&#34; step. In one specific embodiment, all the above-described steps are executed in the CPU, and the computer process is included as a component in the CPU, for example in hardware circuitry, or in microcode, or in Basic Input Output System (BIOS) instructions, or in operating system instructions, or as a device driver. Thus the computer process of this invention is unlike a debugging process in a device external to the CPU, such as an in-circuit emulator. 
     In one embodiment, the step of entering the critical section includes switching to a memory that is otherwise inaccessible, so that the computer process operates transparent to the operating system and to an application program controlled by the operating system. Moreover, depending on the embodiment, the triggering event for the fine tuning process can occur at the start of execution of every application program, or can occur periodically (e.g. every 5 seconds). That is, the computer process can change circuitry operation in a tunable unit, and thereby change a CPU&#39;s profile periodically, even during the execution of an application program. 
     Therefore, the computer process can change operation of internal circuitry such that the CPU has a first profile capable of most efficiently executing a first application program (such as a video game application), and can again change operation of internal circuitry such that the CPU has a second profile capable of most efficiently executing a second application program (such as a spreadsheet application) and so on. Such fine tuning allows the CPU to execute even portions of an application program efficiently. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIGS. 1A, 1B and 1C each illustrate a central processing unit (CPU) circuitry tuner in three different embodiments of a computer system. 
     FIG. 2 illustrates, in a high level flowcharts and block diagrams, various steps performed by the CPU-circuitry tuner of FIGS. 1A, 1B and 1C. 
     FIG. 3 illustrates, in a state machine, the various states of a fine tunable CPU illustrated in FIGS. 1A, 1B and 1C. 
     FIG. 4 illustrates four statistical patterns Pgn, Pss, Pib and Pwp each of which triggers a corresponding one of parameter sets Sgm, Sss, Sib and Swp respectively, thereby to put a fine tunable CPU of into one of the states of FIG. 3. 
    
    
     DETAILED DESCRIPTION 
     In accordance with the invention, a central processing unit (hereinafter &#34;CPU&#34;) has a number of functional units (hereinafter &#34;tunable units&#34;), and each tunable unit has one or more parameters that can be gradually changed, to thereby gradually change operation of circuitry in the tunable unit. Each parameter (also called &#34;multi-valued parameter&#34;) can have one of a number (e.g. 1024) of different values selectable from a predetermined range (e.g. cache size in the range 0-1023 bytes). 
     A computer process in one embodiment of the invention waits for a triggering event (such as a periodic timer event indicating the need for fine tuning of the CPU), reads one or more statistics on performance of the CPU, compares the read statistics with a number of patterns (or a single pattern in one embodiment) of predetermined statistics to determine one or more parameter signals, and drives the parameter signals to one or more tunable units, thereby to change the circuitry operation in the CPU. 
     Examples of circuitry in a tunable unit and a device (also called &#34;fine tuning port&#34;) for changing circuitry in the tunable unit are described in the U.S. patent application Ser. No. 08/710,337entitled &#34;A Port for Fine Tuning a Central Processing Unit&#34; by Sherman Lee and David G. Kyle that is incorporated by reference above. 
     Although specific circuitry is described herein for a particular embodiment of the invention, other such embodiments will be obvious to a person skilled in the art of designing control systems for microprocessors in view of the disclosure. Accordingly, the embodiments described herein are merely illustrative and not limiting. 
     In one embodiment, a computer system 100A includes a tunable CPU 110A that has a fine tuning port 110P (as described above) and a CPU-circuitry tuner 110T. CPU-circuitry tuner 110T reads statistics from fine tuning port 110P and on matching the read statistics to one of a number of patterns of predetermined statistics (as described more completely below) drives a corresponding set of parameter signals to fine tuning port 110P. 
     In addition to tunable CPU 110A, computer system 100A includes a read only memory (ROM) 111 that is encoded with a basic input output system (BIOS) instructions for tunable CPU 110A. Read only memory 111 and tunable CPU 111A are coupled to each other by a CPU bus 112 that is also coupled via a system bridge (not labelled) to a system bus 113. System bus 113 in turn is coupled to a floppy drive 114, a hard disk 115, a monitor 116, a keyboard 117 and a mouse 118. CPU bus 112 is also coupled to a main memory 120 that is encoded with a number of applications, e.g. application 120A . . . 120I . . . 120M, where M is the number of applications. 
     In addition to the above-described parts, computer system 100A also includes a system management memory 130 that is coupled via CPU bus 112 to tunable CPU, and that is accessible to CPU-circuitry tuner 110T. System management memory 130 contains a number of parameter sets, e.g. set 130A, . . . 130I, . . . 130N, where N is the number of parameter sets. Parameter sets for one embodiment are described below in reference to FIG. 4. Note that system management memory 130 can be &#34;hidden&#34; i.e. made inaccessible to tunable CPU 110A while executing one of applications 120A-120M in the manner described in, for example, &#34;The CPU and Undocumented Instructions,&#34; Chapter 3 &#34;The Undocumented PC&#34; by Frank Van Gilluwe, Addison-Wesley Publishing Company, Reading, Mass., that is incorporated by reference herein in its entirety. 
     CPU-circuitry tuner 110T in tunable CPU 110A can be implemented in hardware as circuitry that performs a number of steps illustrated in FIG. 2 (described below), or alternatively can be encoded as microcode resident in storage elements of tunable CPU 110A. In another embodiment, a tunable CPU 110B (FIG. 1B) does not have the above-described CPU-circuitry tuner 110T, but rather has a CPU-circuitry tuner 111T in software that is encoded in read only memory 111 in addition to the BIOS instructions. CPU-circuitry tuner 111T also performs the steps described below in reference to FIG. 2. Note that the same reference numerals are used for various parts in FIG. 13 that are similar or identical to corresponding parts in FIG. 1A. 
     In yet another embodiment of the invention, both tunable CPU 110C and read only memory 111C do not have a CPU-circuitry tuner. Instead, a CPU-circuitry tuner 120T is resident in main memory 120C. In addition, computer system 100C does not have a system management memory 130, and rather the parameter sets 130A-130N are encoded in system management memory 130. In this embodiment as well, CPU-circuitry tuner 120T performs the steps described in reference to FIG. 2. 
     A CPU-circuitry tuner 210 in one embodiment of the invention initializes variables on start up in a step 211 and thereafter checks in step 212 whether the central processing unit, e.g. CPU 110A (FIG. 1A) is tunable, and if not stops in step 213. 
     If the CPU is tunable, CPU-circuitry tuner 210 may load, for example, parameter s et s 130A-130N into memory, and may cause tunable CPU 110A to use one of parameter sets 130A-130M as a default set. Then CPU-circuitry tuner 210 goes from step 212 to step 213 and waits for an event indicating the need for fine tuning. The event can be, for example, the running of an application program by the operating system, termination of an application program by the operating system, or a system interrupt that occurs periodically, e.g. every five seconds or 10 seconds during the running of an application. On occurrence of such an event, CPU-circuitry tuner 210 goes to step 215 and analyzes (as described more completely below) the performance statistics from fine tuning port 110P. 
     Next, CPU-circuitry tuner 210 enters a critical section in step 216, for example by disabling interrupts and serializing the execution of instructions in CPU 110A (so that instructions are executed in sequential order). During this step, if necessary, CPU-circuitry tuner 210 also switches from main memory 120 to system management memory 130 that can be made inaccessible to applications 120A-120M as described above. 
     After entering the critical section, CPU-circuitry tuner 210 goes to step 218 and drives a multi-valued parameter signal (as described in the above-incorporated applications, Ser. No. 08/710,336 and 08/710,337 to fine tuning port 110P. Then CPU-circuitry tuner 210 changes operation of the circuitry in one or more tunable units of CPU 110A for example by driving the parameter signal to the tunable unit. Step 218 can be implemented by use of model specific registers of the type described in the above incorporated book, &#34;The Undocumented PC&#34; by Frank Van Gilluwe (in particular, see Chapter 3, pages 31-91). 
     Thereafter, CPU-circuitry tuner 210 goes to step 219 and exits from the critical section, for example by enabling interrupts, so that out of order execution occurs immediately following the change in operation of circuitry in step 218 based on, for example, the signal DEGREE OF OUT OF ORDER EXECUTION, of the type described in the above-referenced applications Ser. Nos. 08/710,336 and 08/710,337. 
     In the step 219, CPU-circuitry tuner also switches from system management memory 130 to main memory 120 as necessary, and also flushes a cache memory (not shown) if necessary. Thereafter, CPU-circuitry tuner 210 returns to step 214 and awaits another fine tuning event. 
     As noted above, on startup, CPU-circuitry tuner 210 can cause tunable CPU 110A to use one of parameter sets 130A-130M as a default set in default state 310. Thereafter, on occurrence of a match during a fine tuning event, CPU-circuitry tuner 210 causes tunable CPU 110A to transfer from state 310 to one of states 310A-310N (FIG. 3). Specifically, as noted above, CPU-circuitry tuner 210 compares the read statistics to each one of the statistics patterns Pgm, Pss, Pib and Pwp (in sets 130A-130N) and selects depending on a match, one of parameter sets Sgm, Sss, Sib and Swp corresponding to the matched statistics pattern. 
     For example, if statistics read from fine tuning port 110P match ranges 01, U1, A1, B1, I1, D1, L1 and B1 of pattern Pgm, then, the parameter set Sgm is selected, i.e. signals S1, G1, M1, W1, E1, C1, F1, R1 and P1 are driven in step 218 to fine tuning port 110P, thereby to change operation of the circuitry in tunable CPU 110C. In this example, each range, e.g. range O1 is formed of two parts, a minimum limit O1min and a maximum limit O1max. An overflow statistic Os that is read from fine tuning port 110P matches a range O1 if O1min&lt;Os&lt;O1max. Also, each of parameter signals SI, GI, MI, WI, EI, CI, FI, RI and PI is multi-valued, i.e. has one of a number (e.g. 1024) of values within the respective predetermined ranges (Smax, Smin), (Gmax, Gmin), (Mmax, Mmin), (Wmax, Wmin), (Emax, Emin, (Cmax, Cmin), (Fmax, Fmin), (Rmax, Rmin) and (Pmax, Pmin). That is, if Cmax is 512 KBytes and Cmin is 128 Kbytes, cache boundary signal CI can be any value in the predetermined cache boundary range of (128, 512), e.g., 256 KBytes. Such a degree of fine tuning is not possible when a cache is merely disabled and enabled, for example, by use of a single-valued signal (e.g. an ON/OFF signal). 
     In this example, ranges O2 and U2 for overflows and underflows can be predetermined to be fairly small, e.g. O2min set to 0, O2max set to 1, U2min set to 0 and U2max set to 1, thereby to fine tune the configuration of tunable CPU 110A for operation in, for example, spread sheet state 310B. 
     Although certain specific embodiments have been described herein, numerous modifications and adaptations of the described embodiments will be obvious in view of the disclosure. For example, instead of using predetermined parameter sets 130A-130N, a CPU-circuitry tuner can start with a default parameter set, e.g. set 130A and thereafter dynamically change each parameter signal independent of the other parameter signals, or change a group of parameter signals smaller than the set of parameter signals. 
     As another example, the CPU-circuitry tuner can change a parameter signal SI depending on one or more of the statistics signals OI-UI. That is, precision size signal SI is unaffected by the changes in the other statistics, e.g. statistics AI-BI. In this manner, each of the parameter signals SI, GI, MI, WI, EI, CI, FI, RI and PI can be changed dynamically without reference to any of the predetermined parameter sets 130A-130N. 
     Although in one embodiment, the computer process transitions between predetermined states, in other embodiments, the computer process can go to any state that is not predetermined, i.e. dynamically determined based on the statistics. For example, the computer process can &#34;learn&#34; by receiving feedback on statistics generated by changing a parameter, and literally keep changing parameters until certain predetermined optimal statistics are obtained. 
     The degree of such tunability requires a trade-off between the number of transistors needed to implement such logic and the benefit obtained from such fine tuning. Although in one specific embodiment, the computer process is implemented by a set of comparators and registers well known to a person of skill in the art in view of the enclosed disclosure. 
     Numerous such modifications and adaptations of the above described embodiments are encompassed by the attached claims.