An adaptive stack cache method and system
Through the adaptive stack cache method, the status of the stack top pointer register and the stack cache is used to issue two memory access instructions during the instruction issuance phase, which improves the instruction level parallelism and data cache hit rate, and solves the problems in the existing technology. The problem of low stack cache hit rate is applicable to commercial processors and reduces the processor performance impact.
Patent Information
- Application Number
- CN202411035524.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-31
AI Technical Summary
In the existing technology, the hit rate of the stack cache is not high, which results in the inability to effectively apply it in commercial processors. In particular, stack overflow and process switching are expensive and affect processor performance.
Using the adaptive stack cache method, by obtaining the access type and pipeline level of the instruction, using the status of the stack top pointer register and the stack cache, two memory access instructions are issued during the instruction issuance phase, using the stack pointer and the non-stack pointer as respectively Base register, improves instruction-level parallelism and increases data cache hit ratio.
It improves the instruction level parallelism and data cache hit rate, reduces the average load_to_use latency of the processor, reduces the pollution and failure rate of the data cache, is suitable for multi-process environments, and is adaptively closed when the stack overflows, avoiding Performance impact.
Smart Images

Figure CN118568011B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of high-speed cache, and in particular relates to an adaptive stack high-speed cache method and system. Background Art
[0002] Using the principle of locality and adopting one or more levels of cache is one of the effective means to improve the performance of storage systems. Furthermore, in order to better utilize the principle of locality and improve the cache hit rate, the cache is divided into instruction cache and data cache. The memory is divided into code segment, data segment, heap space and stack space according to function, which provides the possibility for further subdivision of data cache. The access to stack space data has good temporal locality and spatial locality. The program continuously accesses data close to the top of the stack. The preservation of local variables, parameter passing, and the preservation and restoration of registers during function calls are all completed through the access to the stack space.
[0003] At present, the research on data cache decoupling technology mainly focuses on setting up a dedicated stack storage device on the chip to separate local stack data from other global data accesses. In order to better parallelize stack access with other data accesses, it is necessary to simultaneously issue a stack access instruction and a non-stack access instruction during the instruction issuance phase. The address of the memory access instruction has not been calculated during the instruction issuance phase. The current technology for distinguishing stack access from other data accesses includes using software to mark the stack when allocating space, using a prediction table to predict the access area of the memory access instruction based on historical information, and adding additional address calculation logic to calculate the address of the memory access instruction during the decoding phase.
[0004] In the prior art, the research on fast address calculation technology is to predict the access address by only calculating the low-order address to reduce the hit time, but the accuracy of stack access address prediction is not high. The overhead of stack cache overflow and process switching is very large, which is the reason why stack cache cannot be applied to commercial general-purpose processors. Summary of the invention
[0005] The purpose of the present invention is to provide an adaptive stack cache method and system to solve one or more of the above-mentioned technical problems. The technical solution provided by the present invention can improve instruction-level parallelism and increase data cache hit rate.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] A first aspect of the present invention provides an adaptive stack caching method, comprising the following steps:
[0008] Get the access type of the instruction;
[0009] Based on the access type, obtaining a corresponding pipeline level; wherein different access types correspond to different pipeline levels;
[0010] Instructions are issued according to the states of the stack cache, the stack top pointer register and the pipeline stage; wherein the stack cache and the stack top pointer register are integrated in the storage subsystem; in the instruction issuance stage, at most two memory access instructions are issued in each beat, the base address register of one instruction is the stack pointer, and the base address register of the other instruction is the non-stack pointer;
[0011] in,
[0012] The step of obtaining the corresponding pipeline level based on the access type includes:
[0013] The stack access instructions that use the stack pointer register as the base register have two pipeline stages;
[0014] For stack access instructions that do not use the stack pointer register as the base address register, the pipeline stage is divided into 3 levels;
[0015] For non-stack access memory access instructions, the pipeline stage is divided into 4 levels;
[0016] In the step of transmitting instructions according to the status of the stack cache, the stack top pointer register and the pipeline stage, the process address space identifier of the instruction is added to the stack cache tag; the value of the process address space identifier of the instruction comes from the control register of the processor.
[0017] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0018] When the pipeline stage is divided into two levels, in the instruction issuance stage, the first beat uses the saved value of the stack top pointer register to perform address calculation and uses the calculated address to access the stack cache, determine whether the stack cache hits and send it to the storage management queue; the second beat writes the access result back.
[0019] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0020] When the pipeline stage is divided into three levels, in the instruction issuance stage, the address operation unit calculates the virtual address in the first beat and sends the memory access request to the stack cache; the second beat accesses the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the third beat writes the access result back.
[0021] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0022] When the pipeline stage is divided into 4 levels, in the instruction issuance stage, the first beat address calculation unit calculates the virtual address and sends the memory access request to the conversion lookaside buffer and data cache; the second beat accesses the data cache while the conversion lookaside buffer converts the virtual address into a physical address; the third beat compares the flag bits according to the access results of the conversion lookaside buffer and the data cache, determines whether the data cache hits, and sends it to the storage management queue; the fourth beat writes the access result back.
[0023] A further improvement of the present invention is that the capacity of the data cache is 64KB, and the structure adopts a four-way set associative, single-port structure; the capacity of the stack cache is 16KB.
[0024] A second aspect of the present invention provides an adaptive stack cache system, comprising:
[0025] A first acquisition module, used for acquiring an access type of an instruction;
[0026] A second acquisition module, configured to acquire a corresponding pipeline level based on the access type; wherein different access types correspond to different pipeline levels;
[0027] An instruction emission module is used for transmitting instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage; wherein the stack cache and the stack top pointer register are integrated in the storage subsystem; in the instruction emission stage, at most two memory access instructions are emitted in each beat, the base address register of one instruction is the stack pointer, and the base address register of the other instruction is the non-stack pointer;
[0028] in,
[0029] The step of obtaining the corresponding pipeline level based on the access type includes:
[0030] The stack access instructions that use the stack pointer register as the base register have two pipeline stages;
[0031] For stack access instructions that do not use the stack pointer register as the base address register, the pipeline stage is divided into 3 levels;
[0032] For non-stack access memory access instructions, the pipeline stage is divided into 4 levels;
[0033] In the step of transmitting instructions according to the status of the stack cache, the stack top pointer register and the pipeline stage, the process address space identifier of the instruction is added to the stack cache tag; the value of the process address space identifier of the instruction comes from the control register of the processor.
[0034] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0035] When the pipeline stage is divided into two levels, in the instruction issuance stage, the first beat uses the saved value of the stack top pointer register to perform address calculation and uses the calculated address to access the stack cache, determine whether the stack cache hits and send it to the storage management queue; the second beat writes the access result back.
[0036] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0037] When the pipeline stage is divided into three levels, in the instruction issuance stage, the address operation unit calculates the virtual address in the first beat and sends the memory access request to the stack cache; the second beat accesses the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the third beat writes the access result back.
[0038] A further improvement of the present invention is that in the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage,
[0039] When the pipeline stage is divided into 4 levels, in the instruction issuance stage, the first beat address calculation unit calculates the virtual address and sends the memory access request to the conversion lookaside buffer and data cache; the second beat accesses the data cache while the conversion lookaside buffer converts the virtual address into a physical address; the third beat compares the flag bits according to the access results of the conversion lookaside buffer and the data cache, determines whether the data cache hits, and sends it to the storage management queue; the fourth beat writes the access result back.
[0040] A further improvement of the present invention is that the capacity of the data cache is 64KB, and the structure adopts a four-way set associative, single-port structure; the capacity of the stack cache is 16KB.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] The present invention specifically provides an adaptive stack cache method, which can improve instruction-level parallelism and increase data cache hit rate. Specifically, the memory access pipeline is no longer simply divided into 4 levels, but is divided into different pipeline levels according to different access types. Such a design enables the storage subsystem to better adapt to different types of memory access operations and improve overall performance.
[0043] In the present invention, the stack access is separated from the data cache access by using the standard of whether the sp register is used as the base address register, thereby improving the instruction level parallelism; neither software support nor additional hardware overhead such as prediction tables or address pre-calculation logic is required, thereby reducing data cache pollution and increasing the data cache hit rate. The characteristics of stack space data access are fully utilized, unnecessary data transmission is reduced, and a fast address calculation mechanism is adopted to reduce the average load_to_use latency of the processor, thereby improving the ability of the memory access function component to provide data for each functional component.
[0044] In the present invention, when stack overflow occurs, it can be closed adaptively to avoid the influence of stack switching on processor performance. In addition, by adding process address space identification in the flag, data does not need to be written to the low-level storage system when the process switches, which is suitable for multi-process environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below; obviously, the drawings described below are some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 It is a schematic diagram of an adaptive stack caching method in an embodiment of the present invention.
[0047] Figure 2 This is a diagram showing the ratio of stack access instructions to memory access instructions.
[0048] Figure 3 This is a graph showing the number of stack access instructions per thousand instructions.
[0049] Figure 4 This is a schematic diagram of the spatial change in the distance between the stack access address and the bottom of the initialization stack.
[0050] Figure 5 This is a diagram showing the ratio of stack accesses using each register as the base register.
[0051] Figure 6 It is a schematic diagram of a storage subsystem micro-architecture of an adaptive stack cache method using fast address calculation in an embodiment of the present invention.
[0052] Figure 7 It is a schematic diagram of an embodiment of the present invention, which adopts an adaptive stack cache with fast address calculation and uses the sp register to predict the prediction accuracy of stack access.
[0053] Figure 84 is a schematic diagram of the proportion of instructions executed in parallel by the data cache and the stack cache to all memory access instructions in an embodiment of the present invention, using an adaptive stack cache with fast address calculation.
[0054] Fig. 9 It is a schematic diagram of the reduction ratio of the failure rate of the data cache by using the adaptive stack cache with fast address calculation in the embodiment of the present invention.
[0055] Fig.10 It is a schematic diagram of the IPC (Instructions per Cycle) value of each program in an embodiment of the present invention, which respectively adopts a single data cache (base cache), an adaptive stack cache with fast address calculation (decouple stack cache), and an adaptive stack cache with fast address calculation in an ideal situation where all stack access operations are predicted correctly (perfect stack cache).
[0056] Fig.11 It is a schematic diagram of an adaptive stack cache system in an embodiment of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0058] See also Figure 1 In an embodiment of the present invention, an adaptive stack cache method is provided, comprising the following steps:
[0059] Step 1, obtain the access type of the instruction;
[0060] Step 2, based on the access type, obtaining a corresponding pipeline level; wherein different access types correspond to different pipeline levels;
[0061] Step 3, according to the status of the stack cache, the stack top pointer register and the pipeline stage, the instruction is issued (interpretatively, it is determined whether to issue an instruction and which instructions to issue, etc.); wherein the stack cache and the stack top pointer register are integrated into the storage subsystem; in the instruction issuance stage, at most two memory access instructions are issued in each beat, the base register of one instruction is the stack pointer, and the base register of the other instruction is the non-stack pointer.
[0062] In the technical solution provided by the embodiment of the present invention, by adopting an adaptive stack cache with fast address calculation, optimizing the design of data cache and memory access pipeline, and enhancing the parallelism of instruction emission, the storage access performance of the system is significantly improved, especially the optimization of stack access operations, so that higher efficiency and stability can be shown when processing complex computing tasks. Specifically, in the embodiment of the present invention, the memory access pipeline is no longer simply divided into 4 levels, but is divided into different pipeline levels according to different access types. Such a design enables the storage subsystem to better adapt to different types of memory access operations and improve overall performance.
[0063] In a further preferred technical solution of the embodiment of the present invention, the stack cache uses a capacity of 16KB to cache stack operations to improve the efficiency of stack access.
[0064] In the embodiment of the present invention, the capacity of the data cache is still 64KB; the structure adopts a four-way set associative, single-port structure to ensure the high efficiency and flexibility of data access.
[0065] The embodiments of the present invention provide a principle explanation of the technical solution:
[0066] The stack cache is a hardware structure specifically used to cache stack data. Since the access pattern of stack data is usually continuous and has the principle of locality, the stack cache can significantly improve the performance of stack operations. Integrating the stack cache into the storage subsystem allows the processor to obtain data faster when accessing stack data, reducing memory access latency. The stack top pointer register is used to track the top position of the stack. Integrating the stack top pointer register into the storage subsystem allows the processor to directly access the stack top pointer when performing stack operations without having to obtain it through memory access, which can further reduce the latency of stack operations.
[0067] When executing an instruction, the processor needs to determine the access type of the instruction, that is, whether the instruction accesses stack data or non-stack data, which can be achieved by checking the base address register of the instruction. Depending on the access type, the processor can divide the instructions into different pipeline stages for processing. For example, for stack access instructions, they can be placed in a pipeline stage that specifically handles stack operations; for non-stack access instructions, they can be placed in a pipeline stage that handles general memory access, which can improve the parallelism and efficiency of the processor.
[0068] After determining the access type and pipeline level of the instruction, the processor can start issuing instructions. In the instruction issuance stage, the processor will decide whether to issue instructions and which instructions to issue based on the status of the stack cache, the stack top pointer register, and the pipeline level. In order to improve the throughput of the processor, the processor can issue multiple instructions in each clock cycle. However, due to the limitations of hardware resources and the dependencies between instructions, the processor can only issue a maximum of two memory access instructions in each clock cycle. Among them, the base register of one instruction is the stack pointer (i.e., stack access instruction), and the base register of the other instruction is the non-stack pointer (i.e., non-stack access instruction). This ensures that the processor can maintain high efficiency and parallelism when processing stack and non-stack access at the same time.
[0069] During the research and development process, the applicant analyzed the program memory access behavior, especially the stack access behavior, and found that an average of 77% of the SPEC CPU2000 program stack space data accesses use the stack pointer (sp, stack pointer) register as the base register, and the accesses using the sp register as the base register are stack accesses; therefore, there is no need to rely on software or perform complex address prediction and pre-calculation, and most of the stack accesses can be distinguished by simply judging whether the sp register is used as the base register. In addition, by saving the value of the sp register at the access stack cache pipeline level, the time for reading the register stack can be reduced, and the address calculation can be performed directly at the first level of the stack cache access; because the stack cache is indexed by virtual addresses and the mapping relationship between virtual and real addresses is recorded in the flag, the access of the stack cache hit does not need to compare the flags; therefore, the stack cache with fast address calculation, the stack access load_to_use latency using the sp register as the base register is reduced by 2 beats, and the average load_to_use latency of memory access is reduced by 17%. Explanatory, Load_to_use latency refers to the number of beats from the issuance of a memory access instruction to the time when the access result can be used by other functional components. It reflects the performance of the processor's memory access functional components in the case of a cache hit and is an important measure of the data supply capability of the processor's memory access functional components.
[0070] The stack cache solution proposed in the embodiment of the present invention can be adaptively closed when stack overflow occurs. Explanatoryally, the above solution of the embodiment of the present invention adds a process identifier to the stack cache flag, and does not need to write data back to the low-level storage system at one time when the process switches, which is suitable for a multi-process environment.
[0071] In the embodiment of the present invention, the memory access behavior of the program is deeply analyzed, and an Adaptive Stack Cache with Fast Address Generation scheme with fast address calculation is proposed. The scheme uses the characteristics of stack access and proposes a method to predict that the access with the sp register as the base address register is a stack access, separates the stack access from the data cache access, and makes 25.8% of the memory access instructions executed in parallel in the two memory access components of the stack cache and the data cache, effectively improving the instruction-level parallelism, avoiding the data cache pollution caused by the stack data replacing the global data in the data cache, and reducing the data cache failure rate by 9.4%. The embodiment of the present invention adopts a fast address calculation strategy to reduce the hit delay of the memory access instruction. When the stack cache overflows, it can be closed adaptively to avoid the impact of stack switching on the processor performance. The process identifier is added to the stack cache flag, and the data does not need to be written to the low-level storage system when the process switches, which is suitable for a multi-process environment. Performance evaluation results show that the adaptive stack cache solution with fast address calculation can improve the IPC (Instruction per Cycle) value of SPEC CPU2000 programs by an average of 6.9%.
[0072] In contrast, Cooper proposed a method to use a special CCM (Compiler-Controlled Memory) to handle the spill code automatically inserted by the compiler. Spill code refers to the code that the compiler automatically inserts to transfer data between registers and memory when registers are insufficient, accounting for 20% of the program code. The compiler adds a mark when inserting the spill code, and the access of the spill code enters the CCM; Spill code is only a part of the stack access, and the CCM does not optimize other stack accesses. In addition, S.cho called all variables accessing the stack local variables (LocalVariable), and proposed to separate the access to local variables from the access to other data, and use a special local variable cache (LVC, Local Variable Cache) and a local variable access queue (LVAQ, Local Variable AccessQueue) to handle the access to local variables. The local variable cache uses the PC index access region prediction table (ARPT, Access Region Prediction Table) to predict whether the memory access instruction is an access to the stack space; LVC does not fully utilize the characteristics of stack access, but is only organized in the form of a normal cache. Furthermore, S. Lee proposed the Stack Value File structure, which can better utilize the characteristics of stack space access [Lee01], and use continuous space to process stack access; add additional address calculation logic to calculate the address of memory access instructions in the decoding stage, and use Stack Value File to process stack access. Stack Value File is organized in the form of a register stack, which is independent of other logical registers and has a high hardware cost. In the embodiment of the present invention, the memory access behavior, especially the stack access behavior, of the SPEC CPU2000 program is analyzed. Figure 2 shows the proportion of stack access instructions in memory access instructions; from Figure 2 As can be seen from the figure, stack access accounts for an average of 39.6% of memory access. Adding memory access components can increase the instruction-level parallelism of the processor. Due to the correlation of memory access instructions, it is difficult to divide memory access into multiple functional components; therefore, the parallelism of memory access can only be increased through complex memory access instruction correlation judgment and increasing the port of the data cache. Stack access is not related to the access of other data spaces and accounts for nearly half of the access; therefore, the stack access can be separated from the access of the data cache, and a dedicated stack cache and data path can be set up. In this way, there is no need to increase the port of the data cache and the correlation judgment logic between the two components, and the characteristics of the stack access can be fully utilized.
[0073] See also Figure 3 , Figure 3 The number of stack access instructions per thousand instructions is given; from Figure 3 It can be seen that the processor accesses 1518 instructions on average for every 1,000 instructions it executes. The number of stack access instructions per 1,000 instructions reflects the role of separating stack access from data cache access and optimizing stack access in processor performance optimization.
[0074] See also Figure 4 ,The access to data in the stack space has good temporal locality and spatial locality, and the program continuously accesses data close to the top of the stack. Figure 4 The spatial variation of the distance between the stack access address and the initialization stack bottom is given, which reflects the spatial locality of stack access. Figure 4 As can be seen from the figure, about 79% of the stack accesses are less than 8KB away from the bottom of the initialized stack, and 87% of the stack accesses are less than 16KB away from the bottom of the initialized stack. The stack accesses of the SPEC CPU2000 program have good spatial locality. In addition, the stack accesses of the SPEC CPU2000 program also have good temporal locality.
[0075] Exemplarily, by sampling the distance between each program stack access address and the bottom of the initialized stack every 1,000,000 clock cycles, we analyze the sizes of the stack cache required to cover 80%, 85%, 90%, 95%, 98% and 100% of each program's continuous stack accesses respectively; it can be seen that the capacity of the stack cache does not need to be very large to have a good hit rate.
[0076] See also Figure 5 , Figure 5 The ratio of each logical register used as the base address register in stack access is given. Figure 5 It can be seen that 77% of the stack space data accesses use the stack pointer register (sp) as the base address register. The access address mode is (sp) + immediate, that is, the access address is equal to the value of the sp register plus the immediate value. Therefore, there is no need to rely on software or perform complex address prediction and pre-calculation. Most stack accesses can be distinguished by simply judging whether the sp register is used as the base address register.
[0077] In addition, the stack space is used to allocate local variables, which defines the characteristics of the stack. Stack space allocation, that is, the stack top pointer (sp) decreases, does not need to retrieve the original value of the corresponding block from the low-level storage system. Stack space recycling, that is, the stack top pointer (sp) increases, does not need to write the recycled value (even if it is dirty) to the low-level storage system. Because the parameters, return values, and internal variables of the previous function call are local, they are meaningless for the next call.
[0078] In summary, based on the analysis of program behavior and local variable characteristics, stack space data access has the following characteristics:
[0079] (1) Access to data in the stack space has good temporal locality and spatial locality. The program continuously accesses data close to the top of the stack; therefore, the capacity of the stack cache does not need to be large to achieve a high hit rate.
[0080] (2) When accessing data in the stack space, the stack pointer register (sp) is usually used as the base register. The access address mode is (sp) + immediate. All memory access instructions that use the stack pointer register (sp) as the base register are stack access instructions.
[0081] (3) Stack space allocation, that is, the stack top pointer (sp) is reduced, and there is no need to retrieve the original value of the corresponding block from the low-level storage system.
[0082] (4) Stack space recovery, that is, the stack top pointer (sp) increases, and there is no need to write the recovered value (even if it is dirty) to the low-level storage system.
[0083] See also Figure 6 , Figure 6 The microarchitecture of the Loongson 2 storage subsystem with an adaptive stack cache using fast address calculation is given. The added stack access functional components are shown in the shaded part of Figure 6. In the instruction issuance stage, at most two memory access instructions are issued per beat, one of which is an instruction with sp as the base register, and the other is an instruction with non-sp as the base register. The stack cache (Stack Cache) is 16KB in capacity through program behavior analysis. The data cache capacity is still 64KB, four-way set associative, single-port structure, and the sizes of other queue items remain unchanged. The memory access pipeline is no longer simply divided into 4 levels, but divided into different pipeline levels according to different accesses.
[0084] In a specific scheme of an embodiment of the present invention, the stack access instruction using the sp register as the base address register has a pipeline stage of two levels; wherein, the first beat uses the saved value of the sp register to perform address calculation and uses the calculated address to access the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the second beat writes the access result back.
[0085] In a specific scheme of an embodiment of the present invention, for stack access instructions that do not use the sp register as the base address register, the pipeline stage is divided into three levels; among them, the first beat address calculation unit calculates the virtual address and sends the memory access request to the stack cache; the second beat accesses the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the third beat writes the access result back.
[0086] In the embodiment of the present invention, the pipeline stage of non-stack access memory access instructions is divided into 4 levels; among them, the first beat address operation unit calculates the virtual address and sends the memory access request to the TLB (full name is Translation Lookaside Buffer, that is, bypass translation buffer or translation backup buffer) and data cache; the second beat accesses the data cache while the TLB converts the virtual address to the physical address; the third beat compares the flag bits according to the access results of the TLB and the data cache, determines whether the data cache hits, and sends it to the storage management queue; the fourth beat writes the access result back.
[0087] Explanatory, the additional hardware overhead of the adaptive stack cache scheme with fast address calculation is mainly 16KB of RAM. Generally, the method of adding data cache ports to increase the memory access functional unit will double the area of the data cache. Therefore, by adding 16KB of RAM to increase the memory access functional unit to two, compared with adding data cache ports to realize two memory access functional units, the area increase is smaller, which has obvious advantages. Other additional hardware overheads include the preservation and checking of sp register values, the emission selection logic and the corresponding data transmission path, etc., which are relatively small.
[0088] In summary, in the technical solution provided by the embodiment of the present invention, the characteristic that most of the accesses to the stack cache are accessed by using the value of the sp register plus the immediate value as the address, a prediction mechanism is added, and the access of the memory access instruction address format of (sp) + immediate is predicted as a stack access. By saving the value of the sp register in the access stack cache pipeline level, the time for reading the register stack is reduced, and the address calculation is performed directly in the first level of the access stack cache. In addition, the stack cache is indexed by a virtual address, and the mapping relationship between the virtual and real addresses is recorded in the tag (Tag), so the access that hits the stack cache does not require a tag comparison (DTAGCMP). When the stack access is predicted correctly, the load_to_use latency can be reduced by 2 beats relative to the data cache access. In addition, in order to distinguish the memory access instruction with the sp register as the base register, it is marked in the decoding stage. In the instruction issuance stage, a memory access instruction with a non-sp register as the base register and a memory access instruction with the sp register as the base register are selected and issued simultaneously. For accesses with sp register as the base register, the stack cache is accessed by adding the immediate value to the predicted sp value while performing address calculation. The predicted sp value is the value of the sp register saved by the Stack Cache module. For accesses with non-sp registers as the base register, the address calculation pipeline determines whether it is a stack access based on the calculated address, and determines whether to access the data cache or the stack cache. Check whether the sp value read from the register stack is equal to the saved sp value. If they are equal, the prediction is correct; otherwise, the stack cache is accessed again with the address calculated by the new sp value. If the stack cache access hits, the hit information and return value are sent to the storage management queue. If the stack cache access does not hit, the invalidation information is sent to the storage management queue. All memory access instructions share the storage management queue. The design of the stack cache fully utilizes the characteristics of the stack space and reduces unnecessary data transmission. Stack space allocation is directly allocated in the stack cache, and there is no need to retrieve the old value from the low-level storage system. Stack space recycling does not need to write dirty recycling values to the low-level storage system, and directly recycles and releases the stack cache space.
[0089] In the embodiment of the present invention, if a lot of stack space is allocated at one time or a process switch is performed, the original dirty value of the stack cache needs to be written back at one time, which is very expensive. This is the difficulty in implementing the stack cache. The adaptive stack cache is to add an adaptive mechanism to solve the problem of excessive overhead caused by the growth of the stack cache top pointer and the write-back of large blocks of space data caused by process switching. The adaptive stack cache is adaptively closed when overflow occurs, and an address space identifier is added to run a multi-core multi-threaded environment. A structure similar to TLB is used to manage the stack cache, and space is allocated to different processes to be suitable for process switching.
[0090] The value of the process address space identifier of the instruction comes from the control register of the processor. For each memory access instruction, there is a corresponding process address space identifier. In the processor, there are control registers that store the corresponding content of the process address space identifier, but the registers and storage methods are different. For example, the MIPS processor uses the EntryHi register to store the address space identifier ASID (Address Space Identifier), and the EntryLow register to store the global bit G (Global Bit), which together constitute the process address space identifier.
[0091] See also Figure 7 , Figure 7 An adaptive stack cache with fast address calculation is presented, and the prediction accuracy of stack access is predicted by using the sp register. Figure 7 It can be seen that the average prediction accuracy of stack space access predicted by judging whether to use the sp register as the base address register is 77.6%. Among them, weighted average is the weighted average of the evaluation indicators, wi represents the weight of the program, vi represents the evaluation value of program i, and other average values average in the embodiment of the present invention all refer to the arithmetic average. The prediction accuracy is calculated by weighted average, and the proportion of the number of instructions running when the stack cache of each program is opened to the number of instructions running when the stack cache of all SPEC CPU2000 programs is opened is used as the weight. This is because the embodiment of the present invention adopts an adaptive mechanism, and the stack cache is adaptively closed when an overflow occurs. Some programs such as gcc, gap and mesa are closed before the stack cache is executed. If the arithmetic average of each program is used for evaluation, these programs will play the same role as other programs when calculating the average value even if the number of runs is very small. Because the proportion of sp registers used by the two programs ggc and gap is less than the average value of 77%, and the stack access is adaptively closed during operation due to poor locality, these two programs are Figure 7The reason why the weight is small in the calculation of the average value is that the adaptive mechanism also improves the prediction accuracy of stack access.
[0092] See also Figure 8 , Figure 8 The adaptive stack cache with fast address calculation is given, and the proportion of instructions executed in parallel between the data cache and the stack cache to all memory access instructions. The results show that an average of 25.8% of the instructions can be executed in parallel between the two memory access functional components, and the adaptive stack cache with fast address calculation can effectively improve the instruction-level parallelism.
[0093] See also Fig. 9 , Fig. 9 The percentage of data cache miss rate reduction for an adaptive stack cache using fast address calculation is given. The results show that the miss rate of data cache is reduced by 9.4% on average compared with a single data cache using an adaptive stack cache using fast address calculation. Among them, the miss rate of data cache of eon.kajiya is reduced significantly, by 67.7% compared with a single data cache. It can be seen that the adaptive stack cache using fast address calculation can well separate stack access from data cache access, reduce data cache pollution, and increase data cache hit rate.
[0094] See also Fig.10 , Fig.10 The IPC (Instructions per Cycle) values of various programs are given, using only a single data cache (base cache), an adaptive stack cache with fast address calculation (decouple stack cache), and an adaptive stack cache with fast address calculation in the ideal case where all stack access operations are predicted correctly (perfect stack cache). Fig.10It can be seen that compared with the single data cache, the IPC value of SPEC CPU2000 programs using the adaptive stack cache scheme with fast address calculation has increased by 6.9% on average, close to the ideal value of 7.3%. Among them, the IPC values of the bzip2 and eon programs have increased significantly, by 22.7% and 18% respectively. The degree of improvement in the program IPC value is the result of the combined effect of the number of stack access instructions per thousand instructions executed, the degree of parallelism between stack access and other data access, and the locality of the stack. The results show that the more stack access instructions, the more memory access instructions that can be executed in parallel, and the better the stack locality of the program, the greater the proportion of IPC value improvement using the adaptive stack cache scheme with fast address calculation. Due to stack access overflow, the adaptive stack cache with fast address calculation of Gcc, gap and mesa programs is automatically closed during operation. The results show that although the stack locality of these three programs is not good and stack overflow occurs, the IPC value does not decrease; it can be seen that the adaptive mechanism ensures that the running performance of programs with poor stack locality is not affected after the stack cache is adopted.
[0095] The following are device embodiments of the present invention, which can be used to implement the method embodiments of the present invention. For details not disclosed in the device embodiments, please refer to the method embodiments of the present invention.
[0096] See also Fig.11 In an embodiment of the present invention, an adaptive stack cache system is provided, comprising:
[0097] A first acquisition module, used for acquiring an access type of an instruction;
[0098] A second acquisition module, configured to acquire a corresponding pipeline level based on the access type; wherein different access types correspond to different pipeline levels;
[0099] The instruction emission module is used to emit instructions according to the status of the stack cache, the stack top pointer register and the pipeline stage; wherein the stack cache and the stack top pointer register are integrated in the storage subsystem; in the instruction emission stage, at most two memory access instructions are emitted in each beat, the base address register of one instruction is the stack pointer, and the base address register of the other instruction is the non-stack pointer.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. An adaptive stack cache method, characterized in that: The following steps are involved: Get the access type of the instruction; Based on the access type, obtaining a corresponding pipeline level; wherein different access types correspond to different pipeline levels; Instructions are issued according to the states of the stack cache, the stack top pointer register and the pipeline stage; wherein the stack cache and the stack top pointer register are integrated in the storage subsystem; in the instruction issuance stage, at most two memory access instructions are issued in each beat, the base address register of one instruction is the stack pointer, and the base address register of the other instruction is the non-stack pointer; in, The step of obtaining the corresponding pipeline level based on the access type includes: The stack access instructions that use the stack pointer register as the base register have two pipeline stages; For stack access instructions that do not use the stack pointer register as the base address register, the pipeline stage is divided into 3 levels; For non-stack access memory access instructions, the pipeline stage is divided into 4 levels; In the step of transmitting instructions according to the status of the stack cache, the stack top pointer register and the pipeline stage, the process address space identifier of the instruction is added to the stack cache tag; the value of the process address space identifier of the instruction comes from the control register of the processor.
2. The adaptive stack cache method according to claim 1, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into two levels, in the instruction issuance stage, the first beat uses the saved value of the stack top pointer register to perform address calculation and uses the calculated address to access the stack cache, determine whether the stack cache hits and send it to the storage management queue; the second beat writes the access result back.
3. The adaptive stack cache method according to claim 1, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into three stages, in the instruction issuance stage, the first beat address operation unit calculates the virtual address and sends the memory access request to the stack cache; The second beat accesses the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the third beat writes the access result back.
4. The adaptive stack cache method according to claim 1, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into 4 levels, in the instruction issuance stage, the first beat address calculation unit calculates the virtual address and sends the memory access request to the conversion lookaside buffer and data cache; the second beat accesses the data cache while the conversion lookaside buffer converts the virtual address into a physical address; the third beat compares the flag bits according to the access results of the conversion lookaside buffer and the data cache, determines whether the data cache hits, and sends it to the storage management queue; the fourth beat writes the access result back.
5. The adaptive stack cache method according to claim 4, characterized in that: The capacity of the data cache is 64KB, and the structure adopts a four-way set associative, single-port structure; the capacity of the stack cache is 16KB.
6. An adaptive stack cache system, characterized in that: include: A first acquisition module, used for acquiring an access type of an instruction; A second acquisition module, configured to acquire a corresponding pipeline level based on the access type; wherein different access types correspond to different pipeline levels; An instruction emission module is used for transmitting instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage; wherein the stack cache and the stack top pointer register are integrated in the storage subsystem; in the instruction emission stage, at most two memory access instructions are emitted in each beat, the base address register of one instruction is the stack pointer, and the base address register of the other instruction is the non-stack pointer; in, The step of obtaining the corresponding pipeline level based on the access type includes: The stack access instructions that use the stack pointer register as the base register have two pipeline stages; For stack access instructions that do not use the stack pointer register as the base address register, the pipeline stage is divided into 3 levels; For non-stack access memory access instructions, the pipeline stage is divided into 4 levels; In the step of transmitting instructions according to the status of the stack cache, the stack top pointer register and the pipeline stage, the process address space identifier of the instruction is added to the stack cache tag; the value of the process address space identifier of the instruction comes from the control register of the processor.
7. The adaptive stack cache system according to claim 6, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into two levels, in the instruction issuance stage, the first beat uses the saved value of the stack top pointer register to perform address calculation and uses the calculated address to access the stack cache, determine whether the stack cache hits and send it to the storage management queue; the second beat writes the access result back.
8. The adaptive stack cache system according to claim 6, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into three stages, in the instruction issuance stage, the first beat address operation unit calculates the virtual address and sends the memory access request to the stack cache; The second beat accesses the stack cache, determines whether the stack cache hits and sends it to the storage management queue; the third beat writes the access result back.
9. The adaptive stack cache system according to claim 6, characterized in that: In the step of issuing instructions according to the states of the stack cache, the stack top pointer register and the pipeline stage, When the pipeline stage is divided into 4 levels, in the instruction issuance stage, the first beat address calculation unit calculates the virtual address and sends the memory access request to the conversion lookaside buffer and data cache; the second beat accesses the data cache while the conversion lookaside buffer converts the virtual address into a physical address; the third beat compares the flag bits according to the access results of the conversion lookaside buffer and the data cache, determines whether the data cache hits, and sends it to the storage management queue; the fourth beat writes the access result back.
10. The adaptive stack cache system according to claim 9, characterized in that: The capacity of the data cache is 64KB, and the structure adopts a four-way set associative, single-port structure; the capacity of the stack cache is 16KB.
Citation Information
Patent Citations
Initialization method and device of ZUC-256 stream cryptographic algorithm and communication method
CN110011798A
Four-stage assembly line stack processor
CN117270969A
Instruction processing method and processor
CN117289995A
Superscalar microprocessor stack structure for judging validity of predicted subroutine return addresses
US5968169A
Stack Pointer Management
US6598151B1
