WO2022021158A1 - 缓存系统、方法和芯片 - Google Patents

缓存系统、方法和芯片 Download PDF

Info

Publication number
WO2022021158A1
WO2022021158A1 PCT/CN2020/105606 CN2020105606W WO2022021158A1 WO 2022021158 A1 WO2022021158 A1 WO 2022021158A1 CN 2020105606 W CN2020105606 W CN 2020105606W WO 2022021158 A1 WO2022021158 A1 WO 2022021158A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
cache
page
memory
information
Prior art date
Application number
PCT/CN2020/105606
Other languages
English (en)
French (fr)
Inventor
张乾龙
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2020/105606 priority Critical patent/WO2022021158A1/zh
Priority to CN202080101464.5A priority patent/CN115668156A/zh
Publication of WO2022021158A1 publication Critical patent/WO2022021158A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems

Definitions

  • the embodiments of the present application relate to the field of cache technologies, and in particular, to a cache system, method, and chip.
  • On-chip memory Die-stacked DRAM
  • TSV through silicon via
  • on-chip memory can be used as ordinary memory or as a cache of off-chip memory (DDR).
  • DDR off-chip memory
  • the on-chip memory is used as a cache, the granularity of the page is usually used, and a storage space of the same size as a page of data in the off-chip memory is preset in the cache.
  • part of the data of a page in the off-chip memory is usually stored in the corresponding space in the cache.
  • the storage capacity of a page in the cache is 4KB, while a page in the cache only stores 1280B of data. Reduced utilization of storage space in on-chip memory.
  • the cache system, method and chip provided by the present application can improve the utilization rate of the cache space.
  • an embodiment of the present application provides a cache system, the cache system includes a cache, the cache includes a cache for storing data from a memory, and the cache also stores first index information and second index information;
  • the first index information is used to indicate that the first page in the cache saves the data from the second page of the memory;
  • the second index information is used to indicate that the first page saves the data from the memory. data in other pages of memory.
  • the data currently stored in the first page in the cache is the first data stored in the second page in the memory; and before this, the first page in the cache stores data from other pages in the memory (third page or fourth page) saved data.
  • the data stored in the third page in the memory previously stored in the cache page is used as an example to illustrate.
  • the data stored in the first page in the cache is The data stored in the third page in the memory is overwritten, but if the data stored in the second page in the memory does not occupy all the data units in the first page, the part of the data in the third page that should be overwritten is substantially are still stored in the first page, and the second index information is used to point to the data saved from the third page in the memory.
  • the first page in the cache may be cached page A as shown in FIG. 7 .
  • the cache page A may store the data stored in the memory page 01 and the data stored in the memory page 31 as shown in FIG. 2 .
  • the second page in the memory may be the memory page 31 as shown in FIG. 2
  • the first index information may be the index information Index31 stored in the Tag Array as shown in FIG. 4 .
  • the index information Index31 is used to indicate the data stored in the cache page A from the memory page 31 .
  • the data stored in the cache page A from the memory page 31 is shown in FIG. 5 .
  • Other pages in the memory may include memory page 01 as shown in FIG. 2 , and the second index information may be index information Index01 stored in the ghost Cache Table as shown in FIG. 4 .
  • the index information Index01 is used to indicate the data stored in the cache page A from the memory page 01 .
  • the data stored in the cache page A from the memory page 01 is shown in FIG. 6 .
  • the second index information By setting the second index information, it can be avoided that, in some scenarios, less data is stored in a cache page, resulting in low cache utilization, which is beneficial to improve cache space utilization, thereby improving the hit rate of processor data access. In addition, it can also reduce the number of dirty data written back to the memory when the data in the page is overwritten, or reduce the number of data retrieved from the memory when the overwritten data is accessed again, which is beneficial to release the cache and Bandwidth for data transmission between memories, thereby improving data transmission efficiency.
  • the data stored in the first page in the cache in other pages from the memory includes first data and second data, and the first data and all The second data comes from different pages in the memory.
  • the second index information includes multiple pieces; the first one of the multiple pieces of second index information is used to indicate the first data, and the multiple pieces of second index information are used to indicate the first data.
  • the second one of the second index information is used to indicate the second data.
  • the first page from the memory may be the memory page 31, and other pages from the memory may include the memory page 01 and the memory page 21 shown in FIG. 2 .
  • the data in the memory page 01, the memory page 21 and the memory page 31 may be simultaneously stored in the cache page A as shown in FIG. 4 .
  • the above-mentioned first data is the data saved in the memory page 01 saved in the cache page A
  • the above-mentioned second data is the data saved in the memory page 21 saved in the cache page A.
  • the index information used to indicate the data saved in the memory page 31 saved in the cache page A can be stored in the tag array Tag Array as shown in FIG. 4 , used to indicate the index information of the first data and used to indicate the second data.
  • the index information can be stored in the ghost Cache Table as shown in Figure 4.
  • the first index information includes the following information: label information, valid bit information, and dirty bit information.
  • the second index information includes the following information: label information, valid bit information, dirty bit information, and location information; wherein the location information is used to indicate the The location of the first page in the cache.
  • the position of the first page in the cache here may be, for example, the position in the data array Data Array as shown in FIG. 4 .
  • the position information in the index information Index01 indicating the position of the cache page A in the data array Data Array may be (Way0).
  • the cache system further includes a cache controller, and the cache controller is configured to: update the first index information stored in the cache; obtain the index information in the first page The location information of the idle data unit, and the second index information stored in the cache is updated according to the location information.
  • the cache controller is further configured to: write the dirty data in the overwritten original data in the first page back to the memory or the next-level cache.
  • an embodiment of the present application provides a caching method, the caching method includes: receiving a data access request, and overwriting the original data in the second page of the cache with the data in the first page of the memory according to the data access request data; update the first index information stored in the cache, the first index information is used to record the index of the data in the first page in the second page; obtain the free data in the second page location information of the unit, and update the second index information stored in the cache according to the location information, where the second index information is used to index the original data in the data unit corresponding to the location information in the second page data.
  • the first page in the memory may be the memory page 31 shown in FIG. 2
  • the second page in the cache may be the cache page A shown in FIG. 7 .
  • the cache controller receives a data access request, and the data requested by the data access request is stored in the memory page 31, the memory page can be stored in the memory page based on the mapping relationship between the memory page and the cache page as shown in The data saved in 31 is stored in the cache page A.
  • the above-mentioned first index information is the index information used to record the original data stored in the cache page A in the Tag Array as shown in FIG. 4 .
  • the first index information is the index from the data stored in the memory page 31, because the first index information is recorded in the cache page A previously saved In this case, the first index information needs to be updated.
  • the cache is usually performed in units of data units. Since the cached page A may only cache the data of some of the data units stored in the memory page 31 , there may still be a large number of idle data units in the cached page A at this time. The original data stored in some data units in the large number of free data units is not overwritten, and is still stored in the cache page A.
  • the second index information is updated, and the second index information is used to record the data stored in the cache page A that is not recorded by the first index information.
  • the updating the first index information stored in the cache includes: updating tag information, valid bit information and dirty bit information in the first index information.
  • the obtaining the location information of the free data unit in the second page includes: determining, based on the valid bit information in the updated first index information, The location information of the free data unit in the second page.
  • the updating the second index information stored in the cache according to the location information includes: updating valid bit information and dirty bit information in the second index information bit information; and adding location information for indicating the location of the second page in the cache to the second index information.
  • the method before the data in the first page of the memory overwrites the original data in the second page of the cache, the method further includes: overwriting the second page Dirty data in the overwritten original data in the page is written back to memory or the next level cache.
  • an embodiment of the present application provides a chip, where the chip includes the cache system described in the first aspect.
  • the chip further includes a processor, configured to access the data saved in the cache system, and store the processed data in the cache system.
  • an embodiment of the present application provides a cache device, the cache device includes one or more cache controllers and a memory; the memory is coupled to the cache controller, and the memory is used to store one or more programs; the one or more A cache controller is configured to run the one or more programs to implement the cache method according to the second aspect.
  • an embodiment of the present application provides a readable storage medium, where an instruction is stored in the readable storage medium, and when the instruction is executed on a computer, the instruction is used to execute any one of the caching methods in the second aspect above.
  • embodiments of the present application provide a computer program or computer program product, which, when the computer program or computer program product is executed on a computer, enables the computer to implement any of the caching methods in the second aspect above.
  • FIG. 1 is a schematic structural diagram of a cache system provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of the correspondence between the storage space in the cache and the storage space in the memory provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of a data unit included in a page stored in a cache provided by an embodiment of the present application;
  • FIG. 4 is a schematic structural diagram of a cache provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a data unit included in a page to be stored in a cache provided by an embodiment of the present application
  • FIG. 6 is a schematic diagram of a data unit stored in a cache by a replaced page in a cache provided by an embodiment of the present application;
  • FIG. 7 is a schematic diagram of the storage situation of the cache after page replacement provided by an embodiment of the present application.
  • FIG. 8 is a flowchart of a caching method provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a cache device provided by an embodiment of the present application.
  • references herein to "first,” “second,” and similar terms do not denote any order, quantity, or importance, but are merely used to distinguish the various components. Likewise, words such as “a” or “an” do not denote a quantitative limitation, but rather denote the presence of at least one.
  • module mentioned in this document generally refers to a functional structure divided according to logic, and the “module” can be realized by pure hardware, or realized by a combination of software and hardware.
  • “and/or” describes the association relationship of the associated objects, which means that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist simultaneously, and B exists alone. three situations.
  • words such as “exemplary” or “for example” are used to indicate an example, illustration or illustration. Any embodiments or designs described in the embodiments of the present application as “exemplary” or “such as” should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as “exemplary” or “such as” is intended to present the related concepts in a specific manner.
  • the meaning of "plurality" refers to two or more. For example, multiple processing units refers to two or more processing units; multiple systems refers to two or more systems.
  • FIG. 1 shows a schematic structural diagram of a cache system applied to the present application.
  • the cache system 100 includes a cache controller and a cache.
  • the cache system 100 is coupled with the memory and the processor. Among them, the data required for the operation of the processor is stored in the memory. Part of the data stored in memory is stored in the cache.
  • the processor can initiate data access requests and perform data processing.
  • the memory controller controls the data interaction between the processor and the cache and between the cache and the memory based on the data access request initiated by the processor.
  • the memory shown in FIG. 1 may include a memory controller.
  • the memory controller is used to control other components to write data to or read data from memory.
  • the cache controller can initiate a data exchange request to the memory controller, and under the control of the memory controller, the cache can obtain data from the memory, provide the data to the processor, or write the data back to the memory.
  • the cache controller can detect whether data exists in the cache based on the data access request. If the data accessed by the processor is stored in the cache, the cache controller controls the cache to provide the data to the processor through the bus; if the data accessed by the processor is not stored in the cache, the cache controller needs to send the data to the memory controller to get the data signal to fetch data from memory and provide it to the processor. In addition, data can be written to the cache after being fetched, so that the processor can fetch the data directly from the cache next time.
  • the cache as shown in FIG. 1 may include a multi-level cache structure, such as L1 level, L2 level and L3 level.
  • a multi-level cache structure such as L1 level, L2 level and L3 level.
  • the processor accesses data, it can first access the L1-level cache.
  • the L1-level cache misses it can continue to access the L2-level cache.
  • the L2-level cache misses it can continue to access the L3-level cache.
  • the L3-level cache misses data can be retrieved from memory. That is, for the L1-level cache, the L2-level cache and the L3-level cache are the next-level caches; for the L2-level cache, the L3-level cache is the next-level cache.
  • the L1-level cache, the L2-level cache, and the L3-level cache may be caches with the same cache structure but different data capacities.
  • the caches shown in Figure 1 do not distinguish between L1, L2, and L3 caches.
  • the cache space in each level of cache is allocated with the granularity of pages.
  • the cache space of each level of cache can be divided into multiple pages.
  • the pages in the cache are collectively referred to as cache pages in the following description.
  • a cache page can also be understood as a cache line.
  • the memory storage space can also be divided into multiple pages.
  • the same page in memory is referred to as a memory page in the following description.
  • the storage capacity of a memory page can be the same as the storage capacity of a cache page.
  • Each cache page can correspond to a memory page. That is to say, the data stored in the same cache page can all come from the same memory page. As shown in FIG.
  • FIG. 2 it schematically shows a schematic diagram of the correspondence between the cache space in the cache and the storage space in the memory.
  • the cache includes two ways Way0 and Way1, and each way can store two sets of page data.
  • the memory storage space can be divided into eight memory pages.
  • the data in memory page 01, memory page 11, memory page 21, and memory page 31 can be respectively stored in the cache pages corresponding to the cached group Set0, memory page 02, memory page 12, memory page 22, and memory page 32.
  • the data in can be respectively stored in the cached pages corresponding to the cached group Set1.
  • Way0 stores data in memory page 01 and data in memory page 22
  • Way1 stores data in memory page 21 and memory page 32 .
  • each page in the current cache stores data from the memory.
  • the data in the memory page 31 can only be stored in the Set0 position.
  • the data in memory page 01 and the data in page 21 are currently stored in the cache page corresponding to the position of Set0.
  • the data in the memory page 31 to be cached needs to overwrite the data in the currently cached memory page 01 or the data in the memory page 21, so as to store the data in the memory page 31 to be cached in the cache.
  • the replacement here means that the data in the memory page 31 to be cached is directly stored at the (Set0, Way0) position or the (Set0, Way1) position in the cache to overwrite the currently stored memory page 01 in the cache.
  • FIG. 2 schematically shows a 2-way set-associative cache structure.
  • the cache structure may also be direct associative, fully associative, four-way group associative, eight-way group associative, etc., which is not specifically limited here.
  • the cache space in the cache may be divided into multiple pages according to the setting of way and set as shown in FIG. 2 , for example, the position of (Set0, Way0) may represent a page.
  • Shown in Figure 2 is a schematic diagram of data from memory stored in the cache.
  • the cache space in the cache can also be used to store information such as Tag Array and ghost Cache Table (GHT).
  • GHT Tag Array and ghost Cache Table
  • the data that can be saved by one page in the cache or the memory may be 4KB.
  • a page can be divided into multiple data units (eg, 32 data units).
  • the size of the data that each data unit can store may be, for example, 128B.
  • data access is usually performed in units of data stored in the data unit.
  • a cache page may store data saved by all data units in a memory page, or may store data saved by some data units in a memory page. That is to say, when data in a certain memory page is written into the cache, only the data stored in some data units in the memory page may be cached. As shown in FIG.
  • each grid represents a data unit
  • the grid with shaded stripes represents that the data unit at the position stores data
  • the white grid represents that the data unit at the position does not store data. It can be seen from FIG. 3 that data are stored in 14 data units in the cache page shown in FIG. 3 .
  • the cache provided by the embodiment of the present application stores a data array Data Array, a tag array Tag Array, and a shadow cache table (Ghost Cache Table, GHT) .
  • Data Array Data Array occupies multiple cache spaces.
  • the cache space in the memory may also be regarded as a page.
  • the data unit stored in a page in the cache may come from one page or multiple pages in the memory.
  • the tag array Tag Array is used to store the first index information, and the first index information records the index information of the first data stored in the cache page.
  • the shadow cache table is used to store the second index information.
  • the second index information records the index information of the second data stored in the same cache page and not recorded by the first index information.
  • the first data and the second data come from different memory pages. That is to say, in the same cache page, the first data and the second data may be stored at the same time, the first data comes from the first memory page, and the second data comes from the second memory page.
  • the same cache page may also store third data, where the third data comes from the third memory page; the shadow cache table may also be used to store third index information.
  • the third index information is index information of the third data stored in the same cache page.
  • the data currently stored in the cache page is the first data from the first memory page; and before this, the data stored in the cache page is from the second memory page or the third memory page data in .
  • the data in the second memory page previously stored in the cache page is used as an example for description.
  • the data in the second memory page stored in the cache is However, if the data in the first memory page does not occupy all the data units in the first memory page, part of the data in the second memory page that should be overwritten is still stored in the cache page. , and the second index information is used to point to the data from the second memory page.
  • the first index information and the second index information By setting the first index information and the second index information, it is possible to avoid low cache utilization due to less data stored in a cache page in some scenarios, which is beneficial to improve cache space utilization, thereby improving processor data access hits Rate. In addition, it can also reduce the number of dirty data written back to the memory when the data in the page is overwritten, or reduce the number of data retrieved from the memory when the overwritten data is accessed again, which is beneficial to release the cache and Bandwidth for data transmission between memories, thereby improving data transmission efficiency.
  • FIG. 4 schematically shows a schematic structural diagram of the cache as shown in FIG. 1 provided by an embodiment of the present application.
  • the cache shown in FIG. 4 may include a data array, a data array, a tag array, and a shadow cache table (Ghost Cache Table, GHT).
  • GHT shadow cache table
  • the tag array Tag Array and the data array Data Array are set separately.
  • the physical address (0 ⁇ 0x7FFFFF) in the cache is the storage location of the tag array Tag Array, and starting from 0x800000 is the physical address of the data array Data Array.
  • the physical address of the index information in the tag array Tag Array is bound with the physical address of the corresponding data, for example, 8 bytes are used to store the index information, and the 4K bytes after the 8 bytes are used for to store data.
  • the position of the corresponding index information in the Tag Array is fixed.
  • the stored data can be directly read from the back of the index information.
  • the mapping relationship between the cache location in the tag array Tag Array and the page in the data array Data Array can be established in advance. For example, when the index information is stored at the physical address (0-0x00007), the data unit that can be indexed by the index information is stored at the page position corresponding to (0x800000-0x801000).
  • index information Index01 is stored in the tag array Tag Array (Set0, Way0), and the data that can be indexed by the corresponding index information Index01 is stored in the data array Data Array (Set0, Way0) ) at the corresponding page location.
  • the tag array Tag Array and the data array Data Array can be respectively an array of m*n, each element in the tag array Tag Array is an index information, and each element in the data array Data Array is a cache page.
  • FIG. 4 schematically shows that the tag array Tag Array and the data array Data Array are 2*2 arrays.
  • each column represents a Way, and each row represents a set of Sets.
  • memory pages have a mapping relationship with cache pages.
  • the data saved by multiple memory pages can be stored in the cache pages corresponding to the same set of Sets in the cache at the same time (for example, the data saved by memory page 01, memory page 11, memory page 21 and memory page 31 in FIG. 2 can be stored in Cached page A and cached page B shown in Figure 4).
  • the data stored in the cache pages corresponding to the same set of Sets have a competitive relationship.
  • each set of Sets can be set with multiple Ways.
  • the cache pages corresponding to the multiple Ways have no data to store, the data stored in the memory pages mapped to the same set of Sets can be stored in the set.
  • How many Ways there are in the cache means how many way groups are associated.
  • FIG. 4 schematically shows that the cache adopts a two-way set associative manner.
  • the elements in the tag array Tag Array are in one-to-one correspondence with the elements in the data array Data Array, and the index information in the tag array Tag Array is at least the data stored in the corresponding cache page in the data array Data Array. Index information for part of the data.
  • the index information Index01 is the index information of the cached data in memory page 01; when cache page A stores both the data in memory page 01 and the memory When there is data in page 11, the index information Index01 can be the index information of the data in the cached memory page 01, or it can also be the index information of the data in the cached memory page 11, another part of the cached page A
  • the index information of the data can be stored in the shadow cache table.
  • Each index information may include tag (Tag) information, least recently used (LRU) information, valid bit (Valid Bits) information and dirty bit (Dirty Bits) information.
  • Tag information is used to indicate the physical address information in the memory of the memory page from which the data stored in the cache page comes and the group set information corresponding to the cache page to which the data is stored.
  • the data from the same memory page has the same Tag information. Since the data stored in the cache page recorded by one index information all come from the same memory page, each cache page may correspond to one Tag information.
  • the least recently used (LRU) information is used to indicate the least recently used data in the cached page;
  • the dirty bit (Dirty Bits) information is used to indicate whether the data in the data unit stored in the cached page is dirty Data, if some bits of Dirty Bits are set to 0, it indicates that the data stored in the corresponding data unit is clean data. When replacement occurs, it can be invalid without writing back to off-chip memory. On the contrary, if some bits of Dirty Bits are set to 1 , when the replacement occurs, all the data in the data unit where the corresponding dirty data is located needs to be written back to the off-chip memory.
  • Valid Bits information is used to indicate whether each data unit in the cache page stores valid data.
  • the valid bit information when the valid bit information is 1, it indicates that the data stored in the data unit of the cache page is valid, that is, data storage In the cache; when the valid bit information is 0, it indicates that the data stored in the data unit of the cached page is invalid, that is, the data is not stored in the cache. For example, in FIG. 3 , the valid bit information corresponding to the blank cell is invalid, and no data is stored in the data unit indicated by the blank cell. By looking up the Valid Bits information, you can determine whether the data accessed by the processor is stored in the cache.
  • the cache page for storing the data stored in the memory page 31 is in a full storage state.
  • the starting position of the memory physical address corresponding to memory page 31 is 0x18000 (the maximum amount of data contained in a cache page is 4KB as the granularity and logically divided into multiple memory pages, and memory page 31 is located in the seventh memory page position in memory , its physical address is the starting position of the seventh 4KB), and the physical address is mapped to the position of the group Set0 in the cache as shown in FIG.
  • the mapping relationship between the memory page and the cache page and the storage location of the data stored in the memory page in the cache may refer to the specific description of FIG. 2 , which will not be repeated here.
  • the data stored in the memory page 01 and the memory page 21 are cached in the group Set0.
  • the cache controller may query the index information index01 and index information index21 stored in the tag array Tag Array, and further query the LRU information in the index information index01 and the LRU information in the index information index21. It is assumed that based on the query result, the data stored in the memory page 01 cached by the cache page A is the least recently used data. At this time, the data stored in the memory page 31 can be cached in the cache page A to replace the data stored in the originally cached memory page 01 .
  • the data unit For a data unit in the cache page, if the data unit is used to store the data stored in the memory page 01, then the data unit cannot be used to store the data stored in the memory page 31. Assuming that there is data in the memory page 31 that needs to be stored in the data unit, the data previously stored in the data unit needs to be flushed or overwritten. It is assumed that the data units occupied by the data in the memory page 31 to be stored in the cache are as shown in FIG. 5 . It can be seen from FIG. 5 that the data stored in the memory page 31 to be stored in the cache needs to occupy 12 data units of a cache page.
  • the data unit of A wherein the data stored in the currently cached memory page 01 occupies the data units 0110, 0116, 0118, 0120, 0126, 0128 and 0131 of the cache page A, and the data stored in the memory page 31 to be cached occupies Data units 3110, 3116, 3118, 3120, 3126, 3128, and 3131 of page A are cached. That is to say, when the data stored in the memory page 31 is stored in the above-mentioned data unit of the cache page A, it conflicts with the data stored in the memory page 01 currently stored in the data unit. Except for the above-mentioned conflicting data, the remaining data stored in the cached memory page 01 and the remaining data stored in the page 31 to be cached do not conflict.
  • FIG. 6 it schematically shows that after the data stored in the memory page 31 is stored in the cache page A, the cache page A still stores the data unit of the data stored in the memory page 01 .
  • storing the data stored in the memory page 31 in the cache page A means that the memory page 01 stored in the cache is stored in the cache. All data is cleared.
  • the processor When the processor needs to access the data stored in the memory page 01 again, it needs to retransmit some or all of the data stored in the memory page 01 from the memory to the cache. At this time, the memory page 01 stored in the cache is not The flushed data also needs to be re-read from memory page 01.
  • dirty data exists in the data unit that stores valid data as shown in FIG. 6 , it is also necessary to write all the data stored in the data unit back to the memory or the next-level cache.
  • a shadow cache table (Ghost Cache Table, GHT) is provided, and the shadow cache table records the index information of the data in the same cache page that is not recorded by the tag array.
  • the structure of the shadow cache table is similar to the structure of the Tag Array in the cache, and the shadow cache table in the cache can also be an array structure, for example, it can be an i*j array.
  • Each element is the index information of the data in the same cache page that is not recorded by the tag array, that is, the index information of the data that is not overwritten when the data stored in the cache page is replaced.
  • the size of the shadow cache table is much smaller than the size of the tag array.
  • FIG. 4 it schematically shows a schematic structural diagram of the shadow cache table. In the shadow cache table shown in Figure 4, each column represents a Way, and each row represents a set of Sets. The shadow cache table shown in FIG. 4 adopts a two-way set associative manner. In other scenarios, the shadow cache table may also adopt a 4-way group associative manner, which will not be repeated here.
  • Each index information may include Tag (Tag) information, Dirty Bits (Dirty Bits) information and Valid Bits (Valid Bits) information.
  • Tag information, Dirty Bits information and Valid Bits information have the same meanings as Tag information, Dirty Bits information, and Valid Bits information in the Tag Array, and will not be repeated here.
  • the index information in the shadow cache table also includes location information, which is used to indicate the storage location of the data in the Data Array.
  • the location information may be road (Way) information, or may be (group Set, Way) information.
  • the group set in the shadow cache table and the group set in the data array have a preset mapping relationship.
  • the index information stored in group SetA in the shadow cache table is respectively used to index data stored in each cache page in group set0 in the data array.
  • the index information of the data stored in each cache page in the data array can be stored at any position in the shadow cache table.
  • the cache provided by the present application stores data stored in multiple memory pages and index information of data stored in multiple memory pages.
  • the index information of the data saved in one memory page is stored in the Tag Array, and the index information of the data saved in the other memory pages is stored in the shadow cache table in GCT.
  • the data unit occupied by the data stored in the cached memory page 01 is 010010110100000111110010 01010010 (hexadecimal notation: 0x4b41f252) as shown in Figure 3, which is reflected by the valid bits (Valid Bits) , that is, the summary of all valid data in the cached memory page 01.
  • the valid bits (Valid Bits) of the data unit occupied by the data stored in the memory page 31 to be stored in the cache are 10100000110010010101100001010010 as shown in FIG. 5 (in hexadecimal: 0xa0c95852).
  • each bit represents a data unit
  • 0 represents that data is stored in the data unit
  • 1 represents that no data is stored in the data unit.
  • the cache controller can compare the data unit occupied by the data stored in the cached memory page 01 with the memory page to be cached
  • the data unit occupied by the data stored in 31 determines the data currently stored in the cache page A, the data that will be flushed by the data stored in the memory page 31 to be cached, and the data in the memory page 31 that is not to be cached flushed data.
  • the data that has not been flushed in the cached memory page 01 is shown in Figure 6.
  • the data unit occupied by the data stored in the memory page 01 stored in the cache is 01001011000000001010001000000000 (in hexadecimal notation: 0x4b00c200).
  • the cache controller may update the dirty bits information of the data in the cached memory page 01 based on the data unit occupied by the data stored in the memory page 01. It should be noted that when a certain bit in the valid bits information is zero, the corresponding dirty bits information is also zero; when a certain bit in the valid bits information is one, the corresponding dirty bits information can keep the previous information unchanged. Change.
  • the cache controller before replacing the data stored in the memory page 31 with the data stored in the cached memory page 01, the cache controller also needs to detect the dirty bits of the flushed data in the cached memory page 01 Information; when the cache controller detects that the dirty bits information of the flushed data in the cached memory page 01 is used to indicate that the data is rewritten, it needs to write all the data of the data unit where the rewritten data is located back to the memory or download Level 1 cache.
  • the processor initiates an instruction requesting access to a certain data, and the instruction carries address information of the requested data, and the address information includes tag information Tag1, group information Set0, and the like.
  • the cache controller uses the group information Set0 to retrieve the Tag Array, and finds the index information index01 and index11 in the Set0 group, as shown in Figure 4.
  • the cache controller may continue to find out whether Tag1 is included in one of the index information of index01 and index11. Assuming that the tag information in index01 is Tag1, it means that the tag is hit.
  • the cache controller controls the cache to communicate with the processor so that the processor can fetch data. Assuming that the Valid Bits information corresponding to the data unit where the data requested by the processor is located is invalid, it means that the data is not stored in the cache and needs to be accessed in memory.
  • the cache controller may determine the least recently used data based on the LRU information in the index information Index01 and the index information Index11. Assume that the data stored in the cache page A corresponding to Index01 is the least recently used data.
  • the cache controller can further determine, based on the valid bit information in Index01 and the valid bit information in the index information Index31 of the data in the memory page 31 to be cached, the difference between the data units occupied by the data stored in the cached page A and the Conflicting data units among the data units occupied by the data stored in the memory page 31 to be cached. It is assumed that the conflicting data units are, for example, 0110, 0116, 0118, 0120, 0126, 0128 and 0131 shown in FIG. 3 .
  • the cache controller may change the bit used to indicate the conflicting data unit in the valid bit information in Index01 to invalid.
  • the modified valid bit information is 01001011000000001010001000000000 (hexadecimal: 0x4b00c200).
  • the cache controller needs to modify the dirty bit information in Index01. Since the specific location of the cache page A in the data array is (Set0, Way0), the cache controller may also add information (eg Way information) to Index01 for indicating the storage location of the data in the cache. Finally, the cache controller stores the modified Index01 in the ghost cache table.
  • the cache controller can store the data saved in the memory page 31 to be cached in the cache page A in the data array Data Array at this time, and store the data to be cached
  • the index information of the data stored in the memory page 31 is stored at the (Set0, Way0) position in the tag array Tag Array.
  • the cache controller can control the cache to communicate with the processor so that the processor can access the data held in the cached memory pages 31 .
  • the data currently saved in the cache is as shown in FIG. 7 .
  • Index01 can be stored in any Way of Set0 in the ghost cache table, for example, it can also be stored in WayB.
  • the instruction when the processor initiates an instruction requesting access to a certain data, the instruction carries the address information of the requested data, and the address information includes tag information Tag2 and group information Set0 Wait. It is assumed that the tag information Tag2 is used to indicate the data stored in the memory page 01. Based on the instruction issued by the processor, the cache controller uses the group information Set0 to retrieve the Tag Array, and finds the index information index31 and index11 in the Set0 group. Next, the cache controller may continue to find out whether Tag2 is included in one of the index information of index31 and index11. Since the index information of the data included in the memory page 01 is not stored in the Tag Array, the data access of the processor at this time misses the Tag Array.
  • the cache controller uses the tag information Tag2 to retrieve the ghost cache table (that is, compares the tag information Tag2 with the tag information in the index information stored in the ghost cache table one by one), finds that the index information index01 includes the tag information Tag2, and the Tag hits . It should be noted that retrieving the index information in the tag array Tag Array and retrieving whether the index information in the shadow cache table includes the tag information Tag2 can also be executed in parallel.
  • the cache controller may further query the valid bit information in the index information index01 to determine whether the valid bit corresponding to the data unit where the data requested to be accessed by the processor is located is valid. If valid, the data is stored in the cache. At this time, the cache controller may further check the Way information in the index information index01. It can be seen from FIG. 7 that the data stored in the memory page 01 is stored in Way0, and the way (Way) in the index information index01 is Way0. Thus, the cache controller can control the Data Array to provide the data to be accessed by the processor to the processor through the bus.
  • the cache controller may also add the index information index01 corresponding to the data stored in the cached memory page 01 to the (Set0, Way0) position in the Tag Array, and replace the cached memory page 31 at this time.
  • Index information index31 of the stored data When the index information index01 of the data stored in the memory page 01 is added to the Tag Array, the location information in the index information Index01 can be deleted.
  • the cache controller may initiate a request for accessing the data to the memory controller, and the memory controller may control the memory to provide the data to the cache through the bus based on the request.
  • the cache controller can also control the cache to communicate with the processor so that the processor can obtain data.
  • the cache controller can update the index information index01. For example, the valid bit information, dirty bit information, etc. in the index information index01 are updated.
  • the cache, the cache controller, the memory controller, and the processor may be integrated on the same chip to form a system on chip (SOC, System on chip).
  • the processor and cache can be integrated on the same chip, and the cache controller can be integrated on another chip.
  • the cache can also be integrated with the processor in different chips.
  • the off-chip cache adopts the same storage structure design as the on-chip cache provided by the embodiment of the present application, and has the same implementation as the on-chip cache provided by the embodiment of the present application. function, the off-chip cache should also be considered to fall within the protection scope of the embodiments in this document.
  • an embodiment of the present application further provides a cache method, which is applied to the cache controller as shown in FIG. 1 .
  • FIG. 8 shows a process 800 of the caching method provided by the embodiment of the present application.
  • the process 800 of the caching method includes the following steps:
  • Step 801 Receive a data access request, and overwrite the data in the first page of the memory with the original data in the second page of the cache according to the data access request.
  • the cache controller may first determine whether the data to be accessed is stored in the cache. When the data to be accessed by the processor is not stored in the cache, the data needs to be fetched from memory.
  • the cache controller controls the data stored in the memory to be stored in the cache
  • the cache is usually based on the granularity of data stored in a page in the memory.
  • the cache space in the cache is divided into multiple pages.
  • data of a page in memory is cached, it is usually cached in a cache page that has a mapping relationship with the memory page.
  • Step 802 Update the first index information stored in the cache, where the first index information is used to record the index of the data in the first page in the second page.
  • the data overwrite is usually performed in units of data units. That is to say, each page in the cache can be divided into multiple data units.
  • each page in the cache can be divided into multiple data units.
  • the data of the first page of the memory is stored in the second page of the cache, it needs to be stored in the data unit of the second page. Since the acquired data of the first page may be part of the data but not all the data, when the data is cached in the data unit of the second page, it may not occupy all the data units.
  • the valid bit in the Valid bits information corresponding to the data unit in the first index information is "valid";
  • the valid bit in the Valid bits information corresponding to the data unit in the first index information is "invalid".
  • updating the first index information includes, for example, updating Tag information, LRU information, Valid bits information, Dirty bits information, and the like.
  • the updated Tag information is used to indicate the physical address information of the first page in the memory and the group set information corresponding to the second page where the data from the first page is stored.
  • the updated LRU information is used to indicate the most recent usage of the data stored in the first page to be cached.
  • the updated Valid Bits information is used to indicate which data units in the second page are occupied by the data stored in the first page to be cached.
  • the updated Dirty Bits information is used to indicate whether there is dirty data in the data saved in the first page to be cached.
  • Step 803 Obtain the location information of the free data unit in the second page, and update the second index information stored in the cache according to the location information, where the second index information is used to index the second page.
  • the cache controller may acquire location information of idle data units in the second page that are not occupied by data from the first page. Specifically, the location information of the idle data unit in the second page may be determined based on the valid bit information in the updated first index information. When the data unit indicated by the valid bit information in the first index information is valid, it indicates that the data unit is occupied; when the data unit indicated by the valid bit information in the first index information is invalid, it indicates that the data unit is not occupied.
  • the second index information for indicating the original data in the second page may be updated based on the location information of the free data unit in the second page. Specifically, it can be determined whether the valid bit information in the second index information before the update is used to indicate whether the position of the valid data unit is the position of the above-mentioned idle data unit, and if so, continue to keep the data unit corresponding to the position valid. , if not, change the data unit to invalid. In addition, the dirty bit information in the second index information needs to be updated based on the valid bit information in the updated second index information.
  • location information for indicating the location of the second page in the cache needs to be added to the second index information.
  • the dirty data in the overwritten original data in the second page also needs to be written back to the memory or the next level cache.
  • the Tag information in the previously stored first index information needs to be recorded first, so as to prevent the previous Tag information from being overwritten after the first index information is updated, and it is impossible to record the original data from which page in memory.
  • the cache controller includes corresponding hardware and/or software modules for executing each function.
  • the present application can be implemented in hardware or in the form of a combination of hardware and computer software in conjunction with the algorithm steps of each example described in conjunction with the embodiments disclosed herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functionality for each particular application in conjunction with the embodiments, but such implementations should not be considered beyond the scope of this application.
  • the cache controller may be divided into functional modules according to the foregoing method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one cache control module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that, the division of modules in this embodiment is schematic, and is only a logical function division, and there may be other division manners in actual implementation.
  • FIG. 9 shows a possible schematic diagram of the composition of the cache device 900 involved in the above embodiment.
  • the cache device 900 may include: a receiving module 901 , a first update module 902 and a second update module 903 .
  • the receiving module 901 is used for receiving a data access request, and according to the data access request, the data in the first page of the memory overwrites the original data in the second page of the cache;
  • the first updating module 902 is used for updating The first index information stored in the cache, the first index information is used to record the index of the data in the first page in the second page;
  • the second update module 903 is used to obtain the second The location information of the free data unit in the page, and the second index information stored in the cache is updated according to the location information, and the second index information is used to index the data corresponding to the location information in the second page.
  • the original data in the data unit is used for receiving a data access request, and according to the data access request, the data in the first page of the memory overwrites the original data in the second page of the cache;
  • the first updating module 902 is used for updating The first index information stored in the cache, the first index information is used to record the index of the data in the first page in the second page;
  • the first update module 902 is further configured to: update label information, valid bit information and dirty bit information in the first index information.
  • the second update module 903 is further configured to: determine the location information of the idle data unit in the second page based on the valid bit information in the updated first index information.
  • the second update module 903 is further configured to: update the valid bit information and dirty bit information in the second index information; The location information describing the location of the second page in the cache.
  • the cache device 900 further includes: a write-back module (not shown in the figure), configured to write the dirty data in the overwritten original data in the second page back to the memory or the next page level cache.
  • a write-back module (not shown in the figure), configured to write the dirty data in the overwritten original data in the second page back to the memory or the next page level cache.
  • the cache device 900 provided in this embodiment is configured to execute the cache method executed by the cache controller shown in the cache system 100, and can achieve the same effect as the above implementation method.
  • the cache apparatus 900 may include a cache controller and a memory.
  • the cache controller may control and manage the actions of the cache apparatus 900, for example, may be used to support the cache apparatus 900 to perform the steps performed by the foregoing modules.
  • the memory may be used to support the execution of the cache device 900 to store program codes and data, and the like.
  • the cache controller may implement or execute various exemplary logic modules described in connection with the present disclosure.
  • the cache controller can also be a combination of computing functions, including, for example, an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistors Logic devices, or discrete hardware components, etc.
  • ASIC application specific integrated circuit
  • FPGA off-the-shelf programmable gate array
  • other programmable logic devices discrete gates or transistors Logic devices, or discrete hardware components, etc.
  • the memory mentioned in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory may be a read-only memory (Read-Only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electrically programmable read-only memory (Erasable PROM, EPROM). Erase programmable read-only memory (Electrically EPROM, EEPROM) or flash memory.
  • Volatile memory may be Random Access Memory (RAM), which acts as an external cache.
  • RAM Static RAM
  • DRAM Dynamic RAM
  • SDRAM Synchronous DRAM
  • SDRAM double data rate synchronous dynamic random access memory
  • Double Data Rate SDRAM DDR SDRAM
  • enhanced SDRAM ESDRAM
  • synchronous link dynamic random access memory Synchlink DRAM, SLDRAM
  • Direct Rambus RAM Direct Rambus RAM
  • This embodiment also provides a computer-readable storage medium, where computer instructions are stored in the computer-readable storage medium, and when the computer instructions are executed on the computer, the computer executes the above-mentioned relevant method steps to implement the caching method in the above-mentioned embodiment. .
  • This embodiment also provides a computer program product, which, when the computer program product runs on a computer, causes the computer to execute the above-mentioned relevant steps, so as to implement the caching method in the above-mentioned embodiment.
  • embodiments of the present application also provide a cache device, which may specifically be a chip, a component or a module, and the cache device may include a coupled cache controller and a memory; wherein the memory is used to store computer execution instructions, and when When the apparatus is running, the cache controller can execute the computer-executed instructions stored in the memory, so that the chip executes the above-mentioned cache method.
  • the cache controller, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, for the beneficial effects that can be achieved, reference may be made to the provided above. The beneficial effects in the corresponding method are not repeated here.
  • the disclosed caching apparatus and method may be implemented in other manners.
  • the device embodiments described above are only illustrative.
  • the division of modules is only a logical function division.
  • there may be other division methods for example, multiple modules or components may be combined or integrated.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices may be in electrical, mechanical or other forms.
  • Units described as separate components may or may not be physically separated, and components shown as units may be one physical unit or multiple physical units, that is, may be located in one place, or may be distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium.
  • a readable storage medium includes several instructions to make a device (which may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned readable storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc. that can store program codes. medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

本申请实施例提供了一种缓存系统、方法和芯片,该缓存系统包括:缓存,缓存用于保存来自内存中的数据,缓存中还保存有第一索引信息和第二索引信息;第一索引信息用于指示缓存中的第一页面保存的来自内存的第二页面中的数据;第二索引信息用于指示第一页面保存的来自内存的其他页面中的数据,本申请实施例所示的缓存系统可以提高数据传输效率和缓存利用率。

Description

缓存系统、方法和芯片 技术领域
本申请实施例涉及缓存技术领域,尤其涉及一种缓存系统、方法和芯片。
背景技术
随着芯片工艺技术的发展,内存的实现介质也越来越多样化。片上内存(Die-stacked DRAM)是为解决内存的访存带宽问题所提出的一种新技术。其中,可以通过硅通孔(through silicon via,TSV)技术把大容量存储芯片与处理器封装在同一个系统级芯片Soc上,以实现片上大容量内存。以2.5D或者3D封装的DRAM为例,有数据表明,片上内存的带宽可以达到片外双倍速率动态随机存储器(double data rate DRAM,DDR DRAM)的4~8倍。
当前技术中,片上内存可以作为普通内存使用,也可以作为片外内存(DDR)的缓存使用。当片上内存作为缓存使用时,通常以页面为粒度,在缓存中预先设置与片外内存一个页面数据相同大小的存储空间。此外,将内存中的页面存储在缓存中时,通常将片外内存中一个页面的部分数据存储在缓存中相应空间位置处。例如,缓存中一个页面的存储容量为4KB,而缓存中某一页面仅存储有1280B的数据。降低了片上内存中存储空间的利用率。
由此,如何提高片上内存中存储空间的利用率成为大容量缓存需要解决的问题。
发明内容
本申请提供的缓存系统、方法和芯片,可以提高缓存空间的利用率。
为达到上述目的,本申请采用如下技术方案:
第一方面,本申请实施例提供一种缓存系统,该缓存系统包括缓存,所述缓存包括用于保存来自内存中的数据,所述缓存中还保存有第一索引信息和第二索引信息;所述第一索引信息用于指示所述缓存中的第一页面保存的来自所述内存的第二页面中的数据;所述第二索引信息用于指示所述第一页面保存的来自所述内存的其他页面中的数据。
在本发明实施例中,缓存中第一页面当前保存的数据是来自内存中第二页面保存的第一数据;而在这之前,缓存中第一页面保存的是来自内存中其他页面(第三页面或第四页面)保存的数据。这里以缓存页面中之前保存的是内存中第三页面保存的数据为例进行说明,在将内存中第二页面保存的数据写入缓存中第一页面的过程中,缓存中第一页面保存的内存中的第三页面保存的数据被覆盖,但是如果内存中第二页面保存的数据并没有占据全部的第一页面中的数据单元,就会应该被覆盖的第三页面中的部分数据实质上仍然被保存在所述第一页面中,而第二索引信息就用于指向这些来自内存中第三页 面保存的数据。
缓存中的第一页面可以是如图7所示的缓存页面A。该缓存页面A中可以存储有如图2所示的内存页面01中保存的数据和内存页面31中保存的数据。内存中的第二页面可以为如图2所示的内存页面31,第一索引信息可以为如图4所示的标签阵列Tag Array中存储的索引信息Index31。索引信息Index31用于指示缓存页面A中所保存的来自内存页面31中的数据。缓存页面A中所保存的来自内存页面31中的数据如图5所示。内存中的其他页面可以包括如图2所示的内存页面01,第二索引信息可以为如图4所示的影子缓存表Ghost Cache Table中存储的索引信息Index01。索引信息Index01用于指示缓存页面A中所保存的来自内存页面01中的数据。缓存页面A中所保存的来自内存页面01中的数据如图6所示。
通过设置第二索引信息,可以避免某些场景下,一个缓存页面中存储较少的数据导致缓存利用率低,有利于提高缓存空间利用率,进而提高处理器数据访问的命中率。此外,还可以减少发生页面中的数据被覆盖时、写回内存的脏数据的数目,或者减少再一次访问该被覆盖的数据时、从内存中取回的数据的数目,有利于释放缓存与内存之间进行数据传输的带宽,从而提高数据传输效率。
基于第一方面,在一种可能的实现方式中,所述缓存中的第一页面保存的来自所述内存的其他页面中的数据包括第一数据和第二数据,所述第一数据和所述第二数据来自于所述内存中的不同页面。
基于第一方面,在一种可能的实现方式中,所述第二索引信息包括多个;所述多个第二索引信息中的第一个用于指示所述第一数据,所述多个第二索引信息中的第二个用于指示所述第二数据。
具体的,来自内存的第一页面可以为内存页面31,来自内存的其他页面可以包括图2所示的内存页面01和内存页面21。此时,如图4所示的缓存页面A中可以同时保存有内存页面01、内存页面21和内存页面31中的数据。上述第一数据即为缓存页面A中保存的内存页面01中保存的数据,上述第二数据即为缓存页面A中保存的内存页面21中保存的数据。用于指示缓存页面A中保存的内存页面31中保存的数据的索引信息可以存储在如图4所示的标签阵列Tag Array中,用于指示第一数据的索引信息和用于指示第二数据的索引信息可以存储在如图4所示的影子缓存表Ghost Cache Table中。
基于第一方面,在一种可能的实现方式中,所述第一索引信息包括以下信息:标签信息、有效位信息和脏污位信息。
基于第一方面,在一种可能的实现方式中,所述第二索引信息包括以下信息:标签信息、有效位信息、脏污位信息和位置信息;其中,所述位置信息用于指示所述第一页面在所述缓存中的位置。
这里的缓存中的第一页面在缓存中的位置例如可以为在如图4所示的数据阵列Data Array中的位置。例如,图7中,索引信息Index01中指示缓存页面A在数据阵列Data Array中的位置的位置信息可以为(Way0)。
基于第一方面,在一种可能的实现方式中,所述缓存系统还包括缓存控制器,所述缓存控制器用于:更新所述缓存保存的第一索引信息;获得所述第一页面中的空闲数据 单元的位置信息,根据所述位置信息更新所述缓存中保存的第二索引信息。
基于第一方面,在一种可能的实现方式中,所述缓存控制器还用于:将所述第一页面中被覆盖的原数据中的脏数据写回内存或者下一级缓存。
第二方面,本申请实施例提供一种缓存方法,该缓存方法包括:接收数据访问请求,根据所述数据访问请求将内存的第一页面中的数据覆盖所述缓存的第二页面中的原数据;更新所述缓存保存的第一索引信息,所述第一索引信息用于记录所述第一页面中的数据在所述第二页面中的索引;获得所述第二页面中的空闲数据单元的位置信息,根据所述位置信息更新所述缓存中保存的第二索引信息,所述第二索引信息用于索引所述第二页面中的与所述位置信息对应的数据单元中的原数据。
内存中的第一页面可以为如图2所示的内存页面31,缓存中的第二页面可以是如图7所示的缓存页面A。当缓存控制器接收到数据访问请求、且该数据访问请求所请求访问的数据存储在内存页面31中时,可以基于如图2所示的内存页面与缓存页面之间的映射关系,将内存页面31中保存的数据存储至缓存页面A中。此时,如果缓存页面A中保存有数据时,需要将内存页面31中保存的数据覆盖缓存页面A当前保存的原数据。上述第一索引信息为如图4所示的标签阵列Tag Array中用于记录缓存页面A中所保存的原数据的索引信息。当内存页面31中保存的数据存储至缓存页面A中后,该第一索引信息即为来自于内存页面31中保存的数据的索引,由于第一索引信息所记录的为缓存页面A中之前保存的数据的索引,此时需要对第一索引信息进行更新。在将内存页面31中保存的数据存储至缓存页面A中时,通常以数据单元为单位进行缓存。由于缓存页面A中可能仅缓存有内存页面31中保存的部分数据单元的数据,此时缓存页面A中可能还存在大量空闲的数据单元。该大量空闲的数据单元中某些数据单元保存的原数据并未被覆盖,仍然存储在缓存页面A中。此时,更新第二索引信息,该第二索引信息用于记录缓存页面A中保存的未被第一索引信息记录的数据。
基于第二方面,在一种可能的实现方式中,所述更新所述缓存保存的第一索引信息,包括:更新所述第一索引信息中的标签信息、有效位信息和脏污位信息。
基于第二方面,在一种可能的实现方式中,所述获得所述第二页面中的空闲数据单元的位置信息,包括:基于更新后的所述第一索引信息中的有效位信息,确定所述第二页面中的空闲数据单元的位置信息。
基于第二方面,在一种可能的实现方式中,所述根据所述位置信息更新所述缓存中保存的第二索引信息,包括:更新所述第二索引信息中的有效位信息和脏污位信息;以及在所述第二索引信息中添加用于指示所述第二页面在缓存中的位置的位置信息。
基于第二方面,在一种可能的实现方式中,所述将内存的第一页面中的数据覆盖所述缓存的第二页面中的原数据之前,所述方法还包括:将所述第二页面中被覆盖的原数据中的脏数据写回内存或者下一级缓存。
第三方面,本申请实施例提供一种芯片,该芯片包括如第一方面所述的缓存系统。
基于第三方面,在一种可能的实现方式中,该芯片还包括处理器,用于访问所述缓存系统中保存的数据,以及将处理后的数据存储至所述缓存系统。
第四方面,本申请实施例提供一种缓存装置,该缓存装置包括一个或多个缓存控制 器和存储器;该存储器耦合至缓存控制器,存储器用于存储一个或多个程序;该一个或多个缓存控制器用于运行所述一个或多个程序,以实现如第二方面所述的缓存方法。
第五方面,本申请实施例提供一种可读存储介质,可读存储介质存储有指令,当指令在计算机上运行时,用于执行上述第二方面中任一的缓存方法。
第六方面,本申请实施例提供一种计算机程序或计算机程序产品,当计算机程序或计算机程序产品在计算机上被执行时,使得计算机实现上述第二方面中任一的缓存方法。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的缓存系统的一个结构示意图;
图2是本申请实施例提供的缓存中存储空间与内存中存储空间之间的对应关系示意图;
图3是本申请实施例提供的缓存中存储的页面所包括的数据单元的一个示意图;
图4是本申请实施例提供的缓存的一个结构示意图;
图5是本申请实施例提供的待存入缓存中的页面所包括的数据单元的示意图;
图6是本申请实施例提供的缓存中被替换的页面在缓存中保存的数据单元的示意图;
图7是本申请实施例提供的页面替换后缓存的存储情况的一个示意图;
图8是本申请实施例提供的缓存方法的一个流程图;
图9是本申请实施例提供的缓存装置的一个结构示意图。
具体实施方式
本文所提及的"第一"、"第二"以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,"一个"或者"一"等类似词语也不表示数量限制,而是表示存在至少一个。
在本文中提及的"模块"通常是指按照逻辑划分的功能性结构,该"模块"可以由纯硬件实现,或者,软硬件的结合实现。在本申请实施中,“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。
在本申请实施例中,“示例性的”或者“例如”等词用于表示例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或两个以上。例如,多个处理单元是指两个或两个以上的处理单元;多个系统 是指两个或两个以上的系统。
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请中的附图,对本申请中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
请参考图1,其示出了应用于本申请的一个缓存系统的结构示意图。
在图1中,缓存系统100包括缓存控制器和缓存。缓存系统100与内存和处理器耦合。其中,内存中存储有处理器运行所需数据。缓存中存储有内存中存储的部分数据。处理器可以发起数据访问请求以及进行数据处理。内存控制器基于处理器发起的数据访问请求,控制处理器与缓存之间以及缓存与内存之间的数据交互。当处理器与内存之间以及缓存与内存之间进行数据交互时,图1所示的内存可以包括内存控制器。内存控制器用于控制其他部件向内存写入数据或者从内存读取数据。缓存控制器可以向内存控制器发起数据交互请求,在内存控制器的控制下,缓存可以从内存中获取数据以及将数据提供给处理器、或者将数据写回内存。
处理器发起数据访问请求后,缓存控制器可以基于该数据访问请求检测数据是否存在缓存中。若处理器所访问的数据存储在缓存中,缓存控制器控制缓存通过总线将数据提供给处理器;若处理器访问的数据未存储在缓存中,则缓存控制器需要向内存控制器发送数据获取信号,以将数据从内存中取出并提供给处理器。此外,数据取出后还可以写入缓存,以使处理器下一次可以直接从缓存获取该数据。
如图1所示的缓存,可以包括多级缓存结构,例如L1级、L2级和L3级。处理器进行数据访问时,可以首先访问L1级缓存,当L1级缓存未命中时,可以继续访问L2级缓存,当L2级缓存未命中时,可以继续访问L3级缓存,当L3级缓存未命中时可以从内存中获取数据。也即对L1级缓存来说,L2级缓存和L3级缓存为其下一级缓存;对L2级缓存来说,L3级缓存为其下一级缓存。当需要进行数据写回时,例如L1级保存的数据需要写回时,可以写回L2级缓存、L3级缓存或者内存;L3级保存的数据需要写回时,仅能写回内存。L1级缓存、L2级缓存和L3级缓存可以为缓存结构相同但数据容量不同的缓存。图1中所示的缓存未将L1级、L2级和L3级缓存加以区分。
在本实施例中,每一级缓存中的缓存空间中是以页面为粒度进行分配的。具体来说,每一级缓存的缓存空间可以划分为多个页面。后面描述中将缓存中的页面统一称为缓存页面。在某些实现方式中,一个缓存页面也可以理解为一个缓存行。基于与缓存空间类似的逻辑结构,内存的存储空间也可以划分为多个页面。后面描述中将内存中的页面同一称为内存页面。一个内存页面的存储容量与一个缓存页面的存储容量可以相同。每一个缓存页面可以对应于一个内存页面。也即是说,存储在同一个缓存页面中的数据均可以来自同一内存页面。如图2所示,其示意性的示出了其中一种缓存中缓存空间与内存中的存储空间之间的对应关系示意图。在图2中,假设缓存中包括两路Way0和Way1,每一路中均可以存储两组页面数据。基于与缓存空间类似的逻辑结构,可以将内存的存储空间划分为八个内存页面。其中,内存页面01、内存页面11、内存页面21、内存页面31中的数据可以分别对应存储于缓存的组Set0对应的缓存页面中,内存页面02、内存页面 12、内存页面22、内存页面32中的数据可以分别对应存储于缓存的组Set1对应的缓存页面中。在图2所示的缓存中,Way0中存储有内存页面01中的数据和内存页面22中的数据,Way1中存储有内存页面21中的数据和内存页面32中的数据。
从图2中可以看出,当前缓存中的各个页面中都存储有来自内存的数据。当需要将内存页面31中的数据存储在缓存中时,内存页面31中的数据仅能存储在Set0位置处。而Set0位置处对应的缓存页面中当前存储有内存页面01中的数据和页面21中的数据。此时,需要将待缓存的内存页面31中的数据覆盖当前所缓存的内存页面01中的数据或者内存页面21中的数据,以将待缓存的内存页面31中的数据存储在缓存中。这里的替换意思是将待缓存的内存页面31中的数据直接存储在缓存中的(Set0、Way0)位置处或者(Set0、Way1)位置处,以覆盖掉缓存中当前存储的内存页面01中的数据或者内存页面21中的数据。图2示意性的示出了2路组相联的缓存结构。在其他一些应用场景中,缓存结构还可以是直接相联、全相联、四路组相联、八路组相联等等,在此不做具体限定。
在本发明实施例中,缓存中的缓存空间可以均按照如图2所示的way和set的设置来划分成多个页面,例如(Set0、Way0)位置可以代表一个页面。图2中所示的是缓存中保存了来自内存中的数据的示意图。此外,如图4中所示,缓存中的缓存空间还可以用于存储诸如标签阵列Tag Array以及影子缓存表(Ghost Cache Table,GHT)中的信息。其中标签阵列Tag Array和GHT的具体内容以及作用可以参考下文中的具体描述。
在本实施例中,缓存或内存中的一个页面所能保存的数据可以为4KB。一个页面又可以被划分为多个数据单元(例如32个数据单元)。其中每一个数据单元所能保存的数据的大小例如可以为128B。将内存中保存的数据存储至缓存中时,通常以数据单元保存的数据为单位进行数据存取。在缓存中,一个缓存页面可能存储有某个内存页面中全部数据单元所保存的数据,也可能存储有某个内存页面中部分数据单元所保存的数据。也即是说,将某一内存页面中的数据写入缓存中时,可以仅缓存该内存页面中的部分数据单元保存的数据。如图3所示,其示意性的示出了一个缓存页面中存储的内存页面01中的数据的示意图。其中,每个格子代表一个数据单元,带有阴影条纹的格子代表该位置处的数据单元存储有数据,白色格子代表该位置处的数据单元未存储有数据。从图3中可以看出,图3所示的缓存页面中14个数据单元中存储有数据。
基于图1所示的缓存系统,图2-图3所示的应用场景,本申请实施例提供的缓存中存储有数据阵列Data Array、标签阵列Tag Array和影子缓存表(Ghost Cache Table,GHT)。数据阵列Data Array占据多个缓存空间。在本发明实施例中,内存中的缓存空间也可以被视为一个页面。其中,缓存中的一个页面保存的数据单元可以来自于内存中的一个页面或多个页面。
标签阵列Tag Array用于存储第一索引信息,该第一索引信息记录的为缓存页面中存储的第一数据的索引信息。影子缓存表用于存储第二索引信息。该第二索引信息记录的为同一个缓存页面中存储的、未被所述第一索引信息记录的第二数据的索引信息。第一数据和第二数据来自于不同的内存页面。也即是说,同一个缓存页面中,可以同时存储有第一数据和第二数据,该第一数据来自于第一内存页面,第二数据来自于第二内存页 面。此外,同一个缓存页面中还可以存储有第三数据,该第三数据来自于第三内存页面;影子缓存表还可以用于存储第三索引信息。该第三索引信息为同一个缓存页面中存储的第三数据的索引信息。在本发明实施例中,所述缓存页面当前保存的数据是来自第一内存页面中的第一数据;而在这之前,所述缓存页面中保存的是来自第二内存页面或第三内存页面中的数据。这里以所述缓存页面中之前保存的是第二内存页面中的数据为例进行说明,在将第一内存页面中的数据写入缓存的过程中,缓存中保存的第二内存页面的数据被覆盖,但是如果第一内存页面中的数据并没有占据全部的第一内存页面中的数据单元,就会应该被覆盖的第二内存页面中的部分数据实质上仍然被保存在所述缓存页面中,而所述第二索引信息就用于指向这些来自第二内存页面中的数据。
通过设置第一索引信息和第二索引信息,可以避免某些场景下,一个缓存页面中存储较少的数据导致缓存利用率低,有利于提高缓存空间利用率,进而提高处理器数据访问的命中率。此外,还可以减少发生页面中的数据被覆盖时、写回内存的脏数据的数目,或者减少再一次访问该被覆盖的数据时、从内存中取回的数据的数目,有利于释放缓存与内存之间进行数据传输的带宽,从而提高数据传输效率。
下面,通过图4-图8所示的实施例,对如图1所示的缓存的结构、以及本申请实施例所达到的技术效果进行详细论述。
请继续参考图4,其示意性的示出了本申请实施例提供的如图1所示的缓存的一个结构示意图。
图4所示的缓存,可以包括数据阵列Data Array、标签阵列Tag Array和影子缓存表(Ghost Cache Table,GHT)。
在如图4所示的缓存中,标签阵列Tag Array和数据阵列Data Array分开设置。例如,缓存中物理地址(0~0x7FFFFF)位置处为标签阵列Tag Array的存储位置,从0x800000开始为数据阵列Data Array的物理地址。在另外一种实施例中,标签阵列Tag Array中的索引信息的物理地址与其所对应的数据的物理地址绑定在一起,例如用8字节存储索引信息,8字节后面的4K字节用来存储数据。通常,数据在数据阵列Data Array中的存储位置固定后,相应的索引信息在标签阵列Tag Array中的位置即固定。在上述索引信息的物理地址和对应的数据的物理地址绑定在一起的结构中,当缓存命中后,可以直接从索引信息后面读取所保存的数据。对于如图4所示的标签阵列Tag Array和数据阵列Data Array分开设置的结构,可以预先建立标签阵列Tag Array中的缓存位置与数据阵列Data Array中的页面之间的映射关系。例如,当索引信息存储在物理地址(0-0x00007)位置处时,索引信息所能索引到的数据单元存储在(0x800000-0x801000)对应的页面位置处。反映在图4中,可以简单理解为索引信息Index01存储在标签阵列Tag Array中(Set0,Way0)位置处,相应的索引信息Index01所能索引到的数据存储在数据阵列Data Array中(Set0、Way0)对应的页面位置处。
在图4中,标签阵列Tag Array和数据阵列Data Array可以分别是一个m*n的阵列,标签阵列Tag Array中的每个元素为一个索引信息,数据阵列Data Array中的每个元素为一个缓存页面。图4示意性的示出了标签阵列Tag Array和数据阵列Data Array为2*2的阵列。在标签阵列Tag Array和数据阵列Data Array中,每一列代表一路Way,每一行代 表一组Set。以数据阵列Data Array为例,内存页面与缓存页面具有映射关系。通常,多个内存页面保存的数据可以同时存储在缓存中同一组Set对应的缓存页面中(例如图2中的内存页面01、内存页面11、内存页面21和内存页面31保存的数据可以存储在图4所示的缓存页面A和缓存页面B中)。存储在同一组Set对应的缓存页面中的数据具有竞争关系。为了缓解该竞争关系,每一组Set可以设置多个路Way,当该多个路Way对应的缓存页面均无数据储存时,映射至同一组Set中的内存页面保存的数据可以存储在该组Set中任意路Way对应的缓存页面中。缓存中有多少路Way即表示有多少路组相联。图4中示意性的示出了缓存采用两路组相联的方式。从图4中可以看出,标签阵列Tag Array中的元素与数据阵列Data Array中的元素是一一对应的,标签阵列Tag Array中的索引信息为数据阵列Data Array中相应缓存页面所存储的至少部分数据的索引信息。例如,当缓存页面A中存储有内存页面01中的数据时,索引信息Index01为所缓存的内存页面01中的数据的索引信息;当缓存页面A中同时存储有内存页面01中的数据和内存页面11中的数据时,索引信息Index01可以为所缓存的内存页面01中的数据的索引信息,或者也可以为所缓存的内存页面11中的数据的索引信息,页面A中所缓存的另外一部分数据的索引信息可以存储在影子缓存表中。
下面对标签阵列Tag Array中存储的索引信息进行介绍。每个索引信息可以包括标签(Tag)信息、最近最少使用(least recently used,LRU)信息、有效位(Valid Bits)信息和脏污位(Dirty Bits)信息。具体的,Tag信息用于指示缓存页面保存的数据所来自的内存页面在内存中的物理地址信息和数据所存储至的缓存页面对应的组set信息。其中,来自于同一内存页面的数据具有相同的Tag信息。由于一个索引信息所记录的缓存页面保存的数据均来自于同一内存页面,因此,每一个缓存页面可以对应一个Tag信息。最近最少使用(least recently used,LRU)信息,用于指示缓存页面中最近最少使用的数据;脏污位(Dirty Bits)信息,用于指示缓存页面中所保存的数据单元中的数据是否为脏数据,若Dirty Bits某些位被设置为0,指示相应数据单元中保存的数据为干净数据,当发生替换时可以不写回片外内存直接无效,反之如果Dirty Bits某些位被设置为1,当发生替换时需要将相应脏数据所位于的数据单元中全部数据写回片外内存。有效位(Valid Bits)信息,用于指示缓存页面中的各个数据单元是否存储有有效数据,例如,当有效位信息为1时,说明缓存页面的数据单元中保存的数据有效,也即数据存储在缓存中;当有效位信息为0时,说明缓存页面的数据单元中保存的数据无效,也即数据未存储在缓存中。例如,在图3中,空白格对应的有效位信息即为无效,空白格所指示的数据单元中未存储有数据。通过查找Valid Bits信息,可以判断处理器访问的数据是否存储在缓存中。
基于图4所示的缓存,在一些应用场景中,当需要将某一内存页面中保存的数据存储至缓存页面中时,例如需要将图2所示的内存页面31中保存的数据存储至缓存中时,用于存储内存页面31中保存的数据的缓存页面为满存储状态。假设内存页面31对应的内存物理地址起始位置为0x18000(内存中以一个缓存页面所容纳的最大数据量4KB为粒度逻辑划分为多个内存页面,内存页面31位于内存中第七个内存页面位置处,其物理地址为第七个4KB的起始位置),该物理地址映射至如图4所示的缓存中组Set0位置处。其中,内存页面与缓存页面的映射关系、以及内存页面中保存的数据在缓存中的存 储位置可以参考图2的具体描述,在次不再赘述。在组Set0中缓存有内存页面01和内存页面21中保存的数据。缓存控制器此时可以查询标签阵列Tag Array中存储的索引信息index01和索引信息index21,并进一步查询索引信息index01中的LRU信息和索引信息index21中的LRU信息。假设基于查询结果,缓存页面A所缓存的来自于内存页面01中保存的数据为最近最少使用的数据。此时,可以将内存页面31中保存的数据缓存在缓存页面A中,以替换掉原来缓存的内存页面01中保存的数据。
对于缓存页面中的一个数据单元来说,若该数据单元用来存储内存页面01中保存的数据,那么该数据单元就不可能用来存储内存页面31中保存的数据。假设内存页面31中有数据需要存储在该数据单元中时,则需要冲刷掉或者覆盖掉之前在该数据单元保存的数据。假设待存储在缓存中的内存页面31中的数据所占用的数据单元如图5所示。从图5中可以看出,待存储在缓存中的内存页面31中保存的数据,需要占用一个缓存页面的12个数据单元,当其存储至缓存页面中时,缓存页面中其余数据单元均未被占用,也即其余数据单元保存的数据均无效。对比图3所示的缓存页面A当前所缓存的内存页面01中保存的数据所占用的缓存页面A的数据单元和图5所示的待缓存的内存页面31中保存的数据所占用的缓存页面A的数据单元,其中,当前所缓存的内存页面01中保存的数据占用缓存页面A的数据单元0110、0116、0118、0120、0126、0128和0131,待缓存的内存页面31中保存的数据占用缓存页面A的数据单元3110、3116、3118、3120、3126、3128和3131。也即是说内存页面31中保存的数据存储至缓存页面A的上述数据单元中时,与该数据单元当前所存储的内存页面01中保存的数据发生冲突。除上述相冲突的数据外,所缓存的内存页面01中存储的其余数据和待缓存的页面31中存储的其余数据不发生冲突。也即是说,当内存页面31中保存的数据存储至缓存中后,所缓存的内存页面01中保存的部分数据实际仍然存储在数据阵列中,即使被标记为无效也未被冲刷掉。如图6所示,其示意性的示出了假设内存页面31中保存的数据存储至缓存页面A中后,缓存页面A中仍然存储有内存页面01中保存的数据的数据单元。传统缓存技术中,由于没有缓存空间可以记录缓存页面A中所存储的仍然有效的数据,将内存页面31中保存的数据存储至缓存页面A中,意味着将缓存中存储的内存页面01中保存的数据全部清除。当处理器需要再次访问内存页面01所保存的数据时,需要将内存页面01中所保存的部分或全部的数据重新从内存中传输至缓存中,此时存储在缓存中的内存页面01中未被冲刷掉的数据也需要从内存页面01中重新读取。此外,当如图6所示的存储有有效数据的数据单元中存在脏数据时,还需要将该数据单元中存储的全部数据写回内存或者下一级缓存。由此,造成访存带宽的浪费,降低了缓存与内存之间的数据传输速率;此外,由于缓存中仅存储有12个数据单元的数据,而每一个缓存页面包括32个数据单元,此时缓存页面A的利用率为0.375,由此降低了缓存空间的利用率。
基于此,本申请实施例所示的缓存中,设置有影子缓存表(Ghost Cache Table,GHT),该影子缓存表中记录有同一缓存页面中,未被标签阵列记录的数据的索引信息。
在一种可能的实现方式中,影子缓存表的结构与缓存中的Tag Array的结构类似,缓存中的影子缓存表也可以是阵列结构,例如可以是一个i*j的阵列,阵列中的每个元素均为同一缓存页面中未被标签阵列记录的数据的索引信息,也即是缓存页面中保存的数据 发生替换时、未被覆盖掉的数据的索引信息。具体实现中,影子缓存表的大小远小于标签阵列的大小。如图4所示,其示意性的示出了影子缓存表的一个结构示意图。在图4所示的影子缓存表中,每一列代表一路Way,每一行代表一组Set。图4所示的影子缓存表采用两路组相联的方式。在其他场景中,影子缓存表也可以采用4路组相联的方式,在此不再赘述。
下面对影子缓存表中的索引信息进行介绍。每个索引信息可以包括标签(Tag)信息、脏污位(Dirty Bits)信息和有效位(Valid Bits)信息。其中,Tag信息、Dirty Bits信息和Valid Bits信息与标签阵列Tag Array中Tag信息、Dirty Bits信息、Valid Bits信息的含义相同,不再赘述。除了上述各信息之外,与标签阵列中的索引信息不同的是,影子缓存表中的索引信息还包括位置信息,用于指示数据在Data Array中的存储位置。该位置信息可以为路(Way)信息,也可以为(组Set,路Way)信息。其根据应用场景的需要以及影子缓存表的结构选择采用哪种位置信息。需要说明的是,当上述位置信息可以为路(Way)信息时,此时影子缓存表中的组set与数据阵列中的组set具有预先设定的映射关系。例如,影子缓存表中的组SetA存储的索引信息分别用于索引数据阵列中的组set0中的各缓存页面保存的数据。当上述位置信息为(组Set,路Way)信息时,数据阵列中的各缓存页面保存的数据的索引信息可以存储在影子缓存表中任意位置处。在进行Tag信息检索时,需要将所要访问的数据的Tag信息与影子缓存表中全部的索引信息中的Tag信息一一进行比较。
从图4所示的实施例中可以看出,本申请提供的缓存,存储有多个内存页面中保存的数据和多个内存页面中保存的数据的索引信息。当多个内存页面中的数据存储在同一缓存页面中时,其中一个内存页面中保存的数据的索引信息存储在标签阵列Tag Array中,其余内存页面中保存的数据的索引信息存储在影子缓存表GCT中。
下面,结合图3-图6,以内存页面31中的数据替换所缓存的内存页面01中的数据为例,对如图4所示的缓存结构的数据缓存方式进行描述。
假设在页面替换之前,所缓存的内存页面01中保存的数据所占用的数据单元为如图3所示的010010110100000111110010 01010010(十六进制表示为:0x4b41f252),其通过有效位(Valid Bits)体现,也即是所缓存的内存页面01中所有有效数据的汇总。待存储在缓存中的内存页面31中保存的数据所占用的数据单元的有效位(Valid Bits)为如图5所示的10100000110010010101100001010010(十六进制表示为:0xa0c95852)。其中,每一位代表一个数据单元,0代表该数据单元中存储有数据,1代表该数据单元中未存储有数据。当需要将内存页面31中保存的数据替换掉所缓存的内存页面01中保存的数据时,缓存控制器可以对比所缓存的内存页面01中保存的数据所占用的数据单元和待缓存的内存页面31中保存的数据所占用的数据单元,确定出缓存页面A当前保存的数据中、将要被待缓存的内存页面31中保存的数据冲刷掉的数据和未被待缓存的内存页面31中的数据冲刷掉的数据。其中,所缓存的内存页面01中未被冲刷掉的数据如图6所示,此时缓存中所存储的内存页面01中保存的数据所占用的数据单元为01001011000000001010001000000000(十六进制表示为:0x4b00c200)。然后,缓存控制器可以基于该内存页面01中保存的数据所占用的数据单元,更新所缓存的内存页面01 中的数据的dirty bits信息。需要说明的是,当Valid bits信息中的某一位为零时,相应的dirty bits信息同样为零;当Valid bits信息中的某一位为一时,相应的dirty bits信息可以保持之前的信息不变。最后,将更新后的索引信息写入影子缓存表中;将待缓存的内存页面31中保存的数据存储在缓存页面A中,将Tag Array中所存储的内存页面01中保存的数据的索引信息更新为所缓存的内存页面31中保存的数据的索引信息,如图7所示,其示意性的示出了数据替换后缓存中的存储情况。
在本实施例中,在将内存页面31中保存的数据替换为所缓存的内存页面01中保存的数据之前,缓存控制器还需要检测所缓存的内存页面01中被冲刷掉的数据的dirty bits信息;当缓存控制器检测到所缓存的内存页面01中被冲刷掉的数据的dirty bits信息用于指示数据被改写时,需要将被改写的数据所在的数据单元的全部数据写回内存或者下一级缓存。
综上可以看出,通过采用图4或图7所示的缓存结构,当缓存页面中保存的数据进行替换时,可以将未被冲覆盖的数据仍然维持在缓存页面中,当处理器需要访问某个数据时,可以基于影子缓存表确定所要访问的数据是否存储在缓存中。当所要访问的数据存储在缓存中时,可以直接将该数据传输给处理器,提高访问缓存的命中率,从而提高与处理器之间的数据传输速率,进而提高处理器的运行速率。当所要访问的数据未存储在缓存中、但影子缓存表中记录有与该数据来自于同一内存页面的其他数据时,可以不需要将存储该数据的内存页面中所存储的其他数据再一次从内存中取出,降低了一次所要传输的数据的数量,从而降低了访存通信量,进而降低了访存带宽压力。
下面结合图4-图7,通过具体示例对处理器的数据访问进行详细描述。处理器发起请求访问某一数据的指令,该指令中携带有所请求的数据的地址信息,该地址信息中包括标签信息Tag1、组信息Set0等。缓存控制器基于处理器发出的指令,利用组信息Set0检索Tag Array,查找到Set0这一组内的索引信息index01、index11,如图4所示。接着,缓存控制器可以继续查找index01和index11的其中一个索引信息中是否包括Tag1。假设index01中的标签信息为Tag1,则表示Tag命中。此时,可以进一步判断处理器请求访问的数据所在的数据单元对应的Valid Bits信息,若有效,则说明待访问的数据存储在缓存中。此时,缓存控制器控制缓存与处理器通信,以使处理器获取数据。假设处理器请求访问的数据所在的数据单元对应的Valid Bits信息无效,则说明该数据未存储在缓存中,需要去内存访问。
假设索引信息index01和索引信息index11中的任意一个索引信息中均不包括Tag1信息,则表示Tag未命中,需要去片外内存访问。假设此时缓存中当前的存储情况如图4所示。缓存控制器可以基于索引信息Index01和索引信息Index11中的LRU信息,确定最近最少使用的数据。假设Index01对应的缓存页面A所保存的数据为最近最少使用的数据。然后,缓存控制器可以进一步基于Index01中的有效位信息和待缓存的内存页面31中的数据的索引信息Index31中的有效位信息,确定出缓存页面A中保存的数据所占用的数据单元中与待缓存的内存页面31保存的数据所占用的数据单元中相冲突的数据单元。假设该相冲突的数据单元例如为图3所示的0110、0116、0118、0120、0126、0128和0131。缓存控制器可以将Index01中的有效位信息中用于指示该相冲突的数据单元的 位改为无效。从而,修改后的有效位信息为01001011000000001010001000000000(十六进制:0x4b00c200)。此外,假设缓存页面A中的0118、0120该两个数据单元中保存的数据包括脏数据,此时,需要将该两个数据单元中保存的数据写回内存。然后,缓存控制器需要修改Index01中的脏污位信息。由于缓存页面A在数据阵列中的具体位置为(Set0,Way0),缓存控制器还可以在Index01中添加用于指示数据在缓存中的存储位置的信息(例如路Way信息)。最后,缓存控制器将修改后的Index01存储至影子缓存表Ghost cache table中。当修改后的Index01存储至影子缓存表Ghost cache table中后,缓存控制器此时可以将待缓存的内存页面31中保存的数据存储至数据阵列Data Array中的缓存页面A中,将待缓存的内存页面31中保存的数据的索引信息存储至标签阵列Tag Array中(Set0、Way0)位置处。同时,缓存控制器可以控制缓存与处理器通信,以使处理器访问所缓存的内存页面31中保存的数据。此时,缓存中当前保存的数据情况如图7所示。
需要说明的是,Index01可以存储在Ghost cache table中Set0的任意一个Way里,例如也可以存储在WayB中。
在图7所示的缓存中的存储情况下,当处理器发起请求访问某一数据的指令,该指令中携带有所请求的数据的地址信息,该地址信息中包括标签信息Tag2、组信息Set0等。假设标签信息Tag2用于指示内存页面01中保存的数据。缓存控制器基于处理器发出的指令,利用组信息Set0检索Tag Array,查找到Set0这一组内的索引信息index31、index11。接着,缓存控制器可以继续查找index31和index11的其中一个索引信息中是否包括Tag2。由于Tag Array中未存储内存页面01中包括的数据的索引信息,此时处理器的数据访问在Tag Array中未命中。然后,缓存控制器利用标签信息Tag2检索Ghost cache table(也即将标签信息Tag2与Ghost cache table存储的索引信息中的标签信息一一进行比较),查找到索引信息index01中包括标签信息Tag2,Tag命中。需要说明的是,检索标签阵列Tag Array中的索引信息和检索影子缓存表中的索引信息是否包括标签信息Tag2也可以并行执行。
接着,缓存控制器可以进一步查询索引信息index01中的有效位信息,确定处理器请求访问的数据所在的数据单元对应的有效位是否有效。若有效,则说明该数据存储在缓存中。此时,缓存控制器可以进一步查看索引信息index01中的路(Way)信息。由图7中可以看出,内存页面01中保存的数据存储在Way0中,索引信息index01中的路(Way)为Way0。由此,缓存控制器可以控制Data Array将处理器所要访问的数据通过总线提供给处理器。
可选的,缓存控制器还可以将所缓存的内存页面01中保存的数据对应的索引信息index01添加至Tag Array中的(Set0、Way0)位置处,此时替换掉所缓存的内存页面31中保存的数据的索引信息index31。将内存页面01中保存的数据的索引信息index01添加至Tag Array中时,可以将索引信息Index01中的位置信息删除。
若索引信息index01中的有效位信息指示处理器请求访问的数据所在的数据单元对应的有效位无效,则说明该数据未存储在缓存中。此时,缓存控制器可以向内存控制器发起访问该数据的请求,内存控制器可以基于该请求控制内存通过总线将该数据提供给缓存。缓存控制器同时可以控制缓存与处理器通信,以使处理器获取数据。该数据存储 在缓存中后,缓存控制器可以更新索引信息index01。例如更新索引信息index01中的有效位信息、脏污位信息等。
在本申请实施例的示例中,缓存、缓存控制器、内存控制器和处理器可以集成在同一个芯片上,形成片上系统(SOC,System on chip)。此外,处理器和缓存可以集成在同一个芯片上,缓存控制器集成在另外一个芯片上。实际应用中,缓存也可以与处理器集成于不同芯片,该片外缓存采用本申请实施例提供的片内缓存相同的存储结构设计、且与本中请实施例提供的片内缓存实现相同的功能,该片外缓存也应视为落入本中请实施例的保护范围之内。
基于同一发明构思,本申请实施例还提供了一种缓存方法,该缓存方法应用于如图1所示的缓存控制器。请继续参考图8,其示出了本申请实施例提供的缓存方法的一个流程800,该缓存方法的流程800包括如下所述的步骤:
步骤801,接收数据访问请求,根据数据访问请求将内存的第一页面中的数据覆盖缓存的第二页面中的原数据。
本实施例中,当缓存控制器接收到处理器发送的数据访问请求后,可以首先确定所要访问的数据是否保存在缓存中。当处理器所要访问的数据未保存在缓存中时,需要从内存中获取该数据。
缓存控制器控制内存中的数据存储至缓存中时,通常以内存中一个页面所保存的数据为粒度进行缓存。同样,缓存中的缓存空间划分为多个页面。将内存中一个页面的数据进行缓存时,通常缓存至与该内存页面具有映射关系的缓存页面中。
当从内存中获取到数据后需要存储至相应的缓存页面中时,如果该缓存页面中当前存储有其他内存页面中保存的数据,则获取的数据需要将缓存页面中当前存储的原数据覆盖掉。其中,内存与缓存的页面划分以及内存中的页面与缓存中的页面之间的映射关系可以参考图2所述,在此不再赘述。
步骤802,更新所述缓存保存的第一索引信息,所述第一索引信息用于记录所述第一页面中的数据在所述第二页面中的索引。
将内存的第一页面中的数据覆盖缓存的第二页面中的原数据时,其通常以数据单元为单位进行数据覆盖。也即是说,缓存中的各页面又可以划分为多个数据单元。将内存的第一页面的数据存储至缓存的第二页面中时,需要存储至第二页面的数据单元中。由于所获取的第一页面的数据有可能是部分数据而不是全部数据,缓存至第二页面的数据单元中时,有可能并不会占用全部的数据单元。其中,当待缓存的第一页面中保存的数据占据某一数据单元时,第一索引信息中该数据单元对应的Valid bits信息中的有效位为“有效”;当待缓存的第一页面中保存的数据未占据某一数据单元时,第一索引信息中该数据单元对应的Valid bits信息中的有效位为“无效”。
这里更新第一索引信息例如包括更新Tag信息、LRU信息、Valid bits信息和Dirty bits信息等。其中,更新后的Tag信息用于指示第一页面在内存中的物理地址信息和来自于第一页面的数据所存储至的第二页面对应的组set信息。更新后的LRU信息用于指示待缓存的第一页面中保存的数据中的最近使用情况。更新后的Valid Bits信息,用于指示待缓存的第一页面中保存的数据所占用的第二页面中的哪些数据单元。更新后的Dirty  Bits信息,用于指示待缓存的第一页面中保存的数据是否存在脏数据。
步骤803,获得所述第二页面中的空闲数据单元的位置信息,根据所述位置信息更新所述缓存中保存的第二索引信息,所述第二索引信息用于索引所述第二页面中的与所述位置信息对应的数据单元中的原数据。
当来自于内存的第一页面中的数据存储至缓存中的第二页面中后,其有可能并未占据第二页面中全部的数据单元。第二页面中存储的某些原数据有可能并未被来自于第一页面中的数据覆盖。此时,缓存控制器可以获取第二页面中未被来自于第一页面中的数据占用的空闲数据单元的位置信息。具体的,可以基于更新后的第一索引信息中的有效位信息,确定第二页面中的空闲数据单元的位置信息。当第一索引信息中的有效位信息所指示的数据单元为有效时,说明数据单元被占用;当第一索引信息中的有效位信息所指示的数据单元为无效时,说明数据单元未占用。
然后,可以基于第二页面中的空闲数据单元的位置信息,来更新用于指示第二页面中的原数据的第二索引信息。具体的,可以确定更新之前的第二索引信息中的有效位信息中,用于指示有效的数据单元的位置是否为上述空闲数据单元的位置,如果是,则继续保持该位置对应的数据单元有效,如果不是,则将该数据单元改为无效。此外,还需要基于更新后的第二索引信息中的有效位信息,来更新第二索引信息中的脏污位信息。
进一步,还需要在第二索引信息中添加用于指示第二页面在缓存中的位置的位置信息。
此外,在将内存的第一页面中的数据覆盖缓存的第二页面中的原数据之前,还需要将第二页面中被覆盖的原数据中的脏数据写回内存或者下一级缓存。
需要说明的是,在更新第一索引信息之前,首先需要记录之前存储的第一索引信息中的Tag信息,以防止更新第一索引信息后,将之前的Tag信息覆盖掉,无法记录原数据来自于内存中的哪个页面。
可以理解的是,缓存控制器为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本实施例可以根据上述方法示例对缓存控制器进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个缓存控制模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,图9示出了上述实施例中涉及的缓存装置900的一种可能的组成示意图,如图9所示,该缓存装置900可以包括:接收模块901、第一更新模块902和第二更新模块903。
其中,接收模块901,用于接收数据访问请求,根据所述数据访问请求将内存的第一页面中的数据覆盖所述缓存的第二页面中的原数据;第一更新模块902,用于更新所述缓 存保存的第一索引信息,所述第一索引信息用于记录所述第一页面中的数据在所述第二页面中的索引;第二更新模块903,用于获得所述第二页面中的空闲数据单元的位置信息,根据所述位置信息更新所述缓存中保存的第二索引信息,所述第二索引信息用于索引所述第二页面中的与所述位置信息对应的数据单元中的原数据。
在一种可能的实现方式中,第一更新模块902进一步用于:更新所述第一索引信息中的标签信息、有效位信息和脏污位信息。
在一种可能的实现方式中,第二更新模块903进一步用于:基于更新后的所述第一索引信息中的有效位信息,确定所述第二页面中的空闲数据单元的位置信息。
在一种可能的实现方式中,第二更新模块903进一步用于:更新所述第二索引信息中的有效位信息和脏污位信息;以及在所述第二索引信息中添加用于指示所述第二页面在缓存中的位置的位置信息。
在一种可能的实现方式中,缓存装置900还包括:写回模块(图中未示出),用于将所述第二页面中被覆盖的原数据中的脏数据写回内存或者下一级缓存。
本实施例提供的缓存装置900,用于执行缓存系统100中所示的缓存控制器所执行的缓存方法,可以达到与上述实现方法相同的效果。
在采用集成的单元的情况下,缓存装置900可以包括缓存控制器和存储器。其中,缓存控制器可以对缓存装置900的动作进行控制管理,例如,可以用于支持缓存装置900执行上述各个模块执行的步骤。存储器可以用于支持缓存装置900执行存储程序代码和数据等。
其中,缓存控制器可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑模块。缓存控制器也可以是实现计算功能的组合,例如包括专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、或分立硬件组件等。
还应理解,本申请实施例中提及的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DR RAM)。
本实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机指令,当该计算机指令在计算机上运行时,使得计算机执行上述相关方法步骤实现上述实施例中的缓存方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的缓存方法。
另外,本申请的实施例还提供一种缓存装置,这个缓存装置具体可以是芯片,组件或模块,该缓存装置可包括耦合的缓存控制器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,缓存控制器可执行存储器存储的计算机执行指令,以使芯片执行上述缓存方法。
其中,本实施例提供的缓存控制器、计算机可读存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的缓存装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的可读存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (16)

  1. 一种缓存系统,其特征在于,包括缓存,所述缓存用于保存来自内存中的数据,所述缓存中还保存有第一索引信息和第二索引信息;
    所述第一索引信息用于指示所述缓存中的第一页面保存的来自所述内存的第二页面中的数据;
    所述第二索引信息用于指示所述第一页面保存的来自所述内存的其他页面中的数据。
  2. 根据权利要求1所述的缓存系统,其特征在于,所述第一页面保存的来自所述内存的其他页面中的数据包括第一数据和第二数据,所述第一数据和所述第二数据来自于所述内存中的不同页面。
  3. 根据权利要求2所述的缓存系统,其特征在于,所述第二索引信息包括多个;所述多个第二索引信息中的第一个用于指示所述第一数据,所述多个第二索引信息中的第二个用于指示所述第二数据。
  4. 根据权利要求1-3任一项所述缓存系统,其特征在于,所述第一索引信息包括以下信息:标签信息、有效位信息和脏污位信息。
  5. 根据权利要求1-4任一项所述缓存系统,其特征在于,所述第二索引信息包括以下信息:标签信息、有效位信息、脏污位信息和位置信息;
    其中,所述位置信息用于指示所述第一页面在所述缓存中的位置。
  6. 根据权利要求1-5任一项所述的缓存系统,其特征在于,所述缓存系统还包括缓存控制器,所述缓存控制器用于:
    更新所述第一索引信息;
    获得所述第一页面中的空闲数据单元的位置信息,根据所述空闲数据单元的位置信息更新所述第二索引信息。
  7. 一种芯片,其特征在于,所述芯片包括如权利要求1-6任一项所述的缓存系统。
  8. 根据权利要求7所述的芯片,其特征在于,还包括:
    处理器,用于访问所述缓存系统中保存的数据,以及将处理后的数据存储至所述缓存系统。
  9. 一种缓存方法,其特征在于,包括:
    接收数据访问请求,根据所述数据访问请求将内存的第一页面中的数据覆盖所述缓存的第二页面中的原数据;
    更新所述缓存保存的第一索引信息,所述第一索引信息用于记录所述第一页面中的数据在所述第二页面中的索引;
    获得所述第二页面中的空闲数据单元的位置信息,根据所述位置信息更新所述缓存中保存的第二索引信息,所述第二索引信息用于索引所述第二页面中的与所述位置信息对应的数据单元中的原数据。
  10. 根据权利要求9所述的缓存方法,其特征在于,所述更新所述缓存保存的第一索引信息,包括:
    更新所述第一索引信息中的标签信息、有效位信息和脏污位信息。
  11. 根据权利要求9或10所述的缓存方法,其特征在于,所述获得所述第二页面中的空闲数据单元的位置信息,包括:
    基于更新后的所述第一索引信息中的有效位信息,确定所述第二页面中的空闲数据单元的位置信息。
  12. 根据权利要求9-11任一项所述的缓存方法,其特征在于,所述根据所述位置信息更新所述缓存中保存的第二索引信息,包括:
    更新所述第二索引信息中的有效位信息和脏污位信息;以及
    在所述第二索引信息中添加用于指示所述第二页面在缓存中的位置的位置信息。
  13. 根据权利要求11所述的缓存方法,其特征在于,所述将内存的第一页面中的数据覆盖所述缓存的第二页面中的原数据之前,所述方法还包括:
    将所述第二页面中被覆盖的原数据中的脏数据写回内存或者下一级缓存。
  14. 一种缓存装置,其特征在于,所述缓存装置包括:
    一个或多个缓存控制器和存储器;
    所述存储器耦合至所述缓存控制器,所述存储器用于存储一个或多个程序;
    所述一个或多个缓存控制器用于运行所述一个或多个程序,以实现如权利要求9-13中任一项所述的方法。
  15. 一种可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在计算机上运行时,使得所述计算机执行如权利要求9-13中任一项所述的方法。
  16. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求9-13中任一项所述的方法。
PCT/CN2020/105606 2020-07-29 2020-07-29 缓存系统、方法和芯片 WO2022021158A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2020/105606 WO2022021158A1 (zh) 2020-07-29 2020-07-29 缓存系统、方法和芯片
CN202080101464.5A CN115668156A (zh) 2020-07-29 2020-07-29 缓存系统、方法和芯片

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/105606 WO2022021158A1 (zh) 2020-07-29 2020-07-29 缓存系统、方法和芯片

Publications (1)

Publication Number Publication Date
WO2022021158A1 true WO2022021158A1 (zh) 2022-02-03

Family

ID=80037004

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/105606 WO2022021158A1 (zh) 2020-07-29 2020-07-29 缓存系统、方法和芯片

Country Status (2)

Country Link
CN (1) CN115668156A (zh)
WO (1) WO2022021158A1 (zh)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090248984A1 (en) * 2008-03-28 2009-10-01 International Business Machines Corporation Method and device for performing copy-on-write in a processor
CN102541757A (zh) * 2011-11-30 2012-07-04 华为技术有限公司 写缓存方法、缓存同步方法和装置
CN103246616A (zh) * 2013-05-24 2013-08-14 浪潮电子信息产业股份有限公司 一种长短周期访问频度的全局共享缓存替换方法
CN103365797A (zh) * 2013-07-05 2013-10-23 华为技术有限公司 物理内存页分配方法和计算机系统
CN104252421A (zh) * 2013-06-25 2014-12-31 华为技术有限公司 缓存方法及装置
CN106055487A (zh) * 2016-05-31 2016-10-26 上海爱数信息技术股份有限公司 一种分区着色实现存储系统加速的方法及系统
CN110196818A (zh) * 2018-02-27 2019-09-03 华为技术有限公司 缓存数据的方法、缓存设备和存储系统

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090248984A1 (en) * 2008-03-28 2009-10-01 International Business Machines Corporation Method and device for performing copy-on-write in a processor
CN102541757A (zh) * 2011-11-30 2012-07-04 华为技术有限公司 写缓存方法、缓存同步方法和装置
CN103246616A (zh) * 2013-05-24 2013-08-14 浪潮电子信息产业股份有限公司 一种长短周期访问频度的全局共享缓存替换方法
CN104252421A (zh) * 2013-06-25 2014-12-31 华为技术有限公司 缓存方法及装置
CN103365797A (zh) * 2013-07-05 2013-10-23 华为技术有限公司 物理内存页分配方法和计算机系统
CN106055487A (zh) * 2016-05-31 2016-10-26 上海爱数信息技术股份有限公司 一种分区着色实现存储系统加速的方法及系统
CN110196818A (zh) * 2018-02-27 2019-09-03 华为技术有限公司 缓存数据的方法、缓存设备和存储系统

Also Published As

Publication number Publication date
CN115668156A (zh) 2023-01-31

Similar Documents

Publication Publication Date Title
US9792221B2 (en) System and method for improving performance of read/write operations from a persistent memory device
US8495301B1 (en) System and method for scatter gather cache processing
CN109582214B (zh) 数据访问方法以及计算机系统
US11210020B2 (en) Methods and systems for accessing a memory
TWI393050B (zh) 促進多重處理器介面之板內建快取記憶體系統之記憶體裝置及方法及使用其之電腦系統
JP5536658B2 (ja) バッファメモリ装置、メモリシステム及びデータ転送方法
US8954672B2 (en) System and method for cache organization in row-based memories
US20120102273A1 (en) Memory agent to access memory blade as part of the cache coherency domain
US20110161597A1 (en) Combined Memory Including a Logical Partition in a Storage Memory Accessed Through an IO Controller
US11016905B1 (en) Storage class memory access
CN107870867B (zh) 32位cpu访问大于4gb内存空间的方法与装置
WO2019128958A1 (zh) 缓存替换技术
JP2007200292A (ja) エントリの時間経過によるキャッシュ・エントリの所有権喪失
WO2015041151A1 (ja) キャッシュメモリシステムおよびプロセッサシステム
WO2024066195A1 (zh) 缓存管理方法及装置、缓存装置、电子装置和介质
US11126573B1 (en) Systems and methods for managing variable size load units
US9128856B2 (en) Selective cache fills in response to write misses
CN110537172B (zh) 混合存储器模块
US11188467B2 (en) Multi-level system memory with near memory capable of storing compressed cache lines
WO2022021158A1 (zh) 缓存系统、方法和芯片
US20230120184A1 (en) Systems, methods, and devices for ordered access of data in block modified memory
WO2022021177A1 (zh) 缓存系统、方法和芯片
CN107870870B (zh) 访问超过地址总线宽度的内存空间
WO2022021178A1 (zh) 缓存方法、系统和芯片
US20220229552A1 (en) Computer system including main memory device having heterogeneous memories, and data management method thereof

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20947092

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20947092

Country of ref document: EP

Kind code of ref document: A1