CN119166315B - Processor with pipeline processing design and execution path prediction method - Google Patents

Processor with pipeline processing design and execution path prediction method Download PDF

Info

Publication number
CN119166315B
CN119166315B CN202411650887.9A CN202411650887A CN119166315B CN 119166315 B CN119166315 B CN 119166315B CN 202411650887 A CN202411650887 A CN 202411650887A CN 119166315 B CN119166315 B CN 119166315B
Authority
CN
China
Prior art keywords
instruction
execution
weight
jump
coefficient
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202411650887.9A
Other languages
Chinese (zh)
Other versions
CN119166315A (en
Inventor
葛小燕
陈家棋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Xinliji Semiconductor Co ltd
Original Assignee
Shanghai Xinliji Semiconductor Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Xinliji Semiconductor Co ltd filed Critical Shanghai Xinliji Semiconductor Co ltd
Priority to CN202411650887.9A priority Critical patent/CN119166315B/en
Publication of CN119166315A publication Critical patent/CN119166315A/en
Application granted granted Critical
Publication of CN119166315B publication Critical patent/CN119166315B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)

Abstract

本发明提出了一种具管线处理设计的处理器及执行路径预测方法。所述具管线处理设计的处理器包括内存控制器、指令快取模块、发送单元、排程器和执行单元;执行路径预测方法包括:将指令的执行作为条件跳转的预测满足条件;当有跳转请求的指令被读取时,则检测条件跳转预测指令对应的条件跳转的满足条件是否发生;当所述条件跳转的满足条件没有发生时,则管线继续执行下一指令;当所述条件跳转的满足条件发生时,则程序指针移到满足条件的条件跳转指令所请求的指定位置,管线自所述条件跳转指令所请求的指定位置继续执行指令,本发明通过快取列具有跳转地址的设计,可以降低因为不正确的预测的效果损失,进而提高程序的执行效率。

The present invention proposes a processor with pipeline processing design and an execution path prediction method. The processor with pipeline processing design includes a memory controller, an instruction cache module, a sending unit, a scheduler and an execution unit; the execution path prediction method includes: taking the execution of the instruction as the predicted satisfied condition of the conditional jump; when the instruction with a jump request is read, detecting whether the satisfied condition of the conditional jump corresponding to the conditional jump prediction instruction occurs; when the satisfied condition of the conditional jump does not occur, the pipeline continues to execute the next instruction; when the satisfied condition of the conditional jump occurs, the program pointer moves to the specified position requested by the satisfied conditional jump instruction, and the pipeline continues to execute the instruction from the specified position requested by the conditional jump instruction. The present invention can reduce the effect loss due to incorrect prediction by designing the cache column with a jump address, thereby improving the execution efficiency of the program.

Description

一种具管线处理设计的处理器及执行路径预测方法Processor with pipeline processing design and execution path prediction method

技术领域Technical Field

本发明提出了一种具管线处理设计的处理器及执行路径预测方法,涉及数据预测技术领域,特别涉及具管线处理设计的处理器及执行路径预测技术领域。The present invention provides a processor with pipeline processing design and an execution path prediction method, which relate to the technical field of data prediction, and in particular to the technical field of a processor with pipeline processing design and an execution path prediction method.

背景技术Background Art

一般在处理器(CPU)内部对于一个指令的执行,通常需要经过包含以下步骤:fetch(获取指令)、decode(译码指令)、execute(执行指令)及write-back(写回数据)。当完全的执行完各阶段的步骤,则表示完成一条指令。Generally, the execution of an instruction in a processor (CPU) usually requires the following steps: fetch (get instruction), decode (decode instruction), execute (execute instruction) and write-back (write back data). When all the steps in each stage are fully executed, it means that an instruction is completed.

处理器的流水线(Pipeline)处理,其可以同时且分段的执行上述步骤,例如前一指令A执行至译码指令时,次一指令B可以开始执行获取指令。如此一来,通过此种执行方式可以缩短执行完所有指令的所需时间。The pipeline processing of the processor can execute the above steps simultaneously and in stages. For example, when the previous instruction A is executed to the decoding instruction, the next instruction B can start to execute the fetch instruction. In this way, the time required to execute all instructions can be shortened through this execution method.

然而对于特定指令,例如「if」指令,其下一条指令必需根据「if」式中的结果是「true(真)」还是「false(假)」来决定,所以必须等到「if」指令执行完,才能知道下一条指令是什么。此时,无疑降低处理器的执行效率,于是,现今处理器对于这种情况,都设计有一个分支预测(Branch Prediction)机制,就是针对这种if指令,不等它执行完毕,先预测一下执行的结果可能是true还是false,然后将对应条件的指令放进流水线。However, for certain instructions, such as the "if" instruction, the next instruction must be determined based on whether the result of the "if" formula is "true" or "false", so you must wait until the "if" instruction is executed before you know what the next instruction is. At this point, the execution efficiency of the processor is undoubtedly reduced. Therefore, today's processors are designed with a branch prediction mechanism for this situation. This is for this kind of if instruction. Before it is executed, it first predicts whether the execution result may be true or false, and then puts the corresponding conditional instructions into the pipeline.

分支预测的使用范围从每次单纯地产生相同的预测的方法至在该程序中维持先前分支的复杂记录以产生记录型预测的方法。分支预测可以透过硬件优化、编译程序优化或两者皆使用而变得容易。基于通过分支预测机制所提供的预测,可以预测地存取及执行指令。当对分支指令做最终评估时,可以确认分支预测。若预测是不正确时,可撤销基于不正确的预测而预测执行的任何指令。但是分支预测准确率高代表更复杂的算法,同时还会影响CPU的周期时间。The use of branch prediction ranges from methods that simply generate the same prediction each time to methods that maintain a complex record of previous branches in the program to generate a record-based prediction. Branch prediction can be facilitated by hardware optimizations, compiler optimizations, or both. Based on the predictions provided by the branch prediction mechanism, instructions can be accessed and executed predictively. When the branch instruction is finally evaluated, the branch prediction can be confirmed. If the prediction is incorrect, any instructions that were predicted to be executed based on the incorrect prediction can be undone. However, high branch prediction accuracy means more complex algorithms and also affects the CPU cycle time.

发明内容Summary of the invention

本发明提供了一种具管线处理设计的处理器及执行路径预测方法,用以解决不正确的预测会造成效果损失等问题:The present invention provides a processor with pipeline processing design and an execution path prediction method to solve the problem that incorrect prediction may cause effect loss.

本发明提出的一种具管线处理设计的处理器及执行路径预测方法,所述具管线处理设计的处理器包括内存控制器、指令快取模块、发送单元、排程器和执行单元;其中,所述内存控制器与指令快取模块进行电性连接;所述指令快取模块与发送单元进行电性连接;所述发送单元与排程器进行电性连接;所述排程器与执行单元进行电性连接。The present invention proposes a processor with pipeline processing design and an execution path prediction method. The processor with pipeline processing design includes a memory controller, an instruction cache module, a sending unit, a scheduler and an execution unit; wherein the memory controller is electrically connected to the instruction cache module; the instruction cache module is electrically connected to the sending unit; the sending unit is electrically connected to the scheduler; and the scheduler is electrically connected to the execution unit.

进一步地,所述排程器与执行单元进行电性连接包括第一电性连接通道和第二电性连接通道;其中,所述第一电性连接通道用于运作数据发送至所述排程器;所述第二电性连接通道用于确认运作数据重新发送至所述排程器。Furthermore, the scheduler is electrically connected to the execution unit including a first electrical connection channel and a second electrical connection channel; wherein the first electrical connection channel is used to send operation data to the scheduler; and the second electrical connection channel is used to confirm that the operation data is resent to the scheduler.

进一步地,所述内存控制器与处理器所处系统的系统内存进行电性连接。Furthermore, the memory controller is electrically connected to a system memory of a system in which the processor is located.

