Computational unit compatible with SIMD calculation and floating-point matrix multiplication and application method thereof
By designing a floating-point matrix multiplication operation component that is compatible with SIMD calculations, and using a reusable operand heap and multiple bypass channels, the problem of low matrix multiplication efficiency in general-purpose processors is solved, and efficient matrix multiplication calculations are realized, supporting deep Performance requirements for learning and other applications.
Patent Information
- Application Number
- CN202111666163.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-30
AI Technical Summary
General-purpose processors lack the ability to directly calculate matrix multiplication, resulting in low matrix multiplication operation efficiency and unable to meet the performance requirements of applications such as deep learning.
A floating-point matrix multiplication operation component that is compatible with SIMD calculations is designed. It realizes the matrix multiplication function through the reusable operand heap and the bypass channels of multiple multiplication and addition components. It supports fp64 and fp32 data formats and can be used in the original SIMD structure. Added matrix multiplication capability.
It improves the computing efficiency and power consumption performance of matrix multiplication, supports inner product and outer product operations of matrices, reduces hardware resource overhead, realizes pipelined calculation of matrix multiplication, and improves the computing power and resource utilization of the processor.
Smart Images

Figure CN114518861B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer micro-architecture and floating point and vector execution unit design technology, and in particular to an operation unit compatible with SIMD calculation and floating point matrix multiplication and an application method thereof. Background Art
[0002] The era of artificial intelligence has arrived. The realization of artificial intelligence relies on frameworks such as machine learning and deep learning. General matrix multiplication is one of the core units of deep learning frameworks and is widely used in operators such as convolution and full connection. Such emerging applications have put forward higher requirements on processor performance. However, general-purpose processors lack the ability to directly calculate matrix multiplication. Therefore, matrix multiplication operations in general-purpose processors are crucial to improving the performance of running deep learning related applications. Due to cost and other factors, matrix multiplication is currently often calculated through vector multiplication, which has low computational efficiency. Summary of the invention
[0003] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a computing unit compatible with SIMD calculation and floating-point matrix multiplication and an application method thereof are provided. The present invention realizes a computing unit compatible with SIMD calculation and floating-point matrix multiplication and an execution path design to make up for the lack of direct matrix multiplication ability of general-purpose processors due to factors such as computing efficiency and power consumption. The proposed design is not only compatible with the original 2×128 SIMD structure and meets the energy consumption, computing efficiency and other conditions of the computing unit inside the microprocessor, but also can realize the matrix multiplication function in the general-purpose processor through the redesign of the original components and bypass.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A computing unit compatible with SIMD calculation and floating-point matrix multiplication, comprising floating-point and vector execution units vfu0 and vfu1 with the same structure and reusable operand stacks, wherein the floating-point and vector execution unit vfu0 comprises four multiplication-addition units vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array, wherein the multiplication-addition unit vfu0_hh and the multiplication-addition unit vfu0_ll have a bypass channel for inputting the same first operand, and the multiplication-addition unit vfu0_lh and the multiplication-addition unit vfu0_lh both have a bypass channel for inputting the same second operand. The multiplication-addition component vfu0_lh and the multiplication-addition component vfu0_hl both have a bypass channel for inputting the same third operand, the multiplication-addition component vfu0_hl and the multiplication-addition component vfu0_ll both have a bypass channel for inputting the same fourth operand, and the output end of the multiplication-addition component vfu0_hh has a result bypass channel for outputting the result as the operand of the multiplication-addition component vfu0_hl, and the output end of the multiplication-addition component vfu0_lh has a result bypass channel for outputting the result as the operand of the multiplication-addition component vfu0_ll.
[0006] Optionally, the floating-point and vector execution units vfu0 and vfu1 each include a row source operand stack with a bit width of 128 bits and a source column operand stack with a bit width of 128 bits that can be reused mutually. When the operation unit supports the fp64 data format, the 2×128-bit data width of the row operand stack and the column operand stack is divided into a 4×64-bit data width to support a maximum of 8 source operands for multiplication and addition operations; when the operation unit supports the fp32 data format, the 2×128-bit data width of the row source operand stack and the column source operand stack is divided into an 8×32-bit data width to support a maximum of 16 source operands for multiplication and addition operations.
[0007] Optionally, the multiplication and addition component includes a floating-point multiplication module FMUL, a temporary register reg, a selector MUX and a floating-point addition module FADD. The floating-point multiplication module FMUL is used to perform floating-point multiplication on two input operands to obtain a floating-point multiplication result, and output it to the floating-point addition module FADD as an operand of the floating-point addition module FADD. At the same time, the floating-point multiplication result is temporarily stored in the temporary register reg as an operand of the floating-point addition module FADD, and another operand from the outside is selected by the selector MUX to be input into the floating-point addition module FADD to obtain a corresponding addition operation result and output it.
[0008] In addition, the present invention also provides a processor, comprising an instruction transmitting unit and an instruction executing unit connected to each other, wherein the instruction executing unit includes the operation unit compatible with SIMD calculation and floating-point matrix multiplication.
[0009] In addition, the present invention also provides a computing acceleration card, including an acceleration card body and a processor arranged on the acceleration card body, and the processor is the processor described above.
[0010] In addition, the present invention also provides a computer device, including a processor and a memory connected to each other, wherein the processor is the processor described above.
[0011] In addition, the present invention also provides an application method of the aforementioned computing unit compatible with SIMD calculation and floating-point matrix multiplication, comprising the steps of performing a double-precision matrix inner product operation as shown in the following formula:
[0012]
[0013] In the above formula, a0, b0, c0, d0 are four operands of the first double precision matrix, a1, b1, c1, d1 are four operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of performing the double precision matrix inner product operation by the floating point and vector execution units vfu0 and vfu1 include:
[0014] STEP1: Prepare data. The source operand of the floating-point and vector execution unit vfu0 is provided by the multiplexing of the source operand sent to the floating-point and vector execution unit vfu0 itself and the two source operands sent to the floating-point and vector execution unit vfu0 after bypassing from the floating-point and vector execution unit vfu1; the source operand of the floating-point and vector execution unit vfu1 is provided by the multiplexing of the source operand sent to the floating-point and vector execution unit vfu1 itself and the two source operands sent to the floating-point and vector execution unit vfu1 after bypassing from the floating-point and vector execution unit vfu0; the operands in the row source operand stack and the column source operand stack of the floating-point and vector execution unit vfu0 are a0, b0, a0, b0, a1, c1, b1, d1, among which a0 and b0 are multiplexed, b1 and d1 are bypassed from the floating-point and vector execution unit vfu1, the source operands of the multiplication and addition unit vfu0_hh are a0 and a1, and the multiplication and addition unit vfu0 The source operands of the multiply-add unit vfu0_lh are b0 and c1, the source operands of the multiply-add unit vfu0_lh are b0 and d1, and the source operands of the multiply-add unit vfu0_ll are a0 and b1. The source operands of the multiply-add units vfu0_lh and vfu0_ll are bypassed; the operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu1 are c0, d0, c0, d0, b1, d1, a1, c1, where c0 and d0 are Multiplexing, a1, c1 are bypassed from the floating point and vector execution unit vfu0, the source operands of the multiplication and addition unit vfu1_hh are c0, a1, the source operands of the multiplication and addition unit vfu1_hl are d0, c1, the source operands of the multiplication and addition unit vfu1_lh are d0, d1, and the source operands of the multiplication and addition unit vfu1_ll are c0, b1, among which the source operands of the multiplication and addition unit vfu1_lh and the multiplication and addition unit vfu1_ll are bypassed;
[0015] STEP2: The operands are respectively entered into the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll of the floating-point and vector execution components vfu0 and vfu1 for multiplication operation, and at this time, the floating-point addition modules FADD in the multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll are all in an idle state;
[0016] STEP3: The multiplication and addition components vfu0_hh and vfu0_hl respectively output the multiplication results to the floating-point addition modules FADD in the multiplication and addition components vfu0_lh and vfu0_ll through the result bus bypass, and the data obtained in STEP2 are added by the floating-point addition module FADD to obtain the final result; at this time, if it is necessary to synchronously pipeline the next double-precision matrix inner product operation, the multiplication operation in the next double-precision matrix inner product operation can be synchronously pipelined through the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array;
[0017] STEP 4: The floating point and vector execution components vfu0 and vfu1 respectively output two final results through the result bus, so that the floating point and vector execution components vfu0 and vfu1 output four results at the same time, and the four results are concatenated to obtain the final double-precision matrix inner product operation result.
[0018] Optionally, the step includes performing a double-precision matrix outer product operation as shown in the following formula:
[0019]
[0020] In the above formula, a0, b0, c0, d0 are 4 operands of the first double precision matrix, a1, b1, c1, d1 are 4 operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of performing the double precision matrix outer product operation by the floating point and vector execution unit vfu0 include:
[0021] STEP1: Prepare data. The source operands of the floating-point and vector execution unit vfu0 are provided by the reuse of the source operands sent to the floating-point and vector execution unit vfu0. The operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu0 are a0, c0, a0, c0, a1, b1, a1, b1, among which the source operands a0, c0, a1, b1 are reused. The source operands of the multiplication and addition unit vfu0_hh are a0, a1, The source operands of vfu0_hl are b1 and c0, the source operands of the multiplication and addition component vfu0_lh are c0 and a1, and the source operands of the multiplication and addition component vfu0_ll are a0 and b1. The intermediate result matrix result 0 is calculated from these four source operands, wherein the source operands of the multiplication and addition component vfu0_lh and the multiplication and addition component vfu0_ll are both bypassed; the intermediate result matrix result 0 of each multiplication and addition component is temporarily stored in the temporary register reg of each multiplication and addition component;
[0022] STEP2: Calculate the intermediate result matrix result 1. Prepare the data organization method according to step STEP1. The source operands enter the operation unit in sequence for operation: the operands in the row source operand stack and the column source operand stack of the floating-point and vector execution unit vfu0 are b0, d0, b0, d0, c1, d1, c1, d1, wherein the source operands b0, d0, c1, d1 are reused, the source operands of the multiplication and addition unit vfu0_hh are b0 and c1, the source operands of the multiplication and addition unit vfu0_hl are d1 and d0, the source operands of the multiplication and addition unit vfu0_lh are d0 and c1, and the source operands of the multiplication and addition unit vfu0_ll are b0 and d1, and the intermediate result matrix result 1 is calculated from these four source operands;
[0023] STEP3: Add the intermediate result matrix result 0 temporarily stored in the temporary register reg of each multiplication-addition component and the multiplication result obtained in step STEP2 through the floating-point addition module FADD in the multiplication-addition component to obtain the addition calculation result.
[0024] STEP 4: Output four addition calculation results simultaneously through the result output bypass of the floating point and vector execution unit vfu0, and output the four addition calculation results in the correct order through data shuffling.
[0025] Optionally, the method includes performing the single-precision matrix inner product operation shown in the following formula:
[0026]
[0027] In the above formula, a0, b0, c0, d0 are four operands of the first single-precision matrix, a1, b1, c1, d1 are four operands of the second single-precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of the floating-point and vector execution units vfu0 and vfu1 performing the single-precision matrix inner product operation include:
[0028] STEP1: Prepare data: In one set of operands, the operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add component vfu0_h are a0, a1, the source operands of the multiply-add component vfu0_l are b0, c1, the source operands of the multiply-add component vfu1_h are b0, d1, and the source operands of the multiply-add component vfu1_l are a0, b1; in the next set of operands, the source operand stack remains unchanged, the source operands of the multiply-add component vfu0_h are c0, a1, the source operands of the multiply-add component vfu0_l are d0, c1, the source operands of the multiply-add component vfu1_h are d0, d1, and the source operands of the v multiply-add component fu1_l are c0, b1;
[0029] STEP2: The operands prepared in step STEP1 are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, and the next set of operands are prepared for calculation;
[0030] STEP3: While the next pair of operands are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, the first pair of operands are bypassed to the floating-point addition module FADD of the next multiplication-addition component through the result bus for addition operation after multiplication, so that the multiplication-addition component vfu0_h and the multiplication-addition component vfu1_h bypass and output the multiplication results to the floating-point addition modules FADD of the multiplication-addition component vfu0_l and the multiplication-addition component vfu1_l respectively through the result bus, and the data calculated in the previous step STEP2 are added in the floating-point addition modules FADD in the multiplication-addition components vfu1_l and the multiplication-addition components vfu0_l to obtain the final result;
[0031] STEP4: Output the two final results calculated in step STEP3, and at the same time, after the second pair of operands are multiplied, bypass them through the result bus to the floating-point addition module FADD of the next operation component for addition operation;
[0032] STEP5: Output the remaining two final results calculated in step STEP4.
[0033] Optionally, the method includes performing the following single-precision matrix outer product operation:
[0034]
[0035] In the above formula, a0, b0, c0, d0 are four operands of the first double precision matrix, a1, b1, c1, d1 are four operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of the floating point and vector execution units vfu0 and vfu1 performing the single precision matrix outer product operation include:
[0036] STEP1: Data preparation: The operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add component vfu0_h are a0, a1, the source operands of the multiply-add component vfu0_l are b1, c0, the source operands of the multiply-add component vfu1_h are c0, a1, and the source operands of the multiply-add component vfu1_l are a0, b1; in the next group of operands, the source operands of the multiply-add component vfu0_h are b0, c1, the source operands of the multiply-add component vfu0_l are d0, d1, the source operands of the multiply-add component vfu1_h are d0, c1, and the source operands of the multiply-add component vfu1_l are b0, d1; the intermediate result matrix result 0 generated by each multiply-add component according to the source operands;
[0037] STEP2: When the intermediate result matrix result 0 has entered the calculation unit for calculation, the intermediate result matrix result 1 of the next set of operands is calculated at the same time. According to the data organization method prepared in step STEP1, the source operands enter the calculation unit for calculation in sequence:
[0038] STEP3: Each multiplication result obtained in step STEP2 is temporarily stored in the temporary register reg, and at the same time, the next pair of operands enters the floating-point multiplication module FMUL of each multiplication-addition component for calculation to obtain the intermediate result matrix result 1;
[0039] STEP4: The intermediate result matrix result 0 calculated in step STEP1 and the intermediate result matrix result 1 calculated in step STEP2 are added in the floating-point addition module FADD of each multiplication and addition component to obtain the final result;
[0040] STEP5: Output the final result of the matrix through the result bypass. Both the floating point and vector execution units vfu0 and vfu1 output 4 final results at the same time.
[0041] Compared with the prior art, the present invention has the following advantages: the computing unit of the present invention includes floating-point and vector execution units vfu0 and vfu1 with reusable operand stacks, and the floating-point and vector execution units vfu0 and vfu1 each include four multiplication-addition units arranged in an array, and the four multiplication-addition units have multiple operands and result bypass channels. The present invention realizes a computing unit and execution path design compatible with SIMD calculation and floating-point matrix multiplication, which has the following advantages:
[0042] From the perspective of computational efficiency, the design proposed in this embodiment is more computationally efficient than simply using vector multiplication to calculate matrices, and can implement pipelined calculations when facing multiple pairs of matrix calculations. 3002 The present invention can also simultaneously calculate the outer product of the matrix and the inner product of the matrix, and the coupling degree between the components is high.
[0043] From the perspective of power consumption, when calculating fp64 operands, the computing resources are doubled, and only 4 source operand bypasses are added. When calculating fp32 operands, there is no need to increase computing resources and bypasses. The present invention is compatible with the original SIMD path, has low hardware resource overhead, is easy to modify, improves resource utilization efficiency, and can significantly improve matrix computing capabilities at a relatively low cost. From a design perspective, this design does not require large-scale modifications to the floating-point and vector execution components. Only the bypass and result channels and data organization can be modified to implement the added matrix multiplication function. It will not cause register changes, reducing the cost and resource increase caused by large-scale redesign. The hardware organization is simple, and the organization and segmentation of the source operands and outputs of the matrix can be implemented by software.
[0044] From the perspective of optimizability, since the present invention can support outer product operations of matrices, it can subsequently provide possibilities for optimizing common sparse matrices.
[0045] From the perspective of computational efficiency, the present invention can double the ideal peak values of floating point and vector components. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 The figure is a schematic diagram showing the principle of the computing unit supporting the fp64 data format according to an embodiment of the present invention.
[0047] Figure 2 The figure is a schematic diagram showing the principle of the computing unit supporting the fp32 data format according to an embodiment of the present invention.
[0048] Figure 3 A schematic diagram of the data width supported by the computing unit in an embodiment of the present invention.
[0049] Figure 4 Schematic diagram of the internal structure of the multiplication and addition component in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] like Figure 1 and Figure 2As shown, the operation unit compatible with SIMD calculation and floating-point matrix multiplication in this embodiment includes floating-point and vector execution units vfu0 and vfu1 with the same structure and reusable operand stacks, and the floating-point and vector execution unit vfu0 includes four multiplication-addition units vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array, wherein the multiplication-addition unit vfu0_hh and the multiplication-addition unit vfu0_ll have a bypass channel for inputting the same first operand, and the multiplication-addition unit vfu0_lh and the multiplication-addition unit vfu0_ll have a bypass channel for inputting the same second operand. The multiplication-addition component vfu0_lh and the multiplication-addition component vfu0_hl both have a bypass channel for inputting the same third operand, the multiplication-addition component vfu0_hl and the multiplication-addition component vfu0_ll both have a bypass channel for inputting the same fourth operand, and the output end of the multiplication-addition component vfu0_hh has a result bypass channel for outputting the result as the operand of the multiplication-addition component vfu0_hl, and the output end of the multiplication-addition component vfu0_lh has a result bypass channel for outputting the result as the operand of the multiplication-addition component vfu0_ll. The computing unit of this embodiment that is compatible with SIMD calculation and floating-point matrix multiplication can add matrix multiplication instructions while being compatible with the original SIMD operation, and directly calculate the matrix multiplication in the floating-point and vector units, which can make up for the lack of the ability of general-purpose processors to directly calculate matrix multiplication due to factors such as computing efficiency and power consumption. The proposed design is not only compatible with the original 2×128 SIMD structure and meets the energy consumption, computing efficiency and other conditions of the computing unit inside the microprocessor, but also can realize the matrix multiplication function in the general-purpose processor through the redesign of the original components and bypass. The floating-point and vector execution unit vfu1 has the same structure as the floating-point and vector execution unit vfu0, that is, it includes four multiplication-addition units vfu1_hh, vfu1_hl, vfu1_lh and vfu1_ll arranged in an array, wherein the multiplication-addition unit vfu1_hh and the multiplication-addition unit vfu1_ll have a bypass channel for inputting the same first operand, and the multiplication-addition unit vfu1_lh and the multiplication-addition unit vfu1_ll both have a bypass channel for inputting the same second operand, the multiplication-addition unit vfu1_lh and the multiplication-addition unit vfu1_hl both have a bypass channel for inputting the same third operand, the multiplication-addition unit vfu1_hl and the multiplication-addition unit vfu1_ll both have a bypass channel for inputting the same fourth operand, and the output end of the multiplication-addition unit vfu1_hh has a result bypass channel for using the output result as the operand of the multiplication-addition unit vfu1_hl, and the output end of the multiplication-addition unit vfu1_lh has a result bypass channel for using the output result as the operand of the multiplication-addition unit vfu1_ll.
[0051] In this embodiment, the floating point and vector execution units vfu0 and vfu1 each include a row source operand stack with a bit width of 128 bits and a source column operand stack with a bit width of 128 bits that can be reused. When the operation unit supports the fp64 data format, the 2×128-bit data width of the row operand stack and the column operand stack is divided into a 4×64-bit data width to support a maximum of 8 source operands for multiplication and addition operations; when the operation unit supports the fp32 data format, the 2×128-bit data width of the row source operand stack and the column source operand stack is divided into an 8×32-bit data width to support a maximum of 16 source operands for multiplication and addition operations, such as Figure 3 shown. Figure 3 It describes the number of computing units supported by 128-bit data width. In the case of 2×128, a 128-bit data width can theoretically support the number of computing units shown in 10. However, when there are multiple vfus, the operands can be reused through the source operand bypass design. Therefore, when resources are sufficient, the computing units can be expanded according to the total number of source operands (including the number of reused ones) and the configuration of a multiplication and addition computing unit for two operands. 11 describes the execution process of a pair of 2×2 matrix inner products. According to the definition of matrix inner product, an inner product is equivalent to the dot product operation Res+=a×b+c×d of the vector, and its result is equal to the value of a certain point in the final result matrix. 12 describes the execution process of a pair of 2×2 matrix outer products. According to the definition of outer product operation, the multiplication of a pair of 2×2 matrices will generate two different intermediate result matrices 0 (13) and intermediate result matrix 1 (14) in two steps. The final calculation result of the matrix is equal to the sum of the two intermediate result matrices 13 and 14.
[0052] The data formats supported by the computing unit compatible with SIMD calculation and floating-point matrix multiplication in this embodiment include fp64 and fp32. Figure 3 As shown, the 128-bit data width can support two 64-bit and four 32-bit operation components. This embodiment is based on the 2×128 SIMD structure. When the data format is fp64, there are 2×128 (4×64) bits of data width. In the case of 2×128, up to 8 source operands are supported for multiplication and addition operations. When the data format is fp32, there are 2×128 (8×32) bits of data width. In the case of 2×128, up to 16 source operands are supported for multiplication and addition operations.
[0053] See also Figure 1, solid line 24 is the original source operand data path (vfu0_hh and vfu0_hl), solid line 25 is the calculation result channel and calculation result bypass, dotted lines 26, 27, 28, 29 are the bypass of the source operand data path after adding computing resources, and vfu0_lh and vfu0_ll are additional computing resources that can be satisfied. For example, solid line 24 is the data path of the original computing unit vfu0_hh, and dotted line 26 is the data path bypassed from the original solid line to vfu0_ll when the computing resources are doubled, and the operand is also the source operand of vfu0_hh. Therefore, vfu0_hh and vfu0_ll can receive the same operand in one step at the same time, and the same applies to the other data channels. As shown by the solid line 25, the result channel can not only be directly output in each module, but also output to another computing module through the result bypass. The operand stacks 20 and 21 on the left and above the multiplication and addition unit are the source operands to be entered into the computing unit, and 23 is a 64-bit operand. It can be seen that the four multiplication and addition components in a vfu require a total of 8 source operands, and two vfus require a total of 16 source operands. Because data multiplexing is performed, there are only 8 actual operands, and the remaining 8 are multiplexed operands. The two 64-bit operands on the left side of 20 are the source operands of vfu0 multiplexing vfu0, and the two 64-bit operands on the upper side of 21 are the source operands of vfu0 multiplexing from the vfu1 bypass. Taking the multiplication of a pair of 2×2 matrices as an example, the elements of matrix A are a0, b0, c0, d0, and the elements of matrix B are a1, b1, c1, d1. The elements of the final matrix C to be calculated are a2, b2, c2, d2, and the calculation process is as follows: Figure 1 As shown in 11, the two vfus (floating point and vector execution units) have a total of 4×128 (8×64) source operands. A vfu has 4×64-bit different operands. The source operands assigned to vfu0 are a0, b0, a1, and c1; the source operands assigned to vfu1 are a0, b0, a1, and c1. The two 64-bit operands b1 and d1 at 21 above the figure are bypassed from the source operands of vfu1, and the two 64-bit operands a1 and c1 at 21 above vfu1 are bypassed from the source operands of vfu0; the two 64-bit 20 on the left side of vfu0 and the two 64-bit 20 on the left side of vfu1 represent the reuse of the source operands inside the vfu. vfu0 reuses a0 and b0, and vfu1 reuses c0 and d0. In this way, there are 8 source operands in each vfu, and half of the operands are either reused from its own operands or from bypassed data from another vfu. Since fp32 is designed without source operand multiplexing, Figure 3There are four pairs of multiplication and addition units in vfu0 and vfu1, and no additional calculation units and dotted line bypass are added. The solid line 24 is the original source operand data path of vfu, and the solid line 25 is the calculation result channel and calculation result bypass. 31 is a 32-bit operand. Figure 1 Similarly, as shown by the solid line 25, the result channel can not only be directly output in each module, but also bypassed to another computing module. On the left and above the computing unit are the source operands of fp32. It can be seen that the four multiplication and addition units in a vfu require 8 source operands in one beat and calculate the result in two beats. Under the 2×128 SIMD structure, a maximum of 16 source operands can be provided, which can just meet the requirement of the number of source operands (16) calculated in two beats for 2×2 matrix multiplication, so no bypass is required.
[0054] like Figure 4 As shown, the multiplication and addition component includes a floating-point multiplication module FMUL, a temporary register reg, a selector MUX and a floating-point addition module FADD. The floating-point multiplication module FMUL is used to obtain a floating-point multiplication result after performing floating-point multiplication on two input operands and output it to the floating-point addition module FADD as an operand of the floating-point addition module FADD. At the same time, the floating-point multiplication result is temporarily stored in the temporary register reg as an operand of the floating-point addition module FADD, and another operand from the outside is selected by the selector MUX to input the floating-point addition module FADD to obtain the corresponding addition result and output it. The operations that the present invention can support simultaneously include SIMD calculation and floating-point matrix multiplication. The multiplication and addition component can perform a floating-point multiplication and floating-point addition operation, and the multiplication and addition components can transmit data through bypass, and the source operand can also be selected between multiple multiplication and addition components through the selector MUX. Figure 4 In the figure, solid lines 41 and 42 represent the source operands entering the operation unit, solid line 43 represents the calculation result of the floating-point multiplication module FMUL, 45 is the calculation result bypassed from other operation units entering the floating-point addition module FADD for accumulation, 44 is the calculation result after the multiplication calculation of this operation module is completed when calculating the outer product matrix entering the floating-point addition module FADD for accumulation, and the temporary register reg needs to add a temporary storage function when performing the matrix outer product to meet the timing requirements in the calculation.
[0055] The computing unit compatible with SIMD calculation and floating-point matrix multiplication in this embodiment is a computing unit with a redesigned data path. It can not only support the original SIMD operation, but also achieve the ability to implement 2×2 matrix multiplication at the cost of only minor changes to the bypass. The matrix multiplication can also be compatible with the inner product and outer product operations of the matrix at the same time, so that the computing power per unit area is significantly improved, and the resource utilization and energy consumption ratio are improved.
[0056] In addition, this embodiment further provides a processor, including an instruction issuing unit and an instruction executing unit connected to each other, wherein the instruction executing unit includes the aforementioned operation unit compatible with SIMD calculation and floating-point matrix multiplication.
[0057] In addition, this embodiment also provides a computing acceleration card, including an acceleration card body and a processor disposed on the acceleration card body, wherein the processor is the aforementioned processor.
[0058] In addition, this embodiment also provides a computer device, including a processor and a memory connected to each other, wherein the processor is the aforementioned processor.
[0059] This embodiment describes in detail the steps of calculating the outer product and inner product of a matrix when the data format is fp64 and fp62. The corresponding structure diagram of the inner product and outer product operation of a double precision matrix is as follows: Figure 1 , the corresponding structure diagram of the inner product and outer product operations of a single precision matrix is Figure 2 .
[0060] In addition, this embodiment also provides an application method of the aforementioned computing unit compatible with SIMD calculation and floating-point matrix multiplication, including the step of performing a double-precision matrix inner product operation as shown in the following formula:
[0061]
[0062] In the above formula, a0, b0, c0, d0 are four operands of the first double precision matrix, a1, b1, c1, d1 are four operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of performing the double precision matrix inner product operation by the floating point and vector execution units vfu0 and vfu1 include:
[0063] STEP1: Prepare data. The source operand of the floating-point and vector execution unit vfu0 is provided by the multiplexing of the source operand sent to the floating-point and vector execution unit vfu0 itself and the two source operands sent to the floating-point and vector execution unit vfu0 after bypassing from the floating-point and vector execution unit vfu1; the source operand of the floating-point and vector execution unit vfu1 is provided by the multiplexing of the source operand sent to the floating-point and vector execution unit vfu1 itself and the two source operands sent to the floating-point and vector execution unit vfu1 after bypassing from the floating-point and vector execution unit vfu0; the operands in the row source operand stack and the column source operand stack of the floating-point and vector execution unit vfu0 are a0, b0, a0, b0, a1, c1, b1, d1, among which a0 and b0 are multiplexed, b1 and d1 are bypassed from the floating-point and vector execution unit vfu1, the source operands of the multiplication and addition unit vfu0_hh are a0 and a1, and the multiplication and addition unit vfu0 The source operands of the multiply-add unit vfu0_lh are b0 and c1, the source operands of the multiply-add unit vfu0_lh are b0 and d1, and the source operands of the multiply-add unit vfu0_ll are a0 and b1. The source operands of the multiply-add units vfu0_lh and vfu0_ll are bypassed; the operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu1 are c0, d0, c0, d0, b1, d1, a1, c1, where c0 and d0 are Multiplexing, a1, c1 are bypassed from the floating point and vector execution unit vfu0, the source operands of the multiplication and addition unit vfu1_hh are c0, a1, the source operands of the multiplication and addition unit vfu1_hl are d0, c1, the source operands of the multiplication and addition unit vfu1_lh are d0, d1, and the source operands of the multiplication and addition unit vfu1_ll are c0, b1, among which the source operands of the multiplication and addition unit vfu1_lh and the multiplication and addition unit vfu1_ll are bypassed;
[0064] STEP2: The operands are respectively entered into the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll of the floating-point and vector execution components vfu0 and vfu1 for multiplication operation, and at this time, the floating-point addition modules FADD in the multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll are all in an idle state (but with the flow of data, the calculation will also flow);
[0065] STEP3: The multiplication and addition components vfu0_hh and vfu0_hl respectively output the multiplication results to the floating-point addition modules FADD in the multiplication and addition components vfu0_lh and vfu0_ll through the result bus bypass, and the data obtained in STEP2 are added by the floating-point addition module FADD to obtain the final result; at this time, if it is necessary to synchronously pipeline the next double-precision matrix inner product operation, the multiplication operation in the next double-precision matrix inner product operation can be synchronously pipelined through the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array;
[0066] STEP 4: The floating point and vector execution components vfu0 and vfu1 respectively output two final results through the result bus, so that the floating point and vector execution components vfu0 and vfu1 output four results at the same time, and the four results are concatenated to obtain the final double-precision matrix inner product operation result.
[0067] In addition, the method of this embodiment also includes the step of performing a double-precision matrix outer product operation as shown in the following formula:
[0068]
[0069] In the above formula, a0, b0, c0, d0 are the four operands of the first double precision matrix, a1, b1, c1, d1 are the four operands of the second double precision matrix, and a2, b2, c2, d2 are the elements in the result matrix obtained by the operation; according to the definition of the outer product operation, a pair of 2×2 matrices are multiplied, such as Figure 1 As shown, intermediate result matrix 0 and intermediate result matrix 1 will be generated in two STEPs, and the final calculation result of the matrix is equal to the sum of the two intermediate result matrices. Compared with the inner product operation, in the outer product operation, the operand does not need to be bypassed from another vfu, and only needs to be calculated in the current vfu to obtain the intermediate result. Due to the operation characteristics of the outer product matrix, it is necessary to wait for the calculation result of the next intermediate result before the final addition operation can be performed, such as Figure 3 Therefore, it is necessary to add a "temporary register reg" so that the intermediate result of the first multiplication operation can wait in the register until the next multiplication calculation is completed, and the addition operation is completed in the floating-point addition module FADD to obtain the final result. Compared with the inner product operation operands "borrowed" from other vfus, due to the characteristics of the outer product operation and the temporary storage function of the register, it is not necessary to "borrow" from other vfus, only the source operands of the vfu need to be reused. When the computing resources are doubled, only one vfu is required for the matrix outer product calculation, and two vfus can calculate two pairs of matrices at the same time. Its source operands need to enter the calculation unit in two beats. And the steps for the floating-point and vector execution unit vfu0 to perform double-precision matrix outer product operations include:
[0070] STEP1: Prepare data. The source operands of the floating-point and vector execution unit vfu0 are provided by the reuse of the source operands sent to the floating-point and vector execution unit vfu0. The operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu0 are a0, c0, a0, c0, a1, b1, a1, b1, among which the source operands a0, c0, a1, b1 are reused. The source operands of the multiplication and addition unit vfu0_hh are a0, a1, The source operands of vfu0_hl are b1 and c0, the source operands of the multiplication and addition component vfu0_lh are c0 and a1, and the source operands of the multiplication and addition component vfu0_ll are a0 and b1. The intermediate result matrix result 0 is calculated from these four source operands, wherein the source operands of the multiplication and addition component vfu0_lh and the multiplication and addition component vfu0_ll are both bypassed; the intermediate result matrix result 0 of each multiplication and addition component is temporarily stored in the temporary register reg of each multiplication and addition component;
[0071] STEP2: Calculate the intermediate result matrix result 1. According to the data organization method prepared in step STEP1, the source operands enter the operation unit in turn for operation: the operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu0 are b0, d0, b0, d0, c1, d1, c1, d1, among which the source operands b0, d0, c1, d1 are reused, the source operands of the multiplication and addition unit vfu0_hh are b0 and c1, the source operands of the multiplication and addition unit vfu0_hl are d1 and d0, the source operands of the multiplication and addition unit vfu0_lh are d0 and c1, and the source operands of the multiplication and addition unit vfu0_ll are b0 and d1. The intermediate result matrix result 1 (such as Figure 3 As shown in the reference numeral 14 in FIG.
[0072] STEP3: The intermediate result matrix result 0 (such as Figure 3 The multiplication result obtained in step STEP2 is added by the floating-point addition module FADD in the multiplication-addition component to obtain the addition calculation result.
[0073] STEP 4: Output four addition calculation results simultaneously through the result output bypass of the floating point and vector execution unit vfu0, and output the four addition calculation results in the correct order through data shuffling.
[0074] This embodiment also includes the step of performing the single-precision matrix inner product operation shown in the following formula:
[0075]
[0076] In the above formula, a0, b0, c0, d0 are the 4 operands of the first single-precision matrix, a1, b1, c1, d1 are the 4 operands of the second single-precision matrix, and a2, b2, c2, d2 are the elements in the result matrix obtained by the operation; in the case of 2×128 data width, 2×2 calculation can be achieved without expanding the operation unit. Unlike 64-bit, 32-bit only implements matrix multiplication by vector multiplication. Its advantage is that the data is regular and simple, no bypass is required, the data flow is clear and the pipeline capability is strong. All operands can be covered by one operand. The floating-point and vector execution units vfu0 and vfu1 are composed of Figure 2 The steps of performing single-precision matrix inner product operations by the floating-point and vector execution units vfu0 and vfu1 include:
[0077] STEP1: Prepare data: Figure 2 As shown, according to the original data path, that is, vfu1 and vfu0 share two elements, there is no need to add a bypass from vfu0_h to vfu1_h. The elements can be input to the corresponding computing components of the two vfus in pairs. In one set of operands, the operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add unit vfu0_h are a0, a1, the source operands of the multiply-add unit vfu0_l are b0, c1, the source operands of the multiply-add unit vfu1_h are b0, d1, and the source operands of the multiply-add unit vfu1_l are a0, b1; in the next set of operands, the source operand stack remains unchanged, the source operands of the multiply-add unit vfu0_h are c0, a1, the source operands of the multiply-add unit vfu0_l are d0, c1, the source operands of the multiply-add unit vfu1_h are d0, d1, and the source operands of the v multiply-add unit fu1_l are c0, b1;
[0078] STEP2: The operands prepared in step STEP1 are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, and the next set of operands are prepared for calculation;
[0079] STEP3: While the next pair of operands are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, the first pair of operands are bypassed to the floating-point addition module FADD of the next multiplication-addition component through the result bus for addition operation after multiplication, so that the multiplication-addition component vfu0_h and the multiplication-addition component vfu1_h bypass and output the multiplication results to the floating-point addition modules FADD of the multiplication-addition component vfu0_l and the multiplication-addition component vfu1_l respectively through the result bus, and the data calculated in the previous step STEP2 are added in the floating-point addition modules FADD in the multiplication-addition components vfu1_l and the multiplication-addition components vfu0_l to obtain the final result;
[0080] STEP4: Output the two final results calculated in step STEP3, and at the same time, after the second pair of operands are multiplied, bypass them through the result bus to the floating-point addition module FADD of the next operation component for addition operation;
[0081] STEP5: Output the remaining two final results calculated in step STEP4.
[0082] In addition, this embodiment also includes the step of performing the single-precision matrix outer product operation shown in the following formula:
[0083]
[0084] In the above formula, a0, b0, c0, d0 are the 4 operands of the first double-precision matrix, a1, b1, c1, d1 are the 4 operands of the second double-precision matrix, and a2, b2, c2, d2 are the elements in the result matrix obtained by the operation; the structure of the outer product and the inner product is the same, and the 32-bit operation will calculate a pair of 2×2 matrices at a width of 2×128. The source operands do not need to be bypassed, but the organization of the operands changes again. Compared with the inner product, the second pair of source operands will be directly sent to the first pair of operation components for accumulation. The steps for the floating-point and vector execution units vfu0 and vfu1 to perform single-precision matrix outer product operations include:
[0085] STEP1: Data preparation: The operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add component vfu0_h are a0, a1, the source operands of the multiply-add component vfu0_l are b1, c0, the source operands of the multiply-add component vfu1_h are c0, a1, and the source operands of the multiply-add component vfu1_l are a0, b1; in the next group of operands, the source operands of the multiply-add component vfu0_h are b0, c1, the source operands of the multiply-add component vfu0_l are d0, d1, the source operands of the multiply-add component vfu1_h are d0, c1, and the source operands of the multiply-add component vfu1_l are b0, d1; the intermediate result matrix result 0 generated by each multiply-add component according to the source operands;
[0086] STEP2: When the intermediate result matrix result 0 has entered the calculation unit for calculation, the intermediate result matrix result 1 of the next set of operands is calculated at the same time. According to the data organization method prepared in step STEP1, the source operands enter the calculation unit for calculation in sequence:
[0087] STEP3: Each multiplication result obtained in step STEP2 is temporarily stored in the temporary register reg, and at the same time, the next pair of operands enters the floating-point multiplication module FMUL of each multiplication-addition component for calculation to obtain the intermediate result matrix result 1;
[0088] STEP4: The intermediate result matrix result 0 calculated in step STEP1 and the intermediate result matrix result 1 calculated in step STEP2 are added in the floating-point addition module FADD of each multiplication and addition component to obtain the final result.
[0089] STEP5: Output the final result of the matrix through the result bypass. Both the floating point and vector execution units vfu0 and vfu1 output 4 results at the same time.
[0090] In summary, the method of this embodiment fills the gap that general-purpose processors cannot directly calculate matrix multiplication while being compatible with existing structures, and supports common floating-point formats such as fp64 and fp32. At present, the main method for general-purpose processors to calculate matrix multiplication is through vector multiplication, which has low computational efficiency, complex instructions, and cumbersome control. The present invention balances the contradiction between operands and functional components by reusing source operands, changing bypass structures, and changing the data flow organization form, thereby improving the resource utilization rate of hardware and the energy consumption ratio. In the context of large applications, matrix multiplication instructions are implemented, and the function of direct matrix operations compatible with SIMD structures in general-purpose processors is implemented, and all operations involved can be completed in VFU, avoiding the cost increase caused by large-scale modifications to the structure. The method of this embodiment can perform inner and outer product calculations of matrices in terms of matrix calculation, and also leaves room for subsequent optimization of commonly used sparse matrices.
[0091] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0092] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A computing unit compatible with SIMD calculation and floating-point matrix multiplication, characterized in that: The invention relates to a floating point and vector execution unit vfu0 and vfu1 having the same structure and a reusable operand stack, wherein the floating point and vector execution unit vfu0 comprises four multiplication and addition units vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array, wherein the multiplication and addition unit vfu0_hh and the multiplication and addition unit vfu0_ll have a bypass channel for inputting the same first operand, and the multiplication and addition unit vfu0_lh and the multiplication and addition unit vfu0_lh both have a bypass channel for inputting the same second operand, and the multiplication and addition unit vf u0_lh and the multiply-add unit vfu0_hl both have a bypass channel for inputting the same third operand, the multiply-add unit vfu0_hl and the multiply-add unit vfu0_ll both have a bypass channel for inputting the same fourth operand, and the output end of the multiply-add unit vfu0_hh has a result bypass channel for outputting the result as the operand of the multiply-add unit vfu0_hl, and the output end of the multiply-add unit vfu0_lh has a result bypass channel for outputting the result as the operand of the multiply-add unit vfu0_ll; The floating point and vector execution units vfu0 and vfu1 each include a row source operand stack with a bit width of 128 bits and a source column operand stack with a bit width of 128 bits, which can be reused mutually. When the operation unit supports the fp64 data format, the 2×128-bit data width of the row operand stack and the column operand stack is divided into a 4×64-bit data width to support a maximum of 8 source operands for multiplication and addition operations; when the operation unit supports the fp32 data format, the 2×128-bit data width of the row source operand stack and the column source operand stack is divided into an 8×32-bit data width to support a maximum of 16 source operands for multiplication and addition operations; The multiplication and addition component includes a floating-point multiplication module FMUL, a temporary register reg, a selector MUX and a floating-point addition module FADD. The floating-point multiplication module FMUL is used to perform floating-point multiplication on two input operands to obtain a floating-point multiplication result, and output it to the floating-point addition module FADD as an operand of the floating-point addition module FADD. At the same time, the floating-point multiplication result is temporarily stored in the temporary register reg as an operand of the floating-point addition module FADD, and another operand from the outside is selected by the selector MUX to input into the floating-point addition module FADD to obtain a corresponding addition operation result and output it.
2. A processor, comprising an instruction issuing unit and an instruction executing unit connected to each other, characterized in that: The instruction execution unit includes the operation unit compatible with SIMD calculation and floating-point matrix multiplication as described in claim 1.
3. A computing acceleration card, comprising an acceleration card body and a processor disposed on the acceleration card body, characterized in that: The processor is the processor according to claim 2.
4. A computer device comprising a processor and a memory connected to each other, characterized in that: The processor is the processor according to claim 2.
5. An application method of the computing unit compatible with SIMD calculation and floating-point matrix multiplication according to claim 1, characterized in that: The steps include performing the double-precision matrix inner product operation shown in the following equation: In the above formula, a0, b0, c0, d0 are four operands of the first double precision matrix, a1, b1, c1, d1 are four operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of performing the double precision matrix inner product operation by the floating point and vector execution units vfu0 and vfu1 include: STEP1: Prepare data. The source operands of the floating-point and vector execution unit vfu0 are provided by the reuse of the source operands sent to the floating-point and vector execution unit vfu0 and the two source operands sent from the floating-point and vector execution unit vfu1 after bypassing. The source operands of the floating-point and vector execution unit vfu1 are provided by the reuse of the source operands sent to the floating-point and vector execution unit vfu1 and the two source operands sent from the floating-point and vector execution unit vfu0 after bypassing. The operands in the row source operand stack and the column source operand stack of the floating-point and vector execution unit vfu0 are a0, b0, a0, b0, a1, c1, b1, d1, among which a0 and b0 are reused, b1 and d1 are bypassed from the floating-point and vector execution unit vfu1, and the source operands of the multiplication and addition unit vfu0_hh are a0, a1, The source operands of the multiply-add unit vfu0_hl are b0 and c1, the source operands of the multiply-add unit vfu0_lh are b0 and d1, the source operands of the multiply-add unit vfu0_ll are a0 and b1, and the source operands of the multiply-add units vfu0_lh and vfu0_ll are all bypassed; the operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu1 are c0, d0, c0, d0, b1, d1, a1, c1, of which c0 and d0 are multiplexed, and a1 and c1 are bypassed from the floating-point and vector execution unit vfu0, the source operands of the multiply-add unit vfu1_hh are c0 and a1, the source operands of the multiply-add unit vfu1_hl are d0 and c1, the source operands of the multiply-add unit vfu1_lh are d0 and d1, The source operands of the multiply-add component vfu1_ll are c0 and b1, wherein the source operands of the multiply-add component vfu1_lh and the multiply-add component vfu1_ll are both bypassed; STEP2: The operands are respectively entered into the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll of the floating-point and vector execution components vfu0 and vfu1 for multiplication operation, and at this time, the floating-point addition modules FADD in the multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll are all in an idle state; STEP3: The multiplication and addition components vfu0_hh and vfu0_hl respectively output the multiplication results to the floating-point addition modules FADD in the multiplication and addition components vfu0_lh and vfu0_ll through the result bus bypass, and the data obtained in STEP2 are added by the floating-point addition module FADD to obtain the final result; at this time, if it is necessary to synchronously pipeline the next double-precision matrix inner product operation, the multiplication operation in the next double-precision matrix inner product operation can be synchronously pipelined through the floating-point multiplication modules FMUL in the four multiplication and addition components vfu0_hh, vfu0_hl, vfu0_lh and vfu0_ll arranged in an array; STEP 4: The floating point and vector execution components vfu0 and vfu1 respectively output two final results through the result bus, so that the floating point and vector execution components vfu0 and vfu1 output four results at the same time, and the four results are concatenated to obtain the final double-precision matrix inner product operation result.
6. The method for applying the computing unit compatible with SIMD calculation and floating-point matrix multiplication according to claim 5, characterized in that: The steps include performing the double-precision matrix outer product operation shown in the following equation: In the above formula, a0, b0, c0, d0 are 4 operands of the first double precision matrix, a1, b1, c1, d1 are 4 operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of performing the double precision matrix outer product operation by the floating point and vector execution unit vfu0 include: STEP1: Prepare data. The source operands of the floating-point and vector execution unit vfu0 are provided by the reuse of the source operands sent to the floating-point and vector execution unit vfu0. The operands in the row source operand stack and column source operand stack of the floating-point and vector execution unit vfu0 are a0, c0, a0, c0, a1, b1, a1, b1, among which the source operands a0, c0, a1, b1 are reused. The source operands of the multiplication and addition unit vfu0_hh are a0, a1, the source operands of vfu0_hl are b1, c0, the source operands of the multiplication and addition unit vfu0_lh are c0, a1, The source operands of the multiply-add component vfu0_ll are a0 and b1, and the intermediate result matrix result 0 is calculated from these four source operands, wherein the source operands of the multiply-add component vfu0_lh and the multiply-add component vfu0_ll are bypassed; the intermediate result matrix result 0 of each multiply-add component is temporarily stored in the temporary register reg of each multiply-add component; STEP2: Calculate the intermediate result matrix result 1. According to the data organization method prepared in step STEP1, the source operands enter the operation unit in sequence for operation: the operands in the row source operand stack and the column source operand stack of the floating-point and vector execution unit vfu0 are b0, d0, b0, d0, c1, d1, c1, d1, where the source operands b0, d0, c1, d1 are reused, the source operands of the multiplication and addition unit vfu0_hh are b0 and c1, the source operands of the multiplication and addition unit vfu0_hl are d1 and d0, the source operands of the multiplication and addition unit vfu0_lh are d0 and c1, and the source operands of the multiplication and addition unit vfu0_ll are b0 and d1. The intermediate result matrix result 1 is calculated from these four source operands; STEP3: Add the intermediate result matrix result 0 temporarily stored in the temporary register reg of each multiplication-addition component and the multiplication result obtained in step STEP2 through the floating-point addition module FADD in the multiplication-addition component to obtain the addition calculation result; STEP 4: Output four addition calculation results simultaneously through the result output bypass of the floating point and vector execution unit vfu0, and output the four addition calculation results in the correct order through data shuffling.
7. The application method of the computing unit compatible with SIMD calculation and floating-point matrix multiplication according to claim 6, characterized in that: The steps include performing the single-precision matrix inner product operation shown in the following equation: In the above formula, a0, b0, c0, d0 are four operands of the first single-precision matrix, a1, b1, c1, d1 are four operands of the second single-precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of the floating-point and vector execution units vfu0 and vfu1 performing the single-precision matrix inner product operation include: STEP1: Prepare data: In one set of operands, the operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add unit vfu0_h are a0, a1, the source operands of the multiply-add unit vfu0_l are b0, c1, the source operands of the multiply-add unit vfu1_h are b0, d1, and the source operands of the multiply-add unit vfu1_l are a0, b1; in the next set of operands, the source operand stack remains unchanged, the source operands of the multiply-add unit vfu0_h are c0, a1, the source operands of the multiply-add unit vfu0_l are d0, c1, the source operands of the multiply-add unit vfu1_h are d0, d1, and the source operands of the v multiply-add unit fu1_l are c0, b1; STEP2: The operands prepared in step STEP1 are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, and the next set of operands are prepared for calculation; STEP3: While the next pair of operands are calculated in the floating-point multiplication modules FMUL of each multiplication-addition component, the first pair of operands are bypassed to the floating-point addition module FADD of the next multiplication-addition component through the result bus for addition operation after multiplication, so that the multiplication-addition component vfu0_h and the multiplication-addition component vfu1_h bypass and output the multiplication results to the floating-point addition modules FADD of the multiplication-addition component vfu0_l and the multiplication-addition component vfu1_l respectively through the result bus, and the data calculated in the previous step STEP2 are added in the floating-point addition modules FADD in the multiplication-addition components vfu1_l and the multiplication-addition components vfu0_l to obtain the final result; STEP4: Output the two final results calculated in step STEP3, and at the same time, after the second pair of operands are multiplied, bypass them through the result bus to the floating-point addition module FADD of the next operation component for addition operation; STEP5: Output the remaining two final results calculated in step STEP4.
8. The method for applying the computing unit compatible with SIMD calculation and floating-point matrix multiplication according to claim 7, characterized in that: The steps include performing the single-precision matrix outer product operation shown in the following equation: In the above formula, a0, b0, c0, d0 are four operands of the first double precision matrix, a1, b1, c1, d1 are four operands of the second double precision matrix, and a2, b2, c2, d2 are elements in the result matrix obtained by the operation; and the steps of the floating point and vector execution units vfu0 and vfu1 performing the single precision matrix outer product operation include: STEP1: Data preparation: The operands of the row source operand stack are a0, b0, c0, d0, the operands of the column source operand stack are a1, b1, c1, d1, the source operands of the multiply-add component vfu0_h are a0, a1, the source operands of the multiply-add component vfu0_l are b1, c0, the source operands of the multiply-add component vfu1_h are c0, a1, and the source operands of the multiply-add component vfu1_l are a0, b1; in the next group of operands, the source operands of the multiply-add component vfu0_h are b0, c1, the source operands of the multiply-add component vfu0_l are d0, d1, the source operands of the multiply-add component vfu1_h are d0, c1, and the source operands of the multiply-add component vfu1_l are b0, d1; the intermediate result matrix result 0 generated by each multiply-add component according to the source operands; STEP2: When the intermediate result matrix result 0 has entered the calculation unit for calculation, the intermediate result matrix result 1 of the next set of operands is calculated at the same time. According to the data organization method prepared in step STEP1, the source operands enter the calculation unit for calculation in sequence: STEP3: Each multiplication result obtained in step STEP2 is temporarily stored in the temporary register reg, and at the same time, the next pair of operands enters the floating-point multiplication module FMUL of each multiplication-addition component for calculation to obtain the intermediate result matrix result 1; STEP4: The intermediate result matrix result 0 calculated in step STEP1 and the intermediate result matrix result 1 calculated in step STEP2 are added in the floating-point addition module FADD of each multiplication and addition component to obtain the final result; STEP5: Output the final result of the matrix through the result bypass. Both the floating point and vector execution units vfu0 and vfu1 output 4 final results at the same time.
