1. Field of the Invention
This invention is related to the field of processors and, more particularly, to combining write buffers in caches.
2. Description of the Related Art
Processors often implement combining write buffers to capture write operations that have been written to a higher level write-through cache (e.g. an L1cache), to buffer those writes prior to updating a lower level cache (e.g. an L2 cache). The combining write buffer combines two or more write operations that target data within the same cache block, and thus present fewer writes to the L2 cache.
The combining write buffer can accumulate write operations for some time. Determining when to flush write operations from one or more combining write buffer entries is a tradeoff between bandwidth and performance. Buffering write operations in the combining write buffer can lead to better bandwidth efficiency. On the other hand, if data is buffered for too long, the performance may suffer as data that needs to be pushed to lower level caches or memory remains in the combining write buffer.
In an embodiment, a combining write buffer is configured to maintain one or more flush metrics to determine when to transmit write operations from buffer entries. The combining write buffer may be configured to dynamically modify the flush metrics in response to activity in the write buffer, modifying the conditions that cause write operations to be transmitted from the write buffer to the next lower level of memory. Thus, the performance/bandwidth tradeoff may be dynamically adjusted based on the detected activity.
In one implementation, the flush metrics may include categorizing write buffer entries as “collapsed.” A collapsed write buffer entry, and the collapsed write operations therein, may include at least one write operation that has overwritten data that was written by a previous write operation in the buffer entry. Such entries may continue to accumulate write operations which overwrite previous data, and thus at least some of the data may be temporary data that is not to be accessed again soon. For example, the write operations in the write buffer entry may be part of a register spill area in memory where register values from the processor are written to make the registers available to store other data. Collapsed write buffer entries may not be considered when determining if the write buffer fullness has reached a specified threshold at which the combined write operations in one or more write buffer entries are transmitted to the next level of memory. The collapsed entries in the buffer may be temporarily ignored in the threshold calculation.
In another implementation, the combining write buffer may maintain the threshold of buffer fullness as a flush metric. The buffer may monitor for buffer full events. If a buffer full event is detected, then the threshold may be too high for the current activity level and may be reduced. On the other hand, if a number of consecutive write operations are received into the buffer without detecting a buffer full event, then the threshold may be too low and the threshold may be increased. Accordingly, based on the actual buffer fullness that is detected over time, the threshold may be adjusted.
The following detailed description makes reference to the accompanying drawings, which are now briefly described.
While the invention is susceptible to various modifications and alternative forms, specific embodiments thereof are shown by way of example in the drawings and will herein be described in detail. It should be understood, however, that the drawings and detailed description thereto are not intended to limit the invention to the particular form disclosed, but on the contrary, the intention is to cover all modifications, equivalents and alternatives falling within the spirit and scope of the present invention as defined by the appended claims. The headings used herein are for organizational purposes only and are not meant to be used to limit the scope of the description. As used throughout this application, the word “may” is used in a permissive sense (i.e., meaning having the potential to), rather than the mandatory sense (i.e., meaning must). Similarly, the words “include”, “including”, and “includes” mean including, but not limited to.
Various units, circuits, or other components may be described as “configured to” perform a task or tasks. In such contexts, “configured to” is a broad recitation of structure generally meaning “having circuitry that” performs the task or tasks during operation. As such, the unit/circuit/component can be configured to perform the task even when the unit/circuit/component is not currently on. In general, the circuitry that forms the structure corresponding to “configured to” may include hardware circuits. Similarly, various units/circuits/components may be described as performing a task or tasks, for convenience in the description. Such descriptions should be interpreted as including the phrase “configured to.” Reciting a unit/circuit/component that is configured to perform one or more tasks is expressly intended not to invoke 35 U.S.C. §112, paragraph six interpretation for that unit/circuit/component.
Turning now to
The processor core 10 may implement any instruction set architecture, and may include the circuitry to execute the instructions defined in the instruction set architecture. In various embodiments, the processor core 10 may implement any microarchitecture, including superscalar or scalar, superpipelined or pipelined, out of order or in order, speculative or non-speculative, etc. Various embodiments may employ microcoding techniques or not, as desired.
The instruction set architecture implemented by the processor core 10 may specify explicit load instructions defined to transfer data from memory to the processor (e.g. to a register in the processor) and explicit store instructions defined to transfer data from the processor to memory. Either transfer may be completed in cache in various embodiments. Alternatively or in addition, the instruction set architecture may specify implicit loads and stores (e.g. for an instruction that performs a non-load/store operation on a memory operand). Accordingly, the processor core 10 may be said to execute or perform a load operation or a store operation. The load/store operation may be derived from the explicit instruction or the implicit load/store.
The processor core 10 may be configured to generate a read operation in response to a load operation and may be configured to generate a write operation in response to a store operation. The read/write operations may be propagated to a memory hierarchy that includes one or more levels of cache and a main memory system. The caches may cache data that is also stored in the main memory subsystem, and data is the memory hierarchy is identified by a memory address defined in a memory address space corresponding to the main memory system. For example, in the embodiment of
The read operation may be completed when the data for the read is returned from the memory hierarchy (e.g. any level of cache, or the main memory subsystem), and the write operation may be completed via the processor core 10 sending the write data. The write operation may include the address, an indication of the size of the write (e.g. in terms of bytes), and the write data. The write operation may also include other attributes of the write (e.g. cacheability, coherence, etc.).
The data cache 12 may implement any capacity and configuration (e.g. direct mapped, set associative, etc.). The data cache 12 may be configured to allocate and deallocate storage in the cache in units of cache blocks. A cache block may have any size (e.g. 32 bytes, 64 bytes, 128 bytes, etc.), and may be aligned in memory at a natural address boundary for the block size (e.g. a cache block of 32 bytes may be aligned to a 32 byte boundary, a cache block of 64 bytes may be aligned to a 64 byte boundary, etc.).
In the illustrated embodiment, the data cache 12 is write-through (WT). In a write-through cache, write operations which hit in the cache are propagated to the next level of memory in addition to updating the cache block in the cache. Write operations which miss the cache are also propagated to the next level of memory. On the other hand, a write-back cache (or store-in cache) may update the stored cache block and may not propagate the write operation. Instead, the updated cache block may eventually be written back to the next level of memory when it is evicted from the cache.
The L2 interface unit 14 may receive the write operations from the L1 data cache 12 and may also receive read cache misses (as fill requests). The L2 interface unit 14 may be configured to store the write operations in the CWB 20, and to store the fill requests in the fill buffer 18. Fill requests may be transmitted to the L2 cache 16 (and lower levels of the memory hierarchy as needed), and the fill data may be returned to the L1 data cache 12 and may be written to the L1 data cache 12.
The CWB 20 may buffer the write operations, and transmit them to the L2cache 16 at various points in time. The write operations may include write-through writes that hit in the cache 12 and updated the cache block therein. The write operations may also include write-through writes that missed in the data cache 12. The CWB 20 may include multiple buffer entries. Each buffer entry may be configured to store write operations on a cache block granularity. That is, the entry may be allocated for a cache block-sized entity aligned to cache block boundary in memory. Any writes within the cache block may be stored in the allocated entry. An initial write operation within the cache block may cause the CWB 20 to allocate the entry, and the write data may be stored in the buffer along with the address and an indication of which bytes within the cache block are updated (e.g. a byte mask). Subsequent write operations may be merged into the buffer, writing the data into the appropriate bytes within the cache block and updating the byte mask.
The CWB 20 may be configured to accumulate one or more flush metrics 22 to determine when to transmit one or more combined write operations from buffer entries to the L2 cache 16. The CWB 20 may be configured to monitor the activity in the write buffer to determine the flush metrics 22. Thus, flush metrics may generally be dynamically-generated data that may be used by the CWB 20 to determine when to transmit the combined write operations (or flush the write buffer entry or entries) to the next level of memory. Because the flush metrics are dynamically generated, the frequency at which the combined write operations are flushed may vary over time based on the detected write buffer activity. That is, the flush metrics may be used along with the fullness of the write buffer (that is, the number of buffer entries that are occupied as compared to the total number of buffer entries) to determine when to transmit one or more combined write operations to the next level of memory.
For example, in one embodiment, the flush metrics may include the detection of collapsed write buffer entries. A collapsed write buffer entry may be an entry in which: at least one write operation has been merged into the entry; and the write operation has overwritten at least one byte of write data that was written to the entry by a previous write operation. For example, if a byte mask is maintained to indicate which bytes within the cache block are updated, the collapsed write may be detected if a write operation is merged into the entry and at least one bit of the byte mask that would be set due to the merging write operation is already set. Other embodiments may detect the collapse at other levels of granularity with the cache block (e.g. word, double word, etc.). Other embodiments may only detect a collapsed write if all bytes updated by the write have their corresponding mask bits set prior to the collapsed write. That is, a collapsed write may be detected if the byte mask is the same value before and after the collapsed write is merged.
The CWB 20 may be configured to remove the collapsed write buffer entries from consideration in detecting write-buffer fullness. For example, the CWB 20 may be configured to transmit combined write operations from one or more write buffer entries as the CWB 20 approaches full (e.g., when a threshold level of fullness is met). Since the collapsed write buffer entries are not considered in determining write buffer fullness for flush write entries, the write buffer may tend to become more full (in terms of occupied entries) when collapsed write buffer entries are detected in the write buffer than when collapsed write buffer entries are not detected in the write buffer. In one embodiment, a fixed or programmable threshold value may be used to determine that the CWB 20 is approaching full. The count of entries that are in use may be compared to the threshold value, less any entries that are in collapsed state. When the threshold value is reached (e.g. met or exceeded), the CWB 20 may flush one or more write buffer entries. In an embodiment, the CWB 20 may flush one write buffer entry in response to reaching the threshold value, and may continue to flush write buffer entries until the number of occupied write buffer entries drops below the threshold value. In other embodiments, more than one write buffer entry may be flushed concurrently. Since the collapsed write buffer entries are not counted toward the fullness threshold, write buffer entries may be flushed less frequently than when there are no collapsed write buffer entries.
Flushing a write buffer entry may involve one or more combined write operations. For example, for each set of contiguous updated bytes in the entry, one write operation may be generated. If there are gaps of non-updated bytes in the entry, multiple write operations may be transmitted. In other embodiments, one combined write operation per write entry may be transmitted with a byte mask or other indication identifying which bytes are to be updated within the cache block. In still other embodiments, writes of a given size (e.g. a word) may be generated.
In another embodiment, the flush metrics 22 may include the threshold value. The threshold value may be dynamically modified based on the detection of write buffer full events. The write buffer full events may indicate that the write buffer is actually full (all buffer entries allocated to write operations). Accordingly, the CWB 20 may flush write entries based on the threshold value, and may detect the buffer full events to indicate that the threshold value is to be modified. For example, if a buffer full event is detected, the CWB 20 may determine that the threshold value is too high (e.g. too close to buffer full), causing the write buffer to fill before flushing of an entry can be completed. The full buffer may impact processor core performance. Accordingly, the threshold value may be reduced in response to the buffer full event. On the other hand, if a certain number of write operations are written to the buffer without detecting a buffer full event, the threshold value may be too low (e.g. too far from buffer full) and may be increased.
Accordingly, the threshold may be adapted over time based on whether the buffer is becoming full or not. If traffic is causing the buffer to fill more quickly, the threshold may be reduced. In this fashion, writes may not back up in the buffer and cause the processor core 10 to stall. If traffic is causing the buffer to fill less quickly, the threshold may be increased. Therefore, the buffer may be permitted to store write operations longer, reducing traffic (and power consumption) in the L2 cache 16. That is, the frequency of transmitting writes from a write buffer entry to the L2 cache 16 may increase and decrease with changes to the threshold.
In other embodiments, other flush metrics may be accumulated (e.g. how frequently a full cache block of writes is buffered, snoop hits in the buffers, etc.). The frequency of flushing write buffer entries to the L2 cache 16 may be modified based on these metrics as well. For example, the frequency of flushing may be increased if snoop hits are being detected (indicating that other processor cores or circuits in the system are using the data being written).
In some embodiments, the write operations stored in the CWB 20 may further include non-cacheable write operations. The non-cacheable write operations may be write-combinable, and may be merged into a buffer entry similar to the write-through writes discussed above. Other non-cacheable write operations may not be write-combinable (or write combining of non-cacheable writes may not be supported). In such cases, each non-cacheable write operation may be allocated its own separate entry in the CWB 20. Other embodiments may store non-cacheable write operations in a different write buffer.
The L2 cache 16 may be of any size and construction, similar to the discussion above for the data cache 12. The L2 cache 16 may be write back or write-through, in various embodiments. The L2 cache 16 may further include an interface to the next level of memory, which may be the main memory subsystem or a third level (L3) cache in various embodiments.
It is noted that a combining write buffer (CWB) 20 may included between other levels of the memory hierarchy as well. For example, a CWB 20 may be included below any cache level that is write-through. It is noted that, in an embodiment, the processor core 10, the L1 data cache 12, and the L2 interface 14 (including the fill buffer 18 and the CWB 20) may be integrated together as a processor. In other embodiments, the L2 interface 14 may be shared with another processor core 10/L1 data cache 12. In still other embodiments, the L2 cache 16 may be integrated into the processor, and or other components may be integrated (e.g. in a system on a chip configuration).
Turning next to
The CWB 20 may be configured to monitor activity in the write buffer (block 30). For example, fullness of the buffer, numbers of write operations merged into the buffer, collapsed writes, etc. may be monitored by the CWB 20. If the detected activity indicates a change in a flush metric maintained by the CWB 20 (decision block 32, “yes” leg), the CWB 20 may modify the flush metric (block 34). If a combination of buffer state and the flush metric(s) 22 indicates a flush of one or more buffer entries (decision block 36, “yes” leg), the CWB 20 may be configured to transmit one or more combined write operations from one or more buffer entries to the L2 cache 16 (block 38). More generally, the write operations may be transmitted to the next level of memory in the memory hierarchy.
Turning now to
Exemplary entries 46A-46B in the buffer 42 are shown in
Turning now to
The CWB 20 may be configured to compare the address of the write operation and the addresses in the write buffer 42 (on a cache line granularity). For example, the address field of the entries in the write buffer 42 may be implemented as a content addressable memory (CAM). If the write operation is a hit in a buffer entry (that is, the write operation is within the cache block represented by the entry—decision block 50, “yes” leg), the control circuit 40 may be configured to reset the age counter in the entry (block 52). Thus, the age counter may be the age of the entry since the most recent write operation was merged into the entry in this embodiment. If the write operation overwrites at least one byte that was already written to the entry by a previous write operation (decision block 54, “yes” leg), the control circuit 40 may be configured to set the collapsed state to indicate collapsed (block 56). The control circuit 40 may be configured to update the byte mask and to cause the data to be written to the data field of the hitting entry.
If the write operation is a miss in the buffer 42 (decision block 50, “no” leg), the control circuit 40 may be configured to allocate a new (currently unoccupied) entry for the write operation (block 60). The control circuit 40 may initialize the allocated entry with information corresponding to the write operation (block 62). Particularly, the control circuit 40 may cause the allocated entry to update with the address and data of the write operation, may set the byte mask to indicate the bytes updated by the write, may clear the age counter, and may clear the collapsed state. If the write buffer is full (that is, there is no currently unoccupied entry), the control circuit 40 may back pressure the L1data cache 12/processor 10 to stall the write operation until an entry is available.
The decision block 54 and the set collapsed state 56 may be the equivalent of the decision block 32 and the block 34, respectively, for the embodiment of the CWB 20 shown in
Turning now to
The control circuit 40 may be configured to determine a full count as the number of occupied entries less the number of collapsed entries (block 70). That is, the full count may be the number of non-collapsed entries. If the full count has reached the full threshold 44C (decision block 72, “yes” leg), the control circuit 40 may be configured to transmit the combined write operations from one or more entries to the L2cache 16, or the next level of the memory hierarchy (block 74). The control circuit 40 may be configured to select any entry to transmit write operations to the L2 cache 16. For example, in an embodiment, the control circuit 40 may select the oldest entry (as indicated by the age counter) that is not a collapsed entry. In another embodiment, both collapsed and non-collapsed entries may be considered for selection based on age. In another embodiment, the entries may be flushed in first in, first out (FIFO) order of their allocation. The combination of blocks 70 and 72 may be the equivalent of block 36, and the block 74 may be the equivalent of block 38, in this embodiment. In another embodiment, an additional threshold may be defined (higher than the full threshold) to be compared against the total number of occupied entries (both collapsed and non-collapsed). If the total number of occupied entries reaches the additional threshold, the control circuit 40 may be configured to transmit combined write operations from one or more buffer entries to the L2 cache 16 (block 74).
The remainder of the flowchart illustrated in
Turning now to
In the embodiment of
Exemplary entries 96A-96B are shown in
The control circuit 90 may be configured to determine if the received write operation fills the buffer 92 (decision block 100). For example, if the received write operation is a miss in the buffer 92 and the last non-occupied entry is allocated to the received write operation, the buffer 92 is full. If so (decision block 100, “yes” leg), the control circuit 90 may be configured to reduce the full threshold 94C (block 102) and to clear the write count 94B (block 104). On the other hand (decision block 100, “no” leg), the control circuit 90 may be configured to increment the write count 94B if the received write operation does not cause a full event (block 106). If the write count has reached the write threshold (decision block 108, “yes” leg), the control circuit 90 may be configured to increase the full threshold. In this embodiment, the flowchart of
Accordingly, the full threshold may be dynamically modified in this embodiment to cause a flush of an entry (as illustrated in blocks 72 and 74, where the full count is the number of occupied entries in this embodiment) to prevent full events from occurring, while permitting the buffer 92 to get as full as possible based on the traffic detected in the CWB 20. The write count may be determined in any desired fashion. For example, if a given percentage of write operations are expected to be merged into write buffer entries, the write count may be equal to the product of the number of write operations per cache block (e.g. the number of words in the cache block), the number of write buffer entries, and the merge percentage.
Turning next to
The memory 352 may be any type of memory, such as dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate (DDR, DDR2, DDR3, etc.) SDRAM (including mobile versions of the SDRAMs such as mDDR3, etc., and/or low power versions of the SDRAMs such as LPDDR2, etc.), RAMBUS DRAM (RDRAM), static RAM (SRAM), etc. One or more memory devices may be coupled onto a circuit board to form memory modules such as single inline memory modules (SIMMs), dual inline memory modules (DIMM5), etc. Alternatively, the devices may be mounted with an integrated circuit 358 in a chip-on-chip configuration, a package-on-package configuration, or a multi-chip module configuration.
The peripherals 354 may include any desired circuitry, depending on the type of system 350. For example, in one embodiment, the system 350 may be a mobile device (e.g. personal digital assistant (PDA), smart phone, etc.) and the peripherals 354 may include devices for various types of wireless communication, such as wifi, Bluetooth, cellular, global positioning system, etc. The peripherals 354 may also include additional storage, including RAM storage, solid state storage, or disk storage. The peripherals 354 may include user interface devices such as a display screen, including touch display screens or multitouch display screens, keyboard or other input devices, microphones, speakers, etc. In other embodiments, the system 350 may be any type of computing system (e.g. desktop personal computer, laptop, workstation, net top etc.).
Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications.
Number | Name | Date | Kind |
---|---|---|---|
5561780 | Glew et al. | Oct 1996 | A |
5630075 | Joshi et al. | May 1997 | A |
5892937 | Caccavale | Apr 1999 | A |
6546462 | Palanca et al. | Apr 2003 | B1 |
6658533 | Bogin et al. | Dec 2003 | B1 |
6671747 | Benkual et al. | Dec 2003 | B1 |
7418555 | Chung | Aug 2008 | B2 |
7685372 | Chen et al. | Mar 2010 | B1 |
7752173 | Gole | Jul 2010 | B1 |
20060095609 | Radhakrishnan et al. | May 2006 | A1 |
20060184341 | Di et al. | Aug 2006 | A1 |
20070143514 | Kaushik et al. | Jun 2007 | A1 |
20090089470 | Ven | Apr 2009 | A1 |
20090157936 | Goss et al. | Jun 2009 | A1 |
Number | Date | Country | |
---|---|---|---|
20120047332 A1 | Feb 2012 | US |