Low-bit-width data matrix vectorization column expansion method and system for vector processor

By storing the low-bit-width data matrix in the double-rate synchronous dynamic random access memory in the vector processor and performing direct memory access operations, the vectorized column expansion of the matrix is ​​realized, and the problem of low-efficiency low-bit-width matrix multiplication in the existing technology is solved. , improves the performance of matrix column expansion.

CN114329326BActive Publication Date: 2024-08-30NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111510661.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-10
Publication Date
2024-08-30
Estimated Expiration
2041-12-10

AI Technical Summary

Technical Problem

When existing vector processors perform low-bit-width matrix multiplication, especially when K is an odd number, data cannot be transferred quickly and effectively through direct memory access (DMA operation), resulting in low efficiency of matrix column expansion operations.

Method used

Store the low-bit-width data matrix in double-rate synchronous dynamic random access memory and load it into the on-chip array memory AM space through direct memory access operations for column expansion processing and use vector load and store instructions for data batch processing and expansion. Implements vectorized column expansion of matrices.

Benefits of technology

It improves the efficiency of column expansion operations of low-bit-width data matrices, can efficiently process low-bit-width matrices of any dimension, effectively utilizes the bandwidth of array memory, and improves the performance of matrix column expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114329326B
    Figure CN114329326B
Patent Text Reader

Abstract

The present invention discloses a vectorized column expansion method and system for a low-bit-width data matrix of a vector processor, the method comprising: storing the low-bit-width data matrix in a double-rate synchronous dynamic random access memory; calling a direct memory access operation to load the low-bit-width data matrix from the double-rate synchronous dynamic random access memory to an on-chip array memory AM space; in the AM space, performing column expansion processing on the matrix loaded into the on-chip AM space to obtain a matrix after column expansion. The present invention can efficiently implement the column expansion operation of the low-bit-width data matrix.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of vector processors, and in particular to a method and system for vectorizing columns of low-bit-width data matrices of a vector processor. Background Art

[0002] Vector processor is a new type of architecture, such as Figure 1 As shown in the figure, it includes a scalar processing unit (SPU) for scalar operations and a vector processing unit (VPU) for vector operations, as well as a direct memory access (DMA) component responsible for data transmission. The SPU is composed of a scalar processing component SPE and a scalar memory SM. The VPU is composed of L vector processing components VPE and an array memory AM. The L vector processing components VPE operate in a collaborative manner in a single instruction multiple data (5IMD) manner, supporting the closing and opening of a specified VPE component, but not supporting data interaction between multiple VPEs. A single VPE can process one 8-byte data (such as FP64, Int64) at a time, or two 4-byte data (such as FP32, Int32). The DMA component is responsible for data transmission between SM and DDR, and between AM and DDR, and its minimum granularity of operation is also 8 bytes.

[0003] For a matrix with a single element width of 8 bytes, many operations of the entire matrix operation can be completed efficiently by simply moving data between the vector processor's AM space and the off-chip DDR through DMA operations. As mentioned above, the minimum granularity of DMA operations is 8 bytes. When multiplying a low-width matrix [M×K]×[K×N], when K is an odd number, it cannot be transferred quickly and efficiently if only DMA operations are used.

[0004] Therefore, how to efficiently implement column expansion operations on low-bit-width data matrices is an urgent problem to be solved. Summary of the invention

[0005] In view of this, the present invention provides a low-bit-width data matrix vectorization column expansion method for a vector processor, which can efficiently implement the column expansion operation of the low-bit-width data matrix.

[0006] The present invention provides a low-bit-width data matrix vectorization column expansion method for a vector processor, comprising:

[0007] storing the low bit width data matrix in a double rate synchronous dynamic random access memory;

[0008] Invoke a direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into an on-chip array memory AM space;

[0009] In the AM space, column expansion processing is performed on the matrix loaded into the on-chip AM space to obtain a column-expanded matrix.

[0010] Preferably, the low bit width data matrix A ddr The dimension is M×N.

[0011] Preferably, the calling of the direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into the on-chip AM space comprises:

[0012] Call direct memory access operation to convert the low-bit width data matrix A ddr The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

[0013] Preferably, in the AM space, column expansion processing is performed on the matrix loaded into the on-chip AM space to obtain a matrix after column expansion, including:

[0014] Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B';

[0015] Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than If the space size exceeds the limit, jump to step 17; otherwise, jump to step 3;

[0016] Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B';

[0017] Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data;