进一步地,所述具管线处理设计的处理器还包括分支预测单元和数据快取模块;其中,所述分支预测单元与所述执行单元进行电性连接,并且,所述分支预测单元与所述指令快取模块进行电性连接;所述数据快取模块分别与执行单元和内存控制器进行电性连接。Furthermore, the processor with pipeline processing design also includes a branch prediction unit and a data cache module; wherein the branch prediction unit is electrically connected to the execution unit, and the branch prediction unit is electrically connected to the instruction cache module; the data cache module is electrically connected to the execution unit and the memory controller respectively.

进一步地,所述具管线处理设计的处理器还包括总线;其中,所述总线与所述执行单元进行电性连接。Furthermore, the processor with pipeline processing design also includes a bus; wherein the bus is electrically connected to the execution unit.

进一步地,所述具管线处理设计的处理器的执行路径预测方法包括:Furthermore, the execution path prediction method of the processor with pipeline processing design includes:

将指令的执行作为条件跳转的预测满足条件;The execution of the instruction is regarded as the prediction that the condition of the conditional jump is satisfied;

当有跳转请求的指令被读取时,则检测条件跳转预测指令对应的条件跳转的满足条件是否发生;When an instruction with a jump request is read, it is detected whether the satisfying condition of the conditional jump corresponding to the conditional jump prediction instruction occurs;

当所述条件跳转的满足条件没有发生时,则管线继续执行下一指令;When the satisfying condition of the conditional jump does not occur, the pipeline continues to execute the next instruction;

当所述条件跳转的满足条件发生时,则程序指针移到满足条件的条件跳转指令所请求的指定位置,管线自所述条件跳转指令所请求的指定位置继续执行指令。When the condition of the conditional jump is satisfied, the program pointer moves to the specified position requested by the conditional jump instruction that satisfies the condition, and the pipeline continues to execute instructions from the specified position requested by the conditional jump instruction.

进一步地,具有跳转请求的该指令于第一次执行,无论该先指令有无执行过,视为该条件跳转的条件不满足。Furthermore, when the instruction with the jump request is executed for the first time, regardless of whether the previous instruction has been executed, it is regarded that the condition of the conditional jump is not satisfied.

进一步地,在所述条件跳转的条件被满足的情况下,具有跳转请求的该指令再次被执行时,则该程序指针移动到该跳转请求所指定的位置。Furthermore, when the condition of the conditional jump is satisfied, when the instruction with the jump request is executed again, the program pointer moves to the position specified by the jump request.

进一步地,所述条件跳转所对应的位置记录于一条件跳转记录表中,且每一所述条件跳转所对应的位置可被标注为有效的或无效的。Furthermore, the position corresponding to the conditional jump is recorded in a conditional jump record table, and each position corresponding to the conditional jump can be marked as valid or invalid.

进一步地,计算指令的指令权重系数和权重更新系数,进而计算权重调节系数,对指令进行权重调节,包括:Further, the instruction weight coefficient and weight update coefficient of the instruction are calculated, and then the weight adjustment coefficient is calculated to adjust the weight of the instruction, including:

获取指令的历史执行数据,根据所述指令的历史执行数据计算指令的指令权重系数;Acquire historical execution data of the instruction, and calculate the instruction weight coefficient of the instruction according to the historical execution data of the instruction;

所述指令权重系数的计算公式为:The calculation formula of the instruction weight coefficient is:

其中,Qzli为第i个指令的指令权重系数,j为数据采集时间段的指令执行记录次数,Si为第i次记录的时间衰减因子,用于减少旧执行记录对当前权重的影响,Ci 为第i次记录中指令的成功执行次数,Lvi为第i次记录中指令的预设权重,Zi为第i次记录中指令的总执行次数;Wherein, Q zli is the instruction weight coefficient of the i-th instruction, j is the number of instruction execution records in the data collection period, S i is the time decay factor of the i-th record, which is used to reduce the impact of old execution records on the current weight, C i is the number of successful executions of the instruction in the i-th record, L vi is the preset weight of the instruction in the i-th record, and Z i is the total number of executions of the instruction in the i-th record;

根据指令执行顺序结合指令权重顺序生成执行预测路径;Generate an execution prediction path based on the instruction execution order combined with the instruction weight order;

将所述每个指令的指令权重系数与预设权重范围进行对比,获得权重对比结果;Comparing the instruction weight coefficient of each instruction with the preset weight range to obtain a weight comparison result;

所述权重对比结果包括范围外指令和范围内指令;The weight comparison result includes out-of-range instructions and in-range instructions;

将执行预测路径中的范围外指令进行剔除,获得执行更新路径;Eliminate out-of-range instructions in the execution prediction path to obtain the execution update path;

获取指令执行动态变化数据,根据所述指令执行动态变化数据对指令的历史执行数据进行更新,获得指令更新数据;Acquire instruction execution dynamic change data, and update historical execution data of the instruction according to the instruction execution dynamic change data to obtain instruction update data;

根据所述权重对比结果、指令权重系数结合指令更新数据计算指令的权重更新系数;Calculating a weight update coefficient of the instruction based on the weight comparison result, the instruction weight coefficient and the instruction update data;

所述权重更新系数的计算公式为:The calculation formula of the weight update coefficient is:

其中,Gzli为第i个指令的权重更新系数,ΔCi为第i次记录中指令的成功执行次数的增加变化量,∇Ci为第i次记录中指令的成功执行次数;Wherein, G zli is the weight update coefficient of the ith instruction, ΔC i is the increase in the number of successful executions of the instruction in the ith record, and ∇C i is the number of successful executions of the instruction in the ith record;

根据所述权重更新系数对指令的指令权重系数进行更新,进而对执行更新路径进行更新,获得执行变化路径;The instruction weight coefficient of the instruction is updated according to the weight update coefficient, and then the execution update path is updated to obtain the execution change path;

当指令权重系数在预设权重范围外,且权重更新系数在预设权重范围内时,根据所述指令权重系数、权重更新系数结合预设权重范围计算权重调节系数;When the instruction weight coefficient is outside the preset weight range and the weight update coefficient is within the preset weight range, the weight adjustment coefficient is calculated according to the instruction weight coefficient, the weight update coefficient and the preset weight range;

所述权重调节系数的计算公式为:The calculation formula of the weight adjustment coefficient is:

其中,Tys为权重调节系数,Xx为预设权重范围下限值,Sx为预设权重范围上限值;Wherein, Tys is the weight adjustment coefficient, Xx is the lower limit of the preset weight range, and Sx is the upper limit of the preset weight range;

根据所述权重调节系数对对应指令的权重进行调节,直至指令的权重在预设权重范围内。The weight of the corresponding instruction is adjusted according to the weight adjustment coefficient until the weight of the instruction is within a preset weight range.

本发明有益效果:通过快取列具有跳转地址的设计,可以降低因为不正确的预测的效果损失,进而提高程序的执行效率。通过指令快取和分支预测技术,减少了对系统内存的访问次数和延迟,提高了指令的执行效率。管线化处理使得指令可以并行执行,进一步提高了处理器的吞吐量。双重电性连接通道(第一通道用于正常发送,第二通道用于重试)的设计,使得处理器在处理异常情况时更加灵活和可靠。总线接口提供了与外部设备通信的能力,增强了处理器的可扩展性和兼容性。排程器根据指令的依赖关系和资源可用性进行智能调度,确保了资源的有效利用和避免了不必要的冲突。数据快取模块减少了数据访问的延迟和带宽消耗,提高了系统整体的性能。高效的指令执行和数据管理能力使得处理器能够更快地响应用户的请求,提升了用户的使用体验。可靠的错误处理和重试机制保证了系统的稳定性和可靠性,减少了因硬件故障导致的系统崩溃和数据丢失的风险。Beneficial effects of the present invention: By designing the cache column with a jump address, the effect loss due to incorrect prediction can be reduced, thereby improving the execution efficiency of the program. Through instruction caching and branch prediction technology, the number of accesses and delays to the system memory are reduced, and the execution efficiency of instructions is improved. Pipeline processing allows instructions to be executed in parallel, further improving the throughput of the processor. The design of dual electrical connection channels (the first channel is used for normal transmission and the second channel is used for retry) makes the processor more flexible and reliable when handling abnormal situations. The bus interface provides the ability to communicate with external devices, enhancing the scalability and compatibility of the processor. The scheduler performs intelligent scheduling based on the dependency relationship and resource availability of instructions, ensuring the effective use of resources and avoiding unnecessary conflicts. The data cache module reduces the delay and bandwidth consumption of data access, and improves the overall performance of the system. The efficient instruction execution and data management capabilities enable the processor to respond to user requests more quickly, improving the user experience. Reliable error handling and retry mechanisms ensure the stability and reliability of the system, and reduce the risk of system crashes and data loss caused by hardware failures.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本发明的预测方法流程图;Fig. 1 is a flow chart of the prediction method of the present invention;

