CN118057308A - Instruction processing optimization method and related device - Google Patents
Instruction processing optimization method and related device Download PDFInfo
- Publication number
- CN118057308A CN118057308A CN202211443791.6A CN202211443791A CN118057308A CN 118057308 A CN118057308 A CN 118057308A CN 202211443791 A CN202211443791 A CN 202211443791A CN 118057308 A CN118057308 A CN 118057308A
- Authority
- CN
- China
- Prior art keywords
- destination address
- load instruction
- instruction
- address
- determining
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30098—Register arrangements
- G06F9/3012—Organisation of register space, e.g. banked or distributed register file
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30003—Arrangements for executing specific machine instructions
- G06F9/30007—Arrangements for executing specific machine instructions to perform operations on data operands
- G06F9/30032—Movement instructions, e.g. MOVE, SHIFT, ROTATE, SHUFFLE
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Executing Machine-Instructions (AREA)
Abstract
Description
技术领域Technical Field
本申请涉及数据处理的技术领域,具体涉及一种指令处理优化方法及相关装置。The present application relates to the technical field of data processing, and in particular to an instruction processing optimization method and related devices.
背景技术Background technique
在当今大数据的时代,电子设备通过指令实现数据处理的过程中,数据的批量处理是不可避免的场景之一,而数据的存储与访问会直接影响数据处理的效率。现有方法中,为提升数据处理的效率,往往采用的是:面向不同的场景,通过在电子设备的芯片中新增额外的功能单元部件,例如:增加图像处理单元(graph processing unit,GPU)、神经网络处理器(neural processing unit,NPU)等加速单元。而采用这种方式,在实现处理效率提升的同时会导致使得芯片资源增加,最终导致芯片面积扩大。In today's era of big data, batch processing of data is one of the inevitable scenarios in the process of electronic devices implementing data processing through instructions, and the storage and access of data will directly affect the efficiency of data processing. In the existing methods, in order to improve the efficiency of data processing, it is often adopted that: for different scenarios, additional functional unit components are added to the chip of the electronic device, such as adding acceleration units such as graph processing unit (GPU) and neural processing unit (NPU). While adopting this method, while achieving improved processing efficiency, it will lead to an increase in chip resources, and ultimately lead to an expansion of the chip area.
为解决上述问题,亟需一种指令处理优化方法。In order to solve the above problems, an instruction processing optimization method is urgently needed.
发明内容Summary of the invention
本申请实施例提供了一种指令处理优化方法及相关装置,有利于提高电子设备进行指令处理的速度,进而提高批量数据加载的效率。The embodiments of the present application provide an instruction processing optimization method and related devices, which are beneficial to improving the speed of instruction processing of electronic devices, thereby improving the efficiency of batch data loading.
第一方面,本申请实施例提供一种指令处理优化方法,应用于电子设备,所述电子设备包括第一寄存器和第二寄存器,所述第一寄存器用于确定获取目标数据的源地址,所述第二寄存器用于确定存储所述目标数据的目的地址,所述第一寄存器包括偏移位和迭代计算位;In a first aspect, an embodiment of the present application provides an instruction processing optimization method, which is applied to an electronic device, wherein the electronic device includes a first register and a second register, the first register is used to determine a source address for obtaining target data, the second register is used to determine a destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit;
所述方法包括:The method comprises:
确定目标加载load指令,其中,所述目标load指令包括以下任意一种:第一load指令和第二load指令,所述偏移位包括源地址偏移位和目的地址偏移位;Determine a target load instruction, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit;
若所述目标load指令为所述第一load指令,则根据所述源地址偏移位和所述第一load指令,确定第一源地址,并根据所述第二寄存器中的初始目的地址和所述目的地址偏移位,确定第一目的地址;If the target load instruction is the first load instruction, determining a first source address according to the source address offset and the first load instruction, and determining a first destination address according to the initial destination address in the second register and the destination address offset;
根据所述第一源地址,获取第一目标数据;According to the first source address, obtaining first target data;
根据所述第一目的地址,将所述第一目标数据回写至所述第一目的地址对应的存储空间;According to the first destination address, writing the first target data back to the storage space corresponding to the first destination address;
根据所述迭代计算位和所述初始目的地址确定最终目的地址,并根据所述最终目的地址判断所述第一load指令是否执行完毕;Determine a final destination address according to the iterative calculation bit and the initial destination address, and determine whether the first load instruction has been executed according to the final destination address;
若所述最终目的地址与所述第一目的地址相同,则确定所述第一load指令执行完毕。If the final destination address is the same as the first destination address, it is determined that the first load instruction has been executed.
第二方面,本申请实施例提供一种指令处理优化装置,应用于电子设备,所述电子设备包括第一寄存器和第二寄存器,所述第一寄存器用于确定获取目标数据的源地址,所述第二寄存器用于确定存储所述目标数据的目的地址,所述第一寄存器包括偏移位和迭代计算位;In a second aspect, an embodiment of the present application provides an instruction processing optimization device, which is applied to an electronic device, wherein the electronic device includes a first register and a second register, wherein the first register is used to determine a source address for obtaining target data, and the second register is used to determine a destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit;
所述装置包括:确定单元、获取单元、执行单元和判断单元;其中,The device comprises: a determination unit, an acquisition unit, an execution unit and a judgment unit; wherein,
所述确定单元,用于确定目标加载load指令,其中,所述目标load指令包括以下任意一种:第一load指令和第二load指令,所述偏移位包括源地址偏移位和目的地址偏移位;以及用于,若所述目标load指令为所述第一load指令,则根据所述源地址偏移位和所述第一load指令,确定第一源地址,并根据所述第二寄存器中的初始目的地址和所述目的地址偏移位,确定第一目的地址;The determining unit is configured to determine a target load instruction, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit; and is configured to, if the target load instruction is the first load instruction, determine a first source address according to the source address offset bit and the first load instruction, and determine a first destination address according to an initial destination address in the second register and the destination address offset bit;
所述获取单元,用于根据所述第一源地址,获取第一目标数据;The acquiring unit is configured to acquire first target data according to the first source address;
所述执行单元,用于根据所述第一目的地址,将所述第一目标数据回写至所述第一目的地址对应的存储空间;The execution unit is configured to write the first target data back to a storage space corresponding to the first destination address according to the first destination address;
所述判断单元,用于根据所述迭代计算位和所述初始目的地址确定最终目的地址,并根据所述最终目的地址判断所述第一load指令是否执行完毕;以及用于,若所述最终目的地址与所述第一目的地址相同,则确定所述第一load指令执行完毕。The judgment unit is used to determine the final destination address according to the iterative calculation bit and the initial destination address, and to judge whether the first load instruction has been executed according to the final destination address; and to determine that the first load instruction has been executed if the final destination address is the same as the first destination address.
第三方面,本申请实施例提供一种电子设备,包括处理器、存储器、通信接口以及一个或多个程序,其中,上述一个或多个程序被存储在上述存储器中,并且被配置由上述处理器执行,上述程序包括用于执行本申请实施例第一方面任一方法中的步骤的指令。In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps of any method of the first aspect of the embodiment of the present application.
第四方面,本申请实施例提供了一种计算机可读存储介质,其中,上述计算机可读存储介质存储用于电子数据交换的计算机程序,其中,上述计算机程序使得计算机执行如本申请实施例第一方面任一方法中所描述的部分或全部步骤。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in any method of the first aspect of the embodiment of the present application.
第五方面,本申请实施例提供了一种计算机程序装置,其中,上述计算机程序装置包括存储了计算机程序的非瞬时性计算机可读存储介质,上述计算机程序可操作来使计算机执行如本申请实施例第一方面任一方法中所描述的部分或全部步骤。该计算机程序装置可以为一个软件安装包。In a fifth aspect, an embodiment of the present application provides a computer program device, wherein the computer program device includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the embodiment of the present application. The computer program device can be a software installation package.
可以看出,本申请实施例中,通过确定目标加载load指令,其中,第一寄存器包括源地址偏移位、目的地址偏移位和迭代计算位;若目标load指令为第一load指令,则根据源地址偏移位和第一load指令,确定第一源地址,并根据第二寄存器中的初始目的地址和目的地址偏移位,确定第一目的地址;根据第一源地址,获取第一目标数据;将第一目标数据回写至第一目的地址对应的存储空间;根据迭代计算位和初始目的地址确定最终目的地址,若最终目的地址与第一目的地址相同,则确定第一load指令迭代执行完毕。如此,可以通过指令的并行处理,实现批量数据处理,为电子设备执行数据处理提供更高的数据吞吐率。It can be seen that in the embodiment of the present application, by determining the target load instruction, the first register includes a source address offset bit, a destination address offset bit and an iterative calculation bit; if the target load instruction is the first load instruction, the first source address is determined according to the source address offset bit and the first load instruction, and the first destination address is determined according to the initial destination address and the destination address offset bit in the second register; the first target data is obtained according to the first source address; the first target data is written back to the storage space corresponding to the first destination address; the final destination address is determined according to the iterative calculation bit and the initial destination address, and if the final destination address is the same as the first destination address, it is determined that the first load instruction is iteratively executed. In this way, batch data processing can be achieved through parallel processing of instructions, providing a higher data throughput rate for electronic devices to perform data processing.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
图1A是本申请实施例提供的一种现有架构的指令处理过程示意图;FIG1A is a schematic diagram of an instruction processing process of a conventional architecture provided in an embodiment of the present application;
图1B是本申请实施例提供的一种现有架构进行指令执行处理过程示意图;FIG1B is a schematic diagram of an instruction execution process of an existing architecture provided by an embodiment of the present application;
图1C是本申请实施例提供的一种电子设备实现指令优化处理的架构示意图;FIG1C is a schematic diagram of an architecture of an electronic device implementing instruction optimization processing provided by an embodiment of the present application;
图2是本申请实施例提供的一种指令处理优化方法的流程示意图;FIG2 is a flow chart of an instruction processing optimization method provided in an embodiment of the present application;
图3是本申请实施例提供的一种第一寄存器结构示意图;FIG3 is a schematic diagram of a first register structure provided in an embodiment of the present application;
图4A是本申请实施例提供的一种指令处理优化方法的整体流程示意图;FIG4A is a schematic diagram of the overall flow of an instruction processing optimization method provided by an embodiment of the present application;
图4B是本申请实施例提供的一种电子设备处理第一load指令的过程示意图;FIG4B is a schematic diagram of a process of an electronic device processing a first load instruction provided by an embodiment of the present application;
图5是本申请实施例提供的一种电子设备的结构示意图;FIG5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
图6是本申请实施例提供的一种指令处理优化装置的功能单元组成框图。FIG6 is a block diagram of the functional units of an instruction processing optimization device provided in an embodiment of the present application.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、装置或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、装置或设备固有的其他步骤或单元。The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, device or equipment that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, devices or equipment.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
电子设备可以是还包含其它功能诸如个人数字助理和/或音乐播放器功能的便携式电子设备,诸如手机、平板电脑、具备无线通讯功能的可穿戴电子设备(如智能手表、智能眼镜)、车载设备等。便携式电子设备的示例性实施例包括但不限于搭载IOS系统、Android系统、Microsoft系统或者其它操作系统的便携式电子设备。上述便携式电子设备也可以是其它便携式电子设备,诸如膝上型计算机(Laptop)等。还应当理解的是,在其他一些实施例中,上述电子设备也可以不是便携式电子设备,而是台式计算机。The electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, a wearable electronic device with a wireless communication function (such as a smart watch, smart glasses), a vehicle-mounted device, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with an IOS system, an Android system, a Microsoft system, or other operating systems. The above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer (Laptop), etc. It should also be understood that in some other embodiments, the above-mentioned electronic device may not be a portable electronic device, but a desktop computer.
尤其是通用处理器方面,在大数据处理方面有严重的缺陷,因此当前的很多新型架构提出,包括用GPU/NPU等等作为面向大数据处理的加速单元。Especially general-purpose processors have serious defects in big data processing. Therefore, many new architectures are currently proposed, including using GPU/NPU and so on as acceleration units for big data processing.
电子设备通过指令,进行批量数据处理的应用场景中,现有架构是在原先基本控制架构中新增一个加速器,这个加速器是由简单的控制以及批量的计算单元组成,例如:GPU和NPU。其中,GPU是独立于中央处理器(center processing unit,CPU)之外的另一种主流加速器,专门用于图像数据加速处理功能。而NPU是近年流行起来的用于人工智能方面的神经网络加速功能。这些无一例外都是自成一套体系,与CPU架构是完全不同的体系,这些体系有一个共同的特性,那就是加载需要大量的数据,而数据加载的过程则往往是通过加载load指令实现。而传统的CPU的数据加载性能是制约着当前现实场景中诸多领域数据加速处理的速度。In the application scenario where electronic devices perform batch data processing through instructions, the existing architecture is to add an accelerator to the original basic control architecture. This accelerator is composed of simple control and batch computing units, such as GPU and NPU. Among them, GPU is another mainstream accelerator independent of the central processing unit (CPU), which is specially used for image data acceleration processing. NPU is a neural network acceleration function for artificial intelligence that has become popular in recent years. These are all self-contained systems without exception, which are completely different from the CPU architecture. These systems have a common feature, that is, loading requires a large amount of data, and the data loading process is often implemented through loading load instructions. The data loading performance of traditional CPUs restricts the speed of data acceleration processing in many fields in current real-life scenarios.
具体地,如图1A所示,图1A是本申请方案提供的一种现有架构的指令处理过程示意图。如图1A所述,该处理器具体包括程序计数器PC、加法器、指令缓存单元、寄存器组、若干个多路选择器以及逻辑算数部件ALU。其中,指令缓存单元的功能是存储读入的所有32-bit位宽的指令,根据程序计数器PC中的指令地址进行取指令操作并对指令类型进行分析,通过指令类型对所取指令的各字段进行区分识别,最后将对应部分传递给其他模块进行后续处理。其中,指令具体包括但不限于:加载load指令和存储store指令等等,load指令将内存中的数据取入通用寄存器,store指令将通用寄存器中的数据存至内存中。每次从指令缓存单元中取出一条指令,程序计数器根据指令长度通过加法器自动递增产生下一条指令所需要的指令地址。Specifically, as shown in FIG. 1A, FIG. 1A is a schematic diagram of an instruction processing process of an existing architecture provided by the present application scheme. As shown in FIG. 1A, the processor specifically includes a program counter PC, an adder, an instruction cache unit, a register group, a plurality of multiplexers, and a logic arithmetic unit ALU. Among them, the function of the instruction cache unit is to store all 32-bit wide instructions read in, perform instruction fetching operations according to the instruction address in the program counter PC and analyze the instruction type, distinguish and identify each field of the fetched instruction by the instruction type, and finally pass the corresponding part to other modules for subsequent processing. Among them, the instructions specifically include but are not limited to: load instructions and store instructions, etc. The load instruction fetches the data in the memory into the general register, and the store instruction stores the data in the general register into the memory. Each time an instruction is taken out from the instruction cache unit, the program counter automatically increments according to the instruction length through the adder to generate the instruction address required for the next instruction.
示例性地,在寄存器类指令中,操作码都由操作码(OP)和辅助操作码(OPX)组成,操作数都包括两个源操作数(RS)和一个目标操作数(RD);立即数类指令都由操作码、源操作数、目标操作数和立即数(Const)组成,立即数的位数各有不同。Exemplarily, in register-type instructions, opcodes are composed of an opcode (OP) and an auxiliary opcode (OPX), and operands include two source operands (RS) and one target operand (RD); immediate-type instructions are composed of an opcode, a source operand, a target operand, and an immediate number (Const), and the number of bits of the immediate number varies.
示例性地,寄存器组中包括若干个寄存器,每个寄存器位宽32-bit,是存放ALU计算所需要的临时数据的,与数据存储器不同,该部分的寄存器存入的数据可能会在程序执行的过程中被多次覆盖,而数据存储器内的数据一般只有sw指令才能进行修改覆盖。寄存器组会根据操作码与RS、RT字段相应的地址读取数据,同时将RS、RT寄存器的地址和其中的数据输出,在时钟的下降沿到来时将数据存放到RS或RT字段的相应地址的寄存器内。For example, the register group includes several registers, each with a width of 32 bits, which are used to store temporary data required for ALU calculations. Unlike the data memory, the data stored in this part of the registers may be overwritten multiple times during the execution of the program, while the data in the data memory can generally only be modified and overwritten by the sw instruction. The register group reads data according to the address corresponding to the opcode and the RS and RT fields, and outputs the address of the RS and RT registers and the data therein, and stores the data in the register corresponding to the RS or RT field when the falling edge of the clock arrives.
示例性地,符号扩展位是用于立即数的扩展,用于对指令位数补齐。多路选择器用于根据指令译码得到的数据,选择对应的存储空间,进而实现获取指令指向的数据。逻辑算数部件根据指令译码后的数据选取对应的操作数,根据操作码进行运算并输出结果与零标志位。用于根据指令执行逻辑运算,其中,逻辑运算包括但不限于:加、减、乘和除等等。Exemplarily, the sign extension bit is used to extend the immediate number and to fill the number of instruction bits. The multiplexer is used to select the corresponding storage space according to the data obtained by instruction decoding, so as to obtain the data pointed to by the instruction. The logical arithmetic component selects the corresponding operand according to the data after instruction decoding, performs calculation according to the operation code and outputs the result and the zero flag bit. It is used to perform logical operations according to the instruction, wherein the logical operations include but are not limited to: addition, subtraction, multiplication and division, etc.
具体地,请参阅图1A所示进行数据处理过程相关描述:Specifically, please refer to FIG. 1A for a description of the data processing process:
示例性地,如图1A所示数据处理具体包括五个流程:取指IF、译指ID、执行EXE、访存MEM和回写WB。Exemplarily, as shown in FIG. 1A , data processing specifically includes five processes: instruction fetch IF, instruction translation ID, execution EXE, memory access MEM, and write back WB.
具体地,取指操作即从指令缓存单元(INSTRCACHE)中读取一条指令。为便于理解,此处以指令(load,a0,4(a5))为例。Specifically, the instruction fetch operation is to read an instruction from the instruction cache unit (INSTRCACHE). For ease of understanding, the instruction (load, a0, 4 (a5)) is taken as an example.
进一步地,译指操作即对该指令进行译码处理。Furthermore, the instruction translation operation is to decode the instruction.
进一步地,对译码后的指令,通过逻辑算数部件对该指令执行对应的数据处理操作,例如对指令(load,a0,4(a5))执行的具体操作为:将a5寄存器的值与十进制数4执行一个加法运算,得到当前load指令对应的存储地址,即,addr=[a5]+4。Furthermore, for the decoded instruction, the corresponding data processing operation is performed on the instruction through the logical arithmetic component. For example, the specific operation performed on the instruction (load, a0, 4(a5)) is: perform an addition operation on the value of the a5 register and the decimal number 4 to obtain the storage address corresponding to the current load instruction, that is, addr=[a5]+4.
进一步地,根据上述计算确定的地址addr,进行访存操作,访问addr对应的存储地址,从该地址中读取数据。Furthermore, according to the address addr determined by the above calculation, a memory access operation is performed to access the storage address corresponding to addr and read data from the address.
最后,将所读取到的数据,回写至寄存器a0中。Finally, the read data is written back to register a0.
具体地,请参阅图1B,图1B为本申请实施例提供的一种现有架构进行指令执行处理过程示意图。Specifically, please refer to FIG. 1B , which is a schematic diagram of an instruction execution processing process of an existing architecture provided in an embodiment of the present application.
示例性地,若当前存在三条load指令需要电子设备进行指令处理。则如图1B所示,电子设备分别对每一条指令执行上述五个步骤:取指、译指、执行、访存和回写操作。For example, if there are currently three load instructions that need to be processed by the electronic device, as shown in FIG1B , the electronic device performs the above five steps for each instruction: instruction fetch, instruction translation, execution, memory access, and write-back operations.
其中,现有方法中,电子设备在对每一条load指令进行处理过程中,若上一条load指令执行结果未执行到回写操作之前,下一条load指令是无法进行到访存阶段。即上述处理过程会出现指令处理互相等待,造成停顿现象,从而影响指令执行的效率。且如果每条load指令实质对应的操作为同一操作,只是在进行迭代的时候,仍需要每次都需要获取同一条load指令,执行相同的操作,造成程序代码的冗余。Among them, in the existing method, when the electronic device processes each load instruction, if the execution result of the previous load instruction has not been executed before the write-back operation, the next load instruction cannot proceed to the memory access stage. That is, the above processing process will cause the instructions to wait for each other, causing a pause, thereby affecting the efficiency of instruction execution. And if the operation corresponding to each load instruction is actually the same operation, but when iterating, it is still necessary to obtain the same load instruction each time and perform the same operation, resulting in redundancy of program code.
针对上述问题,本申请提出一种指令处理优化方法及相关装置,如图1C所示,图1C是本申请提供的一种电子设备实现指令优化处理的架构示意图。In response to the above problems, the present application proposes an instruction processing optimization method and related devices, as shown in FIG1C . FIG1C is a schematic diagram of the architecture of an electronic device provided by the present application for implementing instruction optimization processing.
示例性地,如图1C所示,该架构在复用图1A所示架构的基础上,增加了自定义寄存器和用于做连续性处理load指令的逻辑算数部件。具体硬件新增细节如下:增加两个位宽为32-bit的自定义寄存器。其中,自定义寄存器1(即第一寄存器)用于确定获取目标数据的源地址,自定义寄存器2(即第二寄存器)用于确定存储目标数据的目的地址。当电子设备执行完图1A所述的取指和译指操作后,两个逻辑算数部件同时根据自定义寄存器1和自定义寄存器2中的数据,确定获取目标数据的源地址以及回写目标数据的目的地址。进一步地,根据逻辑算数部件计算结果从对应位置中获取目标数据并将目标数据回写。需要说明的是,当前load指令可以为需要连续执行数据获取操作的load指令。逻辑算数部件只需根据连续执行的次数,以及两个自定义寄存器中的数据,确定每次数据获取的源地址和目的地址,在此过程中,每次重复数据获取和回写操作之间,无需互相等待。从而实现load指令的连续性处理,提高数据处理效率,降低电子设备功耗的目的。Exemplarily, as shown in FIG1C, the architecture adds a custom register and a logic arithmetic component for continuous processing of load instructions on the basis of reusing the architecture shown in FIG1A. The specific hardware details are as follows: two custom registers with a bit width of 32-bit are added. Among them, the custom register 1 (i.e., the first register) is used to determine the source address for obtaining the target data, and the custom register 2 (i.e., the second register) is used to determine the destination address for storing the target data. After the electronic device performs the instruction fetch and instruction translation operations described in FIG1A, the two logic arithmetic components simultaneously determine the source address for obtaining the target data and the destination address for writing back the target data according to the data in the custom register 1 and the custom register 2. Further, the target data is obtained from the corresponding position according to the calculation result of the logic arithmetic component and the target data is written back. It should be noted that the current load instruction can be a load instruction that needs to perform data acquisition operations continuously. The logic arithmetic component only needs to determine the source address and destination address of each data acquisition based on the number of consecutive executions and the data in the two custom registers. In this process, there is no need to wait for each other between each repeated data acquisition and write-back operations. Thereby achieving the purpose of continuous processing of load instructions, improving data processing efficiency, and reducing power consumption of electronic devices.
通过上述架构,在电子设备原本的CPU架构中通过灵活配置自定义寄存器,使得传统的CPU架构可以做批量数据操作。且该架构并非仅仅是针对特定的领域进行设置,增加了电子设备在现代化应用场景的生存能力,同时为当前图像处理、信号处理、人工智能等领域方面提供更高的数据吞吐率,通过提高指令执行的流畅性提高数据处理的效率。Through the above architecture, the custom registers are flexibly configured in the original CPU architecture of the electronic device, so that the traditional CPU architecture can perform batch data operations. And this architecture is not only set up for specific fields, but also increases the viability of electronic devices in modern application scenarios. At the same time, it provides higher data throughput for current image processing, signal processing, artificial intelligence and other fields, and improves the efficiency of data processing by improving the fluency of instruction execution.
为更好地理解本方案,下面将具体进行描述。In order to better understand this solution, it will be described in detail below.
请参阅图2,图2是本申请实施例提供的一种指令处理优化方法的流程示意图,应用于电子设备,所述电子设备包括第一寄存器和第二寄存器,所述第一寄存器用于确定获取目标数据的源地址,所述第二寄存器用于确定存储所述目标数据的目的地址,所述第一寄存器包括偏移位和迭代计算位;如图所示,本指令处理优化方法包括以下操作:Please refer to FIG. 2, which is a flow chart of an instruction processing optimization method provided by an embodiment of the present application, which is applied to an electronic device, wherein the electronic device includes a first register and a second register, wherein the first register is used to determine a source address for obtaining target data, and the second register is used to determine a destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit; as shown in the figure, the instruction processing optimization method includes the following operations:
S201、确定目标加载load指令,其中,所述目标load指令包括以下任意一种:第一load指令和第二load指令,所述偏移位包括源地址偏移位和目的地址偏移位。S201. Determine a target load instruction, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit.
示例性地,如图3所示,图3是本申请实施例提供的一种第一寄存器结构示意图。如图3所示,第一寄存器为位宽32-bit的寄存器,具体包括类型标识位、偏移位和迭代次数位。Exemplarily, as shown in Figure 3, Figure 3 is a schematic diagram of a first register structure provided in an embodiment of the present application. As shown in Figure 3, the first register is a 32-bit register, specifically including a type identification bit, an offset bit, and an iteration count bit.
具体地,类型标识位C占1bit,用于指示当前的load指令是第一load指令,还是第二load指令。第一load指令用于指示当前load指令需要多次执行数据获取和数据回写操作,即,流水化load指令;第二load指令用于指示当前load指令为单次执行数据获取和数据回写操作,即,正常load指令。Specifically, the type identification bit C occupies 1 bit and is used to indicate whether the current load instruction is the first load instruction or the second load instruction. The first load instruction is used to indicate that the current load instruction needs to perform data acquisition and data write-back operations multiple times, that is, a pipelined load instruction; the second load instruction is used to indicate that the current load instruction performs data acquisition and data write-back operations once, that is, a normal load instruction.
示例性地,电子设备在接收到经过译码处理后的目标load指令,根据第一寄存器中的类型标识位,确定出目标load指令为第一load指令还是第二load指令。Exemplarily, after receiving the decoded target load instruction, the electronic device determines whether the target load instruction is the first load instruction or the second load instruction according to the type identification bit in the first register.
S202、若所述目标load指令为所述第一load指令,则根据所述源地址偏移位和所述第一load指令,确定第一源地址,并根据所述第二寄存器中的初始目的地址和所述目的地址偏移位,确定第一目的地址。S202: If the target load instruction is the first load instruction, determine a first source address according to the source address offset and the first load instruction, and determine a first destination address according to the initial destination address in the second register and the destination address offset.
示例性地,如图3所示的第一寄存器结构图中,偏移位占据20bits。其中,偏移位包括源地址偏移位soffset和目的地址偏移位doffset。Exemplarily, in the first register structure diagram shown in Fig. 3, the offset bit occupies 20 bits, wherein the offset bit includes a source address offset bit soffset and a destination address offset bit doffset.
具体地,源地址偏移位soffset和目的地址偏移位doffset分别占10bits,soffset所对应的数值即为源地址偏移量,其中,源地址偏移量用于确定每一次执行第一load指令,获取目标数据对应的地址。例如:若第一load指令为(load,x,y),y为初始源地址,soffset为a,则第n次执行第一load指令时,其源地址为:y+(n-1)a。进一步地,电子设备根据每次确定的源地址从对应位置获取目标数据。其中,源地址包括第一源地址,且源地址的个数与执行第一load指令的次数一致。Specifically, the source address offset bit soffset and the destination address offset bit doffset each occupy 10 bits, and the value corresponding to soffset is the source address offset, wherein the source address offset is used to determine each execution of the first load instruction to obtain the address corresponding to the target data. For example: if the first load instruction is (load, x, y), y is the initial source address, and soffset is a, then when the first load instruction is executed for the nth time, its source address is: y+(n-1)a. Furthermore, the electronic device obtains the target data from the corresponding position according to the source address determined each time. Among them, the source address includes the first source address, and the number of source addresses is consistent with the number of times the first load instruction is executed.
具体地,Doffset所对应的数值,用于确定每一次执行第一load指令,将目标数据回写到内存空间的目的地址。例如:若第一load指令为(load,x,y),x为初始目的地址,doffset为b,则第n次执行第一load指令时,其源地址为:y+(n-1)b。进一步地,电子设备将每次执行第一load指令所获取的目标数据,回写至目的地址对应的存储空间。其中,目的地址包括第一目的地址,且目的地址的个数与执行第一load指令的次数一致。Specifically, the value corresponding to Doffset is used to determine the destination address of the memory space to write the target data back each time the first load instruction is executed. For example: if the first load instruction is (load, x, y), x is the initial destination address, and doffset is b, then when the first load instruction is executed for the nth time, its source address is: y+(n-1)b. Furthermore, the electronic device writes back the target data obtained each time the first load instruction is executed to the storage space corresponding to the destination address. Among them, the destination address includes the first destination address, and the number of destination addresses is consistent with the number of times the first load instruction is executed.
需要说明的是,电子设备通过上述步骤确定源地址和目的地址的处理过程,为并行操作,即源地址和目的地址的确定为同时进行。具体可由图1B所示的两个逻辑算数部件并行处理,同时确定获取目标数据的源地址和回写目的地址。It should be noted that the process of determining the source address and the destination address by the electronic device through the above steps is a parallel operation, that is, the source address and the destination address are determined simultaneously. Specifically, the two logical arithmetic components shown in FIG. 1B can be processed in parallel to simultaneously determine the source address for obtaining the target data and the write-back destination address.
示例性地,以load指令为(load,a0,a5)为例进行详细描述。若电子设备根据类型标识位C确定当前的load指令是第一load指令,则表示每一次数据获取的源地址为[a5]+soffset,即将load指令中指示获取目标数据寄存器地址的数据,叠加一个源地址位移位soffset对应的偏移量,得到实际获取目标数据的源地址。例如:若a5寄存器的值是8,soffset是4,则在第一次执行第一load指令时,第一目标数据的源地址是8,第二目标数据的源地址是12=8+4,第三目标数据的源地址16=12+4,依次类推。Exemplarily, a load instruction (load, a0, a5) is used as an example for detailed description. If the electronic device determines that the current load instruction is the first load instruction according to the type identification bit C, it means that the source address of each data acquisition is [a5] + soffset, that is, the data indicating the acquisition of the target data register address in the load instruction is superimposed with an offset corresponding to the source address shift soffset to obtain the actual source address of the target data. For example: if the value of the a5 register is 8 and soffset is 4, then when the first load instruction is executed for the first time, the source address of the first target data is 8, the source address of the second target data is 12 = 8 + 4, and the source address of the third target data is 16 = 12 + 4, and so on.
示例性地,当前的load指令是第一load指令,则表示每一次获取目标数据后,执行回写操作时,存放目标数据的目的地址destAddr需要在初始目的地址的基础上,叠加一个目的地址位移位doffset对应的偏移量,得到实际回写目标数据的目的地址。例如上述load指令,若a0为1,doffset为5,如从上述存储地址为8的存储空间中得到第一目标数据,则第一目标数据对应的第一目的地址为1;从源地址为12得到第二目标数据,第二目标数据对应第二目的地址则是6=1+(2-1)*5;从存储地址为16得到第三目标数据,第三目标数据对应第二目的地址则是11=1+(3-1)*5。Exemplarily, if the current load instruction is the first load instruction, it means that each time the target data is obtained, when the write-back operation is performed, the destination address destAddr storing the target data needs to be superimposed on the initial destination address with an offset corresponding to the destination address shift doffset to obtain the destination address of the actual write-back target data. For example, in the above load instruction, if a0 is 1 and doffset is 5, if the first target data is obtained from the storage space with the storage address 8, the first destination address corresponding to the first target data is 1; the second target data is obtained from the source address 12, and the second target data corresponds to the second destination address of 6=1+(2-1)*5; the third target data is obtained from the storage address 16, and the third target data corresponds to the second destination address of 11=1+(3-1)*5.
需要说明的是,上述源地址和目的地址确认过程,若为连续进行时,则每次执行第一load指令时,源地址和目的地址均为上一次执行时所确定的源地址和目的地址上叠加位移量。It should be noted that, if the above source address and destination address confirmation process is performed continuously, each time the first load instruction is executed, the source address and destination address are the source address and destination address determined in the previous execution with the displacement added thereto.
S203、根据所述第一源地址,获取第一目标数据。S203. Acquire first target data according to the first source address.
具体地,如步骤S202所述过程,电子设备根据第一load指令和第一寄存器中的源地址偏移位确定第一源地址后,执行访存操作,在第一源地址对应的存储空间获取第一目标数据。Specifically, as described in step S202, after the electronic device determines the first source address according to the first load instruction and the source address offset bit in the first register, it performs a memory access operation to obtain the first target data in the storage space corresponding to the first source address.
S204、根据所述第一目的地址,将所述第一目标数据回写至所述第一目的地址对应的存储空间。S204. According to the first destination address, write the first target data back to a storage space corresponding to the first destination address.
具体地,如步骤S202所述过程,电子设备根据第一load指令和第一寄存器中的目的地址偏移位确定第一目的地址后,执行回写操作,在第一目的地址对应的存储空间存入第一目标数据。Specifically, as described in step S202, after the electronic device determines the first destination address according to the first load instruction and the destination address offset bit in the first register, it performs a write-back operation to store the first target data in the storage space corresponding to the first destination address.
S205、根据所述迭代计算位和所述初始目的地址确定最终目的地址,并根据所述最终目的地址判断所述第一load指令是否执行完毕。S205: Determine a final destination address according to the iterative calculation bit and the initial destination address, and determine whether the first load instruction has been executed according to the final destination address.
示例性地,第一寄存器还包括迭代计算位,其中,迭代计算位占11bits,用于指示当前第一load指令需要迭代的次数。Exemplarily, the first register further includes an iteration calculation bit, wherein the iteration calculation bit occupies 11 bits and is used to indicate the number of iterations required for the current first load instruction.
具体地,电子设备根据第一寄存器的迭代计算位,确定第一load指令需要迭代执行的次数。并根据第一load指令确定初始目的地址。Specifically, the electronic device determines the number of times the first load instruction needs to be iteratively executed according to the iterative calculation bit of the first register, and determines the initial destination address according to the first load instruction.
进一步地,电子设备根据迭代次数、目的地址偏移位和初始目的地址,计算确定执行完该第一load指令时的最终目的地址。并根据最终目的地址,判断迭代执行是否结束。Furthermore, the electronic device calculates and determines the final destination address after executing the first load instruction according to the number of iterations, the destination address offset and the initial destination address, and determines whether the iterative execution is completed according to the final destination address.
S206、若所述最终目的地址与所述第一目的地址相同,则确定所述第一load指令执行完毕。S206: If the final destination address is the same as the first destination address, it is determined that the first load instruction is executed completely.
具体地,若第一load指令迭代执行结束,则电子设备在最后一次执行第一load指令时所确定的目的地址,与最终目的地址一致。Specifically, if the iterative execution of the first load instruction is completed, the destination address determined by the electronic device when the electronic device executes the first load instruction for the last time is consistent with the final destination address.
示例性地,电子设备执行一次第一load指令,确定第一目的地址。比较第一目的地址和最终目的地址是否相同,若相同,则表明当前迭代执行过程结束。若不同,则继续执行第一load指令,获取目标数据。Exemplarily, the electronic device executes the first load instruction once to determine the first destination address, compares whether the first destination address is the same as the final destination address, and if so, indicates that the current iterative execution process is finished, and if not, continues to execute the first load instruction to obtain the target data.
可以看出,本申请实施例所描述的指令处理优化方法,电子设备包括第一寄存器和第二寄存器。其中,电子设备包括第一寄存器和第二寄存器,第一寄存器用于确定获取目标数据的源地址,第二寄存器用于确定存储目标数据的目的地址,第一寄存器包括偏移位和迭代计算位;确定目标加载load指令,其中,目标load指令包括以下任意一种:第一load指令和第二load指令,偏移位包括源地址偏移位和目的地址偏移位;若目标load指令为第一load指令,则根据源地址偏移位和第一load指令,确定第一源地址,并根据第二寄存器中的初始目的地址和目的地址偏移位,确定第一目的地址;根据第一源地址,获取第一目标数据;根据第一目的地址,将第一目标数据回写至第一目的地址对应的存储空间;根据迭代计算位和初始目的地址确定最终目的地址,并根据最终目的地址判断第一load指令是否执行完毕;若最终目的地址与第一目的地址相同,则确定第一load指令执行完毕。如此,可以通过指令的并行处理,实现批量数据处理,为CPU执行数据处理提供更高的数据吞吐率。It can be seen that the instruction processing optimization method described in the embodiment of the present application, the electronic device includes a first register and a second register. Wherein, the electronic device includes a first register and a second register, the first register is used to determine the source address of the target data, the second register is used to determine the destination address of the target data, and the first register includes an offset bit and an iterative calculation bit; determine the target load load instruction, wherein the target load instruction includes any of the following: the first load instruction and the second load instruction, the offset bit includes the source address offset bit and the destination address offset bit; if the target load instruction is the first load instruction, then according to the source address offset bit and the first load instruction, determine the first source address, and according to the initial destination address and the destination address offset bit in the second register, determine the first destination address; according to the first source address, obtain the first target data; according to the first destination address, write the first target data back to the storage space corresponding to the first destination address; determine the final destination address according to the iterative calculation bit and the initial destination address, and judge whether the first load instruction is executed according to the final destination address; if the final destination address is the same as the first destination address, determine that the first load instruction is executed. In this way, batch data processing can be achieved through parallel processing of instructions, providing a higher data throughput rate for CPU to perform data processing.
在一个可能的示例中,所述确定目标加载load指令之前,上述方法可包括如下步骤:获取指令,并对所述指令进行译码,得到指令数据,其中,所述指令数据包括所述指令的类型标识数据;根据所述类型标识数据,判断所述指令的类型;若所述指令的类型为load指令类型,则将所述指令确定为所述目标load指令。In a possible example, before determining the target load instruction, the above method may include the following steps: acquiring an instruction and decoding the instruction to obtain instruction data, wherein the instruction data includes type identification data of the instruction; judging the type of the instruction according to the type identification data; if the type of the instruction is a load instruction type, determining the instruction as the target load instruction.
示例性地,如图1A和图1B所述内容,电子设备通过在指令缓冲单元中获取指令,即取指操作。Exemplarily, as described in FIG. 1A and FIG. 1B , the electronic device obtains instructions from an instruction buffer unit, namely, performs an instruction fetch operation.
进一步地,电子设备对所获取到的指令进行指令译码操作,即译指操作,得到指令数据,其中,指令数据中包括指示当前指令类型的类型标识数据,还包括指示当前指令操作。其中,指令类型包括但不限于:load指令类型和store指令类型等等。Furthermore, the electronic device performs instruction decoding operation on the acquired instruction, i.e., instruction translation operation, to obtain instruction data, wherein the instruction data includes type identification data indicating the current instruction type and also includes data indicating the current instruction operation. The instruction type includes but is not limited to: load instruction type and store instruction type, etc.
进一步地,电子设备根据类型标识数据,确定当前指令的类型。若确定当前指令为load指令,则进一步根据第一寄存器中的类型标识位C判断load指令是第一load指令还是第二load指令。Furthermore, the electronic device determines the type of the current instruction according to the type identification data. If the current instruction is determined to be a load instruction, it further determines whether the load instruction is the first load instruction or the second load instruction according to the type identification bit C in the first register.
可见,电子设备通过从指令缓冲单元进行取指操作,得到指令后,对指令进行译指操作。进而根据译指操作得到的指令数据确定指令的类型是否为load指令,若是,则进一步根据第一寄存器确定load指令的类型。It can be seen that the electronic device performs an instruction fetch operation from the instruction buffer unit, obtains the instruction, and then performs an instruction translation operation on the instruction, and then determines whether the instruction type is a load instruction according to the instruction data obtained by the instruction translation operation, and if so, further determines the type of the load instruction according to the first register.
在一个可能的示例中,所述第一寄存器还包括类型标志位;所述确定目标加载load指令,上述方法可包括如下步骤:若所述类型标识位为1,则确定所述目标load指令为所述第一load指令;若所述类型标识位为0,则确定所述目标load指令为所述第二load指令。In one possible example, the first register also includes a type flag bit; for determining the target load instruction, the method may include the following steps: if the type flag bit is 1, determining that the target load instruction is the first load instruction; if the type flag bit is 0, determining that the target load instruction is the second load instruction.
示例性地,如图3所述的第一寄存器的结构,第一寄存器包括类型标识位C,占1bit。其中,类型标识位通过0/1表征目标load指令的类型。Exemplarily, as shown in the structure of the first register in FIG3 , the first register includes a type identification bit C, which occupies 1 bit. The type identification bit represents the type of the target load instruction through 0/1.
具体地,电子设备获取第一寄存器的类型标识位,若C为1,则确定第一load指令为第一load指令;若C为0,则确定第一load指令为第二load指令。需要说明的是,第一load指令用于指示目标load指令为流水线load指令,需要多次执行处理。第二load指令用于表征目标load指令为常规load指令,按照取指、译指、执行、访存和回写五个处理流程进行常规处理即可。Specifically, the electronic device obtains the type identification bit of the first register. If C is 1, it determines that the first load instruction is the first load instruction; if C is 0, it determines that the first load instruction is the second load instruction. It should be noted that the first load instruction is used to indicate that the target load instruction is a pipeline load instruction, which needs to be executed multiple times. The second load instruction is used to characterize that the target load instruction is a regular load instruction, and it can be processed in the usual way according to the five processing flows of instruction fetch, instruction translation, execution, memory access and write back.
可见,本示例中,电子设备根据第一寄存器的类型标识位判断目标load指令是第一load指令还是第二load指令后,进而可以根据判断结果对应性地进行指令处理,提高指令处理的效率。It can be seen that in this example, after the electronic device determines whether the target load instruction is the first load instruction or the second load instruction according to the type identification bit of the first register, it can then correspondingly process the instruction according to the determination result, thereby improving the efficiency of instruction processing.
在一个可能的示例中,所述目标load指令的指令数据还包括地址数据,所述地址数据包括获取所述目标数据的第一地址数据和回写所述目标数据的第二地址数据;上述方法可包括如下步骤:根据所述第一地址数据,确定第一地址;从所述第一地址对应的存储空间获取所述目标数据;根据所述第二地址数据,确定第二地址;将所述目标数据存入所述第二地址对应的存储空间。In one possible example, the instruction data of the target load instruction also includes address data, and the address data includes first address data for obtaining the target data and second address data for writing back the target data; the above method may include the following steps: determining a first address based on the first address data; obtaining the target data from a storage space corresponding to the first address; determining a second address based on the second address data; and storing the target data in a storage space corresponding to the second address.
示例性地,电子设备对目标load指令进行指令译码操作后,所得到的目标load指令的指令数据除用于指示指令类型为load类型的类型标识数据外,还包括用于地址数据。其中,地址数据包括获取目标数据的第一地址数据和回写目标数据的第二地址数据。Exemplarily, after the electronic device performs instruction decoding operation on the target load instruction, the instruction data of the target load instruction obtained includes address data in addition to type identification data indicating that the instruction type is load type, wherein the address data includes first address data for acquiring target data and second address data for writing back target data.
示例性地,以目标load指令为(load,a0,a5)为例,解析后的指令数据包括用于指示指令类型为load类型指令的类型标识数据load,以及地址数据a0和a5,其中,第一地址数据为a5,用于指示获取目标数据对应的寄存器地址;第二地址数据为a0,用于指示将目标数据回写的寄存器地址。Exemplarily, taking the target load instruction (load, a0, a5) as an example, the parsed instruction data includes type identification data load used to indicate that the instruction type is a load type instruction, and address data a0 and a5, wherein the first address data is a5, which is used to indicate the register address corresponding to the target data; the second address data is a0, which is used to indicate the register address to which the target data is written back.
进一步地,若电子设备确定目标load指令为第二load指令时,即常规load指令时。电子设备根据第一地址数据,确定出获取目标数据的第一地址,并访问第一地址对应的存储空间获取目标数据;根据第二地址数据,确定回写目标数据的第二地址,并将目标数据回写至第二地址对应的存储空间。Furthermore, if the electronic device determines that the target load instruction is a second load instruction, that is, a regular load instruction, the electronic device determines a first address for obtaining the target data according to the first address data, and accesses the storage space corresponding to the first address to obtain the target data; determines a second address for writing back the target data according to the second address data, and writes the target data back to the storage space corresponding to the second address.
可见,本示例中,若当前目标load指令为第二load指令时,电子设备可直接根据第二load指令对应的指令数据,确定执行第二load指令时所需要访问的第一地址,并在第一地址对应的存储空间中获取目标数据,以及确定存储目标数据所对应的第二地址,并将目标数据存入第二地址对应的存储空间。如此,可以实现第一load指令和第二load指令分别对应各自的处理流程以及逻辑算数部件,实现指令的个性化处理,提高指令的处理效率。It can be seen that in this example, if the current target load instruction is the second load instruction, the electronic device can directly determine the first address that needs to be accessed when executing the second load instruction based on the instruction data corresponding to the second load instruction, and obtain the target data in the storage space corresponding to the first address, and determine the second address corresponding to the target data, and store the target data in the storage space corresponding to the second address. In this way, the first load instruction and the second load instruction can correspond to their respective processing flows and logical arithmetic components, realize personalized processing of instructions, and improve the processing efficiency of instructions.
在一个可能的示例中,所述根据所述迭代计算位和所述初始目的地址确定最终目的地址,上述方法可包括如下步骤:根据所述迭代计算位,确定所述第一load指令的迭代总数;根据所述目的地址偏移位和所述迭代总数,确定所述初始目的地址的位移量;根据所述初始目的地址和所述位移量确定所述最终目的地址。In one possible example, the final destination address is determined based on the iterative calculation bits and the initial destination address. The method may include the following steps: determining the total number of iterations of the first load instruction based on the iterative calculation bits; determining the displacement of the initial destination address based on the destination address offset bits and the total number of iterations; and determining the final destination address based on the initial destination address and the displacement.
示例性地,如步骤S205所述,第一寄存器中的迭代计算位占11bits,迭代计算位以二进制的形式表征当前第一load指令所需要迭代的次数。电子设备根据迭代计算位的数据,确定第一load指令所需要执行的迭代总数。Exemplarily, as described in step S205, the iteration calculation bit in the first register occupies 11 bits, and the iteration calculation bit represents the number of iterations required for the current first load instruction in binary form. The electronic device determines the total number of iterations required to execute the first load instruction based on the data of the iteration calculation bit.
进一步地,电子设备根据第一寄存器中所存储的目的地址偏移位,确定每次执行第一load指令时相对于初始目的地址的位移量。Furthermore, the electronic device determines the displacement relative to the initial destination address each time the first load instruction is executed according to the destination address offset bits stored in the first register.
进一步地,电子设备根据第一load指令中的初始目的地址、第一寄存器所确定的迭代总数以及目的地址所对应的偏移量,确定执行完第一load指令时的最终目的地址。其中,最终目的地址的计算方法为:初始目的地址+(迭代总数-1)*初始目的地址的位移量。Further, the electronic device determines the final destination address after executing the first load instruction according to the initial destination address in the first load instruction, the total number of iterations determined by the first register, and the offset corresponding to the destination address. The final destination address is calculated as follows: initial destination address + (total number of iterations - 1) * displacement of the initial destination address.
示例性地,以第一load指令为(load,a0,a5)、目的地址偏移位为011,迭代计算位为11111111。其中,a0表征初始目的地址,a5表征初始源地址,初始目的地址存放于第二寄存器中。电子设备根据迭代计算位确定当前二进制数据所对应的数值为255,即表明第一load指令需要迭代总数256次,根据目的地址偏移位确定初始目的地址的位移量为3。则执行256次第一load指令后,最终目的地址为a0+255*3。For example, the first load instruction is (load, a0, a5), the destination address offset bit is 011, and the iterative calculation bit is 11111111. Among them, a0 represents the initial destination address, a5 represents the initial source address, and the initial destination address is stored in the second register. The electronic device determines that the value corresponding to the current binary data is 255 according to the iterative calculation bit, which means that the first load instruction requires a total of 256 iterations, and the displacement of the initial destination address is determined to be 3 according to the destination address offset bit. After executing the first load instruction 256 times, the final destination address is a0+255*3.
可见,本示例中,电子设备根据迭代计算位,确定第一load指令的迭代总数,进而根据目的地址偏移位和迭代总数,确定初始目的地址的位移量;最后,根据初始目的地址和位移量确定最终目的地址。如此可以实现,电子设备在获取指令的同时,也能够确定出迭代执行完第一load指令时,该指令所对应的最终目的地址。进而可以将最终目的地址用于判断当前第一load指令是否执行完毕中。It can be seen that in this example, the electronic device determines the total number of iterations of the first load instruction based on the iterative calculation bit, and then determines the displacement of the initial destination address based on the destination address offset bit and the total number of iterations; finally, the final destination address is determined based on the initial destination address and the displacement. In this way, while obtaining the instruction, the electronic device can also determine the final destination address corresponding to the instruction when the first load instruction is iteratively executed. The final destination address can then be used to determine whether the current first load instruction has been executed.
在一个可能的示例中,所述根据所述最终目的地址判断所述第一load指令是否执行完毕之后,上述方法可包括如下步骤:若所述第一目的地址与所述最终目的地址不同,则根据所述第一源地址和所述源地址偏移位,确定第二源地址,其中,所述第二源地址由所述第一源地址位移所述源地址偏移位得到;根据所述第一目的地址和所述目的地址偏移位,确定第二目的地址,其中,所述第二目的地址由所述第一目的地址位移所述目的地址偏移位得到;根据所述第二源地址,获取第二目标数据;根据所述第二目的地址,将所述第二目标数据回写至所述第二目的地址对应的存储空间。In a possible example, after determining whether the first load instruction has been executed based on the final destination address, the method may include the following steps: if the first destination address is different from the final destination address, determining a second source address based on the first source address and the source address offset bit, wherein the second source address is obtained by shifting the first source address by the source address offset bit; determining a second destination address based on the first destination address and the destination address offset bit, wherein the second destination address is obtained by shifting the first destination address by the destination address offset bit; obtaining second target data based on the second source address; and writing the second target data back to the storage space corresponding to the second destination address based on the second destination address.
示例性地,电子设备在获取第一load指令的同时,便可根据第一寄存器和第二寄存器确定迭代执行完第一load指令时的最终目的地址。进一步地,电子设备执行一次第一load指令时,得到第一目的地址。判断第一目的地址与最终目的地址是否相同,若相同,则表明当前迭代执行结束;若不同,则在当前基础上继续执行第一load指令。Exemplarily, when the electronic device obtains the first load instruction, it can determine the final destination address after iteratively executing the first load instruction according to the first register and the second register. Further, when the electronic device executes the first load instruction once, the first destination address is obtained. It is determined whether the first destination address is the same as the final destination address. If they are the same, it indicates that the current iterative execution is completed; if they are different, the first load instruction is continued to be executed on the current basis.
进一步地,电子设备根据第一源地址和源地址偏移位对应的源地址偏移量,得到第二源地址;根据第一目的地址和目的地址偏移位所对应的目的地址偏移量,得到第二目的地址。即,每一次执行第一load指令所对应的源地址和目的地址为上一次执行的位置偏移结果。Furthermore, the electronic device obtains the second source address according to the first source address and the source address offset corresponding to the source address offset bit, and obtains the second destination address according to the first destination address and the destination address offset corresponding to the destination address offset bit. That is, the source address and destination address corresponding to each execution of the first load instruction are the position offset results of the previous execution.
进一步地,电子设备根据第二源地址获取第二目标数据,根据第二目的地址回写第二目标数据。Furthermore, the electronic device obtains the second target data according to the second source address, and writes back the second target data according to the second destination address.
需要说明的是,上述第二源地址为一个或多个源地址,用于表征每次执行第一load指令时获取目标数据对应的源地址;第二目的地址为一个或多个目的地址,用于表征每次获取目标数据后回写该目标数据所对应的目的地址。It should be noted that the above-mentioned second source address is one or more source addresses, used to represent the source address corresponding to the target data obtained each time the first load instruction is executed; the second destination address is one or more destination addresses, used to represent the destination address corresponding to the target data written back after each target data is obtained.
可见,本示例中,电子设备根据每次执行第一load指令所确定的目的地址和最终目的地址的关系确定第一load指令是否执行完毕,若未执行完毕,则可根据上一次执行结果确定本次执行的源地址和目的地址,实现第一load指令的连续执行直至执行完毕,并且每一次回写操作对应的目的地址均为上一次执行的目的地址位移固定的目的地址偏移量,实现数据的连续存储,进而保证存储空间的有效利用,节约存储空间。It can be seen that in this example, the electronic device determines whether the first load instruction has been executed based on the relationship between the destination address determined by each execution of the first load instruction and the final destination address. If it has not been executed, the source address and destination address of this execution can be determined according to the result of the previous execution, so as to realize the continuous execution of the first load instruction until the execution is completed, and the destination address corresponding to each write-back operation is the destination address of the previous execution shifted by a fixed destination address offset, so as to realize continuous storage of data, thereby ensuring the effective use of storage space and saving storage space.
在一个可能的示例中,本申请方法可包括如下步骤:确定所述第一load指令当前次执行的迭代次数,其中,所述迭代次数小于或等于所述迭代总数;若所述迭代次数小于所述迭代总数,则根据所述指令数据、所述迭代次数、所述第一寄存器对应的源地址偏移位和所述目的地址偏移位,确定第三源地址和第三目的地址。In a possible example, the method of the present application may include the following steps: determining the number of iterations of the current execution of the first load instruction, wherein the number of iterations is less than or equal to the total number of iterations; if the number of iterations is less than the total number of iterations, determining a third source address and a third destination address based on the instruction data, the number of iterations, the source address offset bits corresponding to the first register, and the destination address offset bits.
示例性地,电子设备在每次执行第一load指令过程中,需要判断当前是否执行完毕,若未执行完毕,则需要一直迭代执行下去。若电子设备需随机确定当前次执行所对应的第三源地址和第三目的地址。只需确定当前次第一load指令执行的迭代次数。For example, during each execution of the first load instruction, the electronic device needs to determine whether the current execution is completed. If the execution is not completed, it needs to be iteratively executed. If the electronic device needs to randomly determine the third source address and the third destination address corresponding to the current execution, it only needs to determine the number of iterations of the current first load instruction execution.
示例性地,若当前迭代次数小于迭代总数,则根据迭代次数、源地址偏移位和目的地址偏移位结合第一load指令的指令数据,确定当前次执行第一load指令所对应的第三源地址和第三目的地址。具体地计算方法,请参阅步骤S202所述内容,在此不做赘述。其中,第三源地址和第三目的地址为某一次迭代执行第一load指令时所对应的源地址和目的地址。Exemplarily, if the current number of iterations is less than the total number of iterations, the third source address and the third destination address corresponding to the current execution of the first load instruction are determined according to the number of iterations, the source address offset bit and the destination address offset bit combined with the instruction data of the first load instruction. For the specific calculation method, please refer to the content described in step S202, which will not be repeated here. Among them, the third source address and the third destination address are the source address and the destination address corresponding to the execution of the first load instruction in a certain iteration.
可见,本示例中,电子设备可通过确定第一load指令当前次执行的迭代次数;若迭代次数小于迭代总数,则根据指令数据、迭代次数、第一寄存器对应的源地址偏移位和目的地址偏移位,确定第三源地址和第三目的地址。如此能够实现,电子设备可随机确定当前次执行第一load指令时,加载目标数据所对应的源地址和目的地址而不必完全依赖于上一次执行的结果,造成指令执行的等待现象,进而提高指令处理和数据加载的效率。It can be seen that in this example, the electronic device can determine the number of iterations of the current execution of the first load instruction; if the number of iterations is less than the total number of iterations, the third source address and the third destination address are determined according to the instruction data, the number of iterations, the source address offset bit and the destination address offset bit corresponding to the first register. In this way, the electronic device can randomly determine the source address and the destination address corresponding to the target data when the first load instruction is executed for the current time without having to completely rely on the result of the previous execution, resulting in a waiting phenomenon for instruction execution, thereby improving the efficiency of instruction processing and data loading.
请参阅图4A,图4A是本申请实施例提供的一种指令处理优化方法的整体流程示意图,应用于电子设备,所述电子设备包括第一寄存器和第二寄存器,所述第一寄存器用于确定获取目标数据的源地址,所述第二寄存器用于确定存储所述目标数据的目的地址,所述第一寄存器包括偏移位和迭代计算位;本指令处理优化方法包括以下操作。Please refer to Figure 4A, which is a schematic diagram of the overall flow of an instruction processing optimization method provided in an embodiment of the present application, which is applied to an electronic device, wherein the electronic device includes a first register and a second register, the first register is used to determine a source address for obtaining target data, and the second register is used to determine a destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit; the instruction processing optimization method includes the following operations.
S401、电子设备从指令缓冲单元中取指。S401, the electronic device fetches instructions from an instruction buffer unit.
S402、电子设备对所取出的指令进行译指。S402: The electronic device translates the retrieved instruction.
S403、电子设备判断当前指令是否为load指令,若否,则电子设备根据该条指令执行步骤S410-S412。S403: The electronic device determines whether the current instruction is a load instruction. If not, the electronic device executes steps S410-S412 according to the instruction.
S404、若是,则电子设备根据第一寄存器判断load指令是否为第一load指令。S404: If yes, the electronic device determines whether the load instruction is the first load instruction according to the first register.
S405、若是第一load指令,则电子设备通过逻辑算数部件,根据第一寄存器,计算第一load指令的源地址。S405: If it is the first load instruction, the electronic device calculates the source address of the first load instruction according to the first register through the logical arithmetic component.
S406、电子设备根据程序计数器判断当前剩余迭代次数是否为0,若否,则对当前次执行第一load指令所确定的源地址执行访存操作,获取目标数据后,返回到步骤S405,根据第一寄存器计算下一次执行第一load指令的源地址。S406. The electronic device determines whether the current remaining number of iterations is 0 according to the program counter. If not, it performs a memory access operation on the source address determined by the current execution of the first load instruction. After obtaining the target data, it returns to step S405 and calculates the source address of the next execution of the first load instruction according to the first register.
S407、若是,则对当前次执行确定的源地址执行访存操作,获取目标数据。S407: If yes, perform a memory access operation on the source address determined by the current execution to obtain the target data.
S408、电子设备根据第一寄存器和第二寄存器,确定每次执行第一load指令时所对应的目的地址。S408: The electronic device determines, according to the first register and the second register, a destination address corresponding to each execution of the first load instruction.
S409、电子设备根据每次所确定的目的地址,将目标数据回写至目的地址对应的存储空间。S409: The electronic device writes the target data back to the storage space corresponding to the destination address according to the destination address determined each time.
S410、若电子设备确定当前指令为第二load指令或为其他类型的指令时,执行当前指令,获得指令对应的源地址。S410: If the electronic device determines that the current instruction is the second load instruction or another type of instruction, the current instruction is executed to obtain a source address corresponding to the instruction.
S411、电子设备根据步骤S410获取的源地址,进行访存,获取该源地址所对应的存储空间的数据。S411. The electronic device accesses memory according to the source address obtained in step S410 to obtain data in the storage space corresponding to the source address.
S412、电子设备回写所获取的数据至目的地址。S412: The electronic device writes back the acquired data to the destination address.
需要说明的是,上述步骤S401-S409的具体描述可参照图2所述的指令处理优化方法的步骤S201-S206对应的步骤,步骤S410-S412为若电子设备确定目标load指令为第二load指令时所对应的处理步骤,在此不做赘述。It should be noted that the specific description of the above steps S401-S409 can refer to the steps corresponding to steps S201-S206 of the instruction processing optimization method described in Figure 2. Steps S410-S412 are the corresponding processing steps when the electronic device determines that the target load instruction is the second load instruction, which will not be repeated here.
可以看出,本申请实施例所描述的指令处理优化方法,电子设备包括第一寄存器和第二寄存器。其中,电子设备包括第一寄存器和第二寄存器,第一寄存器用于确定获取目标数据的源地址,第二寄存器用于确定存储目标数据的目的地址,第一寄存器包括偏移位和迭代计算位;确定目标加载load指令,其中,目标load指令包括以下任意一种:第一load指令和第二load指令,偏移位包括源地址偏移位和目的地址偏移位;若目标load指令为第一load指令,则根据源地址偏移位和第一load指令,确定第一源地址,并根据第二寄存器中的初始目的地址和目的地址偏移位,确定第一目的地址;根据第一源地址,获取第一目标数据;根据第一目的地址,将第一目标数据回写至第一目的地址对应的存储空间;根据迭代计算位和初始目的地址确定最终目的地址,并根据最终目的地址判断第一load指令是否执行完毕;若最终目的地址与第一目的地址相同,则确定第一load指令执行完毕;若目标load指令为第二load指令,则按照常规load指令处理流程,执行指令、访存和数据回写操作。如此,可以通过对第一load指令的并行处理,实现批量数据处理,为CPU执行数据处理提供更高的数据吞吐率。另外,电子设备既能通过自定义的第一寄存器和第二寄存器以及逻辑算数部件,实现对第一load指令的流水线处理,同时还保留了原本针对常规load指令,即第二load指令的工作处理流程。如此能够实现最大化的利用电子设备的CPU内部的存储空间,减少了资源的浪费,使得能效比得到大量优化。It can be seen that the instruction processing optimization method described in the embodiment of the present application, the electronic device includes a first register and a second register. Wherein, the electronic device includes a first register and a second register, the first register is used to determine the source address for obtaining the target data, the second register is used to determine the destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit; determine the target load instruction, wherein the target load instruction includes any of the following: a first load instruction and a second load instruction, the offset bit includes a source address offset bit and a destination address offset bit; if the target load instruction is the first load instruction, then according to the source address offset bit and the first load instruction, determine the first source address, and according to the initial destination address and the destination address offset bit in the second register, determine the first destination address; according to the first source address, obtain the first target data; according to the first destination address, write the first target data back to the storage space corresponding to the first destination address; determine the final destination address according to the iterative calculation bit and the initial destination address, and judge whether the first load instruction is executed according to the final destination address; if the final destination address is the same as the first destination address, determine that the first load instruction is executed; if the target load instruction is the second load instruction, execute the instruction, memory access and data write-back operations according to the conventional load instruction processing flow. In this way, batch data processing can be achieved through parallel processing of the first load instruction, providing a higher data throughput rate for the CPU to perform data processing. In addition, the electronic device can not only implement pipeline processing of the first load instruction through the customized first register and second register and the logical arithmetic component, but also retain the original work processing flow for the conventional load instruction, that is, the second load instruction. In this way, the internal storage space of the CPU of the electronic device can be maximized, the waste of resources can be reduced, and the energy efficiency ratio can be greatly optimized.
为更好地理解上述步骤S201-S206以及步骤S401-S409中所述的电子设备针对第一load指令的处理过程。下面将结合图4B进一步描述,图4B是本申请实施例提供的一种电子设备处理第一load指令的过程示意图。具体地,如图4B所示:To better understand the processing of the electronic device for the first load instruction in the above steps S201-S206 and steps S401-S409, the following will be further described in conjunction with FIG. 4B, which is a schematic diagram of a process of an electronic device processing the first load instruction provided by an embodiment of the present application. Specifically, as shown in FIG. 4B:
具体地,电子设备从指令缓冲单元中进行取指操作后,对该指令进行译指操作,得到指令数据;进一步地,根据指令数据确定当前指令的类型为load指令类型;进一步地,结合第一寄存器确定该指令为第一load指令。即图4B所对应的取指和译指阶段。Specifically, after the electronic device performs an instruction fetch operation from the instruction buffer unit, it performs an instruction translation operation on the instruction to obtain instruction data; further, according to the instruction data, it determines that the type of the current instruction is a load instruction type; further, in combination with the first register, it determines that the instruction is the first load instruction, that is, the instruction fetch and translation stage corresponding to FIG4B.
进一步地,电子设备根据第二寄存器确定当前第一load指令的迭代总数,然后,根据第一load指令、第一寄存器以及第二寄存器,每执行一次第一load指令,确定该次执行所对应的源地址和目的地址。即,图4B所对应的执行阶段。Further, the electronic device determines the total number of iterations of the current first load instruction according to the second register, and then, according to the first load instruction, the first register and the second register, determines the source address and the destination address corresponding to each execution of the first load instruction, that is, the execution stage corresponding to FIG4B .
进一步地,电子设备从源地址对应的存储空间中获取目标数据,即图4B所示的访存阶段。Furthermore, the electronic device obtains the target data from the storage space corresponding to the source address, which is the memory access phase shown in FIG. 4B .
进一步地,电子设备将目标数据回写至当前次执行所确定的目的地址所对应的存储空间中。即图4B所示的回写阶段。Furthermore, the electronic device writes the target data back to the storage space corresponding to the destination address determined by the current execution, which is the write-back stage shown in FIG4B .
需要说明的是,电子设备在确定当前指令为第一load指令后,根据第一寄存器能够确定每次执行第一load指令时,源地址和目的地址的偏移位;根据第二寄存器能够确定第一load指令需要进行的迭代总数。因此,电子设备只需在第一次取指操作,得到第一load指令后,无需反复从指令缓冲单元中获取第一load指令。并且,源地址和目的地址的确定只需根据第一load寄存器和第二load寄存器以及第一load指令的指令数据计算,即可分别确定每次指令执行时所需要访存的源地址以及回写目标数据的目的地址。如此,每次执行第一load指令不需要等待上一次指令执行到回写阶段才开始,这样能极大减少迭代执行指令的时间代价,同时一条第一load指令(即流水线load指令)相当于重复执行n次第二load指令(即常规load指令),即一条第一load指令可以执行n次数据加载操作,极大地简化上位机代码,从而减少芯片上的代码资源空间,降低电子设备的整体功耗,极大节省程序代码,提高指令处理的效率。It should be noted that after the electronic device determines that the current instruction is the first load instruction, the offset bits of the source address and the destination address can be determined according to the first register each time the first load instruction is executed; and the total number of iterations required for the first load instruction can be determined according to the second register. Therefore, the electronic device only needs to obtain the first load instruction in the first instruction fetch operation, and does not need to repeatedly obtain the first load instruction from the instruction buffer unit. In addition, the determination of the source address and the destination address only needs to be calculated according to the first load register and the second load register and the instruction data of the first load instruction, so as to respectively determine the source address required to access the memory and the destination address of the target data to be written back each time the instruction is executed. In this way, each execution of the first load instruction does not need to wait for the previous instruction to be executed to the write-back stage before starting, which can greatly reduce the time cost of iterative execution of instructions. At the same time, a first load instruction (i.e., a pipeline load instruction) is equivalent to repeatedly executing the second load instruction (i.e., a conventional load instruction) n times, that is, a first load instruction can execute n data loading operations, which greatly simplifies the host computer code, thereby reducing the code resource space on the chip, reducing the overall power consumption of the electronic device, greatly saving program code, and improving the efficiency of instruction processing.
请参阅图5,图5是本申请实施例提供的一种电子设备的结构示意图,如图5所示,该电子设备包括处理器、存储器、通信接口以及一个或多个程序,所述一个或多个程序被存储在所述存储器中,并且被配置由所述处理器执行。Please refer to Figure 5, which is a structural diagram of an electronic device provided in an embodiment of the present application. As shown in Figure 5, the electronic device includes a processor, a memory, a communication interface, and one or more programs, and the one or more programs are stored in the memory and configured to be executed by the processor.
可选地,应用于本申请方案的电子设备时,所述电子设备包括第一寄存器和第二寄存器,所述第一寄存器用于确定获取目标数据的源地址,所述第二寄存器用于确定存储所述目标数据的目的地址,所述第一寄存器包括偏移位和迭代计算位;确定目标加载load指令,其中,所述目标load指令包括以下任意一种:第一load指令和第二load指令,所述偏移位包括源地址偏移位和目的地址偏移位;Optionally, when applied to an electronic device of the solution of the present application, the electronic device includes a first register and a second register, the first register is used to determine a source address for acquiring target data, the second register is used to determine a destination address for storing the target data, and the first register includes an offset bit and an iterative calculation bit; determine a target load instruction, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit;
若所述目标load指令为所述第一load指令,则根据所述源地址偏移位和所述第一load指令,确定第一源地址,并根据所述第二寄存器中的初始目的地址和所述目的地址偏移位,确定第一目的地址;If the target load instruction is the first load instruction, determining a first source address according to the source address offset and the first load instruction, and determining a first destination address according to the initial destination address in the second register and the destination address offset;
根据所述第一源地址,获取第一目标数据;According to the first source address, obtaining first target data;
根据所述第一目的地址,将所述第一目标数据回写至所述第一目的地址对应的存储空间;According to the first destination address, writing the first target data back to the storage space corresponding to the first destination address;
根据所述迭代计算位和所述初始目的地址确定最终目的地址,并根据所述最终目的地址判断所述第一load指令是否执行完毕;Determine a final destination address according to the iterative calculation bit and the initial destination address, and determine whether the first load instruction has been executed according to the final destination address;
若所述最终目的地址与所述第一目的地址相同,则确定所述第一load指令执行完毕。If the final destination address is the same as the first destination address, it is determined that the first load instruction has been executed.
可以看出,本申请实施例中所描述的电子设备,电子设备包括第一寄存器和第二寄存器。其中,电子设备包括第一寄存器和第二寄存器,第一寄存器用于确定获取目标数据的源地址,第二寄存器用于确定存储目标数据的目的地址,第一寄存器包括偏移位和迭代计算位;确定目标加载load指令,其中,目标load指令包括以下任意一种:第一load指令和第二load指令,偏移位包括源地址偏移位和目的地址偏移位;若目标load指令为第一load指令,则根据源地址偏移位和第一load指令,确定第一源地址,并根据第二寄存器中的初始目的地址和目的地址偏移位,确定第一目的地址;根据第一源地址,获取第一目标数据;根据第一目的地址,将第一目标数据回写至第一目的地址对应的存储空间;根据迭代计算位和初始目的地址确定最终目的地址,并根据最终目的地址判断第一load指令是否执行完毕;若最终目的地址与第一目的地址相同,则确定第一load指令执行完毕。如此,可以通过指令的并行处理,实现批量数据处理,为CPU执行数据处理提供更高的数据吞吐率。It can be seen that the electronic device described in the embodiment of the present application includes a first register and a second register. Among them, the electronic device includes a first register and a second register, the first register is used to determine the source address of the target data, the second register is used to determine the destination address of the target data, and the first register includes an offset bit and an iterative calculation bit; determine the target load load instruction, wherein the target load instruction includes any of the following: a first load instruction and a second load instruction, the offset bit includes a source address offset bit and a destination address offset bit; if the target load instruction is the first load instruction, then according to the source address offset bit and the first load instruction, determine the first source address, and according to the initial destination address and the destination address offset bit in the second register, determine the first destination address; according to the first source address, obtain the first target data; according to the first destination address, write the first target data back to the storage space corresponding to the first destination address; determine the final destination address according to the iterative calculation bit and the initial destination address, and judge whether the first load instruction is executed according to the final destination address; if the final destination address is the same as the first destination address, determine that the first load instruction is executed. In this way, batch data processing can be achieved through parallel processing of instructions, providing a higher data throughput rate for CPU to perform data processing.
在一个可能的示例中,所述确定目标加载load指令之前,上述程序包括用于执行以下步骤的指令:In a possible example, before determining the target load instruction, the program includes instructions for executing the following steps:
获取指令,并对所述指令进行译码,得到指令数据,其中,所述指令数据包括所述指令的类型标识数据;Obtaining an instruction and decoding the instruction to obtain instruction data, wherein the instruction data includes type identification data of the instruction;
根据所述类型标识数据,判断所述指令的类型;Determining the type of the instruction according to the type identification data;
若所述指令的类型为load指令类型,则将所述指令确定为所述目标load指令。If the type of the instruction is a load instruction type, the instruction is determined to be the target load instruction.
在一个可能的示例中,所述第一寄存器还包括类型标志位;所述确定目标加载load指令,上述程序包括用于执行以下步骤的指令:In a possible example, the first register further includes a type flag bit; the target is determined to load a load instruction, and the program includes instructions for executing the following steps:
若所述类型标识位为1,则确定所述目标load指令为所述第一load指令;If the type identification bit is 1, determining that the target load instruction is the first load instruction;
若所述类型标识位为0,则确定所述目标load指令为所述第二load指令。If the type identification bit is 0, it is determined that the target load instruction is the second load instruction.
在一个可能的示例中,所述目标load指令的指令数据还包括地址数据,所述地址数据包括获取所述目标数据的第一地址数据和回写所述目标数据的第二地址数据;上述程序包括用于执行以下步骤的指令:In a possible example, the instruction data of the target load instruction further includes address data, and the address data includes first address data for acquiring the target data and second address data for writing back the target data; the above program includes instructions for executing the following steps:
根据所述第一地址数据,确定第一地址;Determine a first address according to the first address data;
从所述第一地址对应的存储空间获取所述目标数据;Acquire the target data from the storage space corresponding to the first address;
根据所述第二地址数据,确定第二地址;determining a second address according to the second address data;
将所述目标数据存入所述第二地址对应的存储空间。The target data is stored in the storage space corresponding to the second address.
在一个可能的示例中,所述根据所述迭代计算位和所述初始目的地址确定最终目的地址,上述程序包括用于执行以下步骤的指令:In a possible example, the determining the final destination address according to the iterative calculation bit and the initial destination address, the program includes instructions for performing the following steps:
根据所述迭代计算位,确定所述第一load指令的迭代总数;Determining a total number of iterations of the first load instruction according to the iteration count bit;
根据所述目的地址偏移位和所述迭代总数,确定所述初始目的地址的位移量;Determining the displacement of the initial destination address according to the destination address offset and the total number of iterations;
根据所述初始目的地址和所述位移量确定所述最终目的地址。The final destination address is determined according to the initial destination address and the displacement.
在一个可能的示例中,所述根据所述最终目的地址判断所述第一load指令是否执行完毕之后,上述程序包括用于执行以下步骤的指令:In a possible example, after determining whether the first load instruction has been executed according to the final destination address, the program includes instructions for executing the following steps:
若所述第一目的地址与所述最终目的地址不同,则根据所述第一源地址和所述源地址偏移位,确定第二源地址,其中,所述第二源地址由所述第一源地址位移所述源地址偏移位得到;If the first destination address is different from the final destination address, determining a second source address according to the first source address and the source address offset, wherein the second source address is obtained by shifting the first source address by the source address offset;
根据所述第一目的地址和所述目的地址偏移位,确定第二目的地址,其中,所述第二目的地址由所述第一目的地址位移所述目的地址偏移位得到;Determine a second destination address according to the first destination address and the destination address offset bit, wherein the second destination address is obtained by shifting the first destination address by the destination address offset bit;
根据所述第二源地址,获取第二目标数据;According to the second source address, obtaining second target data;
根据所述第二目的地址,将所述第二目标数据回写至所述第二目的地址对应的存储空间。According to the second destination address, the second target data is written back to the storage space corresponding to the second destination address.
在一个可能的示例中,上述程序包括用于执行以下步骤的指令:In one possible example, the above program includes instructions for executing the following steps:
确定所述第一load指令当前次执行的迭代次数,其中,所述迭代次数小于或等于所述迭代总数;Determine the number of iterations of the current execution of the first load instruction, wherein the number of iterations is less than or equal to the total number of iterations;
若所述迭代次数小于所述迭代总数,则根据所述指令数据、所述迭代次数、所述第一寄存器对应的源地址偏移位和所述目的地址偏移位,确定第三源地址和第三目的地址。If the number of iterations is less than the total number of iterations, a third source address and a third destination address are determined according to the instruction data, the number of iterations, the source address offset bits corresponding to the first register, and the destination address offset bits.
上述主要从方法侧执行过程的角度对本申请实施例的方案进行了介绍。可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所提供的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and/or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiment provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware 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 present application.
本申请实施例可以根据上述方法示例对电子设备进行功能单元的划分,例如,可以对应各个功能划分各个功能单元,也可以将两个或两个以上的功能集成在一个处理单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。需要说明的是,本申请实施例中对单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present application can divide the functional units of the electronic device according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
在采用对应各个功能划分各个功能模块的情况下,图6示出了指令处理优化装置的示意图,如图6所示,所述应用于电子设备,所述装置该指令处理优化装置600可以包括:确定单元601、获取单元602、执行单元603和判断单元604;其中,In the case of dividing each functional module according to each function, FIG6 shows a schematic diagram of an instruction processing optimization device. As shown in FIG6, the instruction processing optimization device 600 applied to an electronic device may include: a determination unit 601, an acquisition unit 602, an execution unit 603 and a judgment unit 604; wherein,
所述确定单元601,用于确定目标加载load指令,其中,所述目标load指令包括以下任意一种:第一load指令和第二load指令,所述偏移位包括源地址偏移位和目的地址偏移位;以及用于,若所述目标load指令为所述第一load指令,则根据所述源地址偏移位和所述第一load指令,确定第一源地址,并根据所述第二寄存器中的初始目的地址和所述目的地址偏移位,确定第一目的地址;The determining unit 601 is configured to determine a target load instruction, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit; and is configured to, if the target load instruction is the first load instruction, determine a first source address according to the source address offset bit and the first load instruction, and determine a first destination address according to an initial destination address in the second register and the destination address offset bit;
所述获取单元602,用于根据所述第一源地址,获取第一目标数据;The acquisition unit 602 is used to acquire first target data according to the first source address;
所述执行单元603,用于根据所述第一目的地址,将所述第一目标数据回写至所述第一目的地址对应的存储空间;The execution unit 603 is used to write the first target data back to the storage space corresponding to the first destination address according to the first destination address;
所述判断单元604,用于根据所述迭代计算位和所述初始目的地址确定最终目的地址,并根据所述最终目的地址判断所述第一load指令是否执行完毕;以及用于,若所述最终目的地址与所述第一目的地址相同,则确定所述第一load指令执行完毕。The judgment unit 604 is used to determine the final destination address according to the iterative calculation bit and the initial destination address, and to judge whether the first load instruction has been executed according to the final destination address; and to determine that the first load instruction has been executed if the final destination address is the same as the first destination address.
可以看出,本申请实施例所描述的指令处理优化装置,通过电子设备的确定单元确定目标加载load指令,其中,目标load指令包括以下任意一种:第一load指令和第二load指令,偏移位包括源地址偏移位和目的地址偏移位;以及,若目标load指令为第一load指令,则确定单元根据源地址偏移位和第一load指令,确定第一源地址,并根据第二寄存器中的初始目的地址和目的地址偏移位,确定第一目的地址;获取单元根据第一源地址,获取第一目标数据;执行单元根据第一目的地址,将第一目标数据回写至第一目的地址对应的存储空间;判断单元根据迭代计算位和初始目的地址确定最终目的地址,并根据最终目的地址判断第一load指令是否执行完毕;若最终目的地址与第一目的地址相同,则确定第一load指令执行完毕。如此,可以通过指令的并行处理,实现批量数据处理,为CPU执行数据处理提供更高的数据吞吐率。It can be seen that the instruction processing optimization device described in the embodiment of the present application determines the target load instruction through the determination unit of the electronic device, wherein the target load instruction includes any one of the following: a first load instruction and a second load instruction, and the offset bit includes a source address offset bit and a destination address offset bit; and, if the target load instruction is the first load instruction, the determination unit determines the first source address according to the source address offset bit and the first load instruction, and determines the first destination address according to the initial destination address and the destination address offset bit in the second register; the acquisition unit acquires the first target data according to the first source address; the execution unit writes the first target data back to the storage space corresponding to the first destination address according to the first destination address; the judgment unit determines the final destination address according to the iterative calculation bit and the initial destination address, and judges whether the first load instruction is executed according to the final destination address; if the final destination address is the same as the first destination address, it is determined that the first load instruction is executed. In this way, batch data processing can be achieved through parallel processing of instructions, providing a higher data throughput rate for CPU to perform data processing.
在一个可能的示例中,所述确定目标加载load指令之前,上述确定单元601具体用于:In a possible example, before determining the target load instruction, the determining unit 601 is specifically used to:
获取指令,并对所述指令进行译码,得到指令数据,其中,所述指令数据包括所述指令的类型标识数据;Obtaining an instruction and decoding the instruction to obtain instruction data, wherein the instruction data includes type identification data of the instruction;
根据所述类型标识数据,判断所述指令的类型;Determining the type of the instruction according to the type identification data;
若所述指令的类型为load指令类型,则将所述指令确定为所述目标load指令。If the type of the instruction is a load instruction type, the instruction is determined to be the target load instruction.
在一个可能的示例中,所述第一寄存器还包括类型标志位;所述确定目标加载load指令,上述确定单元601具体用于:In a possible example, the first register further includes a type flag bit; and the determining unit 601 is specifically configured to:
若所述类型标识位为1,则确定所述目标load指令为所述第一load指令;If the type identification bit is 1, determining that the target load instruction is the first load instruction;
若所述类型标识位为0,则确定所述目标load指令为所述第二load指令。If the type identification bit is 0, it is determined that the target load instruction is the second load instruction.
在一个可能的示例中,所述目标load指令的指令数据还包括地址数据,所述地址数据包括获取所述目标数据的第一地址数据和回写所述目标数据的第二地址数据;上述获取单元602和执行单元603具体用于:In a possible example, the instruction data of the target load instruction further includes address data, and the address data includes first address data for acquiring the target data and second address data for writing back the target data; the acquisition unit 602 and the execution unit 603 are specifically used for:
根据所述第一地址数据,确定第一地址;Determine a first address according to the first address data;
从所述第一地址对应的存储空间获取所述目标数据;Acquire the target data from the storage space corresponding to the first address;
根据所述第二地址数据,确定第二地址;determining a second address according to the second address data;
将所述目标数据存入所述第二地址对应的存储空间。The target data is stored in the storage space corresponding to the second address.
在一个可能的示例中,所述根据所述迭代计算位和所述初始目的地址确定最终目的地址,上述执行单元603具体用于:In a possible example, the determining the final destination address according to the iterative calculation bit and the initial destination address, the execution unit 603 is specifically configured to:
根据所述迭代计算位,确定所述第一load指令的迭代总数;Determining a total number of iterations of the first load instruction according to the iteration count bit;
根据所述目的地址偏移位和所述迭代总数,确定所述初始目的地址的位移量;Determining the displacement of the initial destination address according to the destination address offset and the total number of iterations;
根据所述初始目的地址和所述位移量确定所述最终目的地址。The final destination address is determined according to the initial destination address and the displacement.
在一个可能的示例中,所述根据所述最终目的地址判断所述第一load指令是否执行完毕之后,上述执行单元603具体用于:In a possible example, after determining whether the first load instruction is executed according to the final destination address, the execution unit 603 is specifically configured to:
若所述第一目的地址与所述最终目的地址不同,则根据所述第一源地址和所述源地址偏移位,确定第二源地址,其中,所述第二源地址由所述第一源地址位移所述源地址偏移位得到;If the first destination address is different from the final destination address, determining a second source address according to the first source address and the source address offset, wherein the second source address is obtained by shifting the first source address by the source address offset;
根据所述第一目的地址和所述目的地址偏移位,确定第二目的地址,其中,所述第二目的地址由所述第一目的地址位移所述目的地址偏移位得到;Determine a second destination address according to the first destination address and the destination address offset bit, wherein the second destination address is obtained by shifting the first destination address by the destination address offset bit;
根据所述第二源地址,获取第二目标数据;According to the second source address, obtaining second target data;
根据所述第二目的地址,将所述第二目标数据回写至所述第二目的地址对应的存储空间。According to the second destination address, the second target data is written back to the storage space corresponding to the second destination address.
在一个可能的示例中,上述执行单元603具体用于:In a possible example, the execution unit 603 is specifically used to:
确定所述第一load指令当前次执行的迭代次数,其中,所述迭代次数小于或等于所述迭代总数;Determine the number of iterations of the current execution of the first load instruction, wherein the number of iterations is less than or equal to the total number of iterations;
若所述迭代次数小于所述迭代总数,则根据所述迭代次数、所述第一寄存器对应的源地址偏移位和所述目的地址偏移位,确定第三源地址和第三目的地址。If the number of iterations is less than the total number of iterations, a third source address and a third destination address are determined according to the number of iterations, the source address offset bit corresponding to the first register, and the destination address offset bit.
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
本实施例提供的电子设备,用于执行上述指令处理优化方法,因此可以达到与上述实现方法相同的效果。The electronic device provided in this embodiment is used to execute the above instruction processing optimization method, and thus can achieve the same effect as the above implementation method.
在采用集成的单元的情况下,电子设备可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对电子设备的动作进行控制管理,例如,可以用于支持电子设备执行上述确定单元601、获取单元602、执行单元603和判断单元604执行的步骤。存储模块可以用于支持电子设备执行存储程序代码和数据等。通信模块,可以用于支持电子设备与电子设备的通信。In the case of using integrated units, the electronic device may include a processing module, a storage module and a communication module. Among them, the processing module can be used to control and manage the actions of the electronic device, for example, it can be used to support the electronic device to execute the steps performed by the above-mentioned determination unit 601, acquisition unit 602, execution unit 603 and judgment unit 604. The storage module can be used to support the electronic device to execute stored program codes and data, etc. The communication module can be used to support the communication between electronic devices.
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digitalsignalprocessing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他电子设备交互的设备。Among them, the processing module can be a processor or a controller. It can implement or execute various exemplary logic boxes, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, etc.
本申请实施例还提供一种计算机存储介质,其中,该计算机存储介质存储用于电子数据交换的计算机程序,该计算机程序使得计算机执行如上述方法实施例中记载的任一方法的部分或全部步骤,上述计算机包括电子设备。An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method recorded in the above method embodiments, and the above computer includes an electronic device.
本申请实施例还提供一种计算机程序装置,上述计算机程序装置包括存储了计算机程序的非瞬时性计算机可读存储介质,上述计算机程序可操作来使计算机执行如上述方法实施例中记载的任一方法的部分或全部步骤。该计算机程序装置可以为一个软件安装包,上述计算机包括电子设备。The embodiment of the present application also provides a computer program device, the computer program device includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps of any method described in the above method embodiment. The computer program device can be a software installation package, and the computer includes an electronic device.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which 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, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described above 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.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
上述集成的单元如果以软件功能单元的形式实现并作为独立的装置销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件装置的形式体现出来,该计算机软件装置存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例上述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,RandomAccessMemory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent device, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software device, and the computer software device is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器、随机存取器、磁盘或光盘等。A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the relevant hardware through a program, and the program may be stored in a computer-readable memory, which may include: a flash drive, a read-only memory, a random access memory, a magnetic disk or an optical disk, etc.
以上对本申请实施例进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211443791.6A CN118057308A (en) | 2022-11-18 | 2022-11-18 | Instruction processing optimization method and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211443791.6A CN118057308A (en) | 2022-11-18 | 2022-11-18 | Instruction processing optimization method and related device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118057308A true CN118057308A (en) | 2024-05-21 |
Family
ID=91068463
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211443791.6A Pending CN118057308A (en) | 2022-11-18 | 2022-11-18 | Instruction processing optimization method and related device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118057308A (en) |
-
2022
- 2022-11-18 CN CN202211443791.6A patent/CN118057308A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101916180B (en) | Method and system for executing register type instruction in RISC processor | |
KR101964350B1 (en) | Multiple register memory access instructions, processors, methods, and systems | |
RU2638641C2 (en) | Partial width loading depending on regime, in processors with registers with large number of discharges, methods and systems | |
JP2018504666A (en) | Hardware apparatus and method for prefetching multidimensional blocks of elements from a multidimensional array | |
JP2008530689A (en) | Data processor and method applied to efficient digital signal processing | |
JP2018500657A (en) | Instructions and logic to perform a fused single cycle increment-compare-jump | |
US20120204008A1 (en) | Processor with a Hybrid Instruction Queue with Instruction Elaboration Between Sections | |
US9329865B2 (en) | Context control and parameter passing within microcode based instruction routines | |
RU2630745C2 (en) | Pairs of instructions establishing execution order of instructions, processors, methods and systems | |
JP5335440B2 (en) | Early conditional selection of operands | |
US20230401060A1 (en) | Processing unit, computing device and instruction processing method | |
CN112559037B (en) | Instruction execution method, unit, device and system | |
JP4073721B2 (en) | Data processing device | |
CN111814093A (en) | Multiply-accumulate instruction processing method and device | |
CN118057308A (en) | Instruction processing optimization method and related device | |
CN116339832A (en) | Data processing device, method and processor | |
US11544065B2 (en) | Bit width reconfiguration using a shadow-latch configured register file | |
CN113885943A (en) | Processing unit, system on chip, computing device and method | |
JPH04104350A (en) | Micro processor | |
JP3474384B2 (en) | Shifter circuit and microprocessor | |
US20120079248A1 (en) | Aliased Parameter Passing Between Microcode Callers and Microcode Subroutines | |
US20120079237A1 (en) | Saving Values Corresponding to Parameters Passed Between Microcode Callers and Microcode Subroutines from Microcode Alias Locations to a Destination Storage Location | |
WO2022220835A1 (en) | Shared register for vector register file and scalar register file | |
JP4382076B2 (en) | Data processing device | |
CN119396472A (en) | Branch prediction method, branch predictor and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20241112 Address after: 6th Floor, No.1 Chongqing Road, Banqiao District, Xinbei City, Taiwan, China, China Applicant after: Weiguang Co.,Ltd. Country or region after: Samoa Address before: Room 1501, 15 / F, building 2, No. 10 yard, Chaoyang Park South Road, Chaoyang District, Beijing Applicant before: Zheku Technology (Beijing) Co.,Ltd. Country or region before: China |
|
TA01 | Transfer of patent application right |