[0018] Step 5, using the vector load instruction, starting from AM3, the low-width 1xL data is loaded into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, the low-width 1xL data is loaded into the vector register VR1 according to the half-word vector, and AM3 is incremented by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit;

[0019] Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32;

[0020] Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector;

[0021] Step 8: Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2.

[0022] Step 9: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size;

[0023] Step 10, load the data in the vector register VR1 into the vector register VR0;

[0024] Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size;

[0025] Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32;

[0026] Step 13: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector;

[0027] Step 14: Use the vector load instruction to load the data of the low bit width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2;

[0028] Step 15: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size;

[0029] Step 16, looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20;

[0030] Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space;

[0031] Step 18, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data;

[0032] Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted;

[0033] Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches;

[0034] Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22;

[0035] Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation;

[0036] Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

[0037] A low-bit-width data matrix vectorization column expansion system for a vector processor, comprising:

[0038] A storage module, used for storing the low bit width data matrix in a double rate synchronous dynamic random access memory;

[0039] A loading module, used for invoking a direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into an on-chip array memory AM space;

[0040] The column expansion processing module is used to perform column expansion processing on the matrix loaded into the on-chip AM space in the AM space to obtain a matrix after column expansion.

[0041] Preferably, the low bit width data matrix A ddr The dimension is M×N.

[0042] Preferably, the loading module is specifically used for:

[0043] Call direct memory access operation to convert the low-bit width data matrix A ddr The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

[0044] Preferably, the expansion processing module is specifically used to perform the following steps:

[0045] Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B';

[0046] Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than If the space size exceeds the limit, jump to step 17; otherwise, jump to step 3;

[0047] Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B';

[0048] Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data;

[0049] Step 5, using the vector load instruction, starting from AM3, the low-width 1xL data is loaded into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, the low-width 1xL data is loaded into the vector register VR1 according to the half-word vector, and AM3 is incremented by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit;

[0050] Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32;

[0051] Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector;

[0052] Step 8: Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2.

[0053] Step 9: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size;

[0054] Step 10, load the data in the vector register VR1 into the vector register VR0;

[0055] Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size;

[0056] Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32;

[0057] Step 13: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector;

[0058] Step 14: Use the vector load instruction to load the data of the low bit width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2;

[0059] Step 15: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size;

[0060] Step 16, looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20;

[0061] Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space;

[0062] Step 18, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data;

[0063] Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted;

[0064] Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches;

[0065] Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22;

[0066] Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation;

[0067] Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

[0068] In summary, the present invention discloses a vectorized column expansion method for a low-bit-width data matrix of a vector processor. When a low-bit-width data matrix needs to be vectorized column expansion, the low-bit-width data matrix is ​​stored in a double-rate synchronous dynamic random access memory, and then a direct memory access operation is called to load the low-bit-width data matrix from the double-rate synchronous dynamic random access memory to an on-chip AM space; in the AM space, a column expansion process is performed on the matrix loaded into the on-chip AM space to obtain a matrix after column expansion. The present invention can efficiently implement the column expansion operation of a low-bit-width data matrix. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0070] Figure 1 is a general architecture diagram of a vector processor;

[0071] Figure 2 A method flow chart of an embodiment of a low-bit-width data matrix vectorization column expansion method for a vector processor disclosed in the present invention;

[0072] Figure 3 The present invention is a schematic structural diagram of an embodiment of a low-bit-width data matrix vectorization column expansion system for a vector processor disclosed in the present invention. DETAILED DESCRIPTION

[0073] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] like Figure 2 FIG. 1 is a flowchart of an embodiment of a low-bit-width data matrix vectorization expansion method for a vector processor disclosed in the present invention. The method may include the following steps:

[0075] S201, storing the low bit width data matrix in a double rate synchronous dynamic random access memory;

[0076] When it is necessary to perform vectorized column expansion on a low-bit-width data matrix for a vector processor, the low-bit-width data matrix is ​​first stored in a DDR (double-bit-rate synchronous dynamic random access memory). ddr The dimension is M×N.

[0077] S202, calling a direct memory access operation to load a low-bit-width data matrix from a double-rate synchronous dynamic random access memory into an on-chip array memory AM space;

[0078] Specifically, a direct memory access operation is called to convert the low-bit width data matrix A ddr The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

[0079] S203 . In the AM space, perform column expansion processing on the matrix loaded into the on-chip AM space to obtain a column-expanded matrix.

[0080] Specifically, the following steps may be included:

[0081] Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B';

[0082] Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than AM space size, if exceeded, jump to step 17, otherwise jump to step 3;

[0083] Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B';

[0084] Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data;

