Processor device and computation method
The processor device addresses the memory bandwidth bottleneck in large-scale matrix multiplications by using a matrix expansion control unit and vector processor to optimize memory access and calculation efficiency, reducing the data load ratio and enhancing performance with increasing matrix sizes.
Patent Information
- Application Number
- PCT/JP2024/010054
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-03-14
- Publication Date
- 2024-09-26
AI Technical Summary
Existing processor devices face a bottleneck in memory bandwidth due to the increasing data volumes associated with large-scale matrix multiplications, which are common in applications like Large Language Models, despite advances in process technology that increase computational intensity.
A processor device with a matrix expansion control unit and vector processor that stores and operates on row and column vectors in dedicated registers, optimizing memory access and calculation efficiency by reducing the data load ratio through specific instructions for matrix operations.
This configuration enhances memory bandwidth efficiency and arithmetic performance by minimizing memory input/output operations, effectively addressing the memory bandwidth bottleneck and improving calculation performance with increasing matrix sizes.
Smart Images

Figure JP2024010054_26092024_PF_FP
Abstract
Description
Processor device and calculation method
[0001] This disclosure relates to a processor apparatus and a method of operation.
[0002] With advances in process technology, the number of arithmetic units that can be implemented on an LSI (large-scale integrated circuit) with the same chip area increases exponentially because it is proportional to the area, whereas the memory bandwidth via the I / O of the LSI increases in proportion to the length of the LSI's edges. Because the amount of data required for calculations increases in proportion to the number of arithmetic units, the bottleneck in memory bandwidth is accelerating.
[0003] For example, in the field of generative AI, which has seen rapid growth in recent years, LLMs (Large Language Models) have been used. In LLMs, matrix-matrix multiplication (hereinafter referred to as "matrix multiplication"), which is the multiplication of large matrices, such as several thousand rows and several thousand columns, accounts for a large portion of the computational load.
[0004] The matrix product of two square matrices with L rows and L columns is L×L×L=L 3 Multiplication of and about L 3 It is made up of the sum of about 2 × L 3 On the other hand, the amount of data required for loading the input matrix data required for matrix multiplication from memory is 2×L 2 Therefore, calculation intensity = calculation amount / data amount = approximately L, and by increasing the matrix size L of L x L and making the matrix calculator larger, it is possible to reduce the ratio of the data load amount to the calculation amount (approximately 1 / L), and it is possible to offset the data amount required for the calculation amount that increases in proportion to the progress of process technology.
[0005] In LLM, large-scale matrix multiplication, such as several thousand rows by several thousand columns, accounts for the majority of the computational load, and computational devices and computational methods for efficiently performing such matrix multiplication have been developed. Processors capable of performing matrix multiplication have also been developed. However, existing general processor devices are unable to take advantage of the high computational intensity of large-scale matrix multiplication, and are unable to address the issue of memory bandwidth bottlenecks caused by data volumes that increase in proportion to advances in process technology.
[0006] Patent Document 1 discloses a technology for speeding up large-scale matrix and vector operations. The technology stores data to be used in an operation in the order in which it should be performed in ring buffers of an input storage circuit and a coefficient storage circuit corresponding to the operation unit, and prepares only the elements of the input vector and the elements of the row or column vector constituting the coefficient matrix required for the operation of the operation unit in the order in which it should be performed. This operation circuit enables high-speed operations because it can perform operations in response to a data access request from the operation unit without rearranging the elements of the input vector. However, the technology disclosed in Patent Document 1 does not eliminate the bottleneck of memory bandwidth.
[0007] As described above, the calculation intensity = calculation amount / data amount = approximately L, and by increasing the matrix size L (L×L) and enlarging the matrix calculator, the ratio of the data load amount to the calculation amount (1 / L) can be reduced. However, GPGPUs and the like are equipped with a large number of matrix multiplication calculators of small sizes, such as 4×4 matrices, which increases the ratio of the load amount to the calculation amount, and memory bandwidth becomes a bottleneck.
[0008] International Publication No. 2019 / 077933
[0009] One of the purposes of this disclosure is to provide a technique for reducing the ratio of the amount of data loaded into memory to the amount of calculation.
[0010] This disclosure provides a processor device and a computing method that can solve the above-mentioned problems.
[0011] According to one aspect of this disclosure, a processor device includes an input / output means for inputting and outputting data to and from a memory, a vector storage means which is an area in which memory elements are arranged in columns, an arithmetic means for performing operations between row vectors and column vectors, and a matrix storage means which is an area in which memory elements are arranged in a matrix, wherein the vector storage means stores the row vectors and column vectors loaded from the memory by the input / output means, the arithmetic means performs operations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means stores the results of the operations.
[0012] According to one aspect of this disclosure, an arithmetic method stores row and column vectors loaded from memory in a vector register, which is an area of a processor device where memory elements are arranged in a column, the processor device performs an operation on the row and column vectors, stores the result of the operation in a matrix register, which is an area of the processor device where memory elements are arranged in a matrix, and the processor device outputs the result of the operation stored in the matrix register to the memory.
[0013] According to the processor device and the calculation method of the present disclosure, it is possible to reduce the ratio of the amount of data loaded into memory to the amount of calculation.
[0014] FIG. 1 is a schematic configuration diagram showing an example of a processor device. FIG. 2 is a detailed configuration diagram showing an example of a processor device. FIG. 3 is a diagram showing an example of a matrix multiply-add operation. FIG. 4 is a diagram showing an example of a matrix register and a matrix calculator. FIG. 5 is a first diagram explaining the operation of the matrix calculator and the matrix register. FIG. 6 is a second diagram explaining the operation of the matrix calculator and the matrix register. FIG. 7 is a third diagram explaining the operation of the matrix calculator and the matrix register. FIG. 8 is a fourth diagram explaining the operation of the matrix calculator and the matrix register. FIG. 9 is a second schematic configuration diagram showing an example of a processor device. FIG. 10 is a third schematic configuration diagram showing an example of a processor device. FIG. 11 is a flowchart showing an example of the operation of the processor device.
[0015] Hereinafter, a processor device according to each embodiment of the present disclosure will be described with reference to the drawings. In the drawings used in the following description, the description of parts not related to the present disclosure may be omitted or not shown. The same or equivalent parts in all drawings will be denoted by the same reference numerals, and common descriptions may be omitted.
[0016] 1 is a schematic configuration diagram showing an example of a processor device 1. The processor device 1 includes a matrix expansion control unit 10 and a vector processor device 20 with a vector register length L.
[0017] The matrix expansion control unit 10 includes a matrix register 110 with L rows and L columns, and a matrix calculator 120. When the vector register 310 has L columns, the matrix register 110 stores an L-row by L-column matrix. The matrix calculator 120 includes an L-column multiply-accumulator. The matrix calculator 120 and the matrix register 110 are connected, with the multiply-accumulator for the i-th column corresponding to the i-th column matrix register 110. The calculator interface control unit 150 is provided across the matrix expansion control unit 10 and the vector expansion control unit 30. The matrix calculator 120 is connected to the vector register 310 of the vector expansion control unit 30 of the vector processor unit 20 by the calculator interface control unit 150. The matrix register access control unit 160 is provided across the matrix expansion control unit 10 and the vector expansion control unit 30. The matrix register 110 is connected to the vector register 310 of the vector expansion control unit 30 of the vector processor unit 20 by the matrix register access control unit 160. Although the following description will be given taking as an example a case where the matrix expansion control unit 10 includes one matrix register 110, the matrix expansion control unit 10 may include multiple matrix registers 110.
[0018] The vector processor device 20 includes a vector extension control unit 30 and a RISC (reduced instruction set computer) type scalar processor 40. The scalar processor 40 includes an instruction control unit 490 that executes program instructions, a scalar register 410, a scalar arithmetic unit 420, and a load / store control unit 480 that operate in response to the program instructions. The load / store control unit 480 is connected to an external memory 60. The vector extension control unit 30 includes a plurality of vector registers 310 with a register length L (L columns) and a vector arithmetic unit 320. The plurality of vector registers 310 are connected to the load / store control unit 480. The vector extension control unit 30 is controlled by the instruction control unit 490 in response to vector instructions. The configurations of the vector processor device 20, its components, the RISC type scalar processor 40, and the vector extension control unit 30, are well-known technologies that are included in general processor devices. In contrast, general processor devices do not include the configurations of the matrix extension control unit 10, matrix register access control unit 160, and arithmetic unit interface control unit 150.
[0019] 2 shows a detailed configuration of the processor unit 1. The matrix register 110 has L×L registers 111 arranged in L rows and L columns. The matrix calculator 120 has L columns of product-accumulators 121. One vector register 310 has L columns of registers 311. The vector calculator 320 has one product-accumulator 321.
[0020] As will be described later, in this embodiment, the matrix calculator 120 calculates the cross product of a vector, which is an L row by L column matrix, from two pieces of vector data of vector length L (for example, the column vector aij and the row vector bij in Figure 4), and stores the intermediate results of the matrix multiplication in the matrix register 110 (this will be described later with reference to Figures 6 to 9), thereby setting the ratio of the amount of data to the amount of calculation in the matrix multiplication to the theoretically minimum of 1 / L, thereby improving memory bandwidth efficiency.
[0021] Next, the operation of the processor device 1 will be explained to demonstrate that the memory bandwidth efficiency is improved by the above configuration.
[0022] (General Operation: Scalar Operation) First, the general operation of the vector processor unit 20 will be described with reference to Figure 1. The scalar processor 40 is a RISC type processor, and scalar data required for a scalar operation is loaded by the load / store control unit 480 through connection 61 of memory 60 in response to a scalar load instruction, and stored in the scalar register 410 through connection 461. The scalar operation unit 420 reads the scalar data to be used in the operation from the scalar register 410 through connection 451, performs the operation, and stores the operation result in the scalar register 410 through connection 452. The load / store control unit 480 reads the final operation result data through connection 462 of the scalar register 410 in response to a scalar store instruction, and stores it in the memory 60 via connection 62.
[0023] (General Operation: Vector Operation) Next, the general operation of the vector extension control unit 30 will be described. The instruction control unit 490 determines whether an instruction is a vector instruction (a vector operation instruction). Vector data consists of up to L pieces of data, defined by the register length L of the vector register 310. If a vector instruction is determined to be a vector instruction, the vector data required for the vector operation is first loaded via connection 61 of memory 60 by a vector load instruction from the load / store control unit 480, and stored in the vector register 310 via connection 461. The vector calculator 320 successively reads L pieces of data to be used in the operation from the vector register 310 via connection 351, performs L operations, and stores the operation results in the vector register 310 via connection 352. The L pieces of vector data resulting from the operation are read by the load / store control unit 480 via connection 462 of the vector register 310 by a vector store instruction, and the L pieces of data are stored in the memory 60 via connection 62. The operations of the vector processor device 20 and its constituent elements, the RISC-type scalar processor 40 and the vector extension control unit 30, described here, are well-known techniques.
[0024] (Operation According to the Present Embodiment) The operation of the matrix expansion control unit 10 according to the present embodiment will be described with reference to FIG. 1 and detailed diagram 2. First, the following three instructions are defined as instructions related to the matrix expansion control unit 10, matrix register access control unit 160, and arithmetic unit interface control unit 150 according to the present embodiment. These are issued by the instruction control unit 490. (1) Vector Cross Product Instruction (VOP): VOP is an instruction to perform an operation using two L pieces of vector data in the vector register 310 and one L×L matrix data in the matrix register 110, and to write the resulting L×L matrix to the matrix register 110. (2) Vector Matrix Store Instruction (VSTM): VSTM is an instruction to write one piece of vector data in the vector register 310 to a row or column of the L×L matrix in the matrix register 110. (3) Vector Matrix Load Instruction (VLDM): VLDM is an instruction to write the row or column of the L×L matrix in the matrix register 110 to the vector data in the vector register 310.
[0025] Next, the operation of the processor device 1 of this embodiment will be described using a specific example of a matrix multiplication operation. As shown in Figure 3, A, B, C, and D are each matrices of L rows and L columns, and the elements of the i-th row and j-th column of each matrix are aij, bij, cij, and dij, respectively. The operation will be described using an example in which the matrix multiply-and-accumulate operation D = A x B + C is performed. It is assumed that matrices A, B, and C are stored in memory 60.
[0026] (Overall Flow) First, a vector load instruction is used to load vector data VC1 (c11, c21, c31, ..., cL1) for the first column of matrix C from memory 60 into vector register 310. Next, a vector matrix store instruction (VSTM) is used to write vector data VC1 from vector register 310 into the first column of matrix register 110 via connection 161. Thereafter, the following processes (a) and (b) are repeated in a similar manner to write data of matrix C into matrix register 110. (a) Vector data VCj (c1j, c2j, c3j, ..., cLj) for the jth column of matrix C is loaded into vector register 310. (b) Next, a vector matrix store instruction (VSTM) is used to write vector data VCj from vector register 310 into the jth column of matrix register 110 via connection 161.
[0027] Next, a vector load instruction loads the vector data VA1 (a11, a21, a31, ..., aL1) of the first column of matrix A and the vector data VB1 (b11, b12, b13, ..., b1L) of the first row of matrix B from memory 60 into the vector register 310. The vector data VA1 and VB1 are each loaded into separate vector registers 310. Next, a vector cross product instruction (VOP) causes the matrix calculator 120 to read data VA1 and VB1 from the vector register 310 via connection 151, and further read matrix C from the matrix register 110 via connection 153, and execute the vector cross product operation (cij = ai1 × b1j + cij). Figure 4 shows an overview of the vector cross product operation. The intermediate result is written to the matrix register 110 via connection 154. Subsequently, vector load instructions load vector data VAk (a1k, a2k, a3k, ..., aLk) for the kth column of matrix A and vector data VBk (bk1, bk2, bk3, ..., bkL) for the kth row of matrix B from memory 60 into vector register 310. A vector cross product instruction (VOP) loads VAk and VBk from vector register 310 into matrix calculator 120 via connection 151, and further loads intermediate result matrix C (containing a mixture of the original elements of C and the intermediate result cij of the vector cross product operation) from matrix register 110 into matrix calculator 120 via connection 153, and executes vector cross product operation (cij = aik × bkj + cij). The intermediate result is written to matrix register 110 via connection 154. By executing the vector cross product operation each time k is changed up to L, the matrix product D = A × B + C is obtained.
[0028] To write the result matrix D to the memory 60, a vector matrix load instruction (VLDM) is used to fetch the vector data VD1 (d11, d21, c31, ..., dL1) of the first column of matrix D in the matrix register 110 into the vector register 310 via the connection 162, and a vector store instruction is used to write the vector data VD1 from the vector register 310 to the memory 60 via the connection 62. Subsequently, a vector matrix load instruction (VLDM) is used to fetch the vector data VDj (d1j, d2j, c3j, ..., dLj) of the jth column of matrix D in the matrix register 110 into the vector register 310, and a vector store instruction is used to write the vector data VDj from the vector register 310 to the memory 60. By repeating this process up to the Lth column, the matrix D can be written to the memory 60.
[0029] (Detailed Operation) The detailed operation of the matrix calculator 120 and the matrix register 110 will be described with reference to FIGS. 5 to 9 , taking the case where L=3 as an example. FIG. 5 shows the matrix calculator 120 and the matrix register 110 when L=3. The matrix expansion control unit 10 in FIG. 5 includes the matrix register 110 with 3×3 registers and the matrix calculator 120 with three columns of multiply-accumulators, one for each column of registers. In the following description, for convenience, each configuration is indicated by assigning column numbers 1 to the left column of the page, 2 to the center column, and 3 to the right column. For example, the left column of the matrix calculator will be referred to as matrix calculator 1, and the multiply-accumulator of matrix calculator 1 will be referred to as multiply-accumulator calculator 1. Furthermore, multiply-accumulator calculator 1 is connected to three input registers A1, B1, and C1, and one output register D1. Similarly, input registers A2, B2, and C2 and output register D2 are connected to multiply-accumulator 2 in the center column, and input registers A3, B3, and C3 and output register D3 are connected to multiply-accumulator 3 in the right column. Multiply-accumulators 1 to 3 perform the calculation d = a x b + c. In FIG. 5, it is assumed that matrix C has already been stored in matrix register 110, and that vector data VA1 (a11, a21, a31) in the first column of matrix A and vector data VB1 (b11, b12, b13) in the first row of matrix B are each stored in separate vector registers 310. Reference numerals are omitted in FIGS. 6 to 9.
[0030] (First Cycle Operation: Step 1) The first cycle operation (step 1) is shown on the left side of Fig. 6. The first element a11 of vector data VA1 is input to input register A1 of matrix calculator 1, the first element b11 of vector data VB1 is input to input register B1, and c11 of the first column and first row of matrix C is input to input register C1.
[0031] (Operation in Second Cycle: Step 2) The operation in the second cycle (step 2) is shown near the center of Fig. 6. The second element a21 of vector data VA1 is input to input register A1 of matrix calculator 1, input register B1 holds the first element b11 of vector data VB1, and c21 in the first column, second row of matrix C is input to input register C1. In addition, multiply-accumulator 1 of matrix calculator 1 executes multiply-accumulate operation d11 = a11 × b11 + c11 on the data a11, b11, and c11 stored in input registers A1, B1, and C1 in step 1, and stores resultant data d11 in output register D1. Then, data a11, which is the first element of vector data VA1 and is stored in input register A1 in the first column of the matrix calculator, is input to input register A2 of matrix calculator 2, data b12, the second element of vector data VB1, is input to input register B2, and data c12 in the second column, first row of matrix C is input to input register C2.
[0032] (Operation in the Third Cycle: Step 3) The operation in the third cycle (Step 3) is shown on the right side of FIG. 6 . The third element a31 of the vector data VA1 is input to the input register A1 of the matrix calculator 1, the input register B1 holds the first element b11 of the vector data VB1, and c31 in the first column, third row of the matrix C is input to the input register C1. Furthermore, the multiply-accumulate calculator 1 of the matrix calculator 1 executes a multiply-accumulate operation d21 = a21 × b11 + c21 on the data a21, b11, and c21 stored in the respective input registers in Step 2, and stores the resulting data d21 in the output register D1. Furthermore, the resulting data d11 stored in the output register D1 of the multiply-accumulate calculator 1 of the matrix calculator 1 is stored in the first column, first row of the matrix D of the matrix register 110.
[0033] Data a21, which is the second element of vector data VA1 and is stored in input register A1 of matrix calculator 1, is input to input register A2 of matrix calculator 2, input register B2 holds the first element b12 of vector data VB1, and input register C2 receives c22, which is in the second column and second row of matrix C. In step 2, multiply-accumulator 2 of matrix calculator 2 executes a multiply-accumulate operation d12=a11×b12+c12 on data a11, b12, and c12 stored in input registers A2, B2, and C2, respectively, and stores resultant data d12 in output register D2.
[0034] Data a11, which is the first element of vector data VA1 and is stored in the input register of matrix calculator 2, is input to input register A3 of matrix calculator 3, data b13, the third element of vector data VB1, is input to input register B3, and data c13, the third column, first row of matrix C, is input to input register C3.
[0035] (Operation in Fourth Cycle: Step 4) The operation in the fourth cycle (Step 4) is shown on the left side of FIG. 7. In Step 4, it is assumed that vector data VA2 (a12, a22, a32) in the second column of matrix A and vector data VB2 (b21, b21, b23) in the second row of matrix B are stored in vector register 310. The first element a12 of vector data VA2 is input to input register A1 of matrix calculator 1, the first element b21 of vector data VB2 is input to input register B1, and d11 in the first column and first row of matrix register 110 is input to input register C1. d11 is the data stored in Step 3. In Step 3, multiply-accumulator 1 of matrix calculator 1 executes a multiply-accumulate operation d31 = a31 × b11 + c31 on the data a31, b11, and c31 stored in input registers A1, B1, and C1, respectively, and stores the resulting data d31 in output register D1. In step 3, the result data d21 stored in the output register D1 of the multiply-and-accumulate unit 1 of the matrix calculator 1 is stored in the first column, second row of the matrix register 110.
[0036] Data a31, which is the third element of vector data VA1 and is stored in input register A1 of matrix calculator 1, is input to input register A2 of matrix calculator 2, input register B2 holds the second element b12 of vector data VB1, and input register C2 receives c32, which is in the second column and third row of matrix C. Furthermore, multiply-accumulator 2 of matrix calculator 2 executes a multiply-accumulate operation d22 = a21 × b12 + c22 on data a21, b12, and c22 stored in the input registers in step 3, and stores resultant data d22 in output register D2. Furthermore, resultant data d12 stored in output register D2 of multiply-accumulator 2 in the second column of matrix calculator 2 is stored in the second column and first row of matrix register 110.
[0037] Data a21, which is the second element of vector data VA1 and is stored in input register A2 of matrix calculator 2, is input to input register A3 of matrix calculator 3, input register B3 holds the third element b13 of vector data VB1, and input register C3 receives element c23 of matrix C in the third column, second row of matrix register 110. Furthermore, multiply-accumulate calculator 3 of matrix calculator 3 executes multiply-accumulate operation d13=a11×b13+c13 on data a11, b13, and c13 stored in the respective input registers in step 3, and stores resultant data d13 in output register D3.
[0038] (Operation in 5th Cycle: Step 5) The operation in the 5th cycle (Step 5) is shown near the center of FIG. 7. The second element a22 of vector data VA2 is input to input register A1 of matrix calculator 1, input register B1 holds the first element b21 of vector data VB2, and d21 in the first column, second row of matrix register 110 is input to input register C1. d21 is the value stored in step 4. Furthermore, multiply-accumulator 1 of matrix calculator 1 performs a multiply-accumulate operation e11 = a12 × b21 + d11 on the data a12, b21, and d11 stored in the input registers in the previous step, and stores the resulting data e11 in output register D1. Furthermore, the resulting data d31 stored in output register D1 of multiply-accumulator 1 of matrix calculator 1 is stored in the first column, third row of matrix register 110.
[0039] Data a12, which is the first element of vector data VA2 and is stored in input register A1 in the first column of the matrix calculator, is input to input register A2 of matrix calculator 2, data b22, the second element of vector data VB2, is input to input register B2, and data d12 in the second column, first row of matrix C is input to input register C2. Furthermore, multiply-accumulator 2 of matrix calculator 2 executes a multiply-accumulate operation d32 = a31 × b12 + c32 on data a31, b12, and c32 stored or held in the respective input registers in the previous step, and stores resultant data d32 in output register D2. Furthermore, resultant data d22 stored in output register D2 of multiply-accumulator 2 of matrix calculator 2 is stored in the second column, second row of matrix register 110.
[0040] Data a31, which is the third element of vector data VA1 and is stored in input register A2 of matrix calculator 2, is input to input register A3 of matrix calculator 3, input register B3 holds the third element b13 of vector data VB1, and input register C3 receives c33, which is in the third column and third row of matrix C. Furthermore, multiply-accumulator 3 of matrix calculator 3 performs a multiply-accumulate operation d23 = a21 × b13 + c23 on data a21, b13, and c23 stored in the respective input registers, and stores resultant data d23 in output register D3. Furthermore, matrix calculator 120 stores resultant data d13, which is stored in output register D3 of multiply-accumulator 3 of matrix calculator 3, in the third column and first row of matrix D of the matrix register.
[0041] Operations from the sixth cycle onwards are executed in a similar manner. The right side of Figure 7 shows the operation of the sixth cycle (step 6). The left side of Figure 8 shows the operation of the seventh cycle (step 7), the center shows the operation of the eighth cycle (step 8), and the right side shows the operation of the ninth cycle (step 9). In steps 7 to 9, it is assumed that vector data VA3 (a13, a23, a33) in the third column of matrix A and vector data VB3 (b31, b32, b33) in the third row of matrix B are stored in vector register 310. The operations are the same as those described above.
[0042] The left side of FIG. 9 shows the operation of the 10th cycle (step 10), the center left side shows the operation of the 11th cycle (step 11), the center right side shows the operation of the 12th cycle (step 12), and the right side shows the operation of the 13th cycle (step 13). From step 10 onwards, all data of the input matrices, matrices A and B, are input, and no new data is input to the input data in the first column of the matrix calculator. That is, in steps 10 to 13, vector data VA3 (a13, a23, a33) in the third column of matrix A and vector data VB3 (b31, b32, b33) in the third row of matrix B are stored in vector register 310. Finally, in step 13, result data f33 stored in output register D3 of multiply-accumulate calculator 3 of matrix calculator 3 is stored in the third column, third row of matrix register 110, completing the matrix multiplication operation A×B+C.
[0043] (Summary) Fig. 10 shows an example of a schematic configuration diagram of a processor device 1 that further simplifies the configurations shown in Figs. 1 and 2. The processor device 1 shown in Fig. 10 reads out an M-row, K-column matrix A and a K-row, N-column matrix B stored in a memory 60, calculates the matrix multiplication of matrix A and matrix B, and stores the resulting matrix C, which has M rows and N columns, in the memory 60. Here, assuming that L≥M, K, and N, the processor device 1 includes a matrix calculator 120 having L multiply-accumulators and a matrix register 110 having an L-row, L-column register for holding the matrix resulting from the calculation, and is connected to the memory 60 via memory interfaces 61 and 62. In the processor device 1, the efficiency of memory bandwidth and calculation performance can be improved by using the transistor resources of the LSI for the matrix register 110 and the matrix calculator 120. The processor unit 1 loads, via the memory interface 61, an M-row, K-column matrix A and a K-row, N-column matrix B stored in the memory 60, performs a matrix multiplication of matrix A and matrix B using the matrix calculator 120, and stores an M-row, N-column matrix C in the matrix register 110. The resulting matrix C is then stored in the memory 60 via the memory interface 62. More specifically, the processor unit 1 loads an M-row, 1-column vector of matrix A and a 1-row, N-column vector of matrix B, calculates the cross product of the two vectors, and stores the intermediate result of the matrix multiplication in the matrix register 110. By repeating this process K times, the matrix multiplication of matrix A and matrix B is calculated. Considering the matrix multiplication performed within a typical vector processor unit 20, the vector register 310 has only L columns, so only L calculation results can be stored. In this case, for example, in order to output the calculation result, I / O between the vector register 310 and the memory 60 occurs many times until the matrix multiplication of matrix A and matrix B is completed, and the I / O between the memory and the processor device is likely to become a bottleneck. In contrast, the processor device 1 of this embodiment is provided with a matrix register 110 having L rows and L columns, and therefore the values of each element of the calculation result matrix C having M rows and N columns can be stored in the matrix register 110. In addition, the processor device 1 is provided with a matrix calculator 120 having L column multiply-accumulators, and can perform calculations in parallel, thereby making it possible to speed up the matrix multiplication calculation compared to when calculations are performed by the vector calculator 320 alone.
[0044] Furthermore, based on the fact that the number of arithmetic units is proportional to the LSI area and the memory bandwidth is proportional to the edge length of the LSI, the ratio of the amount of data loaded to the amount of calculation is theoretically 1 / L. According to this embodiment, the process of reading L column vectors and L row vectors from memory 60 is repeated L times while performing a matrix multiplication operation in matrix calculator 120. After the matrix multiplication operation is completed, the process of storing the calculation results stored in matrix register 110 into memory 60, column by column, is repeated L times. Since no additional I / O with memory 60 occurs, memory bandwidth can be used efficiently with the minimum necessary I / O, and the ratio of data volume to the amount of calculation for matrix multiplication can be reduced to the theoretically minimum of 1 / L. In other words, according to this embodiment, the ratio of the amount of data loaded to memory to the amount of calculation can be reduced. Furthermore, by increasing L according to the integrated circuit, memory bandwidth efficiency and calculation performance can be improved.
[0045] (Effects) As explained above, in the processor device 1 according to this embodiment, in order to perform a matrix multiplication operation with L rows and L columns, the ratio of the amount of data to the amount of calculation for the matrix multiplication can be reduced to the theoretically minimum of 1 / L, thereby resolving the memory bandwidth shortage that occurs in the matrix multiplication. Furthermore, if the size of an LSI becomes 1 / A times as a result of the evolution of process technology, the number of transistors that can be integrated in an LSI of the same area will be A 2 The memory bandwidth is doubled, but by increasing L by A, a matrix register with AL rows and AL columns and A 2 × L multiplication and accumulation units can be implemented, and the calculation performance is A 2 As described above, according to this embodiment, the ratio of the amount of data to the amount of calculation is reduced to solve the memory bandwidth shortage, and it is possible to achieve an improvement in calculation performance in line with the evolution of process technology.
[0046] Although the above embodiment has been described using an example in which there is one matrix register 110, the matrix expansion control unit 10 may include multiple matrix registers 110. Multiple matrix registers 110 allow for more efficient matrix multiplication. For example, if there are two matrix registers (C, D), after a matrix product is calculated, the matrix product can be calculated for matrix register D while the calculation result in matrix register C is being transferred to memory 60. For example, it is also possible to calculate the matrix product A×B of matrix A, the result of the matrix multiplication, and matrix B stored in memory. In this case, only the row vectors of matrix B are loaded from memory 60, so the memory bandwidth can be halved. The same applies to the matrix product B×A. If there are three matrix registers 110, the matrix product A×B of matrix A, the result of the matrix multiplication, and matrix B, the result of the matrix multiplication, can be calculated without memory access, more effectively avoiding bottlenecks in memory bandwidth.
[0047] 11 is a third schematic diagram showing an example of a processor device. A processor device 800 includes input / output means 801 for inputting / outputting data to / from a memory, vector storage means 802 which is an area in which memory elements are arranged in rows or columns, calculation means 803 which performs calculations between row vectors and column vectors, and matrix storage means 804 which is an area in which memory elements are arranged in a matrix, wherein the vector storage means 802 stores row vectors and column vectors loaded from the memory by the input / output means, the calculation means 803 performs calculations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means 804 stores the results of the calculations.
[0048] 12 is a flowchart showing an example of the operation of the processor device 800. In the arithmetic processing by the processor device 800, a row vector and a column vector loaded from memory are stored in a vector register, which is an area of the processor where memory elements are arranged in a column shape (step S801), the processor performs an arithmetic operation on the row vector and the column vector (step S802), stores the result of the arithmetic operation in a matrix register, which is an area of the processor where memory elements are arranged in a matrix shape (step S803), and the processor device outputs the result of the arithmetic operation stored in the matrix register to the memory (step S804).
[0049] As described above, several embodiments according to this disclosure have been described, but all of these embodiments are presented as examples and are not intended to limit the scope of the invention. These embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope of the invention and its equivalents as defined in the claims, as well as in the scope and spirit of the invention.
[0050] <Additional Notes> The processor device and the calculation method described in the embodiment can be understood, for example, as follows.
[0051] (1) A processor device according to a first aspect comprises an input / output means for inputting and outputting data to and from a memory, a vector storage means which is an area in which memory elements are arranged in a column or row, an arithmetic means which performs calculations between row vectors and column vectors, and a matrix storage means which is an area in which memory elements are arranged in a matrix, wherein the vector storage means stores the row vectors and column vectors loaded from the memory by the input / output means, the arithmetic means performs calculations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means stores the results of the calculations.
[0052] (2) A processor device according to a second aspect is the processor device described in (1), wherein the calculation means has the same number of multiply-accumulate operators as the number of columns of the matrix storage means, and the multiply-accumulate operators are connected to the memory elements arranged in the same column as the multiply-accumulate operators in the matrix storage means.
[0053] (3) A processor device according to a third aspect is a processor device according to any one of (1) to (2), wherein the matrix storage means has memory elements with a number of columns and rows equal to or greater than the number of columns of the column vector that the vector storage means can store.
[0054] (4) A processor device according to a fourth aspect is a processor device according to any one of (1) to (3), wherein the matrix storage means has the memory elements with the same number of columns and rows as the maximum number of columns of the column vector that the vector storage means can store.
[0055] (5) A processor device according to a fifth aspect is the processor device according to any one of (1) to (4), wherein the operation is a matrix-matrix multiplication.
[0056] (6) A processor device according to a sixth aspect is a processor device according to any one of (1) to (5), wherein the vector storage means and the matrix storage means are connected, and the calculation results stored in the matrix storage means are output to the vector storage means and stored in the vector storage means, and are output from the vector storage means to the memory by the input / output means.
[0057] (7) A seventh aspect of the processor device is a processor device according to any one of (1) to (6), wherein the operation is matrix A x matrix B, where matrix A is a matrix of M rows and K columns and matrix B is a matrix of K rows and N columns, and the vector storage means stores one column of matrix A loaded by the input / output means and outputs it to the operation means, then stores one row of matrix B loaded by the input / output means and outputs it to the operation means, and the operation means calculates the product of one column of matrix A and one row of matrix B, and stores the result of the operation in the matrix storage means. This process is repeated until the operation of matrix A x matrix B is completed.
[0058] (8) A processor device according to an eighth aspect is a processor device according to any one of (1) to (7), wherein the vector storage means and the matrix storage means are connected, and a column vector loaded from the memory and stored in the vector storage means is output from the vector storage means to the matrix storage means and stored in the matrix storage means.
[0059] (9) A ninth aspect of the processor device is the processor device of (8), wherein the operation is matrix A × matrix B + matrix C, where matrix A, matrix B, and matrix C each have L rows and L columns, and the input / output means loads column vectors of matrix C column by column into the vector storage means, and the matrix storage means repeats a process of outputting and storing the loaded column vectors of matrix C to the matrix storage means L times to store matrix C in the matrix storage means, and the vector storage means stores one column of matrix A loaded by the input / output means and outputs it to the operation means, and subsequently stores one row of matrix B loaded by the input / output means and outputs it to the operation means, and the operation means calculates the product of one column of matrix A and one row of matrix B and the sum of matrix C, and stores the result of the operation in the matrix storage means, repeating this process until the operation of matrix A × matrix B + matrix C is completed.
[0060] (10) A processor device according to a tenth aspect is a processor device according to any one of (1) to (9), comprising: a first instruction for performing an operation using two vector data loaded into the vector storage means and matrix data stored in the matrix storage means, and storing the operation result in the matrix storage means; a vector matrix store instruction (VSTM): the VSTM comprises a second instruction for writing one vector data stored in the vector storage means to a row or column of the matrix storage means; and a third instruction for writing vector data from any row or column of the matrix storage means to the vector storage means.
[0061] (11) An eleventh aspect of the present invention relates to a calculation method in which a row vector and a column vector loaded from memory are stored in a vector register, which is an area of a processor device in which memory elements are arranged in a column, the processor device performs a calculation on the row vector and the column vector, stores the result of the calculation in a matrix register, which is an area of the processor device in which memory elements are arranged in a matrix, and the processor device outputs the result of the calculation stored in the matrix register to the memory.
[0062] According to the above-described processor device and calculation method, the ratio of the amount of data loaded into memory to the amount of calculation can be reduced.
[0063] 1...Processor device 10...Matrix expansion control unit 20...Vector processor device 30...Vector expansion control unit 40...Scalar processor 60...Memory 110...Matrix register 111...Register 120...Matrix calculator 121...Production accumulation calculator 150...Calculator interface control unit 160...Matrix register access control unit 310...Vector register 311...Register 320...Vector calculator 321...Production accumulation calculator 410...Scalar register 420...Scalar calculator 480...Load store control unit 490...Instruction control unit 800...Processor device 801...Input / output means 802...Vector storage means 803...Calculation means 804...Matrix storage means
Claims
1. A processor device comprising: input / output means for inputting / outputting data to / from a memory; vector storage means which is an area in which memory elements are arranged in columns; arithmetic means for performing calculations between row vectors and column vectors; and matrix storage means which is an area in which memory elements are arranged in a matrix; wherein the vector storage means stores the row vectors and column vectors loaded from the memory by the input / output means, the arithmetic means performs calculations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means stores the results of the calculations.
2. The processor device according to claim 1, wherein said calculation means comprises a number of multiply-accumulate units equal to the number of columns of said matrix storage means, and said multiply-accumulate units are connected to said memory elements arranged in the same columns as said multiply-accumulate units in said matrix storage means.
3. A processor device according to claim 1 or 2, wherein said matrix storage means comprises memory elements having a number of columns and rows equal to or greater than the maximum number of columns of said column vector that said vector storage means can store.
4. The processor device according to claim 1 or 2, wherein said matrix storage means comprises memory elements having the same number of columns and rows as the number of columns of said column vector that said vector storage means can store.
5. The processor device according to claim 1 or 2, wherein the operation is a matrix-matrix multiplication.
6. A processor device according to claim 1 or claim 2, wherein said vector storage means and said matrix storage means are connected, and the operation results stored in said matrix storage means are output to said vector storage means and stored in said vector storage means, and are output from said vector storage means to said memory by said input / output means.
7. A processor device according to claim 1 or 2, wherein the calculation is matrix A x matrix B, where matrix A is a matrix of M rows and K columns, and matrix B is a matrix of K rows and N columns, and wherein the vector storage means stores one column of matrix A and one row of matrix B loaded by the input / output means and outputs them to the calculation means, and the calculation means calculates the product of one column of matrix A and one row of matrix B, and stores the calculation result in the matrix storage means, repeating this process until the calculation of matrix A x matrix B is completed.
8. The processor device according to claim 1 or 2, wherein said vector storage means and said matrix storage means are connected, and a column vector loaded from said memory and stored in said vector storage means is output from said vector storage means to said matrix storage means and stored in said matrix storage means.
9. The processor device according to claim 8, wherein the calculation is matrix A x matrix B + matrix C, where each of matrices A, B, and C has L rows and L columns, and wherein the input / output means loads column vectors of matrix C column by column into the vector storage means, and the matrix storage means repeats a process of outputting the loaded column vector of matrix C to the matrix storage means and storing it L times to store the matrix C, the vector storage means stores one column of matrix A and one row of matrix B loaded by the input / output means and outputs them to the calculation means, and the calculation means calculates the product of one column of matrix A and one row of matrix B and the sum of matrix C, and stores the calculation result in the matrix storage means, repeating this process until the calculation of matrix A x matrix B + matrix C is completed.
10. A processor device according to claim 1 or 2, comprising: a first instruction for performing an operation using two vector data loaded into said vector storage means and matrix data stored in said matrix storage means, and storing the operation result in said matrix storage means; a vector matrix store instruction (VSTM): VSTM comprises: a second instruction for writing one vector data stored in said vector storage means to a row or column of said matrix storage means; and a third instruction for writing vector data from any row or column of said matrix storage means to said vector storage means.
11. An arithmetic method comprising: storing a row vector and a column vector loaded from memory in a vector register, which is an area of a processor device in which memory elements are arranged in a column; the processor device performs an arithmetic operation on the row vector and the column vector; storing a result of the arithmetic operation in a matrix register, which is an area of the processor device in which memory elements are arranged in a matrix; and the processor device outputting the result of the arithmetic operation stored in the matrix register to the memory.
Citation Information
Patent Citations
Two dimensional addressing of matrix-vector register array
JP2005149492A
Transposition operation apparatus, integrated circuit therefor, and transposition processing method
WO2013054468A1
Data structure relinquishing
WO2021023956A1