图2是本发明的处理器架构的方块示意图;FIG2 is a block diagram of a processor architecture of the present invention;

图3是本发明的处理器架构的分支预测单元的构成示意图。FIG. 3 is a schematic diagram of the structure of a branch prediction unit of the processor architecture of the present invention.

具体实施方式DETAILED DESCRIPTION

以下结合附图对本发明的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本发明,并不用于限定本发明。The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

本发明的一个实施例,本发明提出的一种具管线处理设计的处理器及执行路径预测方法,所述具管线处理设计的处理器包括内存控制器、指令快取模块、发送单元、排程器和执行单元;其中,所述内存控制器与指令快取模块进行电性连接;所述指令快取模块与发送单元进行电性连接;所述发送单元与排程器进行电性连接;所述排程器与执行单元进行电性连接。One embodiment of the present invention proposes a processor with pipeline processing design and an execution path prediction method, wherein the processor with pipeline processing design includes a memory controller, an instruction cache module, a sending unit, a scheduler and an execution unit; wherein the memory controller is electrically connected to the instruction cache module; the instruction cache module is electrically connected to the sending unit; the sending unit is electrically connected to the scheduler; and the scheduler is electrically connected to the execution unit.

所述排程器与执行单元进行电性连接包括第一电性连接通道和第二电性连接通道;其中,所述第一电性连接通道用于运作数据发送至所述排程器;所述第二电性连接通道用于确认运作数据重新发送至所述排程器。The scheduler is electrically connected to the execution unit through a first electrical connection channel and a second electrical connection channel; wherein the first electrical connection channel is used to send operation data to the scheduler; and the second electrical connection channel is used to confirm that the operation data is resent to the scheduler.

所述内存控制器与处理器所处系统的系统内存进行电性连接。The memory controller is electrically connected to the system memory of the system where the processor is located.

所述具管线处理设计的处理器还包括分支预测单元和数据快取模块;其中,所述分支预测单元与所述执行单元进行电性连接,并且,所述分支预测单元与所述指令快取模块进行电性连接;所述数据快取模块分别与执行单元和内存控制器进行电性连接。The processor with pipeline processing design also includes a branch prediction unit and a data cache module; wherein the branch prediction unit is electrically connected to the execution unit, and the branch prediction unit is electrically connected to the instruction cache module; the data cache module is electrically connected to the execution unit and the memory controller respectively.

所述具管线处理设计的处理器还包括总线;其中,所述总线与所述执行单元进行电性连接。The processor with pipeline processing design also includes a bus; wherein the bus is electrically connected to the execution unit.

上述技术方案的工作原理为:本发明实施例所展示的处理器100包含发送单元101可以配置成接收来自指令快取102的指令,且发送单元101能将指令发送至排程器(scheduler)103,其次指令快取102连接内存控制器104。排程器103可以连接执行单元105,且排程器103用以储存等待决定的运作信息。执行单元105可配置成用以执行存取数据快取106的加载/储存单元,且执行单元105所产生的结果可以输出至总线107,以及来自总线107的数据流可以进入执行单元105;进一步,数据快取106连接内存控制器104,以及执行单元105可以提供重演指示108用以确认运作重新发至排程器103。The working principle of the above technical solution is as follows: the processor 100 shown in the embodiment of the present invention includes a sending unit 101 which can be configured to receive instructions from an instruction cache 102, and the sending unit 101 can send instructions to a scheduler 103, and the instruction cache 102 is connected to a memory controller 104. The scheduler 103 can be connected to an execution unit 105, and the scheduler 103 is used to store operation information waiting for decision. The execution unit 105 can be configured as a load/store unit for executing access to a data cache 106, and the result generated by the execution unit 105 can be output to a bus 107, and the data stream from the bus 107 can enter the execution unit 105; further, the data cache 106 is connected to the memory controller 104, and the execution unit 105 can provide a replay indication 108 to confirm that the operation is resent to the scheduler 103.

其次,处理器100内具有分支预测单元109连接执行单元105及指令快取102。内存控制器104连接系统内存110。Secondly, the processor 100 has a branch prediction unit 109 connected to the execution unit 105 and the instruction cache 102. The memory controller 104 is connected to the system memory 110.

在一个实施例中,处理器100可以通过设计以兼容于x86架构。需要注意的是处理器100包括分支预测单元109。分支预测单元109用以暂存包含程序位置的信息。In one embodiment, the processor 100 may be designed to be compatible with the x86 architecture. It should be noted that the processor 100 includes a branch prediction unit 109. The branch prediction unit 109 is used to temporarily store information including program locations.

本实施例指出一个具体实施例,如图3所示,分支预测单元109包含条件跳转记录表120。条件跳转记录表120的字段包含但不限于标签(Tag)栏121、地址(address)栏122及状态(status)栏123。可理解的是,条件跳转记录表120用以记该条件跳转指令的地址的高位(high byte)或卷标 (tag)、跳转指令的目标跳转位置,以及数据或程序目前是有效的(valid)还是无效的(invalid)。This embodiment points out a specific embodiment, as shown in FIG3, the branch prediction unit 109 includes a conditional jump record table 120. The fields of the conditional jump record table 120 include but are not limited to a tag column 121, an address column 122, and a status column 123. It is understandable that the conditional jump record table 120 is used to record the high byte or tag of the address of the conditional jump instruction, the target jump position of the jump instruction, and whether the data or program is currently valid or invalid.

条件跳转记录表120内的信息是可以被自动加载及更新的。例如,当某一跳转指令被第一次执行,则其仍依程序行而依序执行,同时将跳转指令中所要求的跳转地址记录于条件跳转记录表120内,并且被记录成无效的(invalid)。经过一次或数次的执行结果,特别是,在满足预设的跳转条件下,跳转指令再被执行时,即可依所要求的跳转地址,让程序指针(program counter)移动到跳转位置,且在跳转记录表120内的状态,被更改为有效的(valid)。另外,当跳转位置过久没被执行,则跳转记录表120内的状态,也会被更改为无效的(invalid)。The information in the conditional jump record table 120 can be automatically loaded and updated. For example, when a jump instruction is executed for the first time, it is still executed in sequence according to the program line, and the jump address required in the jump instruction is recorded in the conditional jump record table 120 and recorded as invalid. After one or more execution results, in particular, when the jump instruction is executed again under the preset jump condition, the program pointer (program counter) can be moved to the jump position according to the required jump address, and the status in the jump record table 120 is changed to valid. In addition, when the jump position has not been executed for too long, the status in the jump record table 120 will also be changed to invalid.

上述的预设跳转条件包含但不限于是一个指令的执行。满足预设跳转条件的情形,可以是若有一个非跳转的先指令被执行,且非跳转的先指令所执行的内容与被置于跳转指令的默认跳转条件相符,则可以视为为满足预设跳转条件,因此当跳转指令被执行时,则程序指针(program counter)移动到跳转位置。The above-mentioned preset jump condition includes but is not limited to the execution of an instruction. The situation where the preset jump condition is satisfied can be that if a non-jump previous instruction is executed, and the content executed by the non-jump previous instruction matches the default jump condition set in the jump instruction, it can be regarded as satisfying the preset jump condition, so when the jump instruction is executed, the program pointer (program counter) moves to the jump position.