[0085] For example, taking the FP32 matrix, N=17, L=8 as an example, based on DMA (direct memory access), the low-width sub-matrix is ​​loaded from DDR to the on-chip space AM0 starting from N-1 data. The AM space starting address data obtained in this step is shown in Table 1.

[0086] Table 1 AM space start address data

[0087] 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 .. .. .. .. .. .. .. .. .. .. .. .. .. ..

[0088] Step 5, using the vector load instruction, starting from AM3, load the low-width 1xL data into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, load the low-width 1xL data into the vector register VR1 according to the half-word vector, and AM3 increments by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit. The VR0 and VR1 vector register data obtained in this step are shown in Table 2.

[0089] Table 2 VR0, VR1 vector register data

[0090] VR0 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 VR1 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29

[0091] Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32. The VR32 vector register data obtained in this step is shown in Table 3.

[0092] Table 3 VR32 vector register data

[0093] VR32 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23

[0094] Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector. The AM1 space data obtained in this step is shown in Table 4.

[0095] Table 4 AM1 spatial data

[0096] 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23

[0097] Step 8. Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2. The VR0 vector register data obtained in this step is shown in Table 5.

[0098] Table 5 VR0 vector register data

[0099] VR0 17 17 18 18 19 19 20 20 21 21 22 22 23 23 0 23

[0100] Step 9: Use the vector storage instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector. AM2 increments by L-2 low-width data size. The AM space starting address data obtained in this step is shown in Table 6.

[0101] Table 6 AM space start address data

[0102] 16 17 17 18 19 20 21 22 23 23 26 27 28 29 30 31 32 33 .. .. .. .. .. .. .. .. .. .. .. .. .. ..

[0103] Step 10: Load the data in the vector register VR1 into the vector register VR0. The VR0 vector register data obtained in this step is shown in Table 7.

[0104] Table 7 VR0 vector register data

[0105] VR0 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29

[0106] Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size. The VR1 vector register data obtained in this step is shown in Table 8.

[0107] Table 8 VR1 vector register data

[0108] VR1 0 28 0 29 0 30 0 31 0 32 0 33 0 .. 0 ..

[0109] Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32. The VR32 vector register data obtained in this step is shown in Table 9.

[0110] Table 9 VR32 vector register data

[0111] VR32 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29

[0112] Step 13: Use the vector storage instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector. The AM1 space data obtained in this step is shown in Table 10.

[0113] Table 10 AM1 spatial data

[0114] 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23

[0115] Step 14: Use the vector load instruction to load the data of low width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2. The VR0 vector register data obtained in this step is shown in Table 11.

[0116] Table 11 VR0 vector register data

[0117] VR0 23 23 24 24 25 25 26 26 27 27 28 28 29 29 0 29

[0118] Step 15, use the vector storage instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector. AM2 increments by L-2 low-width data size. The AM space starting address data obtained in this step is shown in Table 12.

[0119] Table 12 AM space start address data

[0120] 16 17 17 18 19 20 21 22 23 24 25 26 27 28 29 29 32 33 .. .. .. .. .. .. .. .. .. .. .. .. .. ..

[0121] Step 16, keep looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20. It is also possible to allow multiple cores to process multiple sub-matrices of matrix A in parallel, or to allow multiple vector processors to process more low-bit width data in parallel. The final AM space starting address data obtained in this step is shown in Table 13.

[0122] Table 13 Final AM space starting address data

[0123] 16 17 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 .. .. .. .. .. .. .. .. .. .. .. .. ..

[0124] Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space;

[0125] Step 18, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data;

[0126] Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted;

[0127] Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches;

[0128] Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22;

[0129] Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation;

[0130] Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

[0131] In summary, the low-bit-width data matrix vectorized column expansion method of the vector processor provided by the present invention can handle the expansion operation of low-bit-width data matrices of arbitrary dimensionality, and based on vector Load / Storage and vector expansion units, realize the vectorized operation of low-bit-width matrix column expansion, effectively utilize the bandwidth of AM space, and improve the performance of low-bit-width matrix column expansion.

[0132] like Figure 3 FIG. 1 is a schematic diagram of a structure of an embodiment of a low-bit-width data matrix vectorization column expansion system for a vector processor disclosed in the present invention. The system may include:

[0133] The storage module 301 is used to store the low bit width data matrix in a double rate synchronous dynamic random access memory;

[0134] When it is necessary to perform vectorized column expansion on a low-bit-width data matrix for a vector processor, the low-bit-width data matrix is ​​first stored in a DDR (double-bit-rate synchronous dynamic random access memory). ddr The dimension is M×N.

