This application incorporates by reference, in their entireties, the following co-pending U.S. patent applications:
U.S. patent application Ser. No. [252009-1140], filed on Sep. 19, 2005 (under Express Mail Label No. EV 628221272), having the title “Selecting Multiple Threads for Substantially Concurrent Processing”; and
U.S. patent application Ser. No. [252009-1150], filed on Sep. 19, 2005 (under Express Mail Label No. EV 628221269), having the title “Merging Entries in Processor Caches.”
The present disclosure relates generally to processors and, more particularly, to caches associated with processors.
Increasing complexity in software applications, such as in graphics processing, has led to an increased demand for hardware processing power. Part of modern-day processing architecture includes one or more caches, which are used to improve processing efficiency. Rather than accessing a main memory, which is external to a processor, caches are located within the processing unit itself, thereby permitting faster access to data and, concomitantly, permitting faster processing.
While various cache configurations have developed, there is still a continuing need to improve on those configurations.
The present disclosure relates to caches that are capable of improving processor performance. In some embodiments, among others, a cache request is received, and logic within the cache determines whether the received cache request results in a hit on the cache. If the cache request results in a hit on the cache, then that cache request is serviced. Conversely, if the cache request does not result in a hit (e.g., miss, miss-on-miss, hit-on-miss, etc.), then information related to the received cache request is stored in a missed request table.
For some embodiments, missed read requests are stored in a missed read request table, while missed write requests are stored in a missed write request table.
Other systems, devices, methods, features, and advantages will be or become apparent to one with skill in the art upon examination of the following drawings and detailed description. It is intended that all such additional systems, methods, features, and advantages be included within this description, be within the scope of the present disclosure, and be protected by the accompanying claims.
Many aspects of the disclosure can be better understood with reference to the following drawings. The components in the drawings are not necessarily to scale, emphasis instead being placed upon clearly illustrating the principles of the present disclosure. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
Reference is now made in detail to the description of the embodiments as illustrated in the drawings. While several embodiments are described in connection with these drawings, there is no intent to limit the disclosure to the embodiment or embodiments disclosed herein. On the contrary, the intent is to cover all alternatives, modifications, and equivalents.
Most computer systems employ a cache, which is a small and fast memory that holds recently accessed data. Typically, the cache is designed to speed up subsequent access to the same data.
Generally, when data is read from, or written to, main memory a copy is also saved in the cache, along with the associated main memory address. The cache monitors addresses of subsequent reads to see if the required data is already in the cache. If the data is in the cache (referred to as a “cache hit”) then it is returned immediately and a read of the main memory is aborted or not started. If the data is not in the cache (referred to as a “cache miss”) then the data is fetched from main memory and also saved in the cache.
Typically, the cache is built from faster memory chips than main memory, so that a cache hit takes much less time to complete than a normal memory access. The cache may be located on the same integrated circuit (IC) as a central processing unit (CPU), thereby further reducing access time. Those caches that are located on the same IC as the CPU are often known as primary caches, since there may be larger, slower secondary caches (also known as level-2 (L2) caches) outside the CPU chip. For certain architectures, such as the ones disclosed herein, the caches can also be co-located on the same chip as the processing core, such as, for example, the graphics core of a graphics processing chip.
An important characteristic of a cache is its hit rate, which is the fraction of all memory accesses that are satisfied from the cache. The hit rate depends on the cache design, and often on the size of the cache relative to the size of the main memory. The size is limited by the on-chip cost of fast memory chips.
The hit rate also depends on the access pattern of the particular program being run (the sequence of addresses being read and written). Caches rely on two properties of the access patterns of most programs, namely, temporal locality and spatial locality. Temporal locality posits that if a particular data (or instruction) is accessed once, then it is likely to be accessed again relatively soon. Spatial locality posits that if one memory location is accessed, then nearby memory locations are also likely to be accessed. In order to exploit spatial locality, caches often operate on several words (referred to as “cache line” or “cache block”) at a time. Reads and writes of main memory are whole cache lines.
Generally, when the processor writes to main memory, the data is first written to the cache on the assumption that the processor will probably read it again soon. When the cache is full and another line of data is sought to be cached, a cache entry is selected to be written back to main memory or “flushed.” The new line is then put in its place. As one can imagine, it is generally desirable to have greater cache capacity, since this correspondingly reduces the number of main-memory reads or writes.
In order to accommodate greater cache efficiency, some embodiments of the invention provide for merging of cache requests. For those embodiments, requests are compared to determine whether there is a match between the requests. If the requests match, then the requests are merged, and the return destination identifier (ID) and address are recorded in a pending request queue. By merging requests that match, the cache increases its efficiency by not queuing duplicative requests.
For other embodiments, requests are compared with entries that are already in the pending request queue. If there is a match between a request and an entry, then the request is merged with the entry, thereby not queuing the request that is duplicative of a preexisting entry.
For yet other embodiments, latency within the cache is reduced by providing a missed read request table, which buffers cache read misses and permits cache read hits to pass through with little to no latency.
Yet other embodiments employ a missed write request table, which buffers cache write misses. The missed write request table, therefore, results in little to no latency in the event of a write miss.
It should be noted that, while the following description is framed in the context of a graphics processor, the principles described in the various embodiments can be applied to other types of processors that handle other types of data (e.g., non-graphics data).
As shown in
For example, as shown in
The pixel packer 115 provides pixel shader inputs to the computational core 105 (inputs C and D), also in 512-bit data format. Additionally, the pixel packer 115 requests pixel shader tasks from the EU pool control unit 125, which provides an assigned EU number and a thread number to the pixel packer 115. Since pixel packers and texture filtering units are known in the art, further discussion of these components is omitted here. While
The command stream processor 120 provides triangle vertex indices to the EU pool control unit 125. In the embodiment of
Upon processing, the computational core 105 provides pixel shader outputs (outputs J1 and J2) to the write-back unit 130. The pixel shader outputs include red/green/blue/alpha (RGBA) information, which is known in the art. Given the data structure in the disclosed embodiment, the pixel shader output is provided as two 512-bit data streams.
Similar to the pixel shader outputs, the computational core 105 outputs texture coordinates (outputs K1 and K2), which include UVRQ information, to the texture address generator 135. The texture address generator 135 issues a texture request (T# Req) to the computational core 105 (input X), and the computational core 105 outputs (output W) the texture data (T# data) to the texture address generator 135. Since the various examples of the texture address generator 135 and the write-back unit 130 are known in the art, further discussion of those components is omitted here. Again, while the UVRQ and the RGBA are shown as 512 bits, it should be appreciated that this parameter may also be varied for other embodiments. In the embodiment of
The computational core 105 and the EU pool control unit 125 also transfer to each other 512-bit vertex cache spill data. Additionally, two 512-bit vertex cache writes are output from the computational core 105 (outputs M1 and M2) to the EU pool control unit 125 for further handling.
Having described the data exchange external to the computational core 105, attention is turned to
The L2 cache 210 receives vertex cache spill (input G) from the EU pool control unit 125 (
The memory interface arbiter 245 provides a control interface to the local video memory (frame buffer). While not shown, a bus interface unit (BIU) provides an interface to the system through, for example, a PCI express bus. The memory interface arbiter 245 and BIU provide the interface between the memory and an execution unit (EU) pool L2 cache 210. For some embodiments, the EU pool L2 cache connects to the memory interface arbiter 245 and the BIU through the memory access unit 205. The memory access unit 205 translates virtual memory addresses from the L2 cache 210 and other blocks to physical memory addresses.
The memory interface arbiter 245 provides memory access (e.g., read/write access) for the L2 cache 210, fetching of instructions/constants/data/texture, direct memory access (e.g., load/store), indexing of temporary storage access, register spill, vertex cache content spill, etc.
The computational core 105 also comprises an execution unit pool 230, which includes multiple execution units (EUs) 240a . . . 240h (collectively referred to herein as 240), each of which includes an EU control and local memory (not shown). Each of the EUs 240 are capable of processing multiple instructions within a single clock cycle. Thus, the EU pool 230, at its peak, can process multiple threads substantially simultaneously. These EUs 240, and their substantially concurrent processing capacities, are described in greater detail below. While eight (8) EUs 240 are shown in
The computational core 105 further comprises an EU input 235 and an EU output 220, which are respectively configured to provide the inputs to the EU pool 230 and receive the outputs from the EU pool 230. The EU input 235 and the EU output 220 may be crossbars or buses or other known input mechanisms.
The EU input 235 receives the vertex shader input (E) and the geometry shader input (F) from the EU pool control 125 (
The EU output in the embodiment of
For some embodiments, the address may have a 30-bit format that is aligned to 32-bits. Various portions of the address can be specifically allocated. For example, bits [0:3] can be allocated as offset bits; bits 4 through 5 (designated as [4:5]) can be allocated as word-select bits; bits [6:12] can be allocated as line-select bits; and bits [13:29] can be allocated as tag bits.
Given such 30-bit addresses, the L2 cache 210 can be a four-way set-associative cache, for which the sets are selected by the line-select bits. Also, the word can be selected with the word-select bits. Since the example data structure has 2048-bit line sizes, the L2 cache 210 can have four banks, with each bank having 1RW 512-bit port, for up to four read/write (R/W) accesses for each clock cycle. It should be appreciated that, for such embodiments, the data in the L2 cache 210 (including the shader program code, constants, thread scratch memories, the vertex cache (VC) content, and the texture surface register (T#) content) can share the same virtual memory address space.
An example embodiment is provided with reference to
The outputs include a 512-bit output (Xin CH0315) for writing data to the EU input 235 crossbar, and a 512-bit output (Xin CH1325) for writing data to the EU input 235 crossbar. Also, 512-bit outputs (VC cache 335 and TAG/EUP 345) are provided for writing data to the VC and T# registers, respectively.
In addition to the four inputs 310, 320, 330, 340 and the four outputs 315, 325, 335, 345, the L2 cache 210 includes an external R/W port 350 to the memory access unit 205. For some embodiments, the external write to the memory access unit 205 is given higher priority than other R/W requests. The EU load instruction (designated herein as “LD4/8/16/64”) loads 32/64/128/512-bit data, which is correspondingly aligned to 32/64/128/512-bit memory addresses. For the load instruction, the returned 32/64/128-bit data is replicated to 512 bits. The 512-bit data is masked by the valid pixel or vertex mask and channel mask when the data is written into the EU register file (also referred to herein as the “common register file” or “CRF”). Similarly, the EU store instruction (designated herein as “ST4/8/16/64”) stores 32/64/128/512-bit data, which is correspondingly aligned to 32/64/128/512-bit memory addresses.
Given such data structures, all other read/write requests (e.g., instructions and constants from the EU, vertex data from the vertex cache, texture data from the T# registers, etc.) are aligned to 512-bit memory addresses. Various components of the L2 cache 210 are shown in greater detail with reference to
As shown in
The Xin CH0 FIFO 402 and the Xin CH1 FIFO 404 direct their respective incoming requests to request merge logic 410. The request merge logic 410 determines whether or not the incoming requests from these respective FIFOs should be merged. Components of the request merge logic 410 are shown in greater detail with reference to
The resulting outputs of the request merge logic 410, 412, 414 are conveyed to hit test arbiter 416. The hit test arbiter 416 determines whether there is a hit or a miss on the cache. For some embodiments, the hit test arbiter 416 employs barrel shifters with independent control of shift multiplexers (MUXes 1102, 1104, 1106, 1108, 1110, 1112) as shown in
The results of the hit test arbitration from the hit test arbiter 416, along with the resulting outputs of the request merge logic 410, 412, 414, are conveyed to the hit-test unit 418. Given the configuration of
The L2 cache 210 further comprises a missed write request table 420 and a missed read request table 422, which both feed into a pending memory access unit (MXU) request FIFO 424. The pending MXU request FIFO 424 further feeds into the memory access unit 205. The pending MXU request FIFO 424 is described in greater detail below, with reference to hit-testing of the L2 cache 210.
The return data from the MXU 205 is placed in a return data buffer 428, which conveys the returned data to an L2 read/write (R/W) arbiter 434. Requests from the hit test unit 418 and the read requests from the missed read request table 422 are also conveyed to the L2 R/W arbiter 434. Once the L2 R/W arbiter 434 arbitrates the requests, the appropriate requests are sent to the L2 cache RAM 436. The return data buffer 428, the missed read request table 422420, the missed write request table 420422, the L2 R/W arbiter 434, and the L2 cache RAM 436 are discussed in greater detail with reference to
Given the four-bank structure of
Recalling from the data structure described above, the incoming data to the L2 cache 210 comprises a 32-bit address portion and a 512-bit data portion. Given this, the incoming requests, Xin CH0 and Xin CH1, are each divided into two portions, namely, a 32-bit address portion and a 512-bit data portion. The 32-bit address portion for Xin CH0 is placed in the buffer address0502, while the 512-bit Xin CH0 data is placed in the write data buffer 508. The write data buffer 508, for this embodiment, holds up to four entries. Similarly, the 32-bit address portion for Xin CH1 is placed in the buffer address1504, and the 512-bit Xin CH1 data is placed in the write data buffer 508.
If there are any pending entries, then those pending entries are held in the pending request queue 506. In order to determine whether or not various requests (or entries) can be merged, the various addresses in the pending request queue 506 are compared with the addresses in buffers address0502 and address1504. For some embodiments, five comparators 510a . . . 510e are employed to compare different permutations of addresses. These comparators 510a . . . 510e identify whether or not the entries within those buffers can be merged.
Specifically, in the embodiment of
A second comparator 510b compares a current address for the Xin CH1 data (designated as “cur1”), which is in the address1 buffer 504, with pre0. If cur1 matches pre0, then the merge request entries logic 512 merges cur1 with pre0, and the update request queue logic 514 updates the pending request queue 506 with the return destination ID and address of the merged entry or request.
A third comparator 510c compares cur0 with a previous address for Xin CH1 (designated as “pre1”). If cur0 and pre1 match, then the merge request entries logic 512 merges cur0 with pre1, and the update request queue logic 514 updates the pending request queue 506 with the return destination ID and address of the merged entry or request.
A fourth comparator 501d compares cur1 and pre1. If there is a match between cur1 and pre1, then cur1 and pre1 are merged by the merge request entries logic 512. The pending request queue 506 is then updated by the update request queue logic 514 with the return destination ID and address of the merged entry or request.
If none of the previous entries (pre0 and pre1) in the queue match the incoming request (cur0 and cur1), then a new entry is added into the queue.
A fifth comparator 510e compares cur0 and cur1 to determine if the two incoming requests match. If the two incoming requests are on the same cache line, then those incoming requests are merged by the merge request entries logic 512. In other words, if the two incoming requests match, then they are merged. The destination ID and address of the merged requests are updated in the pending request queue 506 by the update request queue logic 514.
Since the embodiment of
As noted above, L2 cache 210 also includes a write data buffer 508, which holds write request data from the crossbar 220. For the embodiment of
The L2 cache 210 of
As described with reference to
If there is a hit on the L2 cache 210, then the address is sent to the next stage along with the word selections, offsets, return destination IDs, and addresses of up to four requests attached to the hit test entry. If there is a miss on the L2 cache 210, then the line address and other request information is written into a 64-entry miss request table 530. Similarly, if there is a hit-on-miss (described below), then the line address and other request information is written into the 64-entry miss request table 530. Data structures for both a missed read request table 422 and a missed write request table 420 are discussed in greater detail with reference to
Unlike the missed read request table 422, conventional caches often employ a latency FIFO. Such latency FIFOs place all requests within the FIFO. Thus, regardless of whether or not there is a hit on the cache, all of the requests are directed through the latency FIFO in conventional caches. Unfortunately, in such conventional latency FIFOs, all requests will wait for the entire cycle of the latency FIFO regardless of whether or not those requests are hits or misses. Thus, for a latency FIFO (which is about 200 entries deep), a single read miss can result in undesired latency for subsequent requests. For example, if there is a first read miss on cache line 0, but read hits on cache lines 1 and 2, then, for a latency FIFO, the read requests on cache lines 1 and 2 must wait until the read request on cache line 0 clears the latency FIFO before the cache realizes that there is a read miss.
The missed read request table 422 permits pass-through buffering of hit read requests, despite the presence of missed read requests. Thus, when there is a read miss on the L2 cache 210, that read miss is buffered through the missed read request table 422, and all other read requests are passed through. For example, if there is a first read miss on cache line 0, but read hits on cache lines 1 and 2, then, for the missed read request table 422, the read miss on cache line 0 is buffered to the missed read request table 422, while the read requests on cache lines 1 and 2 are passed through the L2 cache 210. Specific embodiments of the missed read request table 422 are provided below.
In the embodiment of
If there is a read miss in the L2 cache 210, the missed read request table 422 is searched, and a free entry is selected to store the CL and other information related to the request (e.g., U7, E7, T7, CRF, S7, TS7, etc.). In addition to storing the CL and other related information, the 2-bit miss pre-counter (MR) of the selected cache line is incremented, and the value of the counter is copied into the table entry.
If there is a read hit in the L2 cache 210, and the pre-counter and post-counter are not equal (“hit-on-miss”), then a new entry is created in the missed read request table 422. For the hit-on-miss, the pre-counter of the selected cache line is not incremented.
If there is a read hit on the L2 cache 210, and the pre-counter equals the post-counter (“hit”), then no new entry is created in the missed read request table 422, and the request is sent directly for read by the L2 cache RAM 436.
Conventional caches typically provide for write-through, which accesses external memory to retrieve the data associated with the write miss. Unfortunately, such write-through mechanisms result in added data traffic to and from the memory. This added data traffic is relatively inefficient.
Unlike conventional write-through mechanisms, the missed write request table 420 of
In the embodiment of
If there is a write miss in the L2 cache 210, then the missed write request table 420 is searched, and a free entry is selected to store the cache line address (CL) and a corresponding update write mask. The 2-bit miss pre-counter (MR) of the selected cache line is incremented, and the value of the counter is copied into the missed write request table 420.
If the miss pre-counter is equal to the miss post-counter before the increment (“first-write-miss”), then the write data is sent to the L2 cache RAM 436 directly, along with the original write mask. If the miss pre-counter is not equal to the miss post-counter before the increment (“miss-on-miss”), then the return data buffer 428 is searched to find a free entry to hold the write data. The structure of the return data buffer 428 is described in greater detail with reference to
If there is a write hit in the L2 cache 210, and the pre-counter is unequal to the post-counter (“hit-on-miss”), then the missed write request table 420 is searched to find a matched entry with the same cache line address (CL) and miss count (MR). If such an entry is found, then the update write mask is merged with the original write mask that is found in the missed write request table 420.
Concurrent with the searching of the missed write request table 420, the return data buffer 428 is searched for an entry with the same cache line address (CL) and miss count (MR). If such a match is found in the return data buffer 428 (“hit-on-miss-on-miss”), then the write data is sent to the return data buffer 428. However, if no such match is found in the return data buffer 428 (“hit-on-miss”), then the write data is sent to the L2 cache RAM 436, along with the merged update write mask.
If there is a write hit in the L2 cache 210, and the pre-counter equals the post counter (“write hit”), then the write data is sent to the L2 cache RAM 436 directly, along with the original write mask. For all write hit requests, the miss pre-counter (MR) is not incremented.
For some embodiments, if a replaced line in a read miss or a write miss is dirty, then the hit test unit 418 first issues a read request to read the dirty line from the MXU 205. Thereafter, the write data is sent during the next cycle.
After the hit test arbitration stage, various entries and requests are arbitrated and sent to the L2 cache RAM 436. These entries include read/write requests from the hit test stage, read requests from a miss request FIFO, and write requests from the MXU 205. In the event that requests from different sources go to the same bank in the same cycle, the MXU write request has the highest priority in this embodiment. Also, for this embodiment, the miss request FIFO has the second highest priority, and the hit test results have the lowest priority. As long as requests from the same source are directed to different banks, those requests can be arranged out of order in order to maximize throughput.
For some embodiments, the output arbitration on the return data can be performed in a round-robin fashion by the output arbiter 450. For such embodiments, the returned data can include the read requests from the crossbar (Xin CH0 and Xin CH1), the read request from the vertex cache (VC), and the read request from the T# registers (TAG/EUP). Since, as noted above, each entry can hold up to four requests, it can take up to four cycles to send the data to the appropriate destinations before the entry is removed from the output buffer.
Upon a cache miss, a request to the MXU 205 is sent to the pending MXU request FIFO 424. For some embodiments, the pending MXU request FIFO 424 includes up to 16 pending request entries. In the embodiments of
Upon an L2 cache write miss, if the pre-counter and post-counter numbers are not equal prior to increment (“miss-on-miss”), then the return data buffer 428 is searched to find a free entry to hold the partial write data. Upon an L2 cache read miss-on-miss, the return data buffer 428 is searched to find a free entry to receive the returned data from the MXU 205. The selected entries are marked with the cache address line number (CL) and a miss pre-count (MR). If all three slots (1, 2, 3) for miss-on-miss requests have been allocated, then the hit-testing stage will, for some embodiments, be stopped.
When returned data from the MXU 205 arrives in the return data buffer 428, the three slots (1, 2, 3) are searched to find a match with the same cache address line number (CL) and miss count (MR). If none of those match the incoming returned data, then the incoming returned data is stored in the bypass slot (0). That stored data is then sent to the L2 cache RAM 436 during the next cycle, along with the update write mask specified in the missed write request table 420. If, however, a match is found, then the data is merged with the entries in the buffer according to the update write mask for a write-miss-initiated memory request. It should be noted that the data is filled in the buffer directly for a read-miss-initiated memory request.
For some embodiments, the order written to the L2 cache 210 is kept as only for the data that has the same cache address. Other data for different cache lines is written into the L2 cache when that data becomes ready.
When a data entry is read from the return data buffer 428 and sent to the L2 cache RAM 436, a new entry is added to the return request queue 430 to store the cache line address (CL) and the miss count (MR). Additionally, all of the valid bits (B0V, B1V, B2V, B3V) are initialized, for example, by setting all valid bits to “1.”
There are four return request control state machines 432, one for each bank. Each return request control state machine 432 reads the first table entry for which the valid bit has been correspondingly set. For example, the first state machine, which corresponds to the first bank, reads the first entry in which B0V is set to “1”; the second state machine reads the first entry in which B1V is set to “1”; and so on. At each cycle, the state machines then use the cache line address (CL) and the miss count (MR) to search the missed read request table 422 for a match. If there is a match, then the matched entry is processed and the request is sent to the L2 R/W arbiter 434.
For some embodiments, the request that is sent to the L2 R/W arbiter 434 has a lower priority than a write request from the return data buffer 428, but a higher priority than a request from the hit test unit 418. After the request to the L2 R/W arbiter 434 is granted access to the L2 cache RAM 436 for read, the entry is released and marked as invalid (bit set to “0”).
After all matched entries in a given bank (identified by CL and MR) of the missed read request table 422 are processed, the valid bits of the corresponding entries in the return request queue 430 are set to “0.”When all four valid bits of an entry are reset to “0,” the miss post-counter for the line is incremented, and the entry in the return request queue 430 is removed. In other words, when the pending request for all four banks of a particular line are served, the miss post-counter of the line is incremented, and the entry in the return queue 430 is removed.
The return data buffer 428 is searched with the updated miss counter value (MR). If a match is found in the slots for the miss-on-miss requests, then the data entry of the slot is moved into the L2 cache RAM 436, and a new entry is added to the return request queue 430.
As shown with reference to
Additionally, the missed read request table 422 and the missed write request table 420 permit faster processing compared to conventional latency FIFOs that suffer from latency problems.
The various logic components are preferably implemented in hardware using any or a combination of the following technologies, which are all well known in the art: a discrete logic circuit(s) having logic gates for implementing logic functions upon data signals, an application specific integrated circuit (ASIC) having appropriate combinational logic gates, a programmable gate array(s) (PGA), a field programmable gate array (FPGA), etc.
Although exemplary embodiments have been shown and described, it will be clear to those of ordinary skill in the art that a number of changes, modifications, or alterations to the disclosure as described may be made. For example, while specific bit-values are provided with reference to the data structures in
Additionally, while four-bank embodiments are shown above, it should be appreciated that the number of data banks can be increased or decreased to accommodate various design needs of particular processor configurations. Preferably, any number that is a power of 2 can be used for the number of data banks. For other embodiments, the configuration need not be limited to such numbers.
All such changes, modifications, and alterations should therefore be seen as within the scope of the disclosure.