是以,在跳转指令执行结束之前猜测哪一分支将会被执行,可用以提高处理器的指令管线的效能,本发明的一个实施例揭示一种执行预测的方法,如图1所示,执行程序时,逐一且依序的读取指令列,且一个具有条件跳转的指令被读取(如方块301);随之,执行一个判断,该判断用以查看是跳转条件成立的跳转地址,是否曾被当作资料移动至缓存器(如方块302);若该指令自条件跳转记录表取得的资料数据位置为无效的,则管线继续执行下一个指令,如方块303。若指令自条件跳转记录表取得的资料位置为有效的,则程式指标(program counter)移动到默认的跳转位置,如方块304;随后程序的执行则自程式指标(program counter)所指位置,接续执行指令,如方块305。Therefore, guessing which branch will be executed before the jump instruction is executed can be used to improve the performance of the processor's instruction pipeline. An embodiment of the present invention discloses a method for execution prediction. As shown in FIG. 1 , when executing a program, the instruction list is read one by one and in sequence, and an instruction with a conditional jump is read (such as block 301); then, a judgment is performed to check whether the jump address that is the jump condition is met has been moved to the buffer as data (such as block 302); if the data data position obtained by the instruction from the conditional jump record table is invalid, the pipeline continues to execute the next instruction, such as block 303. If the data position obtained by the instruction from the conditional jump record table is valid, the program pointer (program counter) moves to the default jump position, such as block 304; then the execution of the program continues to execute instructions from the position pointed to by the program pointer (program counter), such as block 305.

根据以上说明,本发明实施例所揭示的处理器及预测方法,可以降低因为不正确的预测之效果损失,进而提高程序的执行效率。According to the above description, the processor and prediction method disclosed in the embodiments of the present invention can reduce the effect loss due to incorrect prediction, thereby improving the execution efficiency of the program.

当处理器需要执行新的指令时,内存控制器首先从系统内存中读取指令数据,并将其传递给指令快取模块。指令快取模块负责缓存这些指令,以便快速访问。指令快取模块中的指令随后被发送到发送单元,发送单元负责将这些指令按照一定顺序和格式准备好,以便后续处理。发送单元将准备好的指令发送到排程器。排程器根据指令的依赖关系和资源可用性,对指令进行排序和调度,确保其能够按照正确的顺序和时机被执行。排程器与执行单元之间通过第一电性连接通道进行运作数据的发送。执行单元接收来自排程器的指令,并执行相应的操作。如果在执行过程中遇到需要重试或重新发送的情况(如缓存未命中、资源冲突等),执行单元会通过第二电性连接通道向排程器发送确认信号,请求重新发送相关指令或数据。分支预测单元通过分析历史执行模式和当前指令流,预测即将执行的分支路径,以减少因分支跳转带来的延迟。其与指令快取模块和执行单元相连,以便及时获取和更新预测信息。数据快取模块用于缓存执行单元所需的数据,以减少对系统内存的访问次数。其与执行单元和内存控制器相连,确保数据能够快速、准确地传输到执行单元。总线与执行单元相连,为处理器与外部设备或系统其他部分提供通信接口。通过总线,执行单元可以与其他处理器、内存或其他I/O设备交换数据和控制信息。When the processor needs to execute a new instruction, the memory controller first reads the instruction data from the system memory and passes it to the instruction cache module. The instruction cache module is responsible for caching these instructions for fast access. The instructions in the instruction cache module are then sent to the sending unit, which is responsible for preparing these instructions in a certain order and format for subsequent processing. The sending unit sends the prepared instructions to the scheduler. The scheduler sorts and schedules the instructions according to the dependency relationship and resource availability of the instructions to ensure that they can be executed in the correct order and timing. The scheduler and the execution unit send operation data through the first electrical connection channel. The execution unit receives the instructions from the scheduler and performs the corresponding operation. If a situation that requires retry or resending is encountered during the execution process (such as cache miss, resource conflict, etc.), the execution unit will send a confirmation signal to the scheduler through the second electrical connection channel to request the resending of the relevant instructions or data. The branch prediction unit predicts the branch path to be executed by analyzing the historical execution mode and the current instruction stream to reduce the delay caused by branch jumps. It is connected to the instruction cache module and the execution unit to obtain and update the prediction information in a timely manner. The data cache module is used to cache the data required by the execution unit to reduce the number of accesses to the system memory. It is connected to the execution unit and the memory controller to ensure that data can be transferred to the execution unit quickly and accurately. The bus is connected to the execution unit and provides a communication interface between the processor and external devices or other parts of the system. Through the bus, the execution unit can exchange data and control information with other processors, memory or other I/O devices.

上述技术方案的效果为:通过指令快取和分支预测技术,减少了对系统内存的访问次数和延迟,提高了指令的执行效率。管线化处理使得指令可以并行执行,进一步提高了处理器的吞吐量。双重电性连接通道(第一通道用于正常发送,第二通道用于重试)的设计,使得处理器在处理异常情况时更加灵活和可靠。总线接口提供了与外部设备通信的能力,增强了处理器的可扩展性和兼容性。排程器根据指令的依赖关系和资源可用性进行智能调度,确保了资源的有效利用和避免了不必要的冲突。数据快取模块减少了数据访问的延迟和带宽消耗,提高了系统整体的性能。高效的指令执行和数据管理能力使得处理器能够更快地响应用户的请求,提升了用户的使用体验。可靠的错误处理和重试机制保证了系统的稳定性和可靠性,减少了因硬件故障导致的系统崩溃和数据丢失的风险。The effects of the above technical solution are as follows: through instruction cache and branch prediction technology, the number of accesses and delays to the system memory are reduced, and the execution efficiency of instructions is improved. Pipeline processing allows instructions to be executed in parallel, further improving the throughput of the processor. The design of dual electrical connection channels (the first channel is used for normal transmission and the second channel is used for retry) makes the processor more flexible and reliable when handling abnormal situations. The bus interface provides the ability to communicate with external devices, enhancing the scalability and compatibility of the processor. The scheduler performs intelligent scheduling based on the dependency of instructions and resource availability, ensuring the effective use of resources and avoiding unnecessary conflicts. The data cache module reduces the delay and bandwidth consumption of data access, and improves the overall performance of the system. Efficient instruction execution and data management capabilities enable the processor to respond to user requests more quickly, improving the user experience. Reliable error handling and retry mechanisms ensure the stability and reliability of the system, and reduce the risk of system crashes and data loss caused by hardware failures.

本发明的一个实施例,所述具管线处理设计的处理器的执行路径预测方法包括:In one embodiment of the present invention, the execution path prediction method of the processor with pipeline processing design includes:

将指令的执行作为条件跳转的预测满足条件;The execution of the instruction is regarded as the prediction that the condition of the conditional jump is satisfied;

当有跳转请求的指令被读取时,则检测条件跳转预测指令对应的条件跳转的满足条件是否发生;When an instruction with a jump request is read, it is detected whether the satisfying condition of the conditional jump corresponding to the conditional jump prediction instruction occurs;

当所述条件跳转的满足条件没有发生时,则管线继续执行下一指令;When the satisfying condition of the conditional jump does not occur, the pipeline continues to execute the next instruction;

当所述条件跳转的满足条件发生时,则程序指针移到满足条件的条件跳转指令所请求的指定位置,管线自所述条件跳转指令所请求的指定位置继续执行指令。When the condition of the conditional jump is satisfied, the program pointer moves to the specified position requested by the conditional jump instruction that satisfies the condition, and the pipeline continues to execute instructions from the specified position requested by the conditional jump instruction.