[0135] A loading module 302 is used to call a direct memory access operation to load a low-bit-width data matrix from a double-rate synchronous dynamic random access memory into an on-chip array memory AM space;

[0136] Specifically, a direct memory access operation is called to convert the low-bit width data matrix A ddr The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

[0137] The column expansion processing module 303 is used to perform column expansion processing on the matrix loaded into the on-chip AM space in the AM space to obtain a matrix after column expansion.

[0138] Specifically, the following steps may be included:

[0139] Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B';

[0140] Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than AM space size, if exceeded, jump to step 17, otherwise jump to step 3;

[0141] Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B';

[0142] Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data;

[0143] For example, taking the FP32 matrix, N=17, L=8 as an example, based on DMA (direct memory access), the low-width sub-matrix is ​​loaded from DDR to the on-chip space AM0 starting from N-1 data. The AM space starting address data obtained in this step is shown in Table 1.

[0144] Step 5, using the vector load instruction, starting from AM3, load the low-width 1xL data into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, load the low-width 1xL data into the vector register VR1 according to the half-word vector, and AM3 increments by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit. The VR0 and VR1 vector register data obtained in this step are shown in Table 2.

[0145] Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32. The VR32 vector register data obtained in this step is shown in Table 3.

[0146] Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector. The AM1 space data obtained in this step is shown in Table 4.

[0147] Step 8. Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2. The VR0 vector register data obtained in this step is shown in Table 5.

[0148] Step 9: Use the vector storage instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector. AM2 increments by L-2 low-width data size. The AM space starting address data obtained in this step is shown in Table 6.

[0149] Step 10: Load the data in the vector register VR1 into the vector register VR0. The VR0 vector register data obtained in this step is shown in Table 7.

[0150] Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size. The VR1 vector register data obtained in this step is shown in Table 8.

[0151] Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32. The VR32 vector register data obtained in this step is shown in Table 9.

[0152] Step 13: Use the vector storage instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector. The AM1 space data obtained in this step is shown in Table 10.

[0153] Step 14: Use the vector load instruction to load the data of low width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2. The VR0 vector register data obtained in this step is shown in Table 11.

[0154] Step 15, use the vector storage instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector. AM2 increments by L-2 low-width data size. The AM space starting address data obtained in this step is shown in Table 12.

[0155] Step 16, keep looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20. It is also possible to allow multiple cores to process multiple sub-matrices of matrix A in parallel, or to allow multiple vector processors to process more low-bit width data in parallel. The final AM space starting address data obtained in this step is shown in Table 13.

[0156] Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space;

[0157] Step 18, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data;

[0158] Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted;

[0159] Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches;

[0160] Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22;

[0161] Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation;

[0162] Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

[0163] In summary, the low-bit-width data matrix vectorized column expansion system of the vector processor provided by the present invention can handle the expansion operation of low-bit-width data matrices of arbitrary dimensionality, and based on vector Load / Storage and vector expansion units, realize the vectorized operation of low-bit-width matrix column expansion, effectively utilize the bandwidth of AM space, and improve the performance of low-bit-width matrix column expansion.

[0164] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0165] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0166] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0167] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for vectorizing columns of low-bit-width data matrices of a vector processor, characterized in that: include: storing the low bit width data matrix in a double rate synchronous dynamic random access memory; Invoke a direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into an on-chip array memory AM space; In the AM space, performing column expansion processing on the matrix loaded into the on-chip AM space to obtain a column-expanded matrix; In the AM space, column expansion processing is performed on the matrix loaded into the on-chip AM space to obtain a matrix after column expansion, including: Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B'; Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than If the space size exceeds the limit, jump to step 17; otherwise, jump to step 3; Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B'; Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data; Step 5, using the vector load instruction, starting from AM3, the low-width 1xL data is loaded into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, the low-width 1xL data is loaded into the vector register VR1 according to the half-word vector, and AM3 is incremented by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit; Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32; Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector; Step 8: Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2. Step 9: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size; Step 10, load the data in the vector register VR1 into the vector register VR0; Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size; Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32; Step 13: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector; Step 14: Use the vector load instruction to load the data of the low bit width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2; Step 15: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size; Step 16, looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20; Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space; Step 18, let offset=2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data; Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted; Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches; Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22; Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation; Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

2. The method according to claim 1, characterized in that The low bit width data matrix The dimension is .

3. The method according to claim 2, characterized in that The calling of the direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into the on-chip AM space includes: Call direct memory access operation to convert the low-width data matrix The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

