An instruction set execution method and computing device
By introducing control information and operation instructions into the instruction code and configuring the control logic of the execution unit, the problem of difficulty in shortening the instruction flow length in coarse-grained data flow calculations is solved, and the instruction code storage space is reduced and performance is improved.
Patent Information
- Application Number
- CN201980094578.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-01
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2039-04-01
AI Technical Summary
In coarse-grained data flow computing scenarios, existing technologies are difficult to effectively shorten the length of the instruction stream, resulting in increased external storage instruction code space and reduced performance. Especially when a large number of identical or similar operations are processed, a small number of instruction modifications in the loop body require many times. Implementation of a loop body increases the length and storage space of the instruction code.
By newly adding instruction codes, including control information and operation instructions, using continuous execution, paused execution, single-cycle execution and stop execution information, and configuring the control logic on the execution unit, flexible control of instruction codes can be achieved and the storage space of instruction codes can be reduced. and improve performance.
It effectively reduces the storage space of instruction codes and improves the performance of computing devices. Especially in coarse-grained data flow calculations, such as CGRA, TPU and AI computing scenarios, it reduces the length of the instruction flow and improves computing efficiency.
Smart Images

Figure CN113614690B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an instruction set execution method and a computing device. Background Art
[0002] The central processing unit (CPU) and digital signal processing (DSP) are both devices that are executed by instruction flow control. For example, when the CPU or DSP receives the instruction ADDR0, R1, R2, it uses the addition unit to perform an addition of R0 and R1, and outputs the addition result of R0 and R1 to R2. After completing this operation, the CPU or DSP parses the next instruction and continues execution.
[0003] The execution process of a computer is usually divided into several pipelines to achieve continuous execution of the CPU or DSP. It is generally divided into five basic steps: instruction fetch, decode, distribute, execute, and write back. The pipeline instructions of these five steps are used to implement the execution of continuous instruction streams. All instruction streams are fetched from the outside, then decoded, distributed, and then executed in each cycle.
[0004] For coarse-grained data flow computing scenarios, such as coarse-grained reconfigurable arrays (CGRA), tensor processing unit (TPU), artificial intelligence (AI) and other related computing scenarios, the operation mode of these scenarios is usually that a large number of data matrices need to perform a large number of identical or similar operations, with only a small amount of special processing in between, so most of the instruction streams of their operations are repeated, that is, most of the instructions for each fetch, decoding, distribution and execution are repeated, making the length of the instruction stream longer.
[0005] In order to shorten the length of the instruction stream, it is usually implemented through loop control instructions (such as jump instructions), but the instructions of each cycle must be sent to the execution unit before they can be executed. If only a small number of instructions in the loop body need to be modified, then multiple different loop bodies are required to implement it, resulting in the lengthening of the instruction code stored externally, and then the increase in the space for external storage of instruction codes. Summary of the invention
[0006] The embodiments of the present application provide an instruction set execution method and a computing device, which effectively reduces the storage space of the instruction code and improves the performance through newly added instruction codes, including control information and operation instructions, and control logic for executing the instruction code.
[0007] In a first aspect, a method for executing an instruction set is provided, the method being applied to a cyclic calculation of N cycles, the cyclic calculation being executed by an instruction code, the instruction code including control information and an operation instruction; the method comprising:
[0008] Receive an instruction code; and execute a calculation operation corresponding to the operation instruction according to the control information and the operation instruction in the instruction code; wherein the control information includes at least one of continuous execution information, pause execution information, single cycle execution information, or stop execution information.
[0009] The continuous execution information is used to indicate that the operation corresponding to the operation instruction is repeatedly executed in the loop calculation of N cycles.
[0010] The execution suspension information is used to indicate that the operation corresponding to the operation instruction is suspended in the N-cycle cyclic calculation.
[0011] The single-cycle execution information is used to indicate that the operation corresponding to the operation instruction is executed in one cycle calculation of N cycles.
[0012] The stop execution information is used to instruct to stop the operation corresponding to the operation instruction in the loop calculation in N cycles.
[0013] By adopting the execution method of the instruction set, when an instruction code is received, the operation corresponding to the operation instruction is executed according to the control information in the instruction code, which effectively reduces the storage space of the instruction code and improves the performance.
[0014] In one possible implementation, the instruction code also includes pause execution information, operation instructions and a number M, where M<N; the method also includes: when receiving an instruction code including pause instruction information, operation instructions and the number M, suspending the execution of the calculation operation corresponding to the operation instruction within M cycles after receiving the instruction code.
[0015] In a possible implementation, the method further includes: in the stop state, when receiving an instruction code including continuous execution information and an operation instruction, switching from the stop state to the running state according to the continuous execution information; or, in the stop state, when receiving an instruction code including pause information and an operation instruction, switching from the stop state to the pause state according to the continuous execution information; or, in the running state, when receiving an instruction code including stop execution information and an operation instruction, switching from the running state to the stop state according to the stop execution information; or, in the running state, when receiving an instruction code including pause execution information and an operation instruction, switching from the running state to the pause state according to the continuous execution information; or, in the pause state, when receiving an instruction code including stop execution information and an operation instruction, switching from the pause state to the stop state according to the continuous execution information; or, in the pause state, when receiving an instruction code including stop execution information and an operation instruction, switching from the pause state to the running state according to the continuous execution information; or, in the pause state, when the counter counts to 0, switching from the pause state to the running state.
[0016] In one possible implementation, the N-cycle cyclic calculation includes coarse-grained configurable matrix CGRS calculation, tensor processor TPU calculation, and artificial intelligence AI calculation.
[0017] In a second aspect, a computing device is provided, which is applied to cyclic calculation of N cycles, and the cyclic calculation is executed through instruction codes, and the instruction codes include control instruction control information and operation instructions; the computing device includes an execution unit, which is used to execute the calculation operation corresponding to the operation instruction according to the control information; wherein the control information includes at least one of continuous execution information, pause execution information, single cycle execution information or stop execution information.
[0018] The continuous execution information is used to instruct the execution unit to repeatedly execute the calculation operation corresponding to the operation instruction in the loop calculation of N cycles.
[0019] The execution suspension information is used to instruct the execution unit to suspend the calculation operation corresponding to the operation instruction in the loop calculation of N cycles.
[0020] The single-cycle execution information is used to instruct the execution unit to execute the calculation operation corresponding to the operation instruction in one cycle calculation of N cycles.
[0021] The stop execution information is used to instruct the execution unit to stop the calculation operation corresponding to the operation instruction in the loop calculation in N cycles.
[0022] By adding control information and configuring control logic corresponding to the newly added control information on the execution unit, when an instruction code is received, the operation corresponding to the operation instruction is executed according to the control information in the instruction code, which effectively reduces the storage space of the instruction code and improves the performance of the device.
[0023] In a possible implementation, the instruction code also includes execution suspension information, an operation instruction and a number M;
[0024] The instruction code is used to instruct the execution unit to suspend the operation corresponding to the operation instruction within M cycles after receiving the instruction code in the N-cycle cyclic calculation.
[0025] In one possible implementation, the execution unit includes a stop state, a pause state, and a run state;
[0026] The execution unit is also used for switching from the stop state to the running state according to the continuous execution information when the execution unit receives the instruction code including the continuous execution information and the operation instruction in the stop state.
[0027] The execution unit is also used for switching from the stop state to the pause state according to the continuous execution information when the execution unit receives the instruction code including the pause information and the operation instruction in the stop state.
[0028] The execution unit is also used for, when the execution unit is in a running state, when receiving an instruction code including stop execution information and an operation instruction, switching from the running state to the stop state according to the stop execution information.
[0029] The execution unit is also used to switch from the running state to the pause state according to the continuous execution information when the execution unit receives the instruction code including the pause execution information and the operation instruction in the running state.
[0030] The execution unit is also used to switch from the pause state to the stop state according to the continuous execution information when the execution unit receives an instruction code including stop execution information and an operation instruction in the pause state.
[0031] The execution unit is also used for switching from the pause state to the running state according to the continuous execution information when the execution unit receives the instruction code including the continuous execution information and the operation instruction in the pause state.
[0032] In a possible implementation, the computing device further includes a counter; and an execution unit, further configured to switch the execution unit from the pause state to the running state when the counter counts to 0 in the pause state.
[0033] In one possible implementation, the N-cycle cyclic calculation includes coarse-grained configurable matrix CGRS calculation, tensor processor TPU), and artificial intelligence AI calculation.
[0034] In one possible implementation, the computing device is a central processing unit CPU or a digital signal processor DSP.
[0035] Based on the execution method and computing device of the provided instruction set, by adding instruction code, the instruction code includes control information and operation instructions, and the control logic corresponding to the control information is configured on the computing device. When the computing device receives the instruction code, the operation corresponding to the operation instruction is executed according to the control information in the instruction code, which effectively reduces the storage space of the instruction code and improves the performance of the device. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a schematic diagram of the architecture of a device;
[0037] Figure 2 It is a schematic diagram of the architecture of a device provided in an embodiment of the present application;
[0038] Figure 3 It is a logical state schematic diagram provided by an embodiment of the present application;
[0039] Figure 4 is a schematic diagram of the structure of an operation matrix provided in an embodiment of the present application;
[0040] Figure 5 It is a flowchart of an execution method of an instruction set provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In CGRA data flow calculation, in order to reduce the length of the instruction stream, loop control is usually used, that is, loop control instructions (including jumps, conditional jumps, etc.) are added to implement loop execution of instruction segments, as shown in Example 1:
[0042] Example 1
[0043]
[0044] In Example 1, the instructions of each line can be called a cycle of instructions, and the instructions of each line can also be called "a beat". In Example 1, the loop execution of Example 1 is realized by adding the loop control instruction Jump, that is, the continuous execution of the entire loop body of Example 1; wherein the loop body is the first line in Example 1: ADD R0, R1, R2 to the fifth line: SHL R8, 6, R9. The Jump instruction realizes the continuous execution of the loop body of Example 1, and realizes the periodic execution of the loop body of Example 1.
[0045] Among them, Add R0, R1, R2 in the CMACO row means adding R0 and R1 and outputting to R2; the next row ADD R1, R5, R3 means adding R1 and R5 and outputting to R3; the next row CMUL R2, R3, R4 means multiplying R2 and R3 and outputting to R4; the next row ADD R4, R7, R8 means adding R4 and R7 and outputting to R8; the next row SHL R8, 6, R9 means logically shifting R8 left by 6 bits and outputting to R9; then the jump instruction is executed to jump to CMACO and perform the loop operation of the above instructions.
[0046] Using an execution process similar to Example 1, although continuous cycle execution of instructions is achieved, the instructions of each cycle (i.e., each beat) need to be issued to the execution unit. Although the instructions sent in each cycle may be the same in some cases, instructions still need to be issued to control the execution unit to perform the corresponding calculation operations of the instructions of one cycle; moreover, the instructions of each cycle cannot control multiple execution units to perform different calculation operations at the same time. For example, the instructions of one cycle cannot send ADD R0, R1, R2; MUL R2, R3, R4 at the same time, which means that the addition instruction is sent to the addition operation unit and the multiplication instruction is sent to the multiplication operation unit at the same time, that is, the instructions of one cycle cannot send multiple instructions to different execution units at the same time, so that multiple execution units can execute the calculation operations of the corresponding instructions at the same time.
[0047] At the same time, in CGRA data flow calculations, if only a small number of instructions in the loop body need to be modified in a large number of identical or similar calculations, then multiple different loop bodies are required to implement the CGRA data flow calculations, resulting in the lengthening of the instruction code in external storage and increasing the space for external storage instruction code.
[0048] In addition, since the instructions of each cycle cannot be executed continuously for multiple cycles, the performance will be greatly reduced when performing logical matrix operations.
[0049] In order to solve the problem in Example 1 that multiple instructions cannot be sent to different execution units at the same time in one cycle of instructions, so that multiple execution units can execute multiple instructions at the same time, a solution shown in Example 2 is provided. Example 2 adopts the VLIW mechanism, as shown in the first line of Example 2, and can send addition instructions to the addition unit and multiplication instructions to the multiplication unit at the same time, so that the addition unit and the multiplication unit can perform addition and multiplication operations at the same time in one cycle of instructions, and then the continuous execution of instructions is realized through the loop body of Example 2.
[0050] Example 2
[0051]
[0052] Although Example 2 solves the problem that multiple instructions are sent to the execution unit at the same time in one cycle, and the execution unit can execute the corresponding operations of multiple instructions at the same time, multiple instructions are sent to the execution unit in each cycle, resulting in an increase in the instruction code width, thereby increasing the space for external storage of instruction codes. Moreover, in the case of limited instruction code width, it is impossible to send more instructions to be executed in the same cycle, such as the first line in Example 2, and it is impossible to add more instructions.
[0053] At the same time, if only a small number of instructions in the loop body need to be modified, then multiple different loop bodies are required to realize the calculation of the data flow, resulting in the lengthening of the instruction code stored externally, and increasing the space for the externally stored instruction code. For example, in the operation, if there are 100 consecutive 100-line instructions of the same operation, there are 100 consecutive 99-line instructions of the same operation, and these 99 lines of instructions are exactly the same as 99 lines of instructions in these 100 lines of instructions, in this case, the calculation scheme of Example 2 is adopted, and finally written as a loop body of 100 lines of instructions, a loop body of 99 instructions, and 100 lines of instructions of non-identical calculations, which will result in the writing of 99 additional loop bodies of the same instructions in the instruction writing, increasing the space for the externally stored instruction code, wherein the instruction corresponding to each operation operation is called an instruction code.
[0054] In order to solve the problem of data flow operation of coarse granularity (such as CGRA), that is, how to complete the same operation without increasing the external instruction space when multiple execution units of instructions need to be executed continuously for multiple cycles and each cycle has many execution units. To this end, the embodiment of the present application provides an execution method and a computing device of an instruction set.
[0055] First, an embodiment of the present application provides an instruction set, which is applied to coarse-grained data flow computing, such as CGRS computing, TPU computing, AI computing and other scenarios, in which there are a large number of identical or similar computing.
[0056] The instruction set provided in the embodiment of the present application includes multiple instructions (or instruction codes), including control information and operation instructions, and the operation instructions can be operation instructions in existing calculations, such as addition operation instructions ADD, multiplication operation instructions SHL, etc. In other words, the instructions provided in the embodiment of the present application are based on existing operation instructions to add different control information.
[0057] The added control information includes at least one of continuous execution information, suspended execution information, single cycle execution information, or stopped execution information.
[0058] The continuous execution information is used to indicate that the operation corresponding to the operation instruction is repeatedly executed in the cyclic calculation of consecutive cycles.
[0059] The execution suspension information is used to indicate that the operation corresponding to the operation instruction is suspended in the loop calculation of consecutive cycles.
[0060] The single-cycle execution information is used to indicate that the operation corresponding to the operation instruction is executed in a cycle calculation of consecutive cycles.
[0061] The stop execution information is used to indicate that the operation corresponding to the stop operation instruction is stopped in the loop calculation in the consecutive cycles.
[0062] In one embodiment, continuous execution information can be represented by C-. For example, the existing instruction ADD R0, R1, R2 indicates an addition operation, and after being changed to C-ADD R0, R1, R2 of the present application, it means that the instruction continuously performs addition operations in the following cycle;
[0063] The suspension execution information can be represented by P-, which means suspending a certain operation instruction. Taking the ADD instruction as an example, if the instruction is P-ADD, it means that the addition operation is temporarily suspended. In one embodiment, if the instruction is P-ADD N, it means that from now on, the addition operation will be suspended for the next N cycles. For example, if N is 10, then when the instruction is P-ADD10, it means that the addition operation will be suspended for the next 10 cycles.
[0064] Single cycle execution information can be represented by R-. Taking the ADD instruction as an example, if the instruction is R-ADD R0, R1, R2, it means that an addition operation is performed in the current cycle.
[0065] The stop execution information can be represented by S-. Taking the ADD instruction as an example, if the instruction is S-ADD R0, R1, R2, it means that from this cycle onwards, the execution unit corresponding to the addition operation will no longer perform the addition operation and will not output the result.
[0066] The above describes the instructions of the newly defined instruction set. Figure 1 and Figure 2 Describes the control logic configured in hardware corresponding to the control information.
[0067] Figure 1 It is a schematic diagram of the architecture of a computing device, which includes a value acquisition unit 110, a decoding unit 120, a distribution unit 130, multiple execution units 140 (such as execution unit 1, execution unit 2, execution unit 3 and execution unit 4, etc.), and a write-back unit 150.
[0068] It should be noted that Figure 1 In the example, only the execution unit 140 includes 4 execution units, including execution unit 1, execution unit 2, execution unit 3 and execution unit 4.
[0069] The process of computer execution of instructions includes five steps: instruction fetch, decoding, distribution, execution and write back. Figure 1 The value-taking unit 110, decoding unit 120, distribution unit 130, execution unit 140 and write-back unit 150 are functionally divided units, and the actual process of taking values from computer execution instructions is: the computer controller sends the address of the instruction to the memory, and then the memory reads the instruction content according to the received address and returns the instruction content to the controller; the decoding process is: the controller analyzes the operation properties of the instruction, determines the operation to be performed by the instruction, and generates a corresponding control signal; the distribution process is: the controller sends the control signal required for the instruction; the execution process is: the controller reads the operand from the general register or memory, and the controller commands the operator to perform the operation specified by the instruction on the operand; the write-back process is: write the result of the operation back to the general register or memory.
[0070] Figure 1 The computing device shown can be applied to N-cycle cyclic computing, such as coarse-grained data flow computing, for example, CGRS computing, TPU computing, AI computing, etc. The cyclic computing is executed by instruction codes.
[0071] In one embodiment, the computing device may be a CPU or a DSP.
[0072] Figure 2 It is a schematic diagram of the architecture of a computing device provided in an embodiment of the present application. Figure 2 and Figure 1 The difference is that the computing device includes control logic for controlling each execution unit 140, which is respectively arranged on each execution unit 140. When the distribution unit 130 distributes the instruction code, the instruction code including the control information and the operation instruction is directly distributed to the execution unit, so that the execution unit 140 executes the control logic according to the control information in the instruction code, so as to perform the operation corresponding to the operation instruction in the instruction code according to the control information, that is, the execution unit 140 is used to perform the operation corresponding to the operation instruction in the instruction code according to the control information.
[0073] The control information includes at least one of continuous execution information, pause execution information, single-cycle execution information or stop execution information.
[0074] The continuous execution information is used to instruct the execution unit to repeatedly execute the calculation operation corresponding to the operation instruction in the cyclic calculation of N cycles.
[0075] The execution suspension information is used to instruct the execution unit to suspend the calculation operation corresponding to the operation instruction in the loop calculation of N cycles.
[0076] The single-cycle execution information is used to instruct the execution unit to execute the calculation operation corresponding to the operation instruction in one cycle calculation of N cycles.
[0077] The stop execution information is used to instruct the execution unit to stop the calculation operation corresponding to the operation instruction in the loop calculation in N cycles.
[0078] In one embodiment, continuous execution information can be represented by C-; pause execution information can be represented by P-; single-cycle execution information can be represented by R-; and stop execution information can be represented by S-.
[0079] For example, the operation instruction in the instruction code is ADD, and the execution unit that performs the ADD operation is execution unit 1. Then, when the instruction code is C-ADD, the control logic configured in execution unit 1 controls execution unit 1 to continuously execute the operation instruction ADD within the loop period according to the received control information C-.
[0080] When the instruction code is P-ADD, the control logic configured in the execution unit 1 controls the execution unit 1 to suspend the execution of the operation instruction ADD according to the received control information P-.
[0081] In one embodiment, when the instruction code is P-ADD N, the control logic controls the execution unit 1 to suspend the execution of the instruction ADD within N cycles after receiving the instruction code according to the received control information P-.
[0082] When the execution information is R-ADD, the control logic controls the execution unit 1 to execute the operation instruction ADD within one cycle of the loop period according to the received control information R-.
[0083] When the execution information is S-ADD, the control logic controls the execution unit 1 to stop executing the operation instruction ADD in the subsequent cycle according to the received control information S-.
[0084] In one embodiment, the instruction code may also be pause instruction information, an operation instruction and a number M, that is, P-operation instruction M, which is used to instruct the execution unit to pause the operation corresponding to the operation instruction within M cycles after receiving the instruction code in the N-cycle loop calculation. For example, if the instruction code is P-ADD 5, it means that the addition operation is paused within 5 cycles after receiving the instruction code.
[0085] In the embodiment of the present application, the operation of the instruction stream is realized by adding C-, P-, R- and S- control information, and the control logic corresponding to the C-, P-, R- and S- control information. In the embodiment of the present application, Figure 3 As shown in Figure 1, each execution unit has three states: stop state, pause state and running state. The control logic can include the following states, such as Figure 3 As shown:
[0086] It is assumed that the execution unit is in the stopped state after initialization.
[0087] The execution unit is in a stop state. When the execution unit receives an instruction code including C-, the execution unit jumps from the stop state to the running state.
[0088] The execution unit is in the stop state. When the execution unit receives an instruction code including P-, the execution unit jumps from the stop state to the pause state.
[0089] When the execution unit is in the running state and receives an instruction code including S-, the execution unit jumps from the running state to the stopping state.
[0090] When the execution unit is in the running state and receives instruction code information including P-, the execution unit jumps from the running state to the pause state.
[0091] The execution unit is in the pause state. When the execution unit receives an instruction code including S-, the execution unit jumps from the pause state to the stop state.
[0092] The execution unit is in the pause state. When the execution unit receives an instruction code including C-, the execution unit jumps from the pause state to the running state.
[0093] Optionally, in one embodiment, the computing device may further include a counter map ( Figure 2 In one embodiment,
[0094] The execution unit is in the pause state. When the counter of the computing device counts to 0, the execution unit jumps from the pause state to the running state.
[0095] Through the computing device provided in the embodiment of the present application, control logic corresponding to the control information is configured on the execution unit of the computing device, thereby realizing coarse-grained data flow operations such as CGRA. In the calculation of the same data flow, the instruction code storage space is reduced and the performance is improved.
[0096] The operation matrix usually used to calculate the data flow of coarse-grained data (such as CGRA) is composed of a series of process elements (PE), such as Figure 4 As shown, each PE is a separate operation logic that can implement related operations such as addition, subtraction, multiplication, shift, etc. Each PE is implemented by instruction distribution and then executed. Each PE must execute the following instruction set execution method.
[0097] Figure 5An execution method of an instruction set provided in an embodiment of the present application is applied to a cyclic calculation of N cycles. The cyclic calculation is executed through an instruction code, and the instruction code includes control information and operation instructions.
[0098] The N-cycle loop calculation here refers to the loop body calculation that is executed continuously for N cycles, such as CGRS calculation, TPU calculation, AI calculation, etc. Figure 5 As shown, the execution subject of the method is a computing device, which may be the computing device shown in 3. The execution method of the instruction set may include the following steps:
[0099] S201, receiving an instruction code, where the instruction code includes control information and an operation instruction.
[0100] The operation instruction is an operation instruction in an existing instruction set, such as an addition instruction ADD, a multiplication instruction MUL, a shift instruction SHL, and the like.
[0101] The control information is the same as the control information described above, and includes at least one of continuous execution information, pause execution information, single cycle execution information, or stop execution information.
[0102] The continuous execution information is used to indicate that the operation corresponding to the operation instruction is repeatedly executed in the cyclic calculation of N cycles.
[0103] The execution suspension information is used to indicate that the operation corresponding to the operation instruction is suspended in the N-cycle cyclic calculation.
[0104] The single-cycle execution information is used to indicate that the operation corresponding to the operation instruction is executed in one cycle calculation of N cycles.
[0105] The stop execution information is used to instruct to stop the operation corresponding to the operation instruction in the loop calculation in N cycles.
[0106] S202, executing a calculation operation corresponding to the operation instruction according to the control information in the instruction code and the operation instruction.
[0107] When receiving the instruction code distributed by the distribution unit, the execution unit of the computing device executes the calculation operation corresponding to the operation instruction according to the control information in the instruction code.
[0108] In one embodiment, when an instruction code including continuous execution information is received, the operation corresponding to the operation instruction is repeatedly executed in a loop calculation of N cycles.
[0109] In one embodiment, when an instruction code including execution suspension information is received, the operation corresponding to the operation instruction is suspended in the N-cycle loop calculation.
[0110] In one embodiment, when an instruction code including single-cycle execution information is received, the operation corresponding to the operation instruction is executed within one cycle of N cycles.
[0111] In one embodiment, when an instruction code including stop execution information is received, the operation corresponding to the operation instruction is stopped in the N-cycle loop calculation.
[0112] In one embodiment, continuous execution information can be represented by C-; pause execution information can be represented by P-; single-cycle execution information can be represented by R-; and stop execution information can be represented by S-.
[0113] In one embodiment, the instruction code further includes suspension execution information, an operation instruction and a number M, wherein M<N; the method further includes:
[0114] When an instruction code including pause instruction information, an operation instruction and a number M is received, the operation corresponding to the operation instruction is suspended within M cycles after the instruction code is received.
[0115] For example, if the instruction information is P-ADD 10, when the instruction code is received, the addition operation corresponding to the addition instruction is stopped within the next 10 cycles according to the control information P-.
[0116] In one embodiment, when the instruction code is received, at least one of the following states can be jumped according to the control information in the instruction information:
[0117] In the stop state, when receiving an instruction code including continuous execution information and an operation instruction, the stop state is switched to the running state according to the continuous execution information; or,
[0118] In the stop state, when receiving an instruction code including pause information and an operation instruction, the stop state is switched to the pause state according to the continuous execution information; or,
[0119] In the running state, when receiving an instruction code including stop execution information and an operation instruction, the running state is switched to the stop state according to the stop execution information; or,
[0120] In the running state, when receiving an instruction code including the suspension execution information and the operation instruction, the running state is switched to the suspension state according to the continuous execution information; or,
[0121] In the pause state, when receiving an instruction code including stop execution information and an operation instruction, the pause state is switched to the stop state according to the continuous execution information; or,
[0122] In the pause state, when receiving an instruction code including continuous execution information and an operation instruction, switching from the pause state to the running state according to the continuous execution information; or,
[0123] In the pause state, when the counter counts to 0, the pause state is switched to the running state.
[0124] Through the instruction set provided by the embodiment of the present application, as well as the instruction method and computing device of the instruction set, a matrix operation can be reduced to 5 to 6 instructions, and related operations can be completed, reducing Figure 4 The space required for the instruction code of each PE shown can effectively improve the performance of the device.
[0125] Example 3
[0126] C-LOAD R0, R1
[0127] C-MUL R0, R1, R2
[0128] C-ADD R2, R3, R4
[0129] C-SHR R4, 6, R5
[0130] C-STORE R5
[0131] exist Figure 4 In the example, each PE runs the same instruction combination. Each PE includes a multiplication unit, an addition unit, and a shift unit. As shown in Example 3, the instructions of each cycle load two data R0 and R1, first multiply the two data R0 and R1, output the result to R2, then accumulate the multiplication results R2 and R3, and output the accumulated result to R4, then shift the accumulated result R4, output the shift result to R5, and finally store R5; the instructions shown in Example 3 are executed continuously within the cycle to complete the related operations.
[0132] Through the execution method and computing device of the instruction set provided by this embodiment, Figure 4 Taking the power calculation of 100 data by a single PE as an example, it takes about 600 cycles to implement the operation using the previous CPU method, while it takes about 105 cycles using the execution method and computing device of the instruction set provided in this embodiment. The code for the existing CPU to execute the operation is shown in Example 4; the code of the embodiment of the present application is shown in Example 5.
[0133] Example 4
[0134] MOV R6 100
[0135] LOAD R0
[0136] MUL R0, R0, R1
[0137] ADD R1, R2, R3
[0138] STORE R5
[0139] SUB R6,1
[0140] BTNEZ R6, A0
[0141] Example 5
[0142] C-LOAD R0
[0143] C-MUL R0, R0, R1
[0144] C-ADD R1, R2, R3
[0145] C-STORE R5
[0146] LOOP 100
[0147] Comparing Example 4 and Example 5, the instruction code of Example 4 requires 7 instructions to implement the operation, while the instruction code of Example 5 only requires 5 instructions to complete the operation, which reduces the instruction code space required for a single PE and improves performance.
[0148] The embodiment of the present application adds control information on the basis of the existing instruction set, and configures control logic corresponding to the newly added control information on the hardware. When the device receives the instruction code, the computing device executes the operation corresponding to the operation instruction in the instruction code according to the control information in the instruction code, thereby effectively reducing the storage space of the instruction code and improving the performance of the device.
[0149] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for executing an instruction set, characterized in that: The method is applied to cyclic calculations for N cycles, and the cyclic calculations are executed by an instruction code, where the instruction code includes control information and operation instructions; the method includes: Receiving the instruction code; Performing an arithmetic operation corresponding to the operation instruction according to the control information and the operation instruction in the instruction code; Wherein, the control information includes at least one of continuous execution information, pause execution information, single-cycle execution information, or stop execution information; The continuous execution information is used to indicate that, in the cyclic calculation for N cycles, the arithmetic operation corresponding to the operation instruction is repeatedly executed; The pause execution information is used to indicate that, in the cyclic calculation for N cycles, the arithmetic operation corresponding to the operation instruction is paused; The single-cycle execution information is used to indicate that, in a one-cycle calculation for N cycles, the arithmetic operation corresponding to the operation instruction is executed; The stop execution information is used to indicate that, in the cyclic calculation for N cycles, the arithmetic operation corresponding to the operation instruction is stopped.
2. The method according to claim 1, characterized in that The instruction code further includes pause execution information, an operation instruction, and a number M, where M < N; the method further includes: When receiving an instruction code including pause instruction information, an operation instruction, and a number M, pausing the execution of the arithmetic operation corresponding to the operation instruction within M cycles after receiving the instruction code.
3. The method according to claim 1 or 2, characterized in that: The method further includes: In a stopped state, when receiving an instruction code including continuous execution information and an operation instruction, switching from the stopped state to a running state according to the continuous execution information; or, In a stopped state, when receiving an instruction code including pause information and an operation instruction, switching from the stopped state to a paused state according to the continuous execution information; or, In a running state, when receiving an instruction code including stop execution information and an operation instruction, switching from the running state to a stopped state according to the stop execution information; or, In a running state, when receiving an instruction code including pause execution information and an operation instruction, switching from the running state to a paused state according to the continuous execution information; or, In a paused state, when receiving an instruction code including stop execution information and an operation instruction, switching from the paused state to a stopped state according to the continuous execution information; or, In a paused state, when receiving an instruction code including continuous execution information and an operation instruction, switching from the paused state to a running state according to the continuous execution information; or, In a paused state, when the counter counts to 0, switching from the paused state to a running state.
4. The method according to claim 1 or 2, characterized in that: The cyclic calculation for N cycles includes coarse-grained configurable matrix (CGRS) calculation, tensor processing unit (TPU) calculation, and artificial intelligence (AI) calculation.
5. A computing device, characterized in that: Applied to cyclic calculations for N cycles, the cyclic calculations are executed by an instruction code, where the instruction code includes control instruction control information and operation instructions; the computing device includes: a control unit and an execution unit; The execution unit is used to perform an arithmetic operation corresponding to the operation instruction according to the control information; Wherein, the control information includes at least one of continuous execution information, pause execution information, single-cycle execution information, or stop execution information; The continuous execution information is used to instruct the execution unit to repeatedly execute the operation corresponding to the operation instruction in a cyclic calculation of N cycles; The execution suspension information is used to instruct the execution unit to suspend the operation corresponding to the operation instruction in the N-cycle cyclic calculation; The single-cycle execution information is used to instruct the execution unit to execute the operation corresponding to the operation instruction in one cycle calculation of N cycles; The stop execution information is used to instruct the execution unit to stop the calculation operation corresponding to the operation instruction in the cyclic calculation in N cycles.
6. The computing device according to claim 5, characterized in that The instruction code also includes suspension execution information, operation instructions and numbers M, M <N; The instruction code is used to instruct the execution unit to suspend the calculation operation corresponding to the operation instruction within M cycles after receiving the instruction code in the cyclic calculation of N cycles.
7. The computing device according to claim 5 or 6, characterized in that: The execution unit includes a stop state, a pause state and a running state; The execution unit is further configured to, when the execution unit is in a stopped state and receives an instruction code including continuous execution information and an operation instruction, switch from the stopped state to the running state according to the continuous execution information; The execution unit is further configured to, when the execution unit is in a stopped state and receives an instruction code including pause information and an operation instruction, switch from the stopped state to the pause state according to the continuous execution information; The execution unit is further configured to, when the execution unit is in a running state, switch from the running state to the stopping state according to the stopping execution information when receiving an instruction code including the stopping execution information and the operation instruction; The execution unit is further configured to, when the execution unit is in a running state, switch from the running state to the pause state according to the continuous execution information when receiving an instruction code including the pause execution information and the operation instruction; The execution unit is further configured to, when the execution unit is in a pause state, switch from the pause state to the stop state according to the continuous execution information when receiving an instruction code including the stop execution information and the operation instruction; The execution unit is also used for, when the execution unit is in a pause state and receives an instruction code including continuous execution information and an operation instruction, switching from the pause state to the running state according to the continuous execution information.
8. The computing device according to claim 7, characterized in that: The calculation device also includes a counter, The execution unit is also used for switching from the pause state to the running state when the counter counts to 0 when the execution unit is in the pause state.
9. The computing device according to claim 5 or 6, characterized in that: The N-cycle cyclic calculation includes coarse-grained configurable matrix CGRS calculation, tensor processor TPU calculation, and artificial intelligence AI calculation.
10. The computing device according to claim 5 or 6, characterized in that: The computing device is a central processing unit CPU or a digital signal processor DSP.
Citation Information
Patent Citations
Microcomputer
JP2002163104A
Data processor for modifying and executing operation of instruction code
US20040015680A1
Structured control instruction fetch unit
US20140195781A1
Methods and apparatus for implementing complex parallel instructions using control logic
US7870367B1