上述技术方案的工作原理为:在指令执行过程中,处理器将某些指令(特别是条件跳转指令)的执行结果作为后续跳转预测的依据。这种预测基于历史执行模式和当前上下文信息,试图提前确定条件跳转是否会发生。当指令流中遇到条件跳转指令时,处理器会读取该指令,并识别出这是一个需要跳转判断的指令。此时,处理器会检查与该条件跳转指令相关联的预测信息。处理器会根据条件跳转指令的具体条件,检查当前的状态或寄存器值等,以确定条件是否满足。这一步骤是判断是否需要实际执行跳转的关键。如果条件不满足(即预测未发生或实际检测未发生),则处理器会继续沿当前管线执行下一指令,不改变执行路径。如果条件满足(即预测发生且实际检测也发生),则处理器会更新程序指针(PC),将其指向条件跳转指令所请求的指定位置。随后,管线将从该新位置开始继续执行指令,实现执行路径的跳转。The working principle of the above technical solution is as follows: during the instruction execution process, the processor uses the execution results of certain instructions (especially conditional jump instructions) as the basis for subsequent jump prediction. This prediction is based on the historical execution mode and the current context information, and attempts to determine in advance whether the conditional jump will occur. When a conditional jump instruction is encountered in the instruction stream, the processor reads the instruction and recognizes that it is an instruction that requires a jump judgment. At this time, the processor checks the prediction information associated with the conditional jump instruction. The processor checks the current state or register value, etc. according to the specific conditions of the conditional jump instruction to determine whether the condition is met. This step is the key to determining whether the jump needs to be actually executed. If the condition is not met (that is, the prediction does not occur or the actual detection does not occur), the processor will continue to execute the next instruction along the current pipeline without changing the execution path. If the condition is met (that is, the prediction occurs and the actual detection also occurs), the processor will update the program pointer (PC) to point it to the specified position requested by the conditional jump instruction. Subsequently, the pipeline will continue to execute instructions from the new position to achieve the jump of the execution path.

上述技术方案的效果为:通过条件跳转预测,处理器能够提前做出是否跳转的决策,从而减少了因等待条件判断结果而产生的延迟。这对于提高程序的执行效率和响应速度至关重要。预测准确时,处理器能够连续执行指令流中的多个指令,而无需因条件跳转而中断。这有助于提高处理器的指令吞吐量,使其能够处理更多的工作负载。预测和跳转机制使得处理器能够更有效地利用管线资源。当预测到条件跳转将发生时,处理器可以提前准备跳转目标处的指令和数据,从而减少因资源冲突或等待而造成的浪费。总体上,该方法通过优化条件跳转的处理流程,提高了程序的执行效率和性能。这对于需要处理大量条件分支和复杂控制流的程序来说尤为重要。对于用户来说,更快的程序响应和更高的执行效率代表更好的使用体验。无论是在处理日常任务还是在运行大型应用程序时,用户都能感受到明显的性能提升。The effect of the above technical solution is that through conditional jump prediction, the processor can make a decision in advance whether to jump, thereby reducing the delay caused by waiting for the conditional judgment result. This is crucial to improving the execution efficiency and response speed of the program. When the prediction is accurate, the processor can continuously execute multiple instructions in the instruction stream without interruption due to conditional jumps. This helps to improve the instruction throughput of the processor, enabling it to handle more workloads. The prediction and jump mechanism enables the processor to use pipeline resources more efficiently. When it is predicted that a conditional jump will occur, the processor can prepare instructions and data at the jump target in advance, thereby reducing waste caused by resource conflicts or waiting. Overall, the method improves the execution efficiency and performance of the program by optimizing the processing flow of conditional jumps. This is particularly important for programs that need to process a large number of conditional branches and complex control flows. For users, faster program response and higher execution efficiency represent a better user experience. Whether it is handling daily tasks or running large applications, users can feel a significant performance improvement.

本发明的一个实施例,具有跳转请求的该指令于第一次执行,无论该先指令有无执行过,视为该条件跳转的条件不满足。In one embodiment of the present invention, when the instruction with the jump request is executed for the first time, no matter whether the previous instruction has been executed or not, it is considered that the condition of the conditional jump is not satisfied.

上述技术方案的工作原理为:处理器在解析指令流时,会跟踪每条指令的执行状态。当遇到具有跳转请求的指令,并且这是该指令在当前上下文中的第一次执行时,处理器会特别标记这一点。由于缺乏历史执行数据或上下文信息来准确预测该条件跳转是否会真正发生,处理器采取了一种保守的假设,即认为该条件跳转的条件不满足。这代表,在没有足够证据支持条件跳转会发生的情况下,处理器不会冒险改变当前的执行路径。基于上述假设,处理器会继续沿当前的管线执行后续的指令,而不执行跳转操作。这样做可以确保程序流的稳定性,并避免因错误的跳转预测而导致的执行错误或性能下降。当该条件跳转指令实际上被执行,并且其条件被确定满足或不满足时,处理器会更新与该指令相关联的预测信息。这些信息将在未来的执行中用于更准确地预测条件跳转的行为。The working principle of the above technical solution is as follows: when parsing the instruction stream, the processor tracks the execution status of each instruction. When encountering an instruction with a jump request and this is the first execution of the instruction in the current context, the processor will specifically mark this. Due to the lack of historical execution data or context information to accurately predict whether the conditional jump will actually occur, the processor takes a conservative assumption that the condition of the conditional jump is not satisfied. This means that the processor will not risk changing the current execution path if there is not enough evidence to support that the conditional jump will occur. Based on the above assumption, the processor will continue to execute subsequent instructions along the current pipeline without performing a jump operation. Doing so can ensure the stability of the program flow and avoid execution errors or performance degradation caused by incorrect jump predictions. When the conditional jump instruction is actually executed and its condition is determined to be satisfied or not satisfied, the processor will update the prediction information associated with the instruction. This information will be used in future executions to more accurately predict the behavior of the conditional jump.

上述技术方案的效果为:通过在首次执行时采取保守的预测策略,处理器减少了因错误预测而导致的执行路径错误的风险。这有助于提高程序的执行稳定性和可靠性。在没有足够信息支持复杂预测的情况下,选择简单的保守策略可以简化处理器的预测逻辑,降低实现难度和成本。随着程序的执行和预测信息的积累,处理器能够逐渐提高条件跳转的预测准确性。这种逐步优化的过程有助于在保持稳定性的同时提高性能。通过在首次执行时避免冒险的跳转预测,处理器减少了因预测错误而导致的性能波动。这对于需要稳定性能的应用程序来说尤为重要。在程序或系统启动阶段,许多指令都是首次执行。采用保守的预测策略可以确保这些指令能够平稳地执行,从而支持快速启动和初始化过程。The effect of the above technical solution is that by adopting a conservative prediction strategy at the first execution, the processor reduces the risk of execution path errors caused by incorrect predictions. This helps to improve the execution stability and reliability of the program. In the absence of sufficient information to support complex predictions, choosing a simple conservative strategy can simplify the prediction logic of the processor and reduce the difficulty and cost of implementation. As the program is executed and the prediction information is accumulated, the processor can gradually improve the prediction accuracy of conditional jumps. This gradual optimization process helps to improve performance while maintaining stability. By avoiding risky jump predictions at the first execution, the processor reduces performance fluctuations caused by prediction errors. This is particularly important for applications that require stable performance. During the program or system startup phase, many instructions are executed for the first time. Adopting a conservative prediction strategy can ensure that these instructions can be executed smoothly, thereby supporting a fast startup and initialization process.

本发明的一个实施例,在所述条件跳转的条件被满足的情况下,具有跳转请求的该指令再次被执行时,则该程序指针移动到该跳转请求所指定的位置。According to an embodiment of the present invention, when the condition of the conditional jump is satisfied and the instruction with the jump request is executed again, the program pointer moves to the position specified by the jump request.

