The invention itself, as well as a preferred mode of use, further objects, and advantages thereof, will best be understood by reference to the following detailed description of an illustrative embodiment when read in conjunction with the accompanying drawings, wherein:
The present invention provides a method and an apparatus for enabling a prefetch engine to detect and support hardware prefetching with different patterns, such as both unit and non-unit stride streams, in both virtual and physical address accesses. Multiple (simple) history tables are provided within (or associated with) the prefetch engine. Each of the multiple tables is utilized to detect different access patterns. The tables are indexed by different parts of the physical address and are accessed in a preset order to reduce the interference between different patterns. When the detected stream does not fit the patterns of a first table, the stream is passed to the next table and subsequent tables to be checked for a match of different patterns of the second table and subsequent tables until to the last table in the sequence. In this manner, multiple different patterns may be detected utilizing the multiple tables.
Referring now to the drawings and in particular to
Also illustrated within each of CPU 102 and L1 104 and L2 caches 106 of
As utilized herein, the terms prefetch/prefetching refer to the method by which data that is stored in one memory location of the memory hierarchy (i.e., lower level caches 106 or memory 108) is transferred to a higher level memory location that is closer (yields lower access latency) to the CPU processor, before the data is actually needed/demanded by the processor. More specifically, prefetching as described hereinafter, refers to the early retrieval of data from one of the lower level caches/memory to a higher level cache or the CPU (not shown) before the CPU 102 issues a demand for the specific data being returned. Lower level caches may comprise additional levels, which would then be sequentially numbered, e.g., L3, L4. In addition to the illustrated memory hierarchy, data processing system 100 may also comprise additional storage devices that form a part of memory hierarchy from the perspective of CPU 102. Storage device may be one or more electronic storage media such as a floppy disk, hard drive, CD-ROM, or digital versatile disk (DVD). Storage device may also be the cache, memory, and storage media of another CPU in a multiprocessor system.
Those skilled in the art will further appreciate that there are other components that might be utilized in conjunction with those shown in the block diagram of
Also, while an illustrative embodiment of the present invention has been, and will continue to be, described in the context of a fully functional data processing system, those skilled in the art will appreciate that software aspects of an illustrative embodiment of the present invention are capable of being distributed as a program product in a variety of forms, and that an illustrative embodiment of the present invention applies equally regardless of the particular type of signal bearing media used to actually carry out the distribution.
Turning now to
Also illustrated within reference prediction table 207 is reference/stream prediction logic 203, which is utilized to predict future references based on issued references. Further, within active streams table 217 is prefetch request issue logic 213, which is utilized to send out prefetch requests at appropriate times. Both logic components represent the two primary components of the PE 103. Extra logic/table may be added to the reference/stream prediction logic 203 in order to enable the functionality of the multiple history table implementation described herein.
In conventional systems, the reference/stream prediction logic utilizes one table to store a certain number of previous references in each entry and initiate an active stream in the issue logic if some pattern is detected. Different types of applications exhibit different access patterns, and in conventional applications, a few different kinds of tables have been proposed to detect different types of access patterns. However, there is no one table that is able to work efficiently for all access patterns.
Unlike the conventional prefetch engines, PE 103 and Reference/Stream prediction logic 203 are configured with additional logic. Additionally, the present invention provides additional history tables that are ordered for sequential access based on a check of simpler patterns at the first and more complicated patterns at subsequent tables in the sequence. The functionality provided by the invention enables the data prefetch mechanisms within PE 103 to simultaneously support multiple patterns with very little additional hardware or cost to the overall system.
Within the illustration, physical address is depicted having a “Least Significant Bit” (LSB) and a “Most Significant Bit” (MSB). The illustration thus assumes a big endian machine, although the features of the invention are fully applicable to a little endian machine as well. Within the Physical address 301 are index bits, namely idx-l and idx-s, which respectively represent the index for the large stride table and the simple pattern table. The large stride table is indexed by bits within “idx-l”, which includes more significant bits than “idx-s”. In an embodiment having more than two history tables, additional indices are provided to access the specific tables.
The value of “idx-s” and “idx-l” basically determine how large a region to check for access patterns. Using different bits enables the prefetch engine to look into small regions for unit and small non-unit strides and to look into large regions for large strides. Use of different bits also avoids the interferences among simple patterns, and between simple patterns and large strides. This avoidance of interference then enables the PE to successfully detect both simple pattern and large stride streams.
As an example, assuming that “idx-s” begins at the 12th least significant bit and “idx-l” begins at the 20th least significant bit, the logic within the prefetch engine checks each 4-kilobyte region for simple patterns and then each 1-megabyte region for large strides. With this configuration of the physical address, the logic of the PE will successfully detect address sequence 0x0, 0x80, 0x1000, 0x1080, 0x2000, 0x2080, . . . as two streams (1) 0x0, 0x1000, 0x2000, . . . , and (2) 0x80, 0x1080, 0x2080, . . . , with a stride of 0x1000 for both streams. On the contrary, a one-table mechanism will not be able to detect either of the two streams. The two-table prefetch engine will also detect address sequence 0x0, 0x20000, 0x1, 0x30000, 0x2, 0x40000, . . . as two streams (1) 0x0, 0x1, 0x2, . . . and (2) 0x20000, 0x30000, 0x40000, . . . , with stride of 0x1 and 0x10000 respectively, while a conventional one-table prefetch engine can detect only one stream, 0x0, 0x1, 0x2, . . .
According to the illustrated logic of
Thus, when an address is received, the first table (with lower significant index bits) in the ordered sequence of tables is initially accessed. If the prefetch logic does not detect a stride within the first table, then the address is passed/forwarded to the second table (with higher significant index bits) and the prefetch logic checks the second table to detect a stride, which would be larger, if any. Thus, only accesses that do not belong to the first table ever get passed to the second table, and so on, until the last table in the ordered sequence of tables is checked. The sequential checking of tables eliminates the likelihood of interference between different patterns and also enables each table to be a simple yet efficient design.
It is important to note that although the present invention has been described in the context of a data processing system, those skilled in the art will appreciate that the mechanisms of the present invention are capable of being distributed as a program product in a variety of forms, and that the present invention applies equally regardless of the particular type of signal bearing media utilized to actually carry out the distribution. Examples of signal bearing media include, without limitation, recordable type media such as floppy disks or compact discs and transmission type media such as analog or digital communications links.
While the invention has been particularly shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
This invention was made with Government support under Agreement No. NBCH30390004 with the United States Defense Advanced Research Projects Agency (DARPA). The U.S. Government has certain rights to this invention.