4. A low bit width data matrix vectorization column expansion system for a vector processor, characterized in that: include: A storage module, used for storing the low bit width data matrix in a double rate synchronous dynamic random access memory; A loading module, used for invoking a direct memory access operation to load the low bit width data matrix from the double rate synchronous dynamic random access memory into an on-chip array memory AM space; A column expansion processing module, used for performing column expansion processing on the matrix loaded into the on-chip AM space in the AM space to obtain a matrix after column expansion; The expansion processing module is specifically used to perform the following steps: Step 1, let offset = 2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, the sub-matrix of matrix A is A', and the sub-matrix of matrix B is B'; Step 2: Determine whether N exceeds a preset threshold, where the preset threshold must be less than If the space size exceeds the limit, jump to step 17; otherwise, jump to step 3; Step 3: Based on direct memory access, the first N-1 low-bit width data in sub-matrix A' are transferred to sub-matrix B'; Step 4: Based on direct memory access, the low-bit width sub-matrix is ​​loaded from the double-rate synchronous dynamic random access memory to the on-chip space AM0 starting from the N-1 data; Step 5, using the vector load instruction, starting from AM3, the low-width 1xL data is loaded into the vector register VR0 according to the half-word vector, and starting from the AM3+(L-2)th low-width data, the low-width 1xL data is loaded into the vector register VR1 according to the half-word vector, and AM3 is incremented by 2×(L-2) low-width data sizes, where L represents the number of vector processing components in the vector processing unit; Step 6: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32; Step 7: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector; Step 8: Use the vector load instruction to load the low-order width 1×(L×2) data into the vector register VR0 according to the word vector starting from AM1+2. Step 9: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size; Step 10, load the data in the vector register VR1 into the vector register VR0; Step 11, using the vector load instruction, starting from AM3, load the low-width 1×L data into the vector register VR1 according to the half-word vector, and AM3 increments by L-2 low-width data size; Step 12: Use the extended instruction to perform low-order low-order width expansion operation on the vector register VR0 data and load it into the vector register VR32; Step 13: Use the vector store instruction to store the data in the vector register VR32 back to the on-chip space AM1 according to the word vector; Step 14: Use the vector load instruction to load the data of the low bit width 1×(L×2) into the vector register VR0 according to the word vector starting from AM1+2; Step 15: Use the vector store instruction to store the data in the vector register VR0 back to the space AM2 according to the half-word vector, and AM2 increments by L-2 low-bit width data size; Step 16, looping steps 10-15 until the data expansion is completed or the occupied AM space exceeds the threshold. If the stop condition is that the data expansion is completed, jump to step 22, otherwise, jump to step 20; Step 17: Based on direct memory access, the first N-1 data in sub-matrix A' are transferred to sub-matrix B' in batches according to the size of AM space; Step 18, let offset=2, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, and AM3 be the address of AM0 after offset low-width data; Step 19, execute steps 4-16 to calculate the remaining data subscript X that needs to be transmitted; Step 20, let offset = 0, let AM0 be the starting address of the upper half space of AM, AM1 be the starting address of the lower half space of AM, AM2 be the address of AM0 after offset low-width data, AM3 be the address of AM0 after offset low-width data, and based on direct memory access, transfer the data in submatrix A' starting from the data with subscript X to AM0 in batches; Step 21, execute steps 5-16, calculate the remaining data subscript X to be transmitted, if the remaining data is greater than 0, jump to step 20, otherwise, jump to step 22; Step 22: Based on direct memory access, the remaining matrix is ​​stored back into the double rate synchronous dynamic random access memory to complete the sub-matrix expansion operation; Step 23, when M is an even number, according to the above method, each sub-matrix is ​​column-expanded, and finally the column expansion of the entire matrix [M×N] can be completed; when M is an odd number, each sub-matrix is ​​column-expanded, and the column expansion of the matrix [(M-1)×N] can be completed, and based on direct memory access, the data of the Mth row is correspondingly transmitted, and finally the column expansion of the entire matrix [M×N] can be completed.

5. The system according to claim 4, characterized in that The low bit width data matrix The dimension is .

6. The system according to claim 5, characterized in that The loading module is specifically used for: Call direct memory access operation to convert the low-width data matrix The sub-matrices [2×N] of are loaded into the on-chip AM space in batches, where the number of batches is determined by the size of the AM space.

Citation Information

Patent Citations

  • Vector processor-oriented low-bit-width data matrix vectorization transposition method and system

    CN113626769A

  • Implementing instruction set architectures with non-contiguous register file specifiers

    US20070038848A1