# Patent

## Title
Reducing processor energy consumption using compile-time information

## Abstract

A method, for use in a processor, includes mapping a first data access having less than a predetermined memory footprint to a first memory area, and mapping a second data access having greater than the predetermined memory footprint to a second memory area. The method may also include compiling computer code, inserting annotations into an intermediate representation of the computer code generated during compiling, propagating the annotations from the intermediate representation to a low-level representation of the computer code generated during compiling, and inserting instructions into the low-level representation, the instructions controlling mapping of the first data and the second data.

## Background
TECHNICAL FIELD
This invention relates generally to reducing energy consumption in a microprocessor and, more particularly, to reducing energy consumption by directing memory accesses based on compile-time information.
BACKGROUND
Microprocessors (referred to herein simply as “processors”) consume energy during their operation. It is advantageous to reduce the amount of energy consumed, particularly in the case of devices that run off of limited power supplies.
Various factors affect the amount of energy that a processor consumes. For example, the frequency at which the processor operates and the size of the voltage supply that powers the processor contribute to processor energy consumption. Reducing the frequency of the processor or the voltage supply may decrease processor energy consumption, however, doing so may also adversely affect the performance of the processor.
Accordingly, there exists a need for a way of reducing processor energy consumption that does not have a significant adverse affect on the processor's performance. The reductions in energy consumption should also be scaleable, meaning that they can be implemented on processors having different architectures.
SUMMARY
The processor framework described herein address the foregoing need by providing energy savings without significant adverse affects on performance. The framework does this by utilizing static and statically speculative compile-time information to map certain data accesses to a mini-buffer or mini-cache, respectively. The mini-buffer and mini-cache require less energy to access than a conventional cache. As a result, processors using this framework require less energy per memory access and, therefore, less energy to operate. Furthermore, the framework is applicable to processors having different architectures and is therefore scalable.
The invention can be used to save energy on any type of device that includes a processor. For example, the invention can be used to save energy on personal computers, devices containing embedded controllers, and hand-held devices, such as PalmPilots and cellular telephones.
In general, in one aspect, the invention is directed to a method, for use in a processor, which includes mapping a first data access having less than a predetermined memory footprint to a first memory area, and mapping a second data access having greater than the predetermined memory footprint to a second memory area. This aspect may include one or more of the following features.
The method may include identifying the first data access using static compile-time information and/or estimating the first data access using speculative static compile time information. Estimating the first data access may include examining an intermediate representation of computer code that is generated during compiling to identify data accesses that are most likely to occur during execution of the code. A control flow graph of the intermediate representation may be examined to determine the data accesses that are most likely to occur.
The first memory area may be a mini-buffer, a mini-cache, a register, and/or a partition of a standard cache. The second memory area may be a standard cache, a mini-cache, a mini-buffer, and/or a remaining portion of a partitioned cache. The first data access may be a scalar data access. The first memory area may require less energy to access than the second memory area. The first memory area may be smaller than the second memory area.
The method may include compiling computer code, inserting annotations into an intermediate representation of the computer code generated during compiling, propagating the annotations from the intermediate representation to a low-level representation of the computer code generated during compiling, and inserting instructions into the low-level representation. The instructions may control mapping of the first data and the second data. The method may also include estimating a memory footprint of the first data access. The estimating process may include isolating the data access in a computer program, determining a granularity of the data access by performing an instruction analysis, and identifying the memory footprint by counting multiple accesses into a same memory location and by taking a maximum of granularities of the multiple data accesses.
Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. Although methods and materials similar or equivalent to those described herein can be used in the practice or testing of the present invention, suitable methods and materials are described below. In addition, the materials, methods, and examples are illustrative only and not intended to be limiting.
Other features and advantages of the invention will become apparent from the following description, including the claims and drawings.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a block diagram showing the relationship between a compiler, instruction set architecture, and microarchitecture in a processor.
FIG. 2 is a flowchart showing a data access mapping process according to the present invention.
FIG. 3 is a block diagram of processor architecture on which the invention may be implemented.



DESCRIPTION
In the embodiments described herein, a processor framework leverages (i.e., uses) static and speculative static compile-time information to reduce energy consumption. The processor framework also leverages the fact that some types of data have relatively small memory footprints (i.e., the data occupies relatively little memory) and are accessed frequently. Data accesses with footprints that meet these criteria are identified using compile-time information and mapped differently than data accesses with relatively large footprints that are accessed less frequently.
Referring to FIG. 1, a compiler 10 is a software system that programs circuitry to translate applications from high-level programming languages (e.g., C, C++, JAVA®) into machine specific sequences of instructions. An instruction set architecture (ISA) 12 is a set of rules that defines the encoding of operations into machine specific instructions. The ISA acts as the interface between compiler 10 and the microarchitecture (14). A computer program is a collection of machine level instructions that are executed to perform a desired functionality. Micro-architectural (or architectural) components 14 comprise primarily hardware and/or software techniques that are used during execution of the program. The actual machine can be a microprocessor or any other device that is capable of executing instructions that conform to the encoding defined in the ISA.
Compile-time refers to the time during which the program is translated from a high-level programming language into a machine-specific stream of instructions, and it is not part of execution or runtime. Runtime is the time it takes to execute translated machine instructions on the machine. Compilation is typically performed on a different host machine than execution.
Information collected during compilation is called static or compile-time information. Program analyses are performed during compile-time to analyze the program and extract static information. Program transformations (or optimizations) are performed during compile-time to modify the program typically to achieve some objective such as improvement in performance.
Static information is predictable if it can be shown during compilation that the information is true for any possible input set applied to the program, or for any possible execution of the program on the machine in question. Static information is speculative if the information extracted during compile-time is not shown or cannot be shown to be true for all possible execution instances. As such, the available (i.e., extractable) speculative static information is a superset of the available predictable static information in a program.
The processes described herein combine architecture and compiler techniques into a compiler-enabled, tightly integrated, compiler-architecture based system design. An approach is deemed compiler-enabled if the execution of specific instructions is managed to some extent by static information. This is beneficial, since static and static-dynamic energy reduction optimizations can be enabled.
A cache is a fast memory hierarchy layer, typically smaller in size than a physical address space. It is one of the cornerstones of computer systems, and is used to hide the latency of main memory accessing. This is especially important, due to the increasing gap between execution speeds and memory latency. While execution speeds are said to double every 18 months (Moore's law), memory latencies are improving at a much lower rate. With the increasing cache sizes, which are necessary to hide memory latencies, the energy impact of cache accesses becomes even more significant in processor designs.
Using Static Information
In one embodiment, the processor framework uses a statically managed conventional cache (e.g., an L1 cache) and a mini-buffer, although more than one cache and one mini-buffer may be used. The mini-buffer may be small in size, e.g., 1 KiloByte (KB), 2 KB, or the like, relative to the conventional cache. It is noted, however, that the invention is not limited to use with a mini-buffer of these sizes; any size mini-buffer may be used.
In other embodiments, two or more mini-buffers may be used. These multiple mini-buffers may be differently sized to handle different types of data accesses. The compiler may coordinate access to the different mini-buffers. Conventional L1 and/or L2 caches may also be used in combination with the multiple mini-buffers, as above.
The processor analyzes static information (i.e., information that is obtained when a program is compiled) to map data accesses with relatively small memory footprints (e.g., on the order of 1 KB) to the mini-buffer and to map all other data accesses to the conventional cache. This is considered a conservative approach, since it uses a “worst case” estimate for every data access in a compiled program. That is, if a data access cannot be disambiguated at compile time, the processor assumes a maximum memory footprint for that data access (i.e., a footprint that is guaranteed to accommodate that data access), and maps the data access to either the mini-buffer or the conventional cache based on the assumed footprint.
Referring to FIG. 2, the memory footprint of a block of computer code may be estimated (16) during compiling. This is done by breaking the code down into constituent blocks. The data accesses associated with each block may be identified and their sizes determined during compilation.
The compiler may estimate a data access footprint using a number of methods. In this embodiment, the compiler isolates pre-specified (e.g., scalar) data accesses in each routine or block of a program. The compiler determines the granularity of the data by performing an instruction analysis to identify types of operands in the instructions the type of the instructions. For example, the granularity may be eight if the move is a quadword instruction, two if it is a word instruction, and so on. The compiler then identifies the footprint of the data accesses by counting multiple accesses into the same memory location only once and by taking the maximum of the granularities of those data accesses.
Once the compiler identifies the memory footprints, the compiler annotates (18) the blocks of instructions, as described in more detail below, with instructions from the ISA that tell circuitry in the processor (e.g., the microarchitecture) where to map (28) the data accesses. The compiler also may perform a reuse analysis on a data access to ensure that the sum of memory footprints for a data access during different parts of execution does not exceed the size of the mini-buffer.
Since the processor uses static compile-time information and maps all data accesses conservatively, the mappings will be correct. The processor will map all data accesses that fit into the mini-buffer to the mini-buffer, and all data accesses that do not fit into the mini-buffer to the cache. This approach results in energy savings, since the mini-buffer requires less power to access than does the conventional cache. However, even further energy savings can result from using “speculative” information (defined below) to perform the data access mapping.
Using Speculative Static Information
Another processor architecture uses a mini-cache in place of the mini-buffer, and one or more conventional caches. Like the mini-buffer, the mini-cache may be on the order of 1 KB or 2 KB; however, any size mini-cache may be used. This architecture uses speculative static compile-time information to determine where (e.g., the mini-cache or the conventional cache) to map data accesses. The overall process is the same as that shown in FIG. 2.
In this context, speculative static compile-time information identifies the data accesses that are most likely to occur during execution of a program. Data access footprints are estimated speculatively using the speculative static compile-time information. The speculative static compile-time information is used later to make decisions about data mapping. The compiler may estimate (16) the footprints of data accesses in the manner described above and annotate (18) the data accesses. The annotations are used during mapping, as above.
The compiler analyzes the program to extract information speculatively. The information is used in mapping low-footprint data accesses to the mini-cache and others to the conventional cache. As part of the estimation process (16), the compiler determines which data accesses are most likely to occur, as described below. The data access footprints do not need to be determined conservatively, as in the mini-buffer case, since the compiler will determine the most likely footprint for each data access and the data access will be generated and mapped (20) accordingly by the appropriate hardware.
In one embodiment, this estimation process includes partitioning a program into its basic blocks, resulting in an intermediate representation of the program. The compiler examines the source code and every procedure call within the source code to build a control flow graph. Using this graph, the compiler determines which data accesses with an estimated small memory footprint (e.g., 1 KB, 2 KB or thereabouts) are most likely to occur most frequently during execution of the program.
The determination of which data accesses are most likely to occur may be made, e.g., by following branches of the control flow graph noted above. For instance, a loop in a program may contain a data accesses which is most often 1 KB or less and which, in one case, is greater than 1 KB. The compiler will insert an instruction from the ISA in an instruction stream (see below) for the program to map that data access to the mini-cache, since it is most likely that the data access will be 1 KB or less. This is what is meant by estimating the size of the data access and using that information speculatively, i.e., the exact value of the data access at all points during execution need not be used to map the data access, only the most likely value of that data access may be used to map the data access.
Thus, the compiler identifies the data accesses from speculative static compile-time information and the microarchitecture maps data accesses with less than a predetermined estimated memory footprint (e.g., less than 1 KB), which are likely to occur most frequently, to the mini-cache and all other data accesses to the conventional cache. The mini-cache may be sized to accommodate such data accesses.
Improperly mapping some data accesses to the mini-cache should not have a significant adverse affect on the processor's performance or energy consumption, particularly in view of the energy saving resulting from mapping certain data accesses to the mini-cache. If data accesses are mapped improperly, other memory layers, such as an L2 cache, may accommodate those data accesses.
In other embodiments, two or more mini-caches may be used. These multiple mini-caches may be differently sized to handle different types of data accesses. The compiler may coordinate access to the different mini-caches. There are no limits to the sizes and numbers of mini-caches that may be used. Conventional L1 and/or L2 caches may be used in combination with the multiple mini-caches, as above.
Instead of using separate caches, a single cache may be partitioned, such that a portion of the cache acts as an effective mini-cache. The compiler can select the size of the partition dynamically, thereby changing the size of the effective mini-cache on a per program basis, if desired. As above, the compiler can map frequent data accesses with small memory footprints to the effective mini-cache and other data accesses to the remainder of the cache. The partitioned cache can be hardware controlled as well.
Mapping Data Accesses
The same basic processes may be used to map data accesses for the static and the speculative static approaches described above.
An instruction set architecture acts as the interface between the compiler and the processor's microarchitecture. At the beginning of compilation, a program contains high level structures, such as loops, data structures, and the like. Closer to the end of compilation, the program is translated into a low-level (machine-language-like) code that contains branches, conditional branches, memory instructions, register level operators, and the like.
During code generation, the compiler inserts instructions into the instruction stream to indicate the cache to which each data access is directed. In more detail, the compiler makes numerous passes through the code, in the process performing different types of analyses and optimizations on the code. During these passes, the compiler obtains various intermediate representations of the code and annotates these representations. An annotation is a marker or the like that is inserted into the code. The annotations correspond to memory footprints of various blocks of the code determined, as described above. These annotations are propagated down from the high-level code at the beginning of compilation to the low-level code resulting near the end of compilation.
Near the end of compilation, the code generator inserts instructions from the given instruction set at the locations corresponding to the annotations. These instructions direct data accesses for the annotated code to either the mini-cache (or mini-buffer) or the conventional cache depending upon their memory footprint, as described above. If more than one mini-cache, mini-buffer, or cache is used, the instructions direct the data accesses to the appropriate memory areas.
Register Accesses
The mini-cache may be used to accommodate scalar accesses that otherwise would have been mapped to the processor's registers. Following code generation, the compiler makes another pass over the code. This other pass is used for register allocation. The register allocation process decides which of the scalar types of data accesses are going to be mapped to physical registers and which are going to be mapped to the mini-cache (or mini-buffer) or the conventional cache.
During register allocation, a global optimization may be performed on the compiled code to determine which scalar types of data accesses to map to registers, which register accesses to map to the mini-cache (or mini-buffer), and which scalar types of data accesses to map to the conventional (e.g., L1 or L2) cache. To determine which accesses to map to the registers, a reuse analysis may be performed. A reuse analysis includes examining the life cycle and frequency of use of a scalar to determine if that scalar may or may not be mapped to a register.
Sample Implementation
Thus, in the processor framework described herein, some of the processor's data accesses are performed via the mini-cache (or mini-buffer) and some of the data accesses are performed via the conventional cache. Typically, relatively small, frequent data accesses are mapped to the mini-cache (or mini-buffer) and larger, less frequent data accesses are mapped to the conventional cache. Taking multimedia applications (e.g., applications with audio and video components) as an example, scalar accesses may be identified and mapped to the mini-cache (or mini-buffer), since scalars have a relatively small memory footprint and are accessed frequently in multimedia applications.
In this context, a “scalar” is a singular value, meaning a value that is not part of a larger construct, such as an array or a vector. Scalars may be program variables, such as integers or the like and generally contain one or two words (although they are not limited as such). Scalars also may be compiler-generated variables, such as intermediate variables generated by the compiler during compilation of a program.
FIG. 3 shows the architecture of a media processor on which the mini-cache/mini-buffer framework may be implemented. In this context, a media processor is a microprocessor that is capable of executing multimedia applications.
Generally speaking, architectural modifications to a media processor are not required if the processor is already equipped with a scratch-pad memory or some other small memory area that can be used as a mini-cache (or mini-buffer). If the processor is not equipped with a memory that can be used as a mini-cache, then the compiler can be used to devise special load/store instructions which channel the scalar data to a separate, smaller cache area of the processor.
In the embodiment of FIG. 3, the processor 22 includes a core 24 containing logic (circuitry) for executing instructions, a conventional (standard) instruction cache (Icache 26), a conventional (standard) data cache (Dcache 28), and a scratchpad memory 30 that may be used as part of the mini-cache/mini-buffer framework. An L2 cache 32 and main memory 37 may also be included in the architecture, as shown in FIG. 3. Instruction memory management unit (IMMU) 34 contains logic (circuitry) that controls access to Icache 26 and data memory management unit (DMMU 36) contains logic (circuitry) that controls access to Dcache 28 and L2 cache 32. Buses (not labeled) provide paths over which data and/or instructions are transported between the components of processor 10. A mini-cache of 128 bytes can hold a working set of scalar data for most multimedia applications, although mini-caches that are smaller or larger than 128 bytes may be used, as noted below.
It is noted that the processor framework described herein is not limited to use with multimedia applications, to use with scalars, or to use with the architecture of FIG. 3. The framework may be used with any application and with any type of data access.
Other embodiments not described herein are also within the scope of the following claims.

## Claims

1. A method for use in a processor that is configured to execute a computer program, comprising:
estimating a memory footprint of a data access associated with execution of the computer program, where estimating is performed using speculative static compile time information, the speculative static compile time information identifying the data access as one that is more likely to occur during the execution of the computer program than other data accesses but that need not occur;
mapping the data access to a first memory area if the memory footprint is less than or equal to a predetermined size; and
mapping the data access to a second memory area if the memory footprint is greater than the predetermined size, the second memory area comprising a standard cache, the standard cache having a size that is greater than a size of the first memory area.

2. The method of claim 1, wherein estimating the memory footprint comprises examining an intermediate representation of computer code for the computer program that is generated during compiling.

3. The method of claim 1, wherein a control flow graph of the intermediate representation is examined to determine data accesses that are most likely to occur.

4. The method of claim 1, wherein the first memory area comprises a mini-buffer.

5. The method of claim 1, wherein the first memory area comprises a mini-cache.

6. The method of claim 1, wherein the first memory area comprises a register.

7. The method of claim 1, wherein:
the first memory area comprises a partitioned portion of the standard cache; and
the second memory area comprises a remaining portion of the standard cache.

8. The method of claim 1, wherein the data access comprises a scalar data access.

9. The method of claim 1, wherein the first memory area requires less energy to access than the second memory area.

10. The method of claim 1, further comprising:
compiling computer code for the computer program;
inserting annotations into an intermediate representation of the computer code generated during compiling;
propagating the annotations from the intermediate representation to a low-level representation of the computer code generated during compiling; and
inserting instructions into the low-level representation, the instructions controlling mapping of the data access.

11. The method of claim 1, wherein estimating the memory footprint of the data access comprises:
isolating the data access in the computer program;
determining a granularity of the data access by performing an instruction analysis; and
identifying the memory footprint by counting multiple accesses into a same memory location and by taking a maximum of granularities of the multiple data accesses.

12. A processing system comprising:
a first memory area;
a second memory area, the second memory area comprising a standard cache, the standard cache having a size that is greater than a size of the first memory area; and
circuitry to:
estimate a memory footprint of a data access associated with execution of the computer program, where estimating is performed using speculative static compile time information, the speculative static compile time information identifying the data access as one that is more likely to occur during the execution of the computer program than other data accesses but that need not occur;
map the data access to the first memory area if the memory footprint is less than or equal to a predetermined size; and
map the data access to the second memory area if the memory footprint is greater than the predetermined size.

13. The processing system of claim 12, wherein estimating the memory footprint comprises examining an intermediate representation of computer code for the computer program that is generated during compiling.

14. The processing system of claim 12, wherein a control flow graph of the intermediate representation is examined to determine data accesses that are most likely to occur.

15. The processing system of claim 12, wherein the first memory area comprises a mini-buffer.

16. The processing system of claim 12, wherein the first memory area comprises a mini-cache.

17. The processing system of claim 12, wherein the first memory area comprises a register.

18. The processing system of claim 12, wherein:
the first memory area comprises a partitioned portion of the standard cache; and
the second memory area comprises a remaining portion of the standard cache.

19. The processing system of claim 12, wherein the data access comprises a scalar data access.

20. The processing system of claim 12, wherein the first memory area requires less energy to access than the second memory area.

21. The processing system of claim 12, further comprising circuitry to:
compile computer code for the computer program;
insert annotations into an intermediate representation of the computer code generated during compiling;
propagate the annotations from the intermediate representation to a low-level representation of the computer code generated during compiling; and
insert instructions into the low-level representation, the instructions controlling mapping of the data access.

22. The processing system of claim 12, wherein estimating the memory footprint of the data access comprises:
isolating the data access in the computer program;
determining a granularity of the data access by performing an instruction analysis; and
identifying the memory footprint by counting multiple accesses into a same memory location and by taking a maximum of granulanties of the multiple data accesses.