TW202038103A - Cache and method for managing cache - Google Patents
Cache and method for managing cache Download PDFInfo
- Publication number
- TW202038103A TW202038103A TW109116171A TW109116171A TW202038103A TW 202038103 A TW202038103 A TW 202038103A TW 109116171 A TW109116171 A TW 109116171A TW 109116171 A TW109116171 A TW 109116171A TW 202038103 A TW202038103 A TW 202038103A
- Authority
- TW
- Taiwan
- Prior art keywords
- cache memory
- control circuit
- program
- core
- circuit
- Prior art date
Links
Images
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
Abstract
Description
本案是關於快取記憶體,尤其是關於多階層快取記憶體。This case is about cache memory, especially multi-level cache memory.
圖1為習知電子裝置的架構圖。電子裝置100包含處理器110、第一級(L1)快取記憶體120、第二級(L2)快取記憶體130以及系統記憶體140。L1快取記憶體120及L2快取記憶體130通常為靜態隨機存取記憶體(Static Random-Access Memory, SRAM),而系統記憶體140通常為動態隨機存取記憶體(Dynamic Random-Access Memory, DRAM)。L2快取記憶體130包含控制電路132及儲存電路136。控制電路132將資料寫入儲存電路136或從儲存電路136讀取資料。儲存電路136的資料結構以及控制電路132所採用的用來存取儲存電路136的演算法為本技術領域具有通常知識者所熟知,故不再贅述。以下分別就快取記憶體的包容模式(inclusive mode)及專有模式(exclusive mode)討論電子裝置100所遭遇的問題。包容模式及專有模式為本技術領域具有通常知識者所熟知,故不再贅述。FIG. 1 is a structural diagram of a conventional electronic device. The
圖2為電子裝置100操作於包容模式的部分流程圖。於資料存取過程中,當資料於L1快取記憶體120未命中(miss)時,L1快取記憶體120便向L2快取記憶體130請求資料(步驟S210)。在步驟S220中,控制電路132檢查儲存電路136中是否儲存L1快取記憶體120所請求的資料。假設儲存電路136中沒有儲存L1快取記憶體120所請求的資料(亦即L2快取記憶體沒有命中),則控制電路132向系統記憶體140請求資料(步驟S230)。接著,L2快取記憶體130取得來自系統記憶體140的資料(步驟S240),然後L2快取記憶體130將資料回覆給L1快取記憶體120(步驟S250)。收到L2快取記憶體130所回覆的資料之後,L1快取記憶體120儲存該資料。最後,L1快取記憶體120向L2快取記憶體130廣播(broadcast)資料(步驟S260)。在步驟S260中,控制電路132須檢查儲存電路136的標籤(tag)並且將資料寫入儲存電路136中。因為L2快取記憶體130的容量通常大於L1快取記憶體120的容量,所以存取儲存電路136也相對地耗時。舉例來說,如果存取L1快取記憶體120需要1個系統時脈的週期,則存取儲存電路136可能需2~3個週期。由於步驟S260相對地耗時,所以控制電路132無法立即處理的下一個存取命令,造成處理器110停滯(stall)。FIG. 2 is a partial flowchart of the
圖3為電子裝置100操作於專有模式的部分流程圖。於資料存取過程中,當資料在L1快取記憶體120未命中時,L1快取記憶體120便向L2快取記憶體130請求資料(步驟S310)。在步驟S320中,控制電路132檢查儲存電路136中是否儲存L1快取記憶體120所請求的資料。假設儲存電路136中儲存L1快取記憶體120所請求的資料(亦即L2快取記憶體命中(hit)),則控制電路132將資料回覆給L1快取記憶體120(步驟S330)。接著,L1快取記憶體120踢出(evict)一行資料(line data)至L2快取記憶體130(步驟S340)。在步驟S340中,控制電路132須檢查儲存電路136的標籤並且將該行資料寫入儲存電路136的適當位置中。由於存取儲存電路136相對地耗時,所以步驟S340可能使得控制電路132無法立即處理的下一個存取命令,造成處理器110停滯。FIG. 3 is a partial flowchart of the
鑑於先前技術之不足,本案之一目的在於提供一種快取記憶體及快取記憶體的管理方法,以提升電子裝置的效能。In view of the shortcomings of the prior art, one purpose of this project is to provide a cache memory and a method for managing the cache memory to improve the performance of the electronic device.
本案揭露一種快取記憶體,包含一第一級快取記憶體、一第二級快取記憶體以及一暫存器。第一級快取記憶體包含一第一控制電路。第二級快取記憶體包含一第二控制電路。暫存器耦接於該第一控制電路及該第二控制電路。該第一控制電路及該第二控制電路參考該暫存器的一暫存值以分別控制該第一級快取記憶體及該第二級快取記憶體操作於一包含模式(inclusive mode)或一專有模式(exclusive mode)。This case discloses a cache memory, including a first-level cache memory, a second-level cache memory, and a register. The first level cache includes a first control circuit. The second-level cache includes a second control circuit. The register is coupled to the first control circuit and the second control circuit. The first control circuit and the second control circuit refer to a temporary value of the register to respectively control the first-level cache and the second-level cache to operate in an inclusive mode Or an exclusive mode.
本案揭露一種種快取記憶體的管理方法,用於一快取記憶體中,快取記憶體包含一第一級快取記憶體、一第二級快取記憶體以及一暫存器。管理方法包含下述步驟:讀取暫存器的一暫存值;根據暫存值設定控制第一級快取記憶體及第二級快取記憶體操作於一包含模式(inclusive mode)或一專有模式(exclusive mode)。This case discloses a method for managing cache memory, which is used in a cache memory. The cache memory includes a first-level cache memory, a second-level cache memory, and a register. The management method includes the following steps: reading a temporary value of the register; controlling the first-level cache and the second-level cache to operate in an inclusive mode or an inclusive mode according to the temporary value setting Exclusive mode (exclusive mode).
有關本案的特徵、實作與功效,茲配合圖式作實施例詳細說明如下。The features, implementation, and effects of this case are described in detail as follows in conjunction with the drawings.
以下說明內容之技術用語係參照本技術領域之習慣用語,如本說明書對部分用語有加以說明或定義,該部分用語之解釋係以本說明書之說明或定義為準。The technical terms used in the following description refer to the customary terms in the technical field. If part of the terms is described or defined in this specification, the explanation of the part of the terms is based on the description or definition of this specification.
本案之揭露內容包含快取記憶體及快取記憶體的管理方法。由於本案之快取記憶體所包含之部分元件單獨而言可能為已知元件,因此在不影響該裝置實施例之充分揭露及可實施性的前提下,以下說明對於已知元件的細節將予以節略。此外,本案之快取記憶體的管理方法的部分或全部流程可以是軟體及/或韌體之形式,並且可藉由本案之快取記憶體或其等效裝置來執行,在不影響該方法實施例之充分揭露及可實施性的前提下,以下方法實施例之說明將著重於步驟內容而非硬體。The disclosure of this case includes the cache memory and the management method of the cache memory. Since some of the components included in the cache memory in this case may be known components individually, the following description will give details of known components without affecting the full disclosure and implementability of the device embodiments Abridged. In addition, part or all of the process of the cache management method of this case can be in the form of software and/or firmware, and can be executed by the cache or its equivalent device of this case, without affecting the method On the premise that the embodiments are fully disclosed and practicable, the description of the following method embodiments will focus on the content of the steps rather than the hardware.
圖4為本案電子裝置之一實施例的架構圖。電子裝置400包含處理器410、L1快取記憶體420、L2快取記憶體430以及系統記憶體440。L2快取記憶體430包含控制電路432、緩衝電路434以及儲存電路436。緩衝電路434以先進先出(first-in first-out, FIFO)的方式儲存資料,而儲存電路436非以先進先出的方式儲存資料。在一些實施例中,緩衝電路434的容量小於儲存電路436的容量,如此一來,控制電路432對緩衝電路434的存取速度可以大於對儲存電路436的存取速度。儲存電路436儲存複數個標籤及對應該些標籤的複數個資料。儲存電路436的資料結構為本技術領域具有通常知識者所熟知,故不再贅述。緩衝電路434可以以SRAM實作或是以暫存器(例如正反器)實作,儲存電路436以SRAM實作。L1快取記憶體420及L2快取記憶體430可以操作於包容模式或專有模式。Figure 4 is a structural diagram of an embodiment of the electronic device of the present invention. The
圖5為本案快取記憶體的管理方法的一實施例的流程圖。圖5的流程適用於包容模式及專有模式。當控制電路432從L1快取記憶體420或系統記憶體440獲得目標資料並且要儲存該目標資料時,控制電路432將目標資料寫入緩衝電路434而不檢查儲存電路436的標籤(步驟S510)。接著,控制電路432判斷L2快取記憶體430是否處於閒置(idle)狀態(步驟S520)。如果步驟S520為否,控制電路432進一步判斷是否有另一目標資料需要被寫入L2快取記憶體430(步驟S530)。如果步驟S530為是,則控制電路432將該另一目標資料寫入緩衝電路434(步驟S510);如果步驟S530為否,則控制電路432尋找及/或回覆資料(包含存取緩衝電路434及/或儲存電路436)(步驟S540)。步驟S540結束後,流程回到步驟S520。FIG. 5 is a flowchart of an embodiment of the method for managing the cache memory of the present invention. The process in Figure 5 is applicable to both the inclusive model and the proprietary model. When the
當L2快取記憶體430處於閒置狀態時(步驟S520為是),控制電路432判斷緩衝電路434是否為空(步驟S550)。如果緩衝電路434沒有儲存任何資料(亦即步驟S550為是),則回到步驟S520。如果緩衝電路434不為空(亦即步驟S550為否),則控制電路432在儲存電路436中尋找儲存空間(步驟S560),然後將目標資料從緩衝電路434中讀出並且寫入儲存電路436(步驟S570)。換言之,步驟S560及步驟S570的目的在於將目標資料從緩衝電路434移到儲存電路436。搬移之後,該目標資料只存在於儲存電路436而不存在於緩衝電路434。換言之,緩衝電路434及儲存電路436不同時儲存同一筆行資料。步驟S570完成後,控制電路432即完成將目標資料寫入L2快取記憶體430(步驟S580),然後流程回到步驟S520。When the
在步驟S560中,該儲存空間可以是未被占用的空間或是即將被剔除的資料所占用的空間。控制電路432可以根據演算法(例如最近最少使用(Least Recently Used, LRU))及儲存電路436中的標籤找到即將被踢出的資料。In step S560, the storage space may be an unoccupied space or a space occupied by data to be deleted. The
由圖5的流程可知,緩衝電路434可能同時儲存複數個目標資料,而控制電路432以先進先出的方式依序將該些目標資料讀出並寫入儲存電路436。在一些實施例中,緩衝電路434中的資料具有與儲存電路436中的資料相同的格式(例如皆為行資料的格式),以簡化步驟S570。It can be seen from the flow of FIG. 5 that the
因為在步驟S510中控制電路432不需要檢查儲存電路436的標籤來找出適合的儲存空間(無論是空的儲存空間或是即將被踢出的資料所占用的空間),所以理論上步驟S510只需要1個系統時脈的週期即可完成。作為比較,因為控制電路432將目標資料寫入儲存電路436時需要先檢查標籤,所以控制電路432直接將目標資料寫入儲存電路436至少需要2個系統時脈的週期(視儲存電路436的大小而定)。換言之,緩衝電路434可以提升L2快取記憶體430的速度。Because the
步驟S520的閒置狀態包含:(1)控制電路432沒有待處理的讀寫操作時;以及(2)L2快取記憶體430未命中時,從控制電路432向系統記憶體440請求資料後至收到系統記憶體440回覆的期間。因為系統記憶體440的一次存取所需的系統時脈的週期數通常遠大於控制電路432將資料寫入儲存電路436所需的系統時脈的週期數,所以控制電路432在情況(2)中有充裕的時間執行步驟S560及S570。The idle state of step S520 includes: (1) when the
綜合上述,因為無論是L2快取記憶體430在包容模式下未命中或是在專有模式下命中,就處理器410的角度而言, L2快取記憶體430的操作只需要1個系統時脈的週期,所以處理器410不會被停滯,因此大幅增加電子裝置400的效能。To sum up, because whether it is a miss of the
圖6為圖5的步驟S540的一實施例的流程圖。當L1快取記憶體420未命中而向L2快取記憶體430請求資料時,控制電路432檢查緩衝電路434及儲存電路436是否儲存目標資料(步驟S610)。如果命中(亦即緩衝電路434或儲存電路436存有該目標資料,步驟S620為是),則控制電路432讀取該目標資料,並回覆該目標資料給L1快取記憶體420(步驟S630)。如果未命中(亦即緩衝電路434及儲存電路436皆未儲存該目標資料,步驟S620為否),控制電路432向系統記憶體440請求資料(步驟S640)。FIG. 6 is a flowchart of an embodiment of step S540 in FIG. 5. When the
圖7為本案電子裝置之另一實施例的架構圖。電子裝置70包含處理器72、L2快取記憶體74以及暫存器76。處理器72包含核心720及核心730。核心720包含處理單元722及L1快取記憶體724。L1快取記憶體724包含控制電路7241及儲存電路7242。核心730包含處理單元732及L1快取記憶體734。L1快取記憶體734包含控制電路7341及儲存電路7342。簡言之,處理器72為一個多核心的架構,核心720及核心730有各自的L1快取記憶體(分別為724及734),且共用L2快取記憶體74。L2快取記憶體74包含控制電路742、緩衝電路744以及儲存電路746。控制電路742、緩衝電路744及儲存電路746的功能分別與控制電路432、緩衝電路434及儲存電路436相似,故不再贅述。控制電路7241、控制電路7341及控制電路742耦接暫存器76,可讀取暫存器76中的暫存值。FIG. 7 is a structural diagram of another embodiment of the electronic device of the present invention. The
L1快取記憶體724的控制電路7241、L1快取記憶體734的控制電路7341以及L2快取記憶體74的控制電路742參考暫存器76的暫存值來分別控制L1快取記憶體724、L1快取記憶體734及L2快取記憶體74操作於包容模式或專有模式。換言之,L1快取記憶體及L2快取記憶體以可程式化的方式切換於包容模式及專有模式兩者之間。如此一來,電子裝置70不需要在設計階段就決定L1快取記憶體724、L1快取記憶體734以及L2快取記憶體74的操作模式,而是使用者可以在電路完成後再根據實際的應用(亦即動態調整)設定暫存器76的暫存值。在一些實施例中,暫存器76可以是處理器72的控制暫存器。The
以下為電子裝置70的應用範例。The following is an application example of the
範例一:當核心720及核心730平行處理(亦即執行同一程式)時,暫存器76的暫存值可以被設定為第一數值(例如1),使得L1快取記憶體724、L1快取記憶體734及L2快取記憶體74操作於包容模式。Example 1: When the
範例二:當核心720及核心730分別執行第一程式及第二程式,且第一程式及第二程式共用指令及/或資料時,暫存器76的暫存值可以被設定為第一數值(例如1),使得L1快取記憶體724、L1快取記憶體734及L2快取記憶體74操作於包容模式。Example 2: When the
範例三:當核心720及核心730分別執行第一程式及第二程式,且第一程式及第二程式不共用指令及/或資料時(亦即第一程式及第二程式為獨立的程式),暫存器76的暫存值可以被設定為第二數值(例如0),使得L1快取記憶體724、L1快取記憶體734及L2快取記憶體74操作於專有模式。Example 3: When the
在範例一及二中,包容模式有助於減少資料的移動次數(亦即提高命中率),所以電子裝置70的效能可以獲得提升。在範例三中,專有模式有助於L1快取記憶體724、L1快取記憶體734及L2快取記憶體74儲存更多的指令及/或資料,所以電子裝置70的效能可以獲得提升。In Examples 1 and 2, the containment mode helps reduce the number of data movement (that is, increase the hit rate), so the performance of the
在一些實施例中,前述的控制電路432、控制電路7241、控制電路7341及控制電路742可以由有限狀態機(包含複數個邏輯電路)實作。In some embodiments, the
由於本技術領域具有通常知識者可藉由本案之裝置實施例的揭露內容來瞭解本案之方法實施例的實施細節與變化,因此,為避免贅文,在不影響該方法實施例之揭露要求及可實施性的前提下,重複之說明在此予以節略。請注意,前揭圖示中,元件之形狀、尺寸、比例以及步驟之順序等僅為示意,係供本技術領域具有通常知識者瞭解本案之用,非用以限制本案。Since those with ordinary knowledge in the art can understand the implementation details and changes of the method embodiment of this case through the disclosure content of the device embodiment of this case, in order to avoid redundant text, it will not affect the disclosure requirements of the method embodiment and Under the premise of feasibility, repeated descriptions are abbreviated here. Please note that the shapes, sizes, proportions, and sequence of steps in the preceding figures are only illustrative, and are provided for those skilled in the art to understand the case, and are not intended to limit the case.
雖然本案之實施例如上所述,然而該些實施例並非用來限定本案,本技術領域具有通常知識者可依據本案之明示或隱含之內容對本案之技術特徵施以變化,凡此種種變化均可能屬於本案所尋求之專利保護範疇,換言之,本案之專利保護範圍須視本說明書之申請專利範圍所界定者為準。Although the embodiments of this case are as described above, these embodiments are not intended to limit the case. Those with ordinary knowledge in the technical field can apply changes to the technical features of the case based on the explicit or implicit content of the case. All such changes All may fall into the scope of patent protection sought in this case. In other words, the scope of patent protection in this case shall be subject to the scope of the patent application in this specification.
100、400、70:電子裝置
110、410、72:處理器
120、420、724、734:L1快取記憶體
130、430、74:L2快取記憶體
140、440:系統記憶體
132、432、7241、7341、742:控制電路
136、436、7242、7342、746:儲存電路
434、744:緩衝電路
720、730:核心
722、732:處理單元
76:暫存器
S210~S260、S310~S340、S510~S580、S610~S640:步驟100, 400, 70:
[圖1]為習知電子裝置的架構圖。; [圖2]為習知電子裝置操作於包容模式的部分流程圖; [圖3]為習知電子裝置操作於專有模式的部分流程圖; [圖4]為本案電子裝置之一實施例的架構圖; [圖5]為本案快取記憶體的管理方法的一實施例的流程圖; [圖6]為圖5的步驟S540的一實施例的流程圖;以及 [圖7]為本案電子裝置之另一實施例的架構圖。[Figure 1] is a structural diagram of a conventional electronic device. ; [Figure 2] is a partial flow chart of the conventional electronic device operating in the tolerance mode; [Figure 3] is a partial flow chart of the conventional electronic device operating in the proprietary mode; [Figure 4] The architecture diagram of an embodiment of the electronic device in this case; [Figure 5] A flowchart of an embodiment of the method for managing cache memory in this case; [Fig. 6] is a flowchart of an embodiment of step S540 in Fig. 5; and [Fig. 7] The structure diagram of another embodiment of the electronic device of the present invention.
70:電子裝置 70: electronic device
72:處理器 72: processor
724、734:L1快取記憶體 724, 734: L1 cache
74:L2快取記憶體 74: L2 cache
7241、7341、742:控制電路 7241, 7341, 742: control circuit
7242、7342、746:儲存電路 7242, 7342, 746: storage circuit
744:緩衝電路 744: snubber circuit
720、730:核心 720, 730: Core
722、732:處理單元 722, 732: processing unit
76:暫存器 76: register
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109116171A TWI739430B (en) | 2019-01-24 | 2019-01-24 | Cache and method for managing cache |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109116171A TWI739430B (en) | 2019-01-24 | 2019-01-24 | Cache and method for managing cache |
Publications (2)
Publication Number | Publication Date |
---|---|
TW202038103A true TW202038103A (en) | 2020-10-16 |
TWI739430B TWI739430B (en) | 2021-09-11 |
Family
ID=74091282
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW109116171A TWI739430B (en) | 2019-01-24 | 2019-01-24 | Cache and method for managing cache |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI739430B (en) |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070143550A1 (en) * | 2005-12-19 | 2007-06-21 | Intel Corporation | Per-set relaxation of cache inclusion |
US9477600B2 (en) * | 2011-08-08 | 2016-10-25 | Arm Limited | Apparatus and method for shared cache control including cache lines selectively operable in inclusive or non-inclusive mode |
US11042484B2 (en) * | 2016-06-24 | 2021-06-22 | Advanced Micro Devices, Inc. | Targeted per-line operations for remote scope promotion |
US10719448B2 (en) * | 2017-06-13 | 2020-07-21 | Alibaba Group Holding Limited | Cache devices with configurable access policies and control methods thereof |
-
2019
- 2019-01-24 TW TW109116171A patent/TWI739430B/en active
Also Published As
Publication number | Publication date |
---|---|
TWI739430B (en) | 2021-09-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11175853B2 (en) | Systems and methods for write and flush support in hybrid memory | |
JP5526626B2 (en) | Arithmetic processing device and address conversion method | |
JPH06243039A (en) | Method for operating order in cache memory system and microprocessor unit | |
US7657667B2 (en) | Method to provide cache management commands for a DMA controller | |
EP0543487B1 (en) | Method and cache memory controller for fetching data for a CPU that further reduces CPU idle time | |
US9009415B2 (en) | Memory system including a spiral cache | |
US9128856B2 (en) | Selective cache fills in response to write misses | |
US20060031640A1 (en) | Microprocessor and method for utilizing disparity between bus clock and core clock frequencies to prioritize cache line fill bus access requests | |
CN111124297B (en) | Performance improving method for stacked DRAM cache | |
TWI697902B (en) | Electronic device and method for managing electronic device | |
US6976130B2 (en) | Cache controller unit architecture and applied method | |
JP2010146084A (en) | Data processor including cache memory control section | |
JP6228523B2 (en) | Memory control circuit and semiconductor memory device | |
JP2002007373A (en) | Semiconductor device | |
CN111639042B (en) | Processing method and device for prefetching buffer data consistency | |
CN109669881B (en) | Computing method based on Cache space reservation algorithm | |
TWI739430B (en) | Cache and method for managing cache | |
US9158697B2 (en) | Method for cleaning cache of processor and associated processor | |
CN111506252B (en) | Cache memory and management method thereof | |
CN103186474B (en) | The method that the cache of processor is purged and this processor | |
JP2002366433A (en) | Cache memory controller and processor | |
US10599364B2 (en) | Command processing method and storage controller | |
JP3260566B2 (en) | Storage control method and storage control device in information processing system | |
JP2006146340A (en) | Memory control device and memory control method | |
JP2001195301A (en) | Updating circuit for pipeline cache memory |