上述技术方案的工作原理为:当处理器遇到条件跳转指令时,会首先评估与该指令相关联的条件表达式。这通常涉及检查特定的寄存器、内存位置或先前指令的执行结果。处理器根据条件表达式的评估结果来判断条件是否满足。如果条件为真(即满足),则处理器会决定执行跳转操作。一旦决定执行跳转,处理器会查找该条件跳转指令中指定的跳转目标地址。这个地址是程序中的一个具体位置,通常是一个标签或内存地址,标识了跳转后应该开始执行的指令序列。处理器将当前的程序指针(PC)更新为跳转目标地址。这一步骤是改变执行路径的关键,因为指示了接下来应该从哪个位置开始读取和执行指令。由于程序指针的更新,处理器的指令管线会重新定向以从新的地址加载指令。后续的指令获取、解码和执行操作都将基于新的执行路径进行。一旦指令管线重新定向完成,处理器就会从跳转目标地址开始继续执行指令。跳过了一些原本在当前执行路径上的指令,直接跳转到另一个代码块执行。The working principle of the above technical solution is as follows: when the processor encounters a conditional jump instruction, it first evaluates the conditional expression associated with the instruction. This usually involves checking a specific register, memory location, or the execution result of a previous instruction. The processor determines whether the condition is satisfied based on the evaluation result of the conditional expression. If the condition is true (i.e. satisfied), the processor decides to execute the jump operation. Once the decision to execute the jump is made, the processor looks for the jump target address specified in the conditional jump instruction. This address is a specific location in the program, usually a label or memory address, which identifies the sequence of instructions that should be executed after the jump. The processor updates the current program pointer (PC) to the jump target address. This step is key to changing the execution path because it indicates where the instructions should be read and executed next. Due to the update of the program pointer, the processor's instruction pipeline is redirected to load instructions from the new address. Subsequent instruction acquisition, decoding, and execution operations will be based on the new execution path. Once the instruction pipeline is redirected, the processor will continue to execute instructions starting from the jump target address. Some instructions that were originally on the current execution path are skipped and directly jump to another code block for execution.

上述技术方案的效果为:条件跳转允许程序根据条件选择性地执行代码块,从而避免了执行不必要的指令。这有助于减少程序的执行时间和资源消耗,提高整体效率。通过条件跳转,程序可以更加灵活地控制执行流程,实现复杂的控制逻辑和决策过程。这对于开发具有复杂功能和行为的应用程序至关重要。条件跳转使得程序员能够组织代码以更自然和直观的方式表达逻辑结构。例如,循环和条件语句等控制流结构可以基于条件跳转指令来实现,从而使代码更加清晰和易于理解。在模块化编程中,条件跳转可以帮助实现函数或子程序的调用和返回。通过跳转到特定的代码块并执行该块中的指令,程序可以重用和共享代码,减少冗余并提高可维护性。在需要快速响应的应用程序中,条件跳转可以减少处理时间并加快决策速度。The effect of the above technical solution is: conditional jump allows the program to selectively execute code blocks based on conditions, thereby avoiding the execution of unnecessary instructions. This helps to reduce the execution time and resource consumption of the program and improve overall efficiency. Through conditional jumps, the program can control the execution flow more flexibly and implement complex control logic and decision-making processes. This is essential for developing applications with complex functions and behaviors. Conditional jumps enable programmers to organize code to express logical structures in a more natural and intuitive way. For example, control flow structures such as loops and conditional statements can be implemented based on conditional jump instructions, making the code clearer and easier to understand. In modular programming, conditional jumps can help implement the call and return of functions or subroutines. By jumping to a specific code block and executing the instructions in that block, the program can reuse and share code, reduce redundancy and improve maintainability. In applications that require fast response, conditional jumps can reduce processing time and speed up decision-making.

本发明的一个实施例,所述条件跳转所对应的位置记录于一条件跳转记录表中,且每一所述条件跳转所对应的位置可被标注为有效的或无效的。In one embodiment of the present invention, the position corresponding to the conditional jump is recorded in a conditional jump record table, and each position corresponding to the conditional jump can be marked as valid or invalid.

上述技术方案的工作原理为:当编译器或汇编器处理源代码或汇编代码时,其会为每个条件跳转指令生成一个条目,并将其添加到条件跳转记录表中。这个条目至少包含两个关键信息:条件跳转指令的标识符(如标签或地址)和目标位置的地址。在某些情况下,跳转目标的位置可能会变得无效。例如,如果跳转目标位于一个被删除或重构的代码块中,或者由于条件逻辑的变化而不再需要该跳转。在这些情况下,处理器或相关软件会更新条件跳转记录表,将相应的跳转位置标注为无效。当处理器执行到条件跳转指令时,它会首先查找条件跳转记录表以获取目标地址,并检查该地址的有效性。如果目标地址被标注为有效,则处理器会正常执行跳转操作;如果目标地址被标注为无效,则处理器可能会采取特定的错误处理措施,如抛出异常、执行备用代码路径或继续执行下一条指令。在程序执行期间,如果检测到跳转目标位置的有效性发生变化(例如,通过运行时分析或动态代码生成),处理器或相关软件可以动态地更新条件跳转记录表,以反映这些变化。The working principle of the above technical solution is as follows: when the compiler or assembler processes the source code or assembly code, it generates an entry for each conditional jump instruction and adds it to the conditional jump record table. This entry contains at least two key information: the identifier of the conditional jump instruction (such as a label or address) and the address of the target location. In some cases, the location of the jump target may become invalid. For example, if the jump target is located in a deleted or reconstructed code block, or the jump is no longer needed due to changes in the conditional logic. In these cases, the processor or related software will update the conditional jump record table and mark the corresponding jump location as invalid. When the processor executes a conditional jump instruction, it will first look up the conditional jump record table to obtain the target address and check the validity of the address. If the target address is marked as valid, the processor will perform the jump operation normally; if the target address is marked as invalid, the processor may take specific error handling measures, such as throwing an exception, executing an alternate code path, or continuing to execute the next instruction. During program execution, if changes in the validity of jump target locations are detected (e.g., through runtime analysis or dynamic code generation), the processor or associated software can dynamically update the conditional jump record table to reflect these changes.

上述技术方案的效果为:通过在条件跳转记录表中标注跳转位置的有效性,处理器可以避免执行到无效或已删除的代码区域,从而提高程序的稳定性和可靠性。条件跳转记录表提供了一种集中管理跳转信息的方式,使得在修改或重构代码时更容易跟踪和更新跳转目标的有效性。这有助于减少因遗漏或错误更新跳转信息而导致的错误。在运行时,处理器或相关软件可以根据程序的实际执行情况动态地更新条件跳转记录表,以优化执行路径和性能。例如,如果某个条件跳转在大多数情况下都不满足,处理器可能会选择跳过该跳转的预测和检查过程,以减少开销。条件跳转记录表提供了一种结构化的方式来组织和表示跳转信息,使得代码的逻辑结构和控制流更加清晰和易于理解。这有助于其他开发人员更快地熟悉和修改代码。在模块化编程中,条件跳转记录表可以帮助实现模块之间的解耦和独立更新。通过更新跳转记录表而不是修改模块内部的跳转逻辑,可以更容易地替换或升级模块,而不会影响其他部分的程序。The effect of the above technical solution is: by marking the validity of the jump position in the conditional jump record table, the processor can avoid executing to invalid or deleted code areas, thereby improving the stability and reliability of the program. The conditional jump record table provides a way to centrally manage jump information, making it easier to track and update the validity of the jump target when modifying or refactoring the code. This helps to reduce errors caused by missing or erroneous updates to jump information. At runtime, the processor or related software can dynamically update the conditional jump record table according to the actual execution of the program to optimize the execution path and performance. For example, if a conditional jump is not satisfied in most cases, the processor may choose to skip the prediction and checking process of the jump to reduce overhead. The conditional jump record table provides a structured way to organize and represent jump information, making the logical structure and control flow of the code clearer and easier to understand. This helps other developers become familiar with and modify the code faster. In modular programming, the conditional jump record table can help achieve decoupling and independent updates between modules. By updating the jump record table instead of modifying the jump logic inside the module, it is easier to replace or upgrade the module without affecting other parts of the program.

本发明的一个实施例,计算指令的指令权重系数和权重更新系数,进而计算权重调节系数,对指令进行权重调节,包括:In one embodiment of the present invention, the instruction weight coefficient and the weight update coefficient of the instruction are calculated, and then the weight adjustment coefficient is calculated to adjust the weight of the instruction, including:

获取指令的历史执行数据,根据所述指令的历史执行数据计算指令的指令权重系数;Acquire historical execution data of the instruction, and calculate the instruction weight coefficient of the instruction according to the historical execution data of the instruction;

所述指令权重系数的计算公式为:The calculation formula of the instruction weight coefficient is:

其中,Qzli为第i个指令的指令权重系数,j为数据采集时间段的指令执行记录次数,Si为第i次记录的时间衰减因子,用于减少旧执行记录对当前权重的影响,Ci 为第i次记录中指令的成功执行次数(满足条件跳转),Lvi为第i次记录中指令的预设权重,Zi为第i次记录中指令的总执行次数(无论是否满足条件跳转);Wherein, Q zli is the instruction weight coefficient of the ith instruction, j is the number of instruction execution records in the data collection period, S i is the time decay factor of the ith record, which is used to reduce the impact of old execution records on the current weight, C i is the number of successful executions of the instruction in the ith record (satisfying the conditional jump), L vi is the preset weight of the instruction in the ith record, and Z i is the total number of executions of the instruction in the ith record (regardless of whether the conditional jump is met);

根据指令执行顺序结合指令权重顺序生成执行预测路径;Generate an execution prediction path based on the instruction execution order combined with the instruction weight order;

将所述每个指令的指令权重系数与预设权重范围进行对比,获得权重对比结果;Comparing the instruction weight coefficient of each instruction with the preset weight range to obtain a weight comparison result;

所述权重对比结果包括范围外指令和范围内指令;The weight comparison result includes out-of-range instructions and in-range instructions;

将执行预测路径中的范围外指令进行剔除,获得执行更新路径;Eliminate out-of-range instructions in the execution prediction path to obtain the execution update path;

获取指令执行动态变化数据,根据所述指令执行动态变化数据对指令的历史执行数据进行更新,获得指令更新数据;Acquire instruction execution dynamic change data, and update historical execution data of the instruction according to the instruction execution dynamic change data to obtain instruction update data;

根据所述权重对比结果、指令权重系数结合指令更新数据计算指令的权重更新系数;Calculating a weight update coefficient of the instruction based on the weight comparison result, the instruction weight coefficient and the instruction update data;

所述权重更新系数的计算公式为:The calculation formula of the weight update coefficient is:

其中,Gzli为第i个指令的权重更新系数,ΔCi为第i次记录中指令的成功执行次数(满足条件跳转)的增加变化量,∇Ci为第i次记录中指令的成功执行次数(满足条件跳转);Where G zli is the weight update coefficient of the ith instruction, ΔC i is the increase in the number of successful executions of the instruction in the ith record (satisfying the conditional jump), and ∇C i is the number of successful executions of the instruction in the ith record (satisfying the conditional jump);

根据所述权重更新系数对指令的指令权重系数进行更新,进而对执行更新路径进行更新,获得执行变化路径;The instruction weight coefficient of the instruction is updated according to the weight update coefficient, and then the execution update path is updated to obtain the execution change path;

当指令权重系数在预设权重范围外,且权重更新系数在预设权重范围内时,根据所述指令权重系数、权重更新系数结合预设权重范围计算权重调节系数;When the instruction weight coefficient is outside the preset weight range and the weight update coefficient is within the preset weight range, the weight adjustment coefficient is calculated according to the instruction weight coefficient, the weight update coefficient and the preset weight range;

所述权重调节系数的计算公式为:The calculation formula of the weight adjustment coefficient is:

其中,Tys为权重调节系数,Xx为预设权重范围下限值,Sx为预设权重范围上限值;Wherein, Tys is the weight adjustment coefficient, Xx is the lower limit of the preset weight range, and Sx is the upper limit of the preset weight range;

根据所述权重调节系数对对应指令的权重进行调节,直至指令的权重在预设权重范围内。The weight of the corresponding instruction is adjusted according to the weight adjustment coefficient until the weight of the instruction is within a preset weight range.

上述技术方案的工作原理为:系统获取每条指令的历史执行数据,包括指令的执行记录次数、每次记录的时间衰减因子(减少旧数据的影响)、每次记录的成功执行次数、预设权重以及总执行次数。使用这些历史数据计算每条指令的指令权重系数。本考虑了时间衰减、成功执行次数、预设权重和总执行次数,确保旧数据的影响逐渐减弱,同时突出了成功执行次数的重要性。系统根据指令的执行顺序和指令权重顺序生成一个执行预测路径。这个路径反映了根据当前权重系数预测的指令执行顺序。将每条指令的指令权重系数与预设的权重范围进行对比,将权重在范围外的指令视为异常或需调整的指令,从而剔除这些指令,获得更新后的执行路径。系统获取指令执行的动态变化数据,更新历史执行数据,并计算每条指令的权重更新系数。这个系数考虑了成功执行次数的增加变化量,以反映指令性能的改善或恶化。使用权重更新系数对指令权重系数进行更新,并据此更新执行路径,获得执行变化路径。这一步确保了路径能够根据指令性能的最新变化进行调整。对于权重在预设范围外的指令,如果其权重更新系数在预设范围内,系统计算权重调节系数,并使用该系数对指令权重进行调节,直至权重回到预设范围内。这一步骤确保了指令权重的稳定性和合理性。The working principle of the above technical solution is as follows: the system obtains the historical execution data of each instruction, including the number of execution records of the instruction, the time decay factor of each record (to reduce the influence of old data), the number of successful executions of each record, the preset weight and the total number of executions. The instruction weight coefficient of each instruction is calculated using these historical data. This method takes into account time decay, the number of successful executions, the preset weight and the total number of executions to ensure that the influence of old data gradually weakens, while highlighting the importance of the number of successful executions. The system generates an execution prediction path based on the execution order of the instructions and the instruction weight order. This path reflects the instruction execution order predicted based on the current weight coefficient. The instruction weight coefficient of each instruction is compared with the preset weight range, and the instructions with weights outside the range are regarded as abnormal or adjusted instructions, so as to eliminate these instructions and obtain the updated execution path. The system obtains the dynamic change data of instruction execution, updates the historical execution data, and calculates the weight update coefficient of each instruction. This coefficient takes into account the increase in the number of successful executions to reflect the improvement or deterioration of instruction performance. The instruction weight coefficient is updated using the weight update coefficient, and the execution path is updated accordingly to obtain the execution change path. This step ensures that the path can be adjusted according to the latest changes in instruction performance. For instructions with weights outside the preset range, if their weight update coefficients are within the preset range, the system calculates the weight adjustment coefficient and uses it to adjust the instruction weight until the weight returns to the preset range. This step ensures the stability and rationality of instruction weights.

上述技术方案的效果为:通过动态调整指令权重,系统能够更准确地预测和执行指令,减少不必要的执行开销,提高整体执行效率。系统能够根据指令执行的动态变化实时更新权重,适应不同的执行环境和条件,增强系统的适应性和鲁棒性。通过权重调节,系统能够更合理地分配资源给重要的指令,确保关键任务得到优先处理,提高资源利用率。指令执行的准确性和效率的提升,以及资源分配的优化,最终将提升用户的整体体验,使用户能够更高效地完成任务。系统通过自动化的权重计算和调节,减少了人工干预的需要,降低了系统的维护成本。The effect of the above technical solution is: by dynamically adjusting the instruction weights, the system can predict and execute instructions more accurately, reduce unnecessary execution overhead, and improve overall execution efficiency. The system can update the weights in real time according to the dynamic changes in instruction execution, adapt to different execution environments and conditions, and enhance the adaptability and robustness of the system. Through weight adjustment, the system can more reasonably allocate resources to important instructions, ensure that key tasks are given priority, and improve resource utilization. The improvement of the accuracy and efficiency of instruction execution, as well as the optimization of resource allocation, will ultimately enhance the overall user experience and enable users to complete tasks more efficiently. Through automated weight calculation and adjustment, the system reduces the need for manual intervention and reduces the maintenance cost of the system.

显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims (10)

