CPU instruction processing method and related device
By updating the storage sequence, the accuracy of CPU speculation loading is improved, the performance loss problem caused by RAW conflicts in out-of-order execution is solved, and the effectiveness and CPU performance of the storage sequence are optimized.
Patent Information
- Application Number
- CN202410927066.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-07-11
AI Technical Summary
During the out-of-order execution of the superscalar CPU, the accuracy of the inferred loading instructions is low, resulting in performance losses caused by RAW conflicts, and the number and form of indexes are limited due to hardware limitations, resulting in speculation errors.
By obtaining the loading instructions and the serial number and access address of the RAW conflicting loading instructions and the storage instructions, update the storage sequence, streamlining the number of stored instructions in the storage sequence, ensuring the validity of the storage sequence, reducing invalid conflict relationships, and improving the accuracy of speculative loading.
Improves the accuracy of CPU speculative loading, reduces performance losses due to speculative errors, and saves circuit area and power consumption.
Smart Images

Figure CN118939319A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a CPU instruction processing method and related devices. Background Art
[0002] In the design of superscalar central processing units (CPUs), out-of-order execution is often used, that is, the actual order of instruction dispatch and issuance does not follow the program order.
[0003] This is because if the CPU strictly follows the program order to execute instructions, then the load instruction that appears after several store instructions can only be issued after these store instructions are completed, which will cause excessive delay. The out-of-order execution method needs to ensure that the execution order of the load instruction and store instruction that access the same storage address is correct as much as possible to avoid the CPU reading incorrect data.
[0004] In some CPUs, this problem is solved by speculatively dispatching load instructions to memory. If a previous store instruction is later determined to write to the same memory address as the load instruction, the load instruction is rewound and uses the correct data. However, rewinding is complex and expensive and should be avoided whenever possible.
[0005] That is, during the out-of-order execution process, the CPU not only needs to issue the load instruction as early as possible, but also needs to ensure that the execution order of the load instruction and the storage instruction at the same memory location complies with the read after write (RAW) constraint as much as possible to avoid performance loss caused by RAW conflicts.
[0006] In the current design, the CPU can reduce the number of rewinds by predicting whether the load instruction will conflict with the previous store instruction based on whether they conflicted in the past (for example, the store instruction will write to the same memory address as the load instruction). Among them, the program counter (PC) can be used to calculate the index of different instructions so that the CPU can determine whether the load instructions and store instructions in the table or set conflicted in the past. However, due to hardware limitations, the number and form of indexes are limited, and the indexes of different instructions may be the same, which may lead to speculation errors and cause CPU performance loss. Summary of the invention
[0007] The embodiment of the present invention provides a CPU instruction processing method and related device, which can improve the accuracy of CPU speculation loading and reduce the performance loss of the CPU caused by speculation errors.
[0008] A first aspect of an embodiment of the present application provides a (Central Processing Unit, CPU) instruction processing method, which is applied to a CPU; the method includes: obtaining a first load instruction and a first storage instruction that have a read after write (RAW) conflict; based on the serial number and / or access address of the first storage instruction, updating a storage sequence of the first load instruction, wherein the storage sequence includes storage instructions that have a RAW conflict with the first load instruction; based on the storage sequence, distributing the first load instruction.
[0009] In the embodiment of the present application, by using the sequence number of the first storage instruction as the basis for updating the storage sequence, the number of storage instructions in the storage sequence can be simplified; by using the access address of the first storage instruction as the basis for updating the storage sequence, it can be better ensured that there is a RAW conflict between the storage instruction and the first load instruction in the storage sequence. Therefore, the method provided by the embodiment of the present application can improve the quality of the storage sequence, improve the accuracy of CPU speculative loading, and reduce the performance loss of the CPU due to speculation errors when the number and form of indexes are limited.
[0010] In one possible implementation, the storage sequence of the first load instruction is updated based on the serial number and / or access address of the first storage instruction, including: if the serial number of the first storage instruction does not exist in a preset memory access dependency mapping table, the first storage instruction is added to the storage sequence; if the serial number of the first storage instruction exists in the preset memory access dependency mapping table, the storage sequence is maintained unchanged.
[0011] In an embodiment of the present application, by using the serial number of the first storage instruction and the memory access dependency mapping table, it is possible to avoid repeatedly recording the dependency relationship between the first storage instruction and the first load instruction in the storage sequence and the memory access dependency table, thereby saving circuit area; at the same time, reducing the number of times the storage sequence is updated can also reduce the power consumption of the CPU.
[0012] In one possible implementation, the storage sequence of the first loading instruction is updated based on the serial number and / or access address of the first storage instruction, including: if the serial number of the first storage instruction does not exist in a preset memory access dependency mapping table, and the access address of the first storage instruction is the same as the access address of the first loading instruction, then the first storage instruction is added to the storage sequence; if the serial number of the first storage instruction exists in the preset memory access dependency mapping table, or the access address of the first storage instruction is different from the access address of the first loading instruction, then the storage sequence is maintained unchanged.
[0013] In the embodiment of the present application, the update logic of the storage sequence is activated only when the first load instruction and the first storage instruction access the same memory address, which ensures that the RAW conflict maintained in the storage sequence is a truly valid conflict, and can avoid invalid conflict relationships caused by the same index calculated by the PC of different storage instructions, thereby reducing the performance loss caused by invalid conflict relationships.
[0014] In one possible implementation, after updating the storage sequence of the first load instruction, the method further includes: when adding the first storage instruction to the storage sequence, adding a counter corresponding to the first storage instruction, the initial count of the counter is zero; whenever a RAW conflict is detected between the first storage instruction and the first load instruction, the counter is incremented by one; if the counter is greater than or equal to a preset threshold, the first storage instruction is retained in the storage sequence until the storage sequence is cleared.
[0015] In an embodiment of the present application, by counting each storage instruction in the storage sequence and retaining the first storage instruction in the storage sequence of the first load instruction when a RAW conflict between the first load instruction and the first storage instruction is repeatedly detected, the storage instruction oscillation can be stopped as quickly as possible when the storage instruction oscillates in different storage sequences, thereby reducing the performance loss caused by the storage instruction oscillation.
[0016] In one possible implementation, the first load instruction comprises the oldest load instruction in the global history register.
[0017] In the embodiment of the present application, by giving priority to processing the oldest instruction in the global history register, instructions can be retired and abnormal situations can be handled as quickly as possible.
[0018] In one possible implementation, the processor includes a store set identifier table (SSIT) and a store instruction list (store list); the method also includes: when adding the first storage instruction to the storage sequence, writing the storage sequence identifier (store set identifier, SSID) of the first load instruction into the SSIT; writing the sequence number and SSID of the first storage instruction into the storage instruction list.
[0019] In one possible implementation, the processor includes an SSIT, which includes multiple blocks, and the identifier of each block corresponds to the low-bit information of the program counter PC; after obtaining the first load instruction and the first storage instruction with a RAW conflict, the method also includes: based on the first low-bit information of the PC of the first load instruction, writing the storage sequence identification number SSID of the first load instruction into the block corresponding to the first low-bit information.
[0020] In the embodiment of the present application, by storing the information of the first load instruction separately using the PC low-bit information, it is possible to avoid invalid conflict relationships caused by the same index calculated by the PCs of different load instructions, thereby reducing performance losses caused by invalid conflict relationships.
[0021] A second aspect of an embodiment of the present application provides a processor for executing a CPU instruction processing method as described in any possible implementation of the first aspect.
[0022] A third aspect of an embodiment of the present application provides an electronic device, characterized in that the electronic device includes a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program instructions; the processor is used to call the computer program instructions to execute the CPU instruction processing method as described in any possible implementation of the first aspect.
[0023] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer execution instructions; wherein, when the computer execution instructions are executed by a processor, a CPU instruction processing method as described in any possible implementation of the first aspect is implemented.
[0024] It should be understood that the beneficial effects of the above-mentioned various aspects can be referenced to each other. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in 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 only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 A flowchart of a CPU instruction processing method provided in an embodiment of the present application;
[0027] Figure 2 A schematic diagram of a preprocessing flow before a storage instruction is added to a storage sequence provided in an embodiment of the present application;
[0028] Figure 3 A logic diagram of instruction processing provided in an embodiment of the present application;
[0029] Figure 4 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The embodiments of the present application are described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only embodiments of a part of the present application, rather than all embodiments. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0031] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations 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 that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] In the traditional speculative loading method, the central processing unit (CPU) determines whether to distribute the load instruction to the corresponding execution unit based on the store set corresponding to each load instruction. The store set is used to record the store instructions that have had a read after write (RAW) conflict with the corresponding load instruction. The CPU can speculate whether the current load instruction execution will be rolled back based on the historical conflict data.
[0033] Therefore, in order to improve the accuracy of speculative loading and reduce the performance loss caused by load instruction rewind, it is necessary to ensure the validity of the storage instructions in the storage sequence as much as possible, that is, the storage instructions and the corresponding load instructions actually have a RAW conflict.
[0034] Currently, the CPU manages the storage sequence through two tables: the store set identifier table (SSIT) and the last fetched store table (LFST).
[0035] Among them, the table entry index of SSIT includes the value calculated by the program counter (PC) of each storage instruction and load instruction with RAW conflict, and the storage instruction and load instruction correspond to their respective indexes; the table entry content includes the value calculated by the PC of the storage instruction or the load instruction, and the value serves as a shared label of the storage instruction and the load instruction, which is called the storage sequence identifier (SSID).
[0036] The entry index of the LFST is the SSID, and the entry content is the serial number (SN) of the storage instruction in the corresponding storage instruction-load instruction conflict pair.
[0037] Based on the above two tables, before distributing the load instruction, the CPU can find the corresponding SSID in the SSIT through the PC of the load instruction; if the corresponding SSID exists in the SSIT, it means that there is a storage instruction that conflicts with the load instruction, and the CPU needs to first complete the corresponding write-back operation based on the serial number of the storage instruction, and wait for the table entry of the storage instruction to be removed in the SSIT before distributing the load instruction; if it is not in the SSID, the CPU can directly distribute the load instruction.
[0038] However, in the above traditional speculative loading method, due to hardware limitations, the number of table entries in SSIT and LFST is limited, such as 64 or 128 entries. At this time, the index calculated by the CPU needs to fall within this number range; therefore, the indexes calculated by different PCs may be the same, and the wrong index will lead to an incorrect RAW conflict relationship, thereby causing instruction writeback and CPU performance loss.
[0039] To solve the above technical problems, an embodiment of the present application provides a CPU instruction processing method, which can improve the quality of storage sequences, improve the accuracy of CPU speculative loading, and reduce CPU performance losses caused by speculation errors when the number and form of indexes are limited.
[0040] See also Figure 1 , Figure 1 A flowchart of a CPU instruction processing method provided in an embodiment of the present application is provided. The method is applied to a CPU and specifically includes the following steps:
[0041] Step 102: The CPU obtains a first load instruction and a first store instruction having a read after write (RAW) conflict.
[0042] When the execution of a load instruction requires the use of the execution result of a store instruction, there is a dependency relationship between the load instruction and the store instruction; when the load instruction is executed before the store instruction, the CPU will read erroneous data, resulting in a RAW conflict.
[0043] Among them, there is a RAW conflict between the first load instruction and the first storage instruction. Specifically, the quantitative relationship between the first load instruction and the second storage instruction can be one-to-one, one-to-many, many-to-one, or many-to-many. It is understandable that instructions that do not have a RAW conflict with other instructions can be named second, third, or other words, such as a second load instruction, a third storage instruction, etc., and the embodiments of the present application do not specifically limit this.
[0044] When the CPU determines that the access address of the skipped storage instruction is the same as the access address of the early executed load instruction, that is, when the early executed load instruction reads erroneous data, the CPU can determine that there is a RAW conflict between the load instruction and the storage instruction. At this time, the CPU can obtain the load instruction as the first load instruction and obtain the storage instruction as the first storage instruction.
[0045] Step 104: The CPU updates the storage sequence of the first load instruction based on the sequence number and / or access address of the first storage instruction.
[0046] The storage sequence of the first load instruction refers to a set of storage instructions that have a RAW conflict with the first load instruction. It can be understood that each load instruction has its own storage sequence.
[0047] In order to improve the prediction accuracy of speculative loads, it is necessary to ensure the validity of the storage sequence, that is, to ensure that each storage instruction in the storage sequence has a RAW conflict with the corresponding load. Specifically, it is possible to determine whether there is a RAW conflict between the first load instruction and the first storage instruction by accessing the address, thereby avoiding an erroneous RAW conflict relationship caused by CPU misjudgment.
[0048] In one possible implementation, after obtaining the first load instruction and the first storage instruction, if the access address of the first storage instruction is the same as the access address of the first load instruction, the CPU may add the first storage instruction to the storage sequence of the first load instruction; if the access address of the first storage instruction is different from the access address of the first load instruction, the CPU may maintain the storage sequence unchanged.
[0049] In another possible implementation, if the serial number of the first storage instruction does not exist in the preset memory access dependency mapping table, the CPU may add the first storage instruction to the storage sequence; if the serial number of the first storage instruction exists in the preset memory access dependency mapping table, the CPU may maintain the storage sequence unchanged.
[0050] Among them, the CPU is preset with a memory access dependency mapping table for maintaining the correct execution order of memory access instructions. The mapping table specifically includes the read and write dependencies between all memory access instructions in flight, such as the execution of the read operation of instruction A needs to depend on the execution result of the write operation of instruction B. It is understandable that the CPU can also perform speculative loading based on the dependencies recorded in the mapping table. In other words, the dependencies recorded in the access dependency mapping table are similar in function to the RAW conflict relationship represented by the storage sequence.
[0051] Therefore, before the CPU adds the first storage instruction to the storage sequence, the serial number of the first storage instruction can be traversed in the memory access dependency mapping table; when the serial number of the first storage instruction exists in the mapping table, it means that the mapping relationship of the first storage instruction has been recorded. At this time, there is no need to repeatedly write the RAW conflict relationship of similar functions into the storage sequence, thereby saving circuit area; at the same time, reducing the number of times the storage sequence is updated can also make the CPU power consumption lower.
[0052] In contrast, when the sequence number of the first storage instruction does not exist in the mapping table, the CPU may add the first storage instruction to the storage sequence, thereby expanding the sample database for speculative loading and improving prediction accuracy.
[0053] It is understandable that the above two possible implementations can also be combined with each other. In one possible implementation, the CPU can determine whether the serial number of the first storage instruction exists in the access dependency mapping table, and determine whether the access address of the first storage instruction is the same as the access address of the first load instruction; if the serial number of the first storage instruction does not exist in the access dependency mapping table, and the access address of the first storage instruction is the same as the access address of the first load instruction, then the CPU can add the first storage instruction to the storage sequence; if the serial number of the first storage instruction exists in the access dependency mapping table, or the access address of the first storage instruction is different from the access address of the first load instruction, then the storage sequence is maintained unchanged.
[0054] For details, please refer to Figure 2 , Figure 2 A schematic diagram of a preprocessing flow of a storage instruction before adding it to a storage sequence provided in an embodiment of the present application.
[0055] After the CPU executes the first load instruction and finds the first storage instruction that has a RAW conflict with the first load instruction among the instructions to be executed, the CPU can execute the following steps: Figure 2 The pre-processing flow shown is to determine whether to add the first storage instruction to the storage sequence or keep the storage sequence unchanged.
[0056] exist Figure 2 In the specific example, the CPU first obtains the serial number of the first storage instruction and performs a hash calculation to obtain a serial number hash value A; then traverses the serial number hash value A in the access dependency mapping table and determines whether it hits, that is, whether the hash value A exists in the mapping table.
[0057] If it hits, the CPU can keep the storage sequence unchanged; if it misses, the CPU can further obtain the access addresses of the first storage instruction and the first load instruction, and determine whether the access addresses of the two are the same. If the access addresses of the two are different, the CPU can keep the storage sequence unchanged; if the access addresses of the two are the same, the CPU can add the first storage instruction to the storage sequence.
[0058] In an embodiment of the present application, the first storage instruction added to the storage sequence is screened based on the two conditions of serial number and access address, which can ensure that the RAW conflict maintained in the storage sequence is a truly valid conflict, reducing the performance loss caused by invalid conflict relationships; at the same time, it also avoids redundant data occupying the CPU's memory, so that the CPU can have more speculative data samples within a limited storage space, thereby improving the accuracy of speculative loading.
[0059] After determining to add the first storage instruction to the storage sequence, the CPU may write data corresponding to the first storage instruction and the first load instruction into the preset SSIT and LFST, so that before the first load instruction is executed next time, the first storage instruction can be found for speculation.
[0060] In one possible implementation, the SSIT includes multiple banks, and the identifier of each bank corresponds to the low-bit information of the PC; the CPU can write the SSID of the first load instruction into the bank corresponding to the first low-bit information of the PC based on the first low-bit information of the PC of the first load instruction.
[0061] Among them, the block of SSIT is a sub-table of SSIT, the table entry index of each block is the first index, and the table entry content is SSID. Exemplarily, SSIT includes 8 blocks, and the identifiers of the 8 blocks correspond to different situations of the lowest 3 bits of PC; when the lowest 3 bits of PC of the first storage instruction are all 0, the CPU can add the first storage instruction to the block identified as 0. It can be understood that this is only an example and not a limitation. SSIT can also include more blocks, such as 64, and the identifier of each block can correspond to different situations of the lowest 6 bits of PC.
[0062] The first low-order information refers to the low-order information of the PC of the first storage instruction.
[0063] The first index refers to an index calculated from the PC of the first load instruction or the PC of the first store instruction, and the first index is used to index the table entry corresponding to the first load instruction or the first store instruction in the SSIT.
[0064] Correspondingly, the second index is the SSID in the SSIT, which is used to index the table entry corresponding to the instruction pair of the first load instruction-the first storage instruction having a RAW conflict in the LFST.
[0065] Optionally, the second index includes the SSID and the block identifier, for example, (block identifier)0+(SSID)99.
[0066] In the embodiment of the present application, by storing the information of the first load instruction separately using the PC low-bit information, it is possible to avoid invalid conflict relationships caused by the same first index calculated by the PCs of different load instructions, thereby reducing performance losses caused by invalid conflict relationships.
[0067] Among them, since the hardware limits the table size of SSIT and LFST, the calculated first index and second index will fall within a certain range, which may cause incorrect RAW conflict relationships to be recorded between unrelated load instructions and storage instructions; therefore, in some schemes, the CPU may introduce the rule that "the same storage instruction can only exist in one storage sequence at the same time" to avoid incorrect RAW conflict relationships.
[0068] However, when a store instruction has a RAW conflict with multiple load instructions, the store instruction may oscillate in the store sequence of the multiple load instructions, causing both load instructions to fail to execute normally.
[0069] For example, the storage sequence of load instruction 1 includes storage instruction A, and the storage sequence of load instruction 2 is empty; when there is a RAW conflict between load instruction 2 and storage instruction A, storage instruction A will be added to the storage sequence of load instruction 2, and storage instruction A will be deleted from the storage sequence of load instruction 1 to become an empty set. Obviously, in this example, when the CPU executes load instructions 1 and 2, storage instruction A may oscillate between the two storage sequences, and the CPU will take turns to obtain and delete storage instruction A in the two storage sequences; this will cause the execution of load instructions 1 and 2 to always be in a state of being unable to speculate or speculating incorrectly, which will have a significant impact on the performance of the CPU.
[0070] Therefore, in a possible implementation proposed in the present application, when the first storage instruction is added to the storage sequence, a counter corresponding to the first storage instruction is added, and the initial count of the counter is zero; whenever a RAW conflict is detected between the first storage instruction and the first load instruction, the counter is incremented by one; if the counter is greater than or equal to a preset threshold, the first storage instruction is retained in the storage sequence until the storage sequence is cleared.
[0071] Exemplarily, the preset threshold may be 3.
[0072] Among them, when the CPU is powered on again, or after a certain number of clock cycles during operation, the CPU will clear the storage sequence of some or all load instructions to avoid speculation errors caused by outdated RAW conflict relationships.
[0073] In an embodiment of the present application, by counting the RAW conflicts between the first load instruction and the first storage instruction that occur multiple times, and when the count value is greater than or equal to a preset threshold, the first storage instruction is allowed to reside in the storage sequence of the first load instruction, thereby stopping the storage instruction oscillation as quickly as possible and reducing the performance loss caused by the storage instruction oscillation.
[0074] In one possible implementation, the first load instruction comprises the oldest load instruction in the global history register.
[0075] Among them, the CPU executes out of order in the execution stage, but commits in order in the final commit stage of the pipeline; in the commit stage, the out-of-order executed instructions are changed back to the order specified in the program, which is mainly achieved through the reorder buffer (ROB). Specifically, after the instruction is executed, it enters the commit stage, at which time the status of the instruction in the ROB is updated to completed; and the ROB is essentially a first-in-first-out queue, and the instructions before the instruction must be completed before these completed instructions can be retired in order.
[0076] Before an instruction is retired, its status is speculative. The CPU will retire the instruction only when it determines that there is no abnormal situation that needs to be handled.
[0077] Among them, the global history register records the execution results of the previous N branch instructions, where N is greater than 1; when an instruction is retired, the instruction will be deleted from the global history register.
[0078] Therefore, in this possible implementation, the oldest load instruction in the global history register with a RAW conflict relationship is used as the first load instruction, and the oldest load instruction is distributed, executed and retired first, which can avoid the pipeline from accumulating too many instructions in the submission stage, affecting the CPU's judgment on the program execution status.
[0079] Optionally, when the CPU adds the first storage instruction to the storage sequence, the SSID of the first loading instruction is written into the SSIT; and the serial number and SSID of the first storage instruction are written into the storage instruction list.
[0080] Among them, when giving priority to the oldest load instruction, the CPU can allocate table entry content only for the oldest load instruction (which is also the first load instruction) in the SSIT; in addition, the CPU also presets another table, which can be a storage instruction list, which is specifically used to store storage instructions that have RAW conflicts with the oldest load instruction, that is, after obtaining the first storage instruction corresponding to the oldest load instruction, the CPU can write the relevant data of the first storage instruction into the storage instruction list.
[0081] For details, please refer to Figure 3 , Figure 3 A logical diagram of instruction processing provided in an embodiment of the present application.
[0082] exist Figure 3 In the specific example, the CPU first calculates the first index 99 and SSID 102 based on the PC of the first load instruction; then writes SSID 102 into the table entry corresponding to the first index 99 in BANK0 of SSIT, and the SSID entry corresponding to the first storage instruction in the storage instruction list; then uses SSID 102 as the second index, writes the SN B of the first storage instruction into the LFST, and writes the SN B of the first storage instruction into the storage instruction list; finally, sets the identifiers of the corresponding table entries in SSIT and LFST to 1 to indicate that these table entries are enabled.
[0083] Through a specially preset storage instruction list, the CPU can directly perform speculative distribution of the oldest load instruction based on the storage instruction list, and distribute the oldest load instruction as quickly as possible.
[0084] Step 106: The CPU distributes the first load instruction based on the storage sequence.
[0085] After determining that all storage instructions in the storage sequence of the first load instruction have been executed, the CPU may distribute the first load instruction to the corresponding memory for data reading.
[0086] In the embodiment of the present application, by using the sequence number of the first storage instruction as the basis for updating the storage sequence, the number of storage instructions in the storage sequence can be simplified; by using the access address of the first storage instruction as the basis for updating the storage sequence, it can be better ensured that there is a RAW conflict between the storage instruction and the first load instruction in the storage sequence. Therefore, the method provided by the embodiment of the present application can improve the quality of the storage sequence, improve the accuracy of CPU speculative loading, and reduce the performance loss of the CPU due to speculation errors when the number and form of indexes are limited.
[0087] In another embodiment, the present application also provides a processor, which is used to execute the method provided in the above embodiment.
[0088] In some other possible embodiments, the present application also provides electronic devices, which can be specifically referred to in Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 400 provided in the embodiment of the present application includes a processor 410 and a memory 420 .
[0089] Among them, the processor 410 may include one or more processing cores. The processor 410 uses various interfaces and lines to connect various parts in the computing device 400, and executes the method provided by any one or more of the above embodiments by running or executing instructions, programs, code sets or instruction sets stored in the memory 420, and calling data stored in the memory 420. Optionally, the processor 410 can be implemented in at least one hardware form of digital signal processing (digital signal processing, DSP), field-programmable gate array (field-programmable gate array, FPGA), and programmable logic array (programmable logic array, PLA). The processor 410 can integrate one or a combination of several of a CPU, a graphics processing unit (graphics processing unit, GPU) and a modem. It is understandable that the above-mentioned modem may not be integrated into the processor 410, but may be implemented separately through a communication chip.
[0090] The memory 420 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 420 includes a non-transitory computer-readable storage medium. The memory 420 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 420 may include a program storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the method of the embodiment of the present application, etc.
[0091] The processor 410 and the memory 420 are connected to each other through a bus in the computing device 400, which may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0092] In another embodiment of the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores computer-executable instructions. When at least one processor of the device executes the computer-executable instructions, the device executes the above Figure 1 or Figure 2 The method flow described in any embodiment.
[0093] In another embodiment of the present application, a computer program product is also provided. The computer program product includes computer-executable instructions, which are stored in a computer-readable storage medium; at least one processor of the device can read the computer-executable instructions from the computer-readable storage medium, and at least one processor executes the computer-executable instructions so that the device performs the above Figure 1 or Figure 2 The method flow described in any embodiment.
[0094] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0095] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0096] In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0098] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0099] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
Claims
1. A CPU instruction processing method, characterized in that: Applied to a central processing unit (CPU); the method comprises: Obtain a first load instruction and a first store instruction having a write-before-read RAW conflict; Based on the sequence number and / or access address of the first storage instruction, updating a storage sequence of the first load instruction, wherein the storage sequence is a set of storage instructions having a RAW conflict with the first load instruction; Based on the store sequence, the first load instruction is dispatched.
2. The method according to claim 1, characterized in that The updating of the storage sequence of the first load instruction based on the sequence number and / or the access address of the first storage instruction comprises: If the sequence number of the first storage instruction does not exist in the preset memory access dependency mapping table, adding the first storage instruction to the storage sequence; If the serial number of the first storage instruction exists in the memory access dependency mapping table, the storage sequence is maintained unchanged.
3. The method according to claim 1, characterized in that The updating of the storage sequence of the first load instruction based on the sequence number and / or the access address of the first storage instruction comprises: If the sequence number of the first storage instruction does not exist in the preset memory access dependency mapping table, and the access address of the first storage instruction is the same as the access address of the first load instruction, adding the first storage instruction to the storage sequence; If the sequence number of the first storage instruction exists in the memory access dependency mapping table, or the access address of the first storage instruction is different from the access address of the first load instruction, the storage sequence is maintained unchanged.
4. The method according to any one of claims 1 to 3, characterized in that After updating the storage sequence of the first load instruction, the method further includes: When the first storage instruction is added to the storage sequence, a counter corresponding to the first storage instruction is added, and an initial count of the counter is zero; Whenever a RAW conflict is detected between the first storage instruction and the first load instruction, the counter is incremented by one; If the counter is greater than or equal to a preset threshold, the first storage instruction is retained in the storage sequence until the storage sequence is cleared.
5. The method according to any one of claims 1 to 3, characterized in that: The first load instruction comprises the oldest load instruction in the global history register.
6. The method according to claim 5, characterized in that The processor includes a storage sequence identification number table SSIT and a storage instruction list; the method also includes: When the first storage instruction is added to the storage sequence, writing the first load instruction storage sequence identification number SSID into the SSIT; The serial number and SSID of the first storage instruction are written into the storage instruction list.
7. The method according to any one of claims 1 to 3, characterized in that The processor includes an SSIT, the SSIT includes a plurality of blocks, and an identifier of each of the blocks corresponds to low-bit information of a program counter PC; after acquiring a first load instruction and a first store instruction having a RAW conflict, the method further includes: Based on the first low-bit information of the PC of the first load instruction, the storage sequence identification number SSID of the first load instruction is written into the block corresponding to the first low-bit information.
8. A processor, characterized in that: The processor is used to execute the CPU instruction processing method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor; The memory is coupled to the processor; The memory is used to store computer program instructions; The processor is used to call the computer program instructions to execute the CPU instruction processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions; wherein, when the computer-executable instructions are executed by a processor, the CPU instruction processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Handling effective address synonyms in a load-store unit that operates without address translation
CN111133421A
Systems and methods for QCL type d collision processing
CN116918419A
Method for establishing loading and storing instruction dependency, processor and medium
CN117785285A
Store sets poison propagation
US20030126409A1
Out-of-order execution microprocessor with reduced store collision load replay reduction
US20100306508A1
