Data processing method and system, and related device
By dividing the dense matrix into smaller blocks and performing LU decomposition and row exchange operations, the load imbalance problem caused by granular block partitioning in matrix decomposition is solved, and the efficiency of matrix multiplication and overall matrix decomposition is improved.
Patent Information
- Application Number
- PCT/CN2023/118469
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-20
- Filing Date
- 2023-09-13
- Publication Date
- 2024-08-29
AI Technical Summary
During the matrix decomposition calculation process, larger granularity blocking leads to process load imbalance and reduces the computational efficiency of matrix multiplication and overall matrix decomposition.
By dividing the dense matrix into smaller blocks, performing matrix multiplication calculations in LU decomposition and row exchange operations, and using the GEMM operator to perform matrix multiplication, we ensure that the dimension of matrix multiplication is large, reduce load imbalance, and improve the matrix decomposition efficiency.
It achieves process load balancing, improves the computational efficiency of matrix multiplication and overall matrix decomposition, and improves the performance of matrix decomposition.
Smart Images

Figure CN2023118469_29082024_PF_FP_ABST
Abstract
Description
Data processing method, system and related equipment
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on February 20, 2023, with application number 202310183425.X and invention name “A data processing method, system and related equipment”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of data processing technology, and in particular to a data processing method, system and related equipment. Background Art
[0003] Matrix solutions are involved in many scientific and engineering fields, including meteorology, electromagnetism, fluid dynamics, astronomical simulations, and computer performance testing. Matrices can be categorized into dense and sparse matrices based on their storage format. A dense matrix stores all elements in a logically two-dimensional format. A sparse matrix stores only the nonzero elements. Dense matrices can be solved using matrix factorization.
[0004] Currently, dense matrices are divided into blocks, each assigned to a process, and matrix decomposition calculations are performed on a per-block basis. During matrix decomposition calculations, matrix multiplication is computationally intensive. To improve the efficiency of matrix multiplication, matrices are typically divided into blocks at a larger granularity to increase the amount of data involved in the matrix multiplication. However, because each process performs a matrix decomposition calculation with a different number of blocks, large-granularity blocks can lead to uneven process load, reducing the overall efficiency of the matrix decomposition.
[0005] Summary of the Invention
[0006] The present application provides a data processing method, system and related equipment, which can perform combined LU decomposition and combined row exchange operation in the process of matrix decomposition of the processed data, that is, the dense matrix, and perform matrix multiplication calculation with the sum of the R sub-matrix dimensions as the dimension. The dimension of the matrix multiplication calculation is large, and efficient calculation of the matrix multiplication can be achieved. In this way, the dense matrix can be divided into blocks of smaller granularity, and the computational efficiency of the matrix multiplication is guaranteed to be high while achieving a more balanced process load, thereby achieving an improvement in the computational efficiency of the overall matrix decomposition.
[0007] In a first aspect, the present application provides a data processing method, which is applied to a computing device or computing cluster running multiple processes. Data to be processed for an application is obtained. The data to be processed is a dense matrix comprising M×M submatrices. The dense matrix is used as the matrix to be decomposed. The matrix to be decomposed is divided into a first matrix, a second matrix, a third matrix, and a fourth matrix. The first matrix is an R×R submatrix located in the upper left corner of the matrix to be decomposed. The second matrix is an R×(MR) submatrix located directly below and adjacent to the first matrix. The third matrix is an (MR)×R submatrix located to the right of the first matrix and adjacent to the first matrix. The fourth matrix is an (MR)×(MR) submatrix consisting of the remaining submatrices of the matrix to be decomposed. LU decomposition is performed on the first matrix and the second matrix to obtain an updated first matrix and an updated second matrix. A row swap operation is then performed on the third matrix, and a triangular solution is performed using the updated first matrix and the third matrix obtained after the row swap operation to obtain an updated third matrix. The GEMM operator is called to calculate the fourth matrix, and the difference between the product of the matrix multiplication of the updated second matrix and the updated third matrix is obtained to obtain the updated fourth matrix. The updated fourth matrix is then used as the matrix to be decomposed, and the same decomposition operation is performed, and it is iterated until all the M×M sub-matrices are calculated. The dimension of the matrix multiplication calculated by the GEMM operator is the product of R and the dimension of the sub-matrix, that is, the sum of the dimensions of the R sub-matrices. Compared to the dimension of matrix multiplication being the dimension of a single sub-matrix, the dimension of the matrix multiplication calculated using the data processing method of the present application is larger, which can meet the computational needs of efficient matrix multiplication. Under the premise of ensuring the efficiency of matrix multiplication, the dimensions of each sub-matrix included in the dense matrix can be slightly smaller, so that the load imbalance caused by the computational tasks of each sub-matrix being processed separately by multiple processes can be reduced, thereby achieving an improvement in the efficiency of the overall decomposition calculation of the dense matrix.
[0008] In some possible implementations, the size of R is determined by the computing power of a chip that performs the matrix multiplication.
[0009] In some possible implementations, the matrix to be decomposed in the final iteration, that is, the updated fourth matrix generated in the previous iteration, is an N×N submatrix. When N is less than or equal to R, the final iteration directly performs LU decomposition on the N×N submatrices to complete the decomposition of the dense matrix and obtain the decomposition result.
[0010] In some possible implementations, row swap information is generated during LU decomposition of the first and second matrices. As an example, a row swap operation is performed on the third matrix. Specifically, the row swap operation can be performed row by row on the third matrix based on the row swap information. As another example, the row swap information can be preprocessed to obtain processed row swap information, and then the row swap operation can be performed on the third matrix based on the processed row swap information. The preprocessing can merge or filter the row swap information, reduce the number of steps required to perform the row swap operation, and improve the efficiency of the row swap operation on the third matrix.
[0011] In a second aspect, the present application provides a data processing system, comprising:
[0012] An acquisition module is used to acquire data to be processed by an application, wherein the data to be processed is a dense matrix including M×M sub-matrices;
[0013] a partitioning module, configured to use the dense matrix as a matrix to be decomposed and divide it into a first matrix, a second matrix, a third matrix, and a fourth matrix, wherein the first matrix is an R×R submatrix located in the upper left corner of the matrix to be decomposed, the second matrix is an R×(MR) submatrix located directly below and adjacent to the first matrix, the third matrix is an (MR)×R submatrix located to the right of the first matrix and adjacent to the first matrix, and the fourth matrix is an (MR)×(MR) submatrix composed of the remaining submatrices;
[0014] a computing module, configured to perform LU decomposition on the first matrix and the second matrix to obtain an updated first matrix and an updated second matrix, perform a row swap operation on the third matrix, perform a triangular solution using the updated first matrix and the third matrix obtained after the row swap operation to obtain an updated third matrix, call a GEMM operator to calculate matrix multiplication of the updated second matrix and the updated third matrix to obtain a product, and calculate a difference between the fourth matrix and the product to obtain an updated fourth matrix;
[0015] The calculation module is further configured to use the updated fourth matrix as a matrix to be decomposed, perform the same decomposition operation as the dense matrix, and iterate until all the M×M sub-matrices are calculated.
[0016] In some possible implementations, the size of R is determined by the computing power of the chip in the computing device that performs the matrix multiplication, as well as the size of the dense matrix and the size of the computing device cluster to which it belongs.
[0017] In some possible implementations, the computing module is further configured to, when the updated fourth matrix consists of N×N sub-matrices and N is less than or equal to R, perform LU decomposition on the N×N sub-matrices.
[0018] In some possible implementations, the computing module, configured to perform a row swap operation on the third matrix, includes:
[0019] The calculation module is configured to perform a row swap operation on the third matrix row by row based on row swap information, where the row swap information is generated by performing LU decomposition on the first matrix and the second matrix.
[0020] In some possible implementations, the computing module, configured to perform a row swap operation on the third matrix, includes:
[0021] The computing module is configured to preprocess the row break information to obtain processed row break information, where the row break information is generated by performing LU decomposition on the first matrix and the second matrix; and perform a row swap operation on the third matrix based on the processed row break information.
[0022] In a third aspect, the present application provides a computer code product comprising instructions, which, when executed on a computing device, enables the computing device to execute the method described in the first aspect or any one of the implementations of the first aspect.
[0023] Based on the implementation methods provided in the above aspects, this application can also be further combined to provide more implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a schematic diagram of a dense matrix divided into blocks and then allocated to each process;
[0025] FIG2 is a schematic diagram of a dense matrix decomposition;
[0026] FIG3 is a schematic diagram of another dense matrix decomposition;
[0027] FIG4 is a flow chart of a data processing method provided in an embodiment of the present application;
[0028] FIG5 is a schematic diagram of a matrix to be decomposed provided in an embodiment of the present application, including a first matrix, a second matrix, a third matrix, and a fourth matrix;
[0029] FIG6 is a schematic diagram of the structure of a data processing system provided in an embodiment of the present application;
[0030] FIG7 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0031] FIG8 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will describe the solutions in the embodiments provided in this application in conjunction with the drawings in this application.
[0033] The terms "first," "second," and the like in the specification and claims of this application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate and are merely used to describe the manner in which objects with the same attributes are described in the embodiments of this application.
[0034] Dense matrix decomposition methods can be implemented using block and recursive strategies. Taking the LU decomposition, which is applicable to general matrix decomposition, as an example, the following describes the current LU decomposition process for dense matrices using a dense matrix of shape AxA, where A is a positive integer.
[0035] First, the dense matrix is divided so that the divided dense matrix includes blocks in units of NBxNB. NB is a positive integer. See Figure 1. Each square represents a block. Blocks can also be called sub-matrices. The dense matrix is divided into 81 blocks in units of NBxNB. In a distributed computing program, the divided blocks are assigned to multiple running processes. Taking 9 processes as an example, a two-dimensional loop method is used to assign 9×9 blocks to 9 processes. As shown in Figure 1, the numbers in the square represent (process row number, process column number), which are used to identify the process responsible for the calculation of the block.
[0036] LU decomposition uses a multi-iteration approach. Each iteration processes one NB row and one NB column, and updates the tail matrix. After multiple iterations, the decomposition of the entire matrix can be achieved. Specifically, during the first iteration, the first NB column is first decomposed. See Figure 2, which is a schematic diagram of a dense matrix decomposition. The first NB column is first decomposed to obtain L11, U11, and L21 of the diagonal block. L11 is the lower triangular portion of the diagonal block, and U11 is the upper triangular portion of the diagonal block. L21 is the portion of the first NB column without the diagonal block. It should be noted that the decomposition uses the column-selected pivot Gaussian elimination method. The column-selected pivot is the largest element in the column. After selecting the column-selected pivot, the row containing the column-selected pivot needs to be swapped with the current row, and then elimination is performed. During the decomposition of the first NB column, row break information is generated based on the selected column-selected pivot. The row break information is used to indicate the NB row that needs to be swapped with the current NB row, that is, the first NB row. The NB row indicated by the line break information is swapped with the first NB row to obtain the swapped U12. U12 is the portion of the first NB row excluding the diagonal blocks. Then solve the triangular equation U12=L11-1U12 to obtain the updated U12. Finally, the tail matrix A22 is updated. The tail matrix A22 is the portion of the dense matrix excluding the first NB column and U12. Calculate A22=A22-L21U12. Use the calculated A22 to update A22 in the matrix. The tail matrix update involves matrix multiplication, and the algorithm for calculating matrix multiplication can be called for calculation. After the first iteration is completed, A22 is iteratively decomposed using the same steps for the next time. See Figure 3, which is a schematic diagram of another dense matrix decomposition. Among them, the solid line box represents the NB column and NB row processed in each iteration. After so many iterations, the decomposition of the dense matrix can be completed.
[0037] During the LU decomposition process, the tail matrix update in each iteration accounts for the majority of the computational effort. Currently, the matrix multiplication calculations during the tail matrix update process are implemented using the general matrix to matrix multiplication (GEMM) operator. However, for memory-constrained computing chips with limited memory bandwidth, the GEMM operator requires controlling the dimensions of the matrix input for computation. Assuming the memory bandwidth supports this, a larger matrix input dimension can improve the GEMM operator's computational efficiency. In the current LU decomposition process, the second dimension K of the matrix input to the GEMM operator is equal to the dimension size NB of the matrix's blocks, i.e., K = NB. Therefore, to achieve higher GEMM operator computational efficiency, a larger NB value is required to partition the dense matrix. However, a larger NB value results in larger granularity in the resulting blocks. When implementing matrix decomposition using individual processes, larger granularity in the blocks leads to an uneven computational load across the processes, impacting the overall computational efficiency of the matrix decomposition and preventing efficient matrix decomposition computation.
[0038] To address the above issues, embodiments of the present application provide a data processing method capable of performing LU decomposition on the data to be processed, that is, a dense matrix. First, the dense matrix is divided into M×M submatrices. The dense matrix is then used as the matrix to be decomposed, and the matrix to be decomposed is divided into a first matrix, a second matrix, a third matrix, and a fourth matrix. The first matrix is the R×R submatrix located in the upper left corner of the matrix to be decomposed. The second matrix is the R×(MR) submatrix located directly below and adjacent to the first matrix. The third matrix is the (MR)×R submatrix located adjacent to and to the right of the first matrix. The fourth matrix is the matrix to be decomposed excluding the first, second, and third matrices. LU decomposition is performed on the first and second matrices, that is, the first R columns of the matrix to be decomposed, to obtain the updated first and second matrices. Row swapping and triangular solution are then performed on the third matrix to obtain the updated third matrix. The difference between the fourth matrix and the product of the updated third matrix and the updated second matrix is calculated to obtain the updated fourth matrix. This completes one iteration. The updated fourth matrix is used as the matrix to be decomposed and the same decomposition operation is performed. This process is repeated multiple times until the dense matrix is decomposed. The dimension of the matrix multiplication between the updated second matrix and the updated third matrix is calculated as the product of R and the submatrix dimension. The matrix multiplication is calculated in a larger dimension, which enables efficient matrix multiplication calculation. This can divide the dense matrix into smaller blocks, ensuring high matrix multiplication efficiency while achieving a relatively balanced process load, thereby improving the overall efficiency of the matrix decomposition calculation.
[0039] In one possible implementation, the data processing method provided in the embodiments of the present application can be applied to a standalone computing device configured with a computing chip with limited memory access. The standalone computing device is, for example, a supercomputer. The standalone computing device operates in a multi-process manner.
[0040] The following describes the data processing methods provided by the embodiments of the present application using the High Performance Linear Systems Package (HPL) to test the computing performance of a computing device. The HPL testing process primarily includes steps such as matrix generation, matrix decomposition, back substitution, result verification, and performance evaluation. Matrix decomposition is the most time-consuming phase of the HPL process and a crucial step in determining computer performance.
[0041] The HPL benchmark uses the Linear Congruential Algorithm (LCA) to generate a pseudo-random dense matrix. The computing device obtains the application's data to be processed, which is the dense matrix generated by the HPL benchmark. The dense matrix is partitioned into M×M submatrices, where M is a positive integer. Each submatrix is assigned to each process running on the computing device using a two-dimensional round-robin approach. The dense matrix is used as the matrix to be decomposed, and the matrix to be decomposed is partitioned into a first matrix, a second matrix, a third matrix, and a fourth matrix. The first matrix is the R×R submatrix located in the upper left corner of the matrix to be decomposed. The second matrix is the R×(MR) submatrix located directly below and adjacent to the first matrix. The third matrix is the (MR)×R submatrix located to the right of and adjacent to the first matrix. The fourth matrix is the (MR)×(MR) submatrix consisting of the remaining submatrices. The first and second matrices to be decomposed are combined using a LU decomposition. The third matrix is then subjected to a combined row swap operation and a triangular solution. Finally, matrix multiplication is performed using the updated second and third matrices, and the resulting matrix is used to update the fourth matrix. The updated fourth matrix is then used as the matrix to be decomposed and decomposed using the decomposition method described above. This process is repeated multiple times until all M×M submatrices are calculated, resulting in the LU decomposition of the dense matrix. The decomposition results can be used for subsequent back-substitution and verification.
[0042] In another possible implementation, the data processing method provided in the embodiments of the present application can be applied to a computing cluster with memory-limited computing chips. The computing cluster operates in a multi-process manner, such as using a multi-point interface (MPI). The computing nodes included in the computing cluster are connected via a network and communicate using a communication protocol such as MPI.
[0043] As an example, a computing cluster can use the data processing method provided in the embodiments of the present application to implement high-performance computing (HPC) applications in the field of scientific computing based on the boundary element method or the method of moments. In the boundary element method, the physical area to be solved is meshed. Analytical expressions within the area and on the boundary are established using Green's function, and the original partial differential equation is converted into a boundary integral equation. The boundary integral equation is then discretized on the surface mesh to establish a system of linear equations. A dense matrix is established based on the system of linear equations, and the physical modeling problem is converted into a dense matrix solution problem. The established dense matrix is the data to be processed for the application. The computing cluster divides the data to be processed for the application, that is, the dense matrix, into M×M sub-matrices. The dense matrix is used as the matrix to be decomposed. The matrix to be decomposed is divided into a first matrix, a second matrix, a third matrix, and a fourth matrix. The first matrix is the R×R sub-matrix located in the upper left corner of the matrix to be decomposed. The second matrix is the R×(MR) sub-matrix located directly below and adjacent to the first matrix. The third matrix is a (MR)×R submatrix located to the right of the first matrix and adjacent to the first matrix. The fourth matrix is a (MR)×(MR) submatrix composed of the remaining submatrices. The first and second matrices of the matrix to be decomposed are subjected to a combined LU decomposition, and the third matrix is subjected to a combined row exchange operation and a triangular solution. Finally, the updated second matrix and the updated third matrix are used to calculate the matrix multiplication, and the obtained matrix is used to update the fourth matrix. The updated fourth matrix is then used as the matrix to be decomposed, and the decomposition operation is performed according to the above decomposition method. This is repeated many times until all M×M submatrices are calculated, and the LU decomposition result of the dense matrix is obtained. Based on the LU decomposition result, the solution to the linear equations can be calculated, that is, the physical field results on the boundary surface.
[0044] It should be noted that the two application scenarios described above are only implementation examples. In actual application, the data processing method provided in the embodiments of the present application can also be applied to other applicable data processing scenarios.
[0045] For ease of understanding, the data processing method provided by an embodiment of the present application is described in detail below in conjunction with the accompanying drawings. Referring to Figure 4 , this figure is a schematic flow chart of a data processing method provided by an embodiment of the present application. This method can be applied to a computing device or computing cluster running multiple processes. As shown in Figure 4 , this method may specifically include the following steps.
[0046] S401: Acquire data to be processed of an application, where the data to be processed is a dense matrix including M×M sub-matrices.
[0047] The data to be processed by an application is data generated during the application's operation that needs to be processed, or data required for the application's operation. The data to be processed is a dense matrix. A dense matrix is a matrix that stores all elements in a logically two-dimensional order. The obtained dense matrix is a matrix that needs to be decomposed. As an example, the application is used to test the performance of a computing device. The data to be processed by the application is a randomly generated dense matrix used to test the performance of the computing device. As another example, the application is used to implement physical or mathematical calculations. The dense matrix calculates physical or mathematical equations. The embodiments of this application do not limit the data type of the elements included in the dense matrix. For example, the elements included in the dense matrix can be one or more of single-precision real numbers, double-precision real numbers, single-precision complex numbers, and double-precision complex numbers. The dense matrix includes M×M submatrices, where M is a positive integer smaller than the dimension of the dense matrix. In one possible implementation, the dimension NB of the submatrix can be pre-set, and the ratio of the dimension of the dense matrix to the dimension of the submatrix can be calculated to obtain the value of M. The embodiments of this application do not limit the specific value of M. The value of M can be determined based on the number of processes and the load of each process. As an example, if the number of processes is 100, the value of M is 20. The dense matrix after partitioning is 20×20 sub-matrices.
[0048] S402: Taking the dense matrix as a matrix to be decomposed, and dividing it into a first matrix, a second matrix, a third matrix, and a fourth matrix.
[0049] Decompose the dense matrix and use the dense matrix as the matrix to be decomposed. Divide the matrix to be decomposed into four matrices, a first matrix, a second matrix, a third matrix and a fourth matrix. Referring to Figure 5, this figure is a schematic diagram of a first matrix, a second matrix, a third matrix and a fourth matrix included in a matrix to be decomposed provided in an embodiment of the present application. The first matrix is an R×R submatrix located in the upper left corner of the matrix to be decomposed. The second matrix is an R×(MR) submatrix located below the first matrix and adjacent to the first matrix in the matrix to be decomposed. The third matrix is an (MR)×R submatrix located to the left of the first matrix and adjacent to the first matrix in the matrix to be decomposed. The fourth matrix is an (MR)×(MR) submatrix in the matrix to be decomposed excluding the first matrix, the second matrix and the third matrix.
[0050] R is a positive integer greater than 1 and less than M. The size of R is determined by the computing power of the chip performing the matrix multiplication. The chip performing the matrix multiplication is a chip in a computing device or a computing cluster.
[0051] S403: Perform LU decomposition on the first matrix and the second matrix to obtain an updated first matrix and an updated second matrix, perform a row swap operation on the third matrix, and use the updated first matrix to solve to obtain an updated third matrix, call a GEMM operator to calculate the fourth matrix, and obtain an updated fourth matrix by calculating the difference between the matrix product of the updated second matrix and the updated third matrix.
[0052] After partitioning the matrix to be decomposed into four matrices, perform LU decomposition on the matrix to be decomposed. First, perform LU decomposition on the first and second matrices. That is, perform LU decomposition on the first R columns of the matrix to be decomposed, resulting in an updated first matrix and an updated second matrix. The updated first matrix includes the upper triangular matrix U11 and the lower triangular matrix L11 obtained after LU decomposition. The updated second matrix is L21.
[0053] As an example, the embodiment of the present application provides a specific implementation method for performing LU decomposition on a first matrix and a second matrix, including the following steps:
[0054] A1: Perform strip-block decomposition on the i-th column of the first matrix and the second matrix to obtain the i-th decomposition result and the row break information of the i-th row.
[0055] Wherein, the initial value of i is 1. The ith decomposition result can be obtained by performing Panel decomposition in LU decomposition on the ith column. The ith decomposition result includes the lower triangular matrix L11i, the upper triangular matrix U11i and the ith column of the second matrix, that is, L21i, generated by the decomposition of the ith column. The lower triangular matrix is the lower triangular part of the submatrix of the ith row of the ith column after decomposition. The upper triangular matrix is the upper triangular part of the submatrix of the ith row of the ith column after decomposition. The ith column of the second matrix is the submatrix of the ith column submatrix after decomposition excluding the submatrices of the first R rows. Panel decomposition is performed on the ith column to generate row break information for the ith row. The row break information of the ith row is used to indicate the row swap from the i+1th column to the Mth column in the ith row.
[0056] A2: Perform panel broadcast of the i-th decomposition result and the row break information of the i-th row among the processes assigned to process the submatrix from the 1st column to the Rth column.
[0057] The i-th decomposition result obtained after decomposing the i-th column needs to be sent to the process responsible for the calculation tasks of each submatrix in columns 1 to R. The i-th decomposition result and the i-th row break information are transmitted between processes using panel broadcast.
[0058] A3: Based on the line feed information of the i-th row, rows from the i+1th column to the R-th column of the i-th row are swapped.
[0059] During the LU decomposition of the first and second matrices, that is, columns 1 to R, only the submatrices from columns 1 to R are processed. Based on the row wrap information of row i, columns i+1 to R of row i are swapped with columns i+1 to R of the row containing the column pivot of column i. The resulting columns i+1 to R of column i after the row swap is U12i.
[0060] A4: Update the local tail matrix using L21i, U12i, and the local tail matrix.
[0061] The local tail matrix A22i is a matrix of the [Ri] × [Ri] part. The difference between the local tail matrix and the product of the matrix multiplication of L21i and U12i is calculated to obtain the updated local tail matrix.
[0062] In one possible implementation, a matrix multiplication operator is called to calculate the matrix multiplication in the process of updating the local tail matrix. In the process of performing LU decomposition on the first matrix and the second matrix, the dimension of the matrix passed into the matrix multiplication operator is the dimension of a single submatrix. As an example, the matrix multiplication operator can be one of a general matrix matrix multiplication (GEneral Matrix to Matrix Multiplication, GEMM) operator, a double precision GEneric Matrix Multiplication (DGEMM), a SGEMM single precision matrix multiplication (SGEMM), a single precision complex matrix multiplication (CGEMM), and a double complex precision GEneric Matrix Multiplication (ZGEMM).
[0063] A5: Add 1 to the value of i.
[0064] A6: If the value of i is less than R, the process returns to steps A1 to A5.
[0065] A7: If the value of i is equal to R, perform LU decomposition on the i-th column of the matrix to be decomposed, obtain the i-th decomposition result and the row break information of the i-th row, and complete the LU decomposition of the first matrix and the second matrix.
[0066] Column R is the last column in the LU decomposition of columns 1 to R. LU decomposition is performed on column R to obtain L11R, L21R, and the row break information for row R. The row break information for row R is used to indicate the row swap between columns R+1 to M of row R, and does not need to be performed during the LU decomposition of the first and second matrices. L211 to L21R, obtained after decomposing the first and second matrices, constitute the updated second matrix. U111 to U11R-1 constitute the upper triangular matrix of the updated first matrix. L111 to L11R constitute the lower triangular matrix of the updated first matrix.
[0067] After performing LU decomposition on the first matrix and the second matrix, row swap information for performing a row swap operation on the third matrix can be obtained. The row swap operation is performed on the third matrix using the row swap information.
[0068] As some examples, embodiments of the present application provide specific implementation methods for performing row swap operations on the third matrix using two types of row swap information.
[0069] In a possible implementation, row swap operations are performed on the 1st to Rth rows of the third matrix in sequence from the 1st to the Rth row of the third matrix.
[0070] In another possible implementation, the row break information is first preprocessed to obtain processed row break information. The present application does not limit the specific implementation of the preprocessing. In one possible implementation, the preprocessing includes combining multiple swap operations on submatrices in the same row, or deleting row break information that does not require a row break operation. This preprocessing can reduce the number of row swap steps and improve the efficiency of row swapping.
[0071] After completing the row swap operation, a triangular solution is performed using the first matrix and the third matrix obtained after the row swap operation. Specifically, the triangular solution formula is U12 = L11 - 1U120. Where U12 is the updated third matrix obtained after the triangular solution. L11 is the lower triangular matrix of the first matrix. U120 is the third matrix obtained after the row swap operation.
[0072] Calculate the matrix multiplication of the updated second matrix and the updated third matrix to obtain the product, and then calculate the difference between the fourth matrix and the product to obtain the updated fourth matrix.
[0073] The matrix multiplication of the updated second and third matrices is performed with the product of R and the submatrix dimensions as the dimension. A large value for R satisfies the efficient computational requirements of matrix multiplication and ensures data continuity in memory, meeting the data storage requirements of the GEMM operator.
[0074] S404: Using the updated fourth matrix as a matrix to be decomposed, and performing the same decomposition operation as that of the dense matrix, and iterating until all the M×M sub-matrices are calculated.
[0075] The updated fourth matrix is used as the matrix to be decomposed in the next iteration. The matrix to be decomposed is then divided into four matrices in the same manner. The first and second matrices are decomposed using LU, and the rows of the third matrix are swapped. A triangular solution is performed using the first matrix and the swapped third matrix to obtain the updated third matrix. Finally, the difference between the fourth matrix and the product of the updated second matrix and the updated third matrix is calculated to obtain the updated fourth matrix. This process is repeated multiple times until the dense matrix is decomposed, meaning all M×M submatrices have been calculated.
[0076] In one possible implementation, the updated fourth matrix is composed of N×N submatrices, where N is less than or equal to R. It is not possible to partition the updated fourth matrix. LU decomposition is performed directly on the N×N submatrices to decompose the dense matrix.
[0077] Based on the data processing method provided in the above embodiment, an embodiment of the present application also provides a data processing system. Referring to Figure 6, this figure is a structural diagram of a data processing system provided in an embodiment of the present application. Among them, the data processing system 600 can be configured in a separate computing device, or configured in a computing cluster. The system can be applied to the application scenario shown in Figure 4 above, or it can also be applied to other applicable application scenarios. As an example, taking the computing performance of the above-mentioned HPL test computing device as an implementation scenario as an example, the data processing system 600 can be deployed on a supercomputer. As another example, taking the implementation scenario of the above-mentioned scientific computing field calculation as an example, the data processing system 600 can be deployed on a computing cluster.
[0078] Data processing system 600 includes an acquisition module 601, a partitioning module 602, and a calculation module 603. Acquisition module 601 is configured to support one of the computing devices or computing clusters or a computing device in executing S401 in the embodiment shown in FIG. 4 ; partitioning module 602 is configured to support one of the computing devices or computing clusters or a computing device in executing S402 in the embodiment shown in FIG. ; and calculation module 603 is configured to support one of the computing devices or computing clusters or a computing device in executing S403 and S404 in the embodiment shown in FIG. For the specific execution process, please refer to the detailed description of the corresponding steps in the embodiment shown in FIG. 4 , and no further description will be given here.
[0079] The data processing system shown in FIG. 4 (including the acquisition module 601, partitioning module 602, and calculation module 603) can be software configured on a computing device or computing cluster. By running this software on the computing device or computing device cluster, the computing device or computing device cluster can implement the functions of the data processing system. The following describes the data processing system involved in the data processing process in detail, based on the perspective of hardware implementation.
[0080] Figure 7 shows a structural diagram of a computing device, on which the above-mentioned data processing system can be deployed. The computing device can be a computing device in a cloud environment (such as a server), or a computing device in an edge environment, or a terminal device, etc., which can be specifically used to implement the functions of the above-mentioned acquisition module 601, division module 602 and computing module 603.
[0081] As shown in Figure 7, computing device 700 includes a processor 710, a memory 720, a communication interface 730, and a bus 740. The processor 710, the memory 720, and the communication interface 730 communicate with each other via bus 740. Bus 740 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in Figure 7, but this does not mean that there is only one bus or one type of bus. Communication interface 730 is used to communicate with the outside world, such as receiving data processing tasks.
[0082] The processor 710 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits. The processor 710 may also be an integrated circuit chip with signal processing capabilities. During implementation, the functions of each module in the data processing system may be implemented by hardware integrated logic circuits or software instructions in the processor 710. The processor 710 may also be a general-purpose processor, a digital signal processor (DSP), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The methods disclosed in the embodiments of this application may be directly implemented as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or the like. The storage medium is located in the memory 720 , and the processor 710 reads the information in the memory 720 and completes part or all of the functions of the data processing system in combination with its hardware.
[0083] The memory 720 may include a volatile memory, such as a random access memory (RAM), or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a HDD, or an SSD.
[0084] The memory 720 stores executable codes, and the processor 710 executes the executable codes to perform the method performed by the aforementioned data processing system.
[0085] Specifically, when the embodiment shown in Figure 4 is implemented based on the acquisition module 601, division module 602 and calculation module 603 described in the embodiment shown in Figure 6, and the acquisition module 601, division module 602 and calculation module 603 described in the embodiment shown in Figure 6 are implemented by software, the software or program code required for the acquisition module 601, division module 602 and calculation module 603 to perform the functions of each step in the embodiment shown in Figure 4 is stored in the memory 720, the interaction between the acquisition module 601 and other devices is realized through the communication interface 730, and the processor is used to execute instructions in the memory 720 to implement the method executed by the data processing system.
[0086] FIG8 is a schematic diagram illustrating the structure of a computing device cluster. The computing device cluster 80 shown in FIG8 includes multiple computing devices, and the data processing system described above can be deployed in a distributed manner across the multiple computing devices in the computing device cluster 80. As shown in FIG8 , the computing device cluster 80 includes multiple computing devices 800, each of which includes a memory 820, a processor 810, a communication interface 830, and a bus 840. The memory 820, the processor 810, and the communication interface 830 are communicatively connected to each other via the bus 840.
[0087] The processor 810 can be a CPU, GPU, ASIC, or one or more integrated circuits. The processor 810 can also be an integrated circuit chip with signal processing capabilities. During implementation, some functions of the data processing system can be performed by hardware integrated logic circuits or software instructions within the processor 810. The processor 810 can also be a DSP, FPGA, general-purpose processor, other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, and can implement or execute some of the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules within the decoding processor. The software modules can be located in storage media well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory 820. In each computing device 800, the processor 810 reads information from memory 820 and, in conjunction with its hardware, can perform some of the functions of the data processing system.
[0088] The memory 820 may include ROM, RAM, static storage devices, dynamic storage devices, hard disks (e.g., SSDs, HDDs), etc. The memory 820 may store program codes, for example, part or all of the program codes for implementing the acquisition module 601, part or all of the program codes for implementing the partitioning module 602, and part or all of the program codes for implementing the calculation module 603. For each computing device 800, when the program codes stored in the memory 820 are executed by the processor 810, the processor 810 executes part of the method executed by the data processing system based on the communication interface 830. For example, a portion of the computing devices 800 may be used to execute the method executed by the acquisition module 601, while another portion of the computing devices 800 may be used to execute the methods executed by the partitioning module 602 and the calculation module 603. The memory 820 may also store data, for example, intermediate data or result data generated by the processor 810 during the execution process, for example, the acquired data to be processed and the results obtained by decomposition.
[0089] The communication interface 803 in each computing device 800 is used for external communication, such as interacting with other computing devices 800 .
[0090] The bus 840 may be a peripheral component interconnect standard bus or an extended industry standard architecture bus, etc. For ease of illustration, the bus 840 in each computing device 800 in FIG8 is represented by only one thick line, but this does not mean that there is only one bus or one type of bus.
[0091] The plurality of computing devices 800 establish communication paths through a communication network to implement the functions of the data processing system. Any computing device can be a computing device in a cloud environment (e.g., a server), a computing device in an edge environment, or a terminal device.
[0092] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on one or more computing devices, it enables the one or more computing devices to execute the methods executed by the various modules of the data processing system of the above embodiment.
[0093] In addition, embodiments of the present application further provide a computer program product. When the computer program product is executed by one or more computing devices, the one or more computing devices perform any of the aforementioned data processing methods. The computer program product may be a software installation package. When any of the aforementioned data processing methods is required, the computer program product may be downloaded and executed on a computer.
[0094] It should also be noted that the system embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separate, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed across multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the system embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0095] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by dedicated hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits, or dedicated circuits. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0096] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0097] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A data processing method, characterized in that: The method is applied to a computing device or a computing cluster running multiple processes, and the method includes: Acquire data to be processed of an application, wherein the data to be processed is a dense matrix, and the dense matrix includes M×M sub-matrices; The dense matrix is used as a matrix to be decomposed, and is divided into a first matrix, a second matrix, a third matrix, and a fourth matrix, wherein the first matrix is an R×R submatrix located at the upper left corner of the matrix to be decomposed, the second matrix is an R×(MR) submatrix located directly below the first matrix and adjacent to the first matrix, the third matrix is an (MR)×R submatrix located to the right of the first matrix and adjacent to the first matrix, and the fourth matrix is an (MR)×(MR) submatrix composed of the remaining submatrices; Performing LU decomposition on the first matrix and the second matrix to obtain an updated first matrix and an updated second matrix, performing a row exchange operation on the third matrix, and performing a triangular solution using the updated first matrix and the third matrix obtained after the row exchange operation to obtain an updated third matrix, calling a GEMM operator to calculate matrix multiplication of the updated second matrix and the updated third matrix to obtain a product, and calculating a difference between the fourth matrix and the product to obtain an updated fourth matrix; The updated fourth matrix is used as a matrix to be decomposed, and the same decomposition operation as that of the dense matrix is performed, and it is iterated until all the M×M sub-matrices are calculated.
2. The data processing method according to claim 1, characterized in that: The size of R is determined by the computational power of the chip that performs the matrix multiplication.
3. The data processing method according to claim 1, characterized in that: When the updated fourth matrix consists of N×N sub-matrices, and N is less than or equal to R, LU decomposition is performed on the N×N sub-matrices.
4. The data processing method according to any one of claims 1 to 3, characterized in that: The performing a row exchange operation on the third matrix includes: A row swap operation is performed row by row on the third matrix based on row swap information, where the row swap information is generated by performing LU decomposition on the first matrix and the second matrix.
5. The data processing method according to any one of claims 1 to 3, characterized in that: The performing a row exchange operation on the third matrix includes: Preprocessing the line break information to obtain processed line break information, where the line break information is generated by performing LU decomposition on the first matrix and the second matrix; Based on the processed row-swap information, a row-swap operation is performed on the third matrix.
6. A data processing system, characterized in that: The system comprises: An acquisition module, used for acquiring data to be processed of an application, wherein the data to be processed is a dense matrix, and the dense matrix includes M×M sub-matrices; a partitioning module, configured to use the dense matrix as a matrix to be decomposed, and divide it into a first matrix, a second matrix, a third matrix, and a fourth matrix, wherein the first matrix is an R×R submatrix located at the upper left corner of the matrix to be decomposed, the second matrix is an R×(MR) submatrix located directly below the first matrix and adjacent to the first matrix, the third matrix is an (MR)×R submatrix located to the right of the first matrix and adjacent to the first matrix, and the fourth matrix is an (MR)×(MR) submatrix composed of the remaining submatrices; A computing module, configured to perform LU decomposition on the first matrix and the second matrix to obtain an updated first matrix and an updated second matrix, perform a row swap operation on the third matrix, perform a triangular solution using the updated first matrix and the third matrix obtained after the row swap operation to obtain an updated third matrix, call a GEMM operator to calculate matrix multiplication of the updated second matrix and the updated third matrix to obtain a product, and calculate a difference between the fourth matrix and the product to obtain an updated fourth matrix; The calculation module is further used to use the updated fourth matrix as a matrix to be decomposed, and perform the same decomposition operation as the dense matrix, and iterate until all the M×M sub-matrices are calculated.
7. The data processing system according to claim 6, characterized in that: The size of R is determined by the computing power of the chip in the computing device that performs the matrix multiplication.
8. The data processing system according to claim 6, characterized in that: The calculation module is further used to perform LU decomposition on the N×N sub-matrices when the updated fourth matrix is N×N sub-matrices and N is less than or equal to R.
9. The data processing system according to any one of claims 6 to 8, characterized in that: The calculation module is used to perform a row exchange operation on the third matrix, including: The calculation module is used to perform a row swap operation on the third matrix row by row based on row wrap information, where the row wrap information is generated by performing LU decomposition on the first matrix and the second matrix.
10. The data processing system according to any one of claims 6 to 8, characterized in that: The calculation module is used to perform a row exchange operation on the third matrix, including: The calculation module is used to preprocess the row break information to obtain processed row break information, where the row break information is generated by performing LU decomposition on the first matrix and the second matrix; based on the processed row break information, perform a row swap operation on the third matrix.
11. A computer code product comprising instructions which, when executed on a computing device, cause the computing device to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Data processing method and system and related equipment
CN118520206A
Spark-based distributed matrix inversion parallel operation method
CN105373517A
System code coding method and apparatus
CN105515589A
A GEMM (general matrix-matrix multiplication) high-performance realization method based on a domestic SW 26010 many-core CPU
CN107168683A
Information processing apparatus
US20220253507A1
Cited By
Matrix multiplication implementation method and device, electronic equipment, storage medium and program product
CN121210826A