1. A method for predicting an execution path of a processor with a pipeline processing design, the method comprising:
taking the execution of the instruction as the prediction of conditional jump to meet the condition;
When an instruction with a jump request is read, detecting whether a condition jump meeting condition corresponding to a condition jump prediction instruction occurs or not;
When the condition jump meeting condition does not occur, the pipeline continues to execute the next instruction;
when the condition jump meeting condition occurs, the program pointer moves to the appointed position requested by the condition jump instruction meeting condition, and the pipeline continues to execute the instruction from the appointed position requested by the condition jump instruction;
acquiring historical execution data of an instruction, calculating an instruction weight coefficient of the instruction, generating an execution prediction path, updating the historical execution data of the instruction to obtain instruction update data, calculating a weight update coefficient of the instruction, updating the instruction weight coefficient of the instruction to obtain an execution change path, calculating a weight adjustment coefficient, and adjusting the weight of the corresponding instruction;
Acquiring historical execution data of an instruction, and calculating an instruction weight coefficient of the instruction according to the historical execution data of the instruction;
the calculation formula of the instruction weight coefficient is as follows:
Wherein, Q zli is the instruction weight coefficient of the ith instruction, j is the instruction execution record number of times in the data acquisition time period, S i is the time attenuation factor of the ith record for reducing the influence of the old execution record on the current weight, C i is the successful execution number of the instruction in the ith record, L vi is the preset weight of the instruction in the ith record, and Z i is the total execution number of the instruction in the ith record;
Generating an execution prediction path according to the instruction execution sequence and the instruction weight sequence;
Comparing the instruction weight coefficient of each instruction with a preset weight range to obtain a weight comparison result;
the weight comparison result comprises an out-of-range instruction and an in-range instruction;
removing the out-of-range instruction in the execution prediction path to obtain an execution update path;
acquiring instruction execution dynamic change data, and updating historical execution data of an instruction according to the instruction execution dynamic change data to acquire instruction update data;
And calculating the weight updating coefficient of the instruction according to the weight comparison result and the instruction weight coefficient and the instruction updating data.
2. The method of claim 1, wherein the instruction with jump request is executed for the first time, and the condition for conditional jump is considered as not satisfied regardless of whether the instruction is executed.
3. The method of claim 1, wherein the program pointer is moved to a location specified by the jump request when the instruction having the jump request is executed again if the condition of the conditional jump is satisfied.
4. The method of claim 1, wherein the locations corresponding to the conditional jumps are recorded in a conditional jump recording table, and each location corresponding to the conditional jump is marked as valid or invalid.
5. The method of claim 1, wherein obtaining historical execution data of an instruction, calculating an instruction weight coefficient of the instruction, generating an execution prediction path, updating the historical execution data of the instruction, obtaining instruction update data, calculating a weight update coefficient of the instruction, updating the instruction weight coefficient of the instruction, obtaining an execution change path, calculating a weight adjustment coefficient, and adjusting the weight of a corresponding instruction comprises:
the calculation formula of the weight update coefficient is as follows:
Wherein G zli is a weight update coefficient of the ith instruction, Δc i is an increasing variable amount of the number of successful execution times of the instruction in the ith record, ∇ C i is the number of successful execution times of the instruction in the ith record;
updating the instruction weight coefficient of the instruction according to the weight updating coefficient, and further updating the execution updating path to obtain an execution changing path;
when the instruction weight coefficient is out of the preset weight range and the weight updating coefficient is in the preset weight range, calculating a weight adjusting coefficient according to the instruction weight coefficient and the weight updating coefficient combined with the preset weight range;
The calculation formula of the weight adjustment coefficient is as follows:
Wherein T ys is a weight adjustment coefficient, X x is a lower limit value of a preset weight range, and S x is an upper limit value of the preset weight range;
and adjusting the weight of the corresponding instruction according to the weight adjusting coefficient until the weight of the instruction is within a preset weight range.
6. A processor with a pipeline processing design comprises a memory controller, an instruction cache module, a sending unit, a scheduler and an execution unit, wherein the memory controller is electrically connected with the instruction cache module, the instruction cache module is electrically connected with the sending unit, the sending unit is electrically connected with the scheduler, the scheduler is electrically connected with the execution unit, and the processor comprises the execution path prediction method according to any one of claims 1-5.
7. The processor of claim 6, wherein the scheduler and execution unit are electrically coupled to each other by a first electrical connection channel and a second electrical connection channel, wherein the first electrical connection channel is configured to send operation data to the scheduler, and the second electrical connection channel is configured to confirm that the operation data is resent to the scheduler.
8. The processor of claim 6, wherein the memory controller is electrically connected to a system memory of a system in which the processor is located.
9. The processor of claim 6 further comprising a branch prediction unit and a data cache module, wherein the branch prediction unit is electrically coupled to the execution unit and the branch prediction unit is electrically coupled to the instruction cache module, and wherein the data cache module is electrically coupled to the execution unit and the memory controller, respectively.
10. The processor with pipeline processing design of claim 6, wherein, the processor with pipeline processing design further comprises a bus; wherein the bus is electrically connected with the execution unit.
CN202411650887.9A 2024-11-19 2024-11-19 Processor with pipeline processing design and execution path prediction method Active CN119166315B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411650887.9A CN119166315B (en) 2024-11-19 2024-11-19 Processor with pipeline processing design and execution path prediction method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411650887.9A CN119166315B (en) 2024-11-19 2024-11-19 Processor with pipeline processing design and execution path prediction method

Publications (2)

Publication Number Publication Date
CN119166315A CN119166315A (en) 2024-12-20
CN119166315B true CN119166315B (en) 2025-02-07

Family

ID=93885612

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411650887.9A Active CN119166315B (en) 2024-11-19 2024-11-19 Processor with pipeline processing design and execution path prediction method

Country Status (1)

Country Link
CN (1) CN119166315B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104793921A (en) * 2015-04-29 2015-07-22 深圳芯邦科技股份有限公司 Instruction branch prediction method and system
CN114372299A (en) * 2022-01-09 2022-04-19 北京航空航天大学杭州创新研究院 Method for resisting Spectre attack of safety branch predictor based on physical unclonable function

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200739419A (en) * 2006-04-07 2007-10-16 Univ Feng Chia Prediction mechanism of a program backward jump instruction
US11334361B2 (en) * 2020-03-02 2022-05-17 Arm Limited Shared pointer for local history records used by prediction circuitry

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104793921A (en) * 2015-04-29 2015-07-22 深圳芯邦科技股份有限公司 Instruction branch prediction method and system
CN114372299A (en) * 2022-01-09 2022-04-19 北京航空航天大学杭州创新研究院 Method for resisting Spectre attack of safety branch predictor based on physical unclonable function

Also Published As

Publication number Publication date
CN119166315A (en) 2024-12-20

Similar Documents

Publication Publication Date Title
JP2898820B2 (en) Self-parallelized computer system and method
JP4374221B2 (en) Computer system and recording medium
CN100487641C (en) Run-time updating of prediction hint instructions
US8776034B2 (en) Dynamically maintaining coherency within live ranges of direct buffers
US6622300B1 (en) Dynamic optimization of computer programs using code-rewriting kernal module
JP4027620B2 (en) Branch prediction apparatus, processor, and branch prediction method
JP4003830B2 (en) Method and system for transparent dynamic optimization in a multiprocessing environment
US6453411B1 (en) System and method using a hardware embedded run-time optimizer
CN104756078B (en) Apparatus and method for processing resource allocation
US7383417B2 (en) Prefetching apparatus, prefetching method and prefetching program product
US20090150890A1 (en) Strand-based computing hardware and dynamically optimizing strandware for a high performance microprocessor system
CN104156197B (en) Microprocessor and microprocessor operation method
US7243195B2 (en) Software managed cache optimization system and method for multi-processing systems
WO2007041122A1 (en) Thread-data affinity optimization using compiler
JPH05282265A (en) Self-scheduling parallel computer system and method
JPH09120372A (en) Harmonized software control of Harvard architecture cache memory using prefetch instructions
US6711651B1 (en) Method and apparatus for history-based movement of shared-data in coherent cache memories of a multiprocessor system using push prefetching
JPH05282266A (en) Self-organizing parallel computer system and its method
CA2830605A1 (en) Code versioning for enabling transactional memory region promotion
US8359435B2 (en) Optimization of software instruction cache by line re-ordering
US6892280B2 (en) Multiprocessor system having distributed shared memory and instruction scheduling method used in the same system
US20100180101A1 (en) Method for Executing One or More Programs on a Multi-Core Processor and Many-Core Processor
CN119166315B (en) Processor with pipeline processing design and execution path prediction method
KR20120064446A (en) Appratus and method for processing branch of bytecode on computing system
US11442757B2 (en) Simulation method and simulation system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant