Hardware-friendly circuit speculation loading method based on loading sequence

By combining Load-Sets and RAW! data structures, the handling of RAW conflicts between Load and Store instructions is optimized, solving the problems of performance loss and circuit area waste in the prior art, and realizing a hardware-friendly and efficient speculative load.

CN119005118AInactive Publication Date: 2024-11-22SHENZHEN AOWEI LINGXIN TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411043592.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-11-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, it is speculated that loading circuits in processors suffer from performance loss and wasted circuit area, especially in high-performance CPUs with out-of-order execution, where they cannot accurately handle RAW conflicts between Load and Store instructions.

Method used

The Load-Sets data structure is adopted, using the memory address of the store instruction as the key to store the PC difference between the violating load and the dependent store. It is combined with the RAW! data structure for retrieval, optimizing the timing design and reducing the retrieval complexity.

Benefits of technology

It achieves hardware-friendly precise speculative load, reduces circuit area consumption, and reduces retrieval complexity from O(N²) to O(N), thereby improving processor performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119005118A_ABST
    Figure CN119005118A_ABST
Patent Text Reader

Abstract

The invention discloses a hardware-friendly circuit speculation loading method based on a loading sequence. The hardware-friendly circuit speculation loading method based on the loading sequence comprises the first design of saving area, the second design of saving area and the second design of optimizing the time sequence. The invention opens up a read-after-write data structure RAW! According to the method, the concept of a Load-Sets (Load-Sets) is provided. Employing RAW! According to the method and the system, a search mode of Load-Sets is combined, and accurate updating of a preorder storage instruction in a speculative Load process is realized with a relatively small circuit area. The method and the system have the advantages that the method and the system are easy to implement, and the method and the system can be used for realizing accurate updating of the preorder storage instruction in the speculative Load process. RAW! According to the method, a memory address stdr written by a Store instruction is taken as a key (Key), and a difference value between a specific load and a program counter of a dependent store is taken as a value (Values), so that the situation that a large area is consumed when a complete storepc is stored is avoided; in the design of optimizing the time sequence, firstly, stadr is matched in Load-Sets, a Load instruction for speculating loading failure aiming at a memory address in history is locked, and then RAW! Is carried out. The method comprises the following steps of: indexing the Load instructions to obtain each dependent store; relative to direct RAW! According to a traditional method for retrieving storepc, the retrieval complexity is reduced from O (N2) to O (N) in a step-by-step retrieval mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of integrated circuit design, and in particular to a method for hardware-friendly speculative loading circuits based on loading sequences. Background Art

[0002] High-performance CPUs often use out-of-order execution, that is, the actual order of instruction dispatch and issuance does not follow the program order.

[0003] When a later load instruction in the program sequence does not depend on a preceding store instruction, the load instruction can be speculatively executed. This loading method is called speculative loading. For example, there is a conditional branch instruction whose taken program segment contains a store instruction; at the same time, the first instruction on the non-taken logical link of the branch is a load instruction that accesses the same memory address. Assume that the branch predictor (Branch Predict Unit: BPU) has historically predicted that the current conditional branch instruction is non-taken with a high probability. At this time, this load instruction can be speculatively executed. This approach will greatly improve the performance of the processor. However, if the BPU prediction in the above example fails and the program enters the taken path, that is, the store instruction in the branch is executed, then the speculative load also fails, and the load instruction needs to be re-executed, which will cause performance loss.

[0004] The correct execution of speculative load depends on the use of a specific data structure to store historical RAW conflict entries. Store-Set[1] is a method for implementing speculative load. The original design is based on a two-level cascaded key-value mapping table. The first table is called the store sequence identifier table (Store-Set-Identifier-Table: SSIT); the second table is called the table of the most recently fetched store instructions (Last-Fetched-Store-Table: LFST), whose table entry index is the content of the first table entry, and the content of the table entry is the instruction sequence number (Sequence Number: SN) of the most recent store that had a RAW conflict with a load.

[0005] After the RAW conflict is generated, the program counter (PC) of the load instruction is shifted and the total number of entries SSIT_ENTRIES is modulo (%) to obtain the entry index:

[0006] load_index=(load_pc>>2)%SSIT_ENTRIES

[0007] Formula 10;

[0008] Similarly, the index of the store instruction in SSIT can be calculated from store_pc

[0009] store_index=(store_pc>>2)%SSIT_ENTRIES

[0010] Formula 11;

[0011] The content of the table entry is generated by HASHing the PC of the load instruction, and the tag shared by the load / store with RAW conflict is obtained, which is called the storage sequence identification number (Store-Set-Identifier: SSID):

[0012] ssid=(load_pc^(load_pc>>10))%LFSTENTRIES

[0013] Formula 12;

[0014] The above formula has two meanings: On the one hand, a load with a RAW conflict may have multiple dependent stores. Ideally, all stores that have had a RAW conflict with the load in the past need to be stored. Given that stores are always retired sequentially, the minimum requirement for the RAW constraint relationship is to be established between the load and the store that most recently had a RAW conflict with it. In the original design of Store-Set, the value of each entry in LFST is a single-element value, that is, only the SN of the store that most recently generated a RAW conflict is recorded. On the other hand, from the perspective of circuit feasibility: the area overhead required to store complete 64-bit PCs is unacceptable. Therefore, Formula 12 adopts the approach of HASHing the PC and then constraining it within the range of LFST_ENTRIES, thereby achieving a certain degree of unique representation of the load.

[0015] This design cannot achieve precise RAW constraints in principle.

[0016] Different store_pc may have the same store_index calculated according to formula 11, but there may be an incorrect dependency between store_pc and load_pc, as shown below:

[0017]

[0018] Load_pc and store_pc_1 jointly maintain a set of RAW constraints, that is, they occupy a SSID:99 (obtained from formula 12). However, according to formula 11, both store_pc_1 and store_pc_2 can obtain store_index=28. Therefore, LFST

[99] is updated to store_pc_2's SN:828451, that is, the original design of Store-Set will determine that store_pc_2 is the store that has the most recent RAW conflict with load_pc:0xffffffe000228cc0, but in fact, the read and write addresses of the two are different and have no correlation. Summary of the invention

[0019] The purpose of the present invention is to solve the problems existing in the prior art and to propose a method for a hardware-friendly speculative loading circuit based on a loading sequence.

[0020] In order to achieve the above object, the present invention adopts the following technical solutions:

[0021] A method for hardware-friendly speculative loading circuit based on loading sequence, including a first design for saving area, a design for optimizing timing and a second design for saving area;

[0022] The area-saving design 1 specifically includes the following steps:

[0023] S1. The data structure of Load-Sets is proposed. The key is the memory address st_addr to be written by the store instruction. The value is the set of differences between the violating load and the PC of each dependent store.

[0024] The second design for saving area specifically comprises the following steps:

[0025] P1, use the difference between the PC vio_ld_pc of the instruction that failed to load and the PC store_pc of its preceding store instruction to replace store_pc for storage, as shown in Formula 1;

[0026] Right now:

[0027] {delta_pc | delta_pc(i)=(vio_ld_pc-store_pc(i)),i=1,2,…} Formula 1;

[0028] P2, in the instruction dispatch stage, the newly entered store_pc and delta_pc are used as the input of the decoding circuit to obtain vio_ld_pc in formula 2;

[0029] Right now:

[0030] vio_ld_pc=delta_pc(i)+store_pc(i),i=1,2,… Formula 2;

[0031] P3, use the obtained vio_ld_pc to match the Key in RAW!;

[0032] Preferably, the violating load specifically refers to a load instruction with a RAW conflict, which is distinguished from a regular load instruction;

[0033] The key-value mapping table storing the RAW constraint relationship is represented by RAW!;

[0034] The key of RAW! is the PC value of the violating load, vio_ld_pc; the Values ​​of each RAW! entry is a set that represents the value store_pc of the stores that have RAW conflicts with the violating load.

[0035] The design of the optimized timing specifically includes the following steps:

[0036] L1. When the store instruction is in the Dispatch Stage, check whether the store already exists in RAW! If it does, update the store to the "most recent" store that has a RAW conflict with the violating load;

[0037] L2, use Load-Sets combined with RAW! to search, reduce the retrieval complexity, first lock all related violating loads according to the memory address written by the store, and then use vio_ld_pc to retrieve the retrieval of each dependent store to reduce the retrieval complexity from O(N) to O(N). 2 ) reduces the dimension to O(N) to ensure timing closure;

[0038] Preferably, in the design of optimizing the timing, if the location of the store is updated only by relying on RAW!, it is necessary to traverse each entry of RAW! to check whether the current store is included in the dependent stores;

[0039] The total complexity of the search:

[0040]

[0041] Where N represents the number of entries in RAW!, and M(i) represents the number of dependentstores contained in each entry in RAW!.

[0042] Preferably, in the design of the optimized timing, the following analysis is performed on L3:

[0043] 1) If the total number of entries in Load-Sets is l, the complexity of retrieving a specific st_addr_j is O(l);

[0044] 2) Assume that the number of vio_ld associated with st_addr_j is x (x is much smaller than N), that is, Load-Sets[st_addr_j] points to x delta_pc; then, these x delta_pc are sent to the decoding circuit to obtain x load_pc;

[0045] Matching these x load_pc in N lines of RAW! has a complexity of:

[0046] O(N)+O(N-1)+…+O(N-(x-1))=x·O(N)

[0047] Formula 4;

[0048] 3) Assume that after hitting the i-th row of RAW!, the complexity of searching delta_pc[j](0≤j≤(x-1)) in the dependent stores it contains is O(M(i));

[0049] Then the retrieval complexity of delta_pc for all x rows is:

[0050]

[0051] Therefore, the total complexity of the retrieval method of Load-Sets combined with RAW! is:

[0052]

[0053] Compare the above two methods:

[0054] 1) If M(i) is approximately equal to N, the complexity of the first method shown in Formula 3 can be further expressed as O(N 2 ); At the same time, assuming that l is also approximately equal to N, the complexity given by Formula 6 can be further expressed as:

[0055]

[0056] Thus, O(N 2 )->O(N) dimensionality reduction;

[0057] 2) If M(i) is much smaller than N, the complexity of the first method shown in formula 3 is:

[0058]

[0059] On the other hand, still assuming that l is approximately equal to N, the complexity given by Formula 6 is:

[0061]

[0062] Based on the above, no matter whether M(i) is in the same order of magnitude as N, compared with searching the storePC directly in the entire RAW!, the retrieval complexity can always be reduced from O(N) to O(N) by first locking all related violating loads according to the memory address written by the store and then retrieving each dependent store by vio_ld_pc. 2 ) is reduced to O(N).

[0063] Compared with the prior art, the present invention has the following beneficial effects:

[0064] 1. The present invention uses the newly entered store_pc and delta_pc as inputs of a decoding circuit to obtain vio_ld_pc in the instruction dispatch stage, and uses the difference between vio_ld_pc and store_pc to replace store_pc for storage, thereby avoiding the situation where storing a complete store_pc consumes a large amount of circuit area.

[0065] 2. Compared with the prior art that directly searches for store PC in the entire RAW!, the present invention first matches st_addr in Load-Sets, locks the Load instructions that have failed to perform speculative loads on the memory address in the past, and then matches these Load instructions in RAW! to obtain each dependent store. Through this step-by-step search method, the complexity of the search is reduced from O(N 2 ) to O(N) dimensionality reduction. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 A data structure diagram of a two-level cascade mapping table used in the original Store-Set design of the present invention;

[0067] Figure 2 It is a schematic diagram of the complexity calculation of the new store search based on the data structure RAW! in the present invention;

[0068] Figure 3 An example diagram of the basic data structure of Load-Sets and the mapping relationship between loads and stores accessing the same memory address in the present invention;

[0069] Figure 4 A schematic diagram of resource saving caused by selecting to write the memory address st_addr instead of the PC value of the store instruction as the Keys of Load-Sets in the present invention;

[0070] Figure 5 This is an overall test performance benefit diagram using the CPU standard test set SPEC06 as an example in the present invention;

[0071] Figure 6 A more detailed performance counting statistics chart for the configurations of the first-level table entry number SSIT Entries being 128 and 1024 in the present invention. DETAILED DESCRIPTION

[0072] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0073] Embodiment 1:

[0074] Reference Figure 1-Figure 6 , a method for hardware-friendly speculative loading circuits based on loading sequences, including an area-saving design 1, an area-saving design 2, and a timing-optimized design;

[0075] It should be noted that in this solution, violating load refers specifically to load instructions with RAW conflicts, which are distinguished from regular load instructions;

[0076] The key-value mapping table storing the RAW constraint relationship is represented by RAW!;

[0077] The key of RAW! is the PC value of the violating load, vio_ld_pc; the Values ​​of each RAW! entry is a set that represents the value store_pc of the stores that have RAW conflicts with the violating load.

[0078] A similar consideration to the original design of Store-Set is that storing all complete store_pc will consume a lot of circuit area.

[0079] Considering that there are usually only a few to dozens of instructions between load-stores that actually cause RAW conflicts, the difference in PC between the two can be represented by 7 bits. Therefore, the cost of storing the difference in PC is much smaller than storing store_pc (7 / 64=10.9%).

[0080] Design 1 for saving area uses the difference between vio_ld_pc and store_pc to replace store_pc for storage, as shown in Formula 1;

[0081] Right now:

[0082] {delta_pc|delta_pc(i)=(vio_ld_pc-store_pc(i)),i=1,2,…} Formula 1;

[0083] In the instruction dispatch stage, the newly entered store_pc and delta_pc are used as the input of the decoding circuit to obtain vio_ld_pc in formula 2;

[0084] Right now:

[0085] vio_ld_pc=delta_pc(i)+store_pc(i),i=1,2,...Formula 2;

[0086] Use the obtained vio_ld_pc to match the Key in RAW!;

[0087] Embodiment 2 proposed based on Embodiment 1:

[0088] Design for optimized timing:

[0089] When the store instruction is in the Dispatch Stage, check whether the store already exists in RAW! If so, update the store to the "most recent" store that has a RAW conflict with the violating load.

[0090] refer to Figure 2If you only rely on RAW! to update the location of the store, you need to traverse each entry of RAW! to check whether the dependent stores contain the current store;

[0091] The total complexity of the search:

[0092]

[0093] Where N represents the total number of entries in RAW! and M(i) represents the number of dependentstores contained in each entry in RAW!.

[0094] This solution proposes a data structure of Load-Sets, which is essentially still a key-value mapping table. The key is the memory address st_addr to be written by the store instruction; the value is the set of differences between the violating load and the PC of each dependent store, as shown in Formula 1.

[0095] Load-Sets combined with RAW! is used to reduce the retrieval complexity. All related violating loads are first locked according to the memory address written by the store, and then the retrieval method of each dependent store is retrieved by vio_ld_pc to reduce the retrieval complexity from O(N) to O(N). 2 ) reduces the dimension to O(N) to ensure timing closure;

[0096] In the design of optimizing timing, the following analysis is made on L3:

[0097] 1) If the total number of entries in Load-Sets is l, the complexity of retrieving a specific st_addr_j is O(l);

[0098] 2) Assume that the number of vio_ld associated with st_addr_j is x (x is much smaller than N), that is, Load-Sets[st_addr_j] points to x delta_pc; then, these x delta_pc are sent to the decoding circuit to obtain x load_pc;

[0099] Matching these x load_pc in N lines of RAW! has a complexity of:

[0100] O(N)+O(N-1)+…+O(N-(x-1))=x·O(N)

[0101] Formula 4;

[0102] 4) Assume that after hitting the i-th row of RAW!, the complexity of searching delta_pc[j](0≤j≤(x-1)) in the dependent stores it contains is O(M(i));

[0103] Then the retrieval complexity of delta_pc for all x rows is:

[0104]

[0105] Therefore, the total complexity of the retrieval method of Load-Sets combined with RAW! is:

[0106]

[0107] Compare the above two methods:

[0108] 1) If M(i) is approximately equal to N, the complexity of the first method shown in Formula 3 can be further expressed as O(N 2 ); At the same time, assuming that l is also approximately equal to N, the complexity given by Formula 6 can be further expressed as:

[0109]

[0110] Thus, O(N 2 )->O(N) dimensionality reduction;

[0111] 2) If M(i) is much smaller than N, the complexity of the first method shown in formula 3 is:

[0112]

[0113] On the other hand, still assuming that l is approximately equal to N, the complexity given by Formula 6 is:

[0114]

[0115] Based on the above, no matter whether M(i) is in the same order of magnitude as N, compared with searching the storePC directly in the entire RAW!, the retrieval complexity can always be reduced from O(N) to O(N) by first locking all related violating loads according to the memory address written by the store and then retrieving each dependent store by vio_ld_pc. 2 ) is reduced to O(N).

[0116] Embodiment 3 proposed based on Embodiment 2:

[0117] Design 2 for saving area: The object to be matched in the first step of the above step-by-step search strategy is the address st_addr of the store instruction in the Load-Sets. The original intention of Store-Set is to obtain the information of the store that may have a RAW conflict. In fact, storing the store pc will also be wasteful.

[0118] Figure 3 By capturing the instruction snippet of the libquantum group of the CPU standard test set SPEC06, we can see that both store instructions access the same memory address, which is also loaded by multiple load instructions at the same time.

[0119] like Figure 4 As shown in Figure 1, the number of non-repeated delta_pc obtained between these loads and dependent stores is indefinite. When delta_pc is different, that is,

[0120]

[0121] In this example, at most 6 delta_pc are generated; on the contrary, if the delta_pc obtained according to formula 1 are the same, then the effect of storing 1 delta_pc and 6 delta_pc is the same.

[0122] Therefore, the method adopted in this embodiment is to use the write memory address st_addr of the store instruction as the Key of Load-Sets; in the Dispatch Stage, according to the PC of the new store, the violating load PC can still be correctly decoded according to Formula 2.

[0123] Through specific implementation, it is proved that after adopting the present invention, the overall test performance benefit of taking the CPU standard test set SPEC06 as an example is as follows: Figure 5 (The horizontal axis represents each group of SPEC06 use cases, and the vertical axis represents the number of instructions executed per clock cycle (Instruction Per Cycle: IPC)) as shown; performance statistics are as follows Figure 6 As shown in (More detailed performance count statistics for configurations with 128 and 1024 first-level table entries), when the number of table entries is appropriately increased (1024), the ratio of memory-order-violation decreases by approximately 10.5.

[0124] The present invention has the following effects:

[0125] The data structure of Load-Sets is proposed and implemented, and combined with the data structure RAW!, a hardware-friendly precise speculative load is implemented.

[0126] The RAW! data structure is used, with the load PC as the key, to solve the incorrect RAW dependency between Load-Store that may be introduced by the two-level cascade table entry in the original Store-Set design.

[0127] RAW! The data structure uses the difference between the load PC and the dependent stores PC instead of the store PC itself, thus reducing storage resource consumption to 10.9% of the original.

[0128] The memory address written by the store instruction is selected as the key of Load-Sets, avoiding the huge resource consumption of storing complete store PCs.

[0129] The search complexity of the target store is reduced from O(N) to O(N) by combining Load-Sets with RAW! 2 ) is reduced to O(N), where N is the total number of load PCs with RAW conflicts.

[0130] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for hardware-friendly speculative loading circuit based on loading sequence, characterized in that: It includes area saving design 1, area saving design 2 and timing optimized design; The area-saving design 1 specifically includes the following steps: S1. The data structure of Load-Sets is proposed. The key is the memory address st_addr to be written by the store instruction. The value is the set of differences between the violating load and the PC of each dependent store. The second design for saving area specifically comprises the following steps: P1, use the difference between the PC vio_ld_pc of the instruction that failed to load and the PC store_pc of its preceding store instruction to replace store_pc for storage, as shown in Formula 1; Right now: {delta_pc|delta_pc(i)=(vio_ld_pc-store_pc(i)),i=1,2,…} Formula 1; P2, in the instruction dispatch stage, the newly entered store_pc and delta_pc are used as the input of the decoding circuit to obtain vio_ld_pc in formula 2; Right now: vio_ld_pc=delta_pc(i)+store_pc(i),i=1,2,… Formula 2; P3, use the obtained vio_ld_pc to match the Key in RAW!; The design of the optimized timing specifically includes the following steps: L1, when the store instruction is in the Dispatch Stage, check whether the store is part of the RAW! table content. If so, update the store to the "most recent" store that caused a RAW conflict with the violating load; L2, use Load-Sets combined with RAW! to search, reduce the retrieval complexity, first lock all related violating loads according to the memory address written by the store, and then use vio_ld_pc to retrieve the retrieval of each dependent store to reduce the retrieval complexity from O(N) to O(N). 2 ) is reduced to O(N) to ensure timing closure.

2. The method of a hardware-friendly speculative loading circuit based on a loading sequence according to claim 1, characterized in that: The violating load specifically refers to a load instruction with a RAW conflict, which is distinguished from a regular load instruction; The key-value mapping table storing the RAW constraint relationship is represented by RAW!; The key of RAW! is the PC value of violating load, vio_ld_pc; the values ​​of each RAW! entry is the set store_pc of delta_pc shown in formula 1.

3. The method of a hardware-friendly speculative loading circuit based on a loading sequence according to claim 1, characterized in that: In the design of optimizing the timing, if the location of the store is updated only by relying on RAW!, it is necessary to traverse each entry of RAW! and check whether the current store is included in the dependent stores; The total complexity of the search: Where N represents the total number of entries in RAW! and M(i) represents the number of dependentstores contained in each entry in RAW!.

4. The method of a hardware-friendly speculative loading circuit based on a loading sequence according to claim 1, characterized in that: In the design of the optimized timing, the following analysis is made on L3: 1) If the total number of entries in Load-Sets is l, then the complexity of retrieving a specific st_addr_j is O(l); 2) Assume that the number of vio_ld associated with st_addr_j is x (x is much smaller than N), that is, Load-Sets[st_addr_j] points to x delta_pc; then, these x delta_pc are sent to the decoding circuit to obtain x load_pc; Matching these x load_pc in N lines of RAW! has a complexity of: O(N)+O(N-1)+…+O(N-(x-1))=x·O(N) Formula 4; 3) Assume that after hitting the i-th row of RAW!, the complexity of searching delta_pc[j](0≤j≤(x-1)) in the dependent stores it contains is O(M(i)); Then the retrieval complexity of delta_pc for all x rows is: Therefore, the total complexity of the retrieval method of Load-Sets combined with RAW! is: Compare the above two methods: 1) If M(i) is approximately equal to N, the complexity of the first method shown in Formula 3 can be further expressed as O(N 2 ); At the same time, assuming that l is also approximately equal to N, the complexity given by Formula 6 can be further expressed as: Thus, O(N 2 )->O(N) dimensionality reduction; 2) If M(i) is much smaller than N, the complexity of the first method shown in formula 3 is: On the other hand, still assuming that l is approximately equal to N, the complexity given by Formula 6 is: Based on the above, no matter whether M(i) is in the same order of magnitude as N, compared to searching the store PC directly in the entire RAW!, the retrieval complexity can always be reduced from O(N) to O(N) by first locking all related violating loads according to the memory address written by the store and then retrieving the dependent stores by vio_ld_pc. 2 ) is reduced to O(N).

Citation Information

Patent Citations

  • High-performance speculation execution algorithm protected from Spectre attacks

    CN108427576A

  • Methods and apparatus for facilitating a memory mis-speculation recovery

    US10606603B1

  • Method and system for early speculative store-load bypass

    US20040044881A1

  • Computing System with Transactional Memory Using Millicode Assists

    US20080288819A1