Large-scale matrix QR decomposition single-core serial calculation method, device and equipment and storage medium
By dividing large-scale matrices into blocks according to fast memory capacity and using Level-3 BLAS for serial QR decomposition, the problem of low computation-to-transfer ratio in existing technologies is solved, improving single-core computing efficiency and memory access efficiency, and achieving efficient matrix decomposition.
Patent Information
- Application Number
- CN202511621087.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, large-scale matrix QR decomposition has a low computation-to-transfer ratio in slow memory, making it difficult to efficiently utilize fast memory, resulting in poor computational complexity and memory access efficiency.
Large-scale matrices are stored in blocks according to the capacity of fast memory, and Level-3 BLAS is used to perform serial QR decomposition of the matrix blocks. By using the block method, the number of data accesses from slow memory is reduced, thereby improving computational complexity and memory access efficiency.
It improves single-core computing efficiency and fast memory utilization, reduces data transfer overhead, and enables efficient computation of large-scale matrix QR decomposition.
Smart Images

Figure CN121501447A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of digital signal processing, in particular to a large-scale matrix QR decomposition single-core serial calculation method and device, equipment and storage medium. BACKGROUND
[0002] QR decomposition decomposes a matrix into an orthogonal matrix (Q) and an upper triangular matrix (R), thereby taking advantage of the orthogonality and triangular structure of the matrix to simplify the calculation, improve the numerical stability, and solve various mathematical and engineering problems, and is one of the important pre-work for solving the eigenvalues of a matrix, solving a linear equation set, and solving a least square problem in modern scientific calculation.
[0003] In related technologies, the serial QR decomposition widely used in a single core is based on Level-1 (first level) and Level-2 (second level) BLAS (Basic Linear Algebra Subprograms) for iterative calculation, and the generation of a Householder vector (Level-1 BLAS), the multiplication of a residual sub-matrix and the Householder vector (Level-2 BLAS) are calculated in one iteration step. This method updates the QR calculation according to the matrix column by column, which is referred to as a one-stage method.
[0004] BLAS is the core component of scientific calculation, and its three levels correspond to different calculation complexities: Level-1 is a vector-vector operation, which processes basic vector operations with linear time complexity, and the calculation transmission ratio is O (1); Level-2 is a matrix-vector operation, which processes the interaction between a matrix and a vector with quadratic time complexity, and the calculation transmission ratio is O (n); Level-3 is a matrix-matrix operation, which processes dense matrix operations with cubic time complexity, and the calculation transmission ratio is O (n 2 ). The existing QR decomposition based on Householder transformation is based on Level-1 and Level-2 BLAS, which needs to read new data for calculation and write back repeatedly in fast memory, and the calculation transmission ratio is far less than that of Level-3 BLAS.
[0005] In large-scale matrices (A ∈ R m×n , m nThe original data is stored in slow memory (hard disk drive HDD, solid state drive SSD), and the fast memory (dynamic random access memory DRAM, cache) of a modern computer is limited, and it is difficult to directly save all elements of a column of a matrix (that is, the Householder transformation based on Level-1 BLAS needs to access the column vector multiple times) in one calculation, and the calculation transmission ratio is not high.
[0006] In the related art, the matrix elements are sequentially stored in the slow memory according to the column-major order of the matrix, that is, the column elements in the matrix in the column-major order are stored in the slow memory, and the arrow represents the column-major order. Figure 1 The column elements in the matrix in the column-major order are stored in the slow memory, and the arrow represents the column-major order. The existing serial scheme is used for matrix A ∈ R m×n , m n The calculation steps of the Householder-based QR decomposition are as follows (taking the i-th column as an example): the larfg step: calculating the norm of the i-th column of A, and updating the i-th column of A according to the norm; the larf step: updating the remaining submatrix of the matrix A using the updated i-th column. This process is based on Level-1 BLAS for matrix operation, and such calculation needs to repeatedly read the data of the column vector, and the calculation complexity is relatively low compared with the memory access. Especially when the number of rows of the matrix is large, it is difficult to store a column vector in the fast memory, and when the data exceeding the capacity of the fast memory is calculated by Level-1 BLAS, the data needs to be read in multiple times for one task. Assuming that the capacity of the fast memory is 2MB and the actual column vector occupies 8MB of memory, the calculation core needs to access the fast memory and the slow memory at least 4 times to calculate the complete norm. SUMMARY
[0007] The application provides a large-scale matrix QR decomposition single-core serial calculation method, device, equipment and storage medium.
[0008] In a first aspect, the application provides a large-scale matrix QR decomposition single-core serial calculation method, comprising: According to the capacity of the fast memory, the target large-scale matrix is divided into a plurality of matrix blocks, wherein each matrix block is stored continuously in column-major order, and the required storage space of each matrix block is less than or equal to the capacity of the fast memory; The leftmost and uppermost matrix blocks in all the matrix blocks are taken as target matrix blocks, and the target matrix blocks are subjected to serial QR decomposition to obtain an upper triangular matrix corresponding to the target matrix blocks, b column Householder reflection vectors of an orthogonal matrix, and factors of the b Householder reflection vectors, wherein b is the order of the current matrix block; updating the matrix block right to the current matrix block based on the bth column Householder reflection vector of the orthogonal matrix corresponding to the current matrix block and the factors of the b Householder reflection vectors, until all the matrix blocks in the row where the current matrix block is located are updated; updating the matrix block below the target matrix block based on the upper triangular matrix corresponding to the target matrix block, until all the matrix blocks in the column where the target matrix block is located are updated, and updating the upper triangular matrix of the target matrix block; updating the matrix block right to the current matrix block based on the bth column Householder reflection vector of the orthogonal matrix corresponding to the current matrix block and the factors of the b Householder reflection vectors, until all the matrix blocks in the row where the current matrix block is located are updated;
[0009] In an optional embodiment of the present application, the serial QR decomposition of the target matrix block includes: calculating the norm of the target column of the target matrix block, updating the target column using one division according to the norm, obtaining the scaling factor and the Householder reflection vector corresponding to the target column, and writing the Householder reflection vector as the updated target column into the storage position corresponding to the target column; updating the other columns of the target matrix block using the updated target column, and the updated target column and the other columns constituting the updated target matrix block as the upper triangular matrix corresponding to the target matrix block; writing the scaling factor and the Householder reflection vector corresponding to all the columns of the target matrix block as the Householder reflection vector and the factor of the Householder reflection vector corresponding to the target matrix block, respectively.
[0010] In an optional embodiment of the present application, the updating the other columns of the target matrix block using the updated target column includes: determining the projection amount corresponding to the remaining columns of the target matrix block according to the scaling factor and the Householder reflection vector corresponding to the target column and the remaining columns of the target matrix block; determining the updated remaining columns according to the remaining columns of the target matrix block, the projection amount corresponding to the remaining columns and the Householder reflection vector corresponding to the target column.
[0011] In an optional embodiment of this application, the projection amount corresponding to the remaining columns of the target matrix block is determined by the following expression, based on the scaling factor corresponding to the target column, the Householder reflection vector, and the remaining columns of the target matrix block:
[0012] in, The remaining columns of the target matrix are divided into blocks. j The projection quantity corresponding to the column, The scaling factor is the value corresponding to the target column. For the target list i The conjugate transpose of the Householder reflection vector corresponding to the column. The remaining columns of the target matrix are divided into blocks. j Column vector, The updated remaining columns are determined using the following expression, based on the remaining columns of the target matrix block, their corresponding projections, and the Householder reflection vectors corresponding to the target columns:
[0013] in, For the remaining columns after the update j Column vector, The remaining columns of the target matrix are divided into blocks. j Column vector, The remaining columns of the target matrix are divided into blocks. j The projection quantity corresponding to the column, For the target list i The Householder reflection vector corresponding to the column.
[0014] In an optional embodiment of this application, the matrix blocks to the right of the target matrix block are updated based on the b columns of Householder reflection vectors and the b factors of the orthogonal matrix corresponding to the target matrix block, using the following expression:
[0015] in, Divide the target matrix into blocks, and then divide the matrix into blocks on the right side of the updated matrix. Divide the matrix to the right of the target matrix into blocks. Householder reflection vectors of orthogonal matrices corresponding to blocks of the target matrix. Factors of the Householder reflection vector corresponding to the block partition of the target matrix.
[0016] In an optional embodiment of this application, based on the upper triangular matrix corresponding to the target matrix block, the matrix blocks below the target matrix block are updated until all matrix blocks in the column where the target matrix block is located have been updated, and the upper triangular matrix of the target matrix block is updated, including: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null and the scaling factor corresponding to the current matrix block; Update the upper triangular matrix corresponding to the current matrix block and the target matrix block based on the Householder reflection vector and scaling factor.
[0017] In an optional embodiment of this application, determining the Householder reflection vector that nullifies the current matrix block and the scaling factor corresponding to the current matrix block for each matrix block below the target matrix block includes: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null; The scaling factor corresponding to the current matrix block is determined based on the Householder reflection vector using the following expression: τ = 2 / (1 + ||v||²) Where τ is the scaling factor corresponding to the current matrix block, and v is the Householder reflection vector corresponding to the current matrix block.
[0018] A second aspect of this application provides a large-scale matrix QR decomposition single-core serial computing device, comprising: The partitioning module is used to divide the target large-scale matrix into multiple matrix blocks according to the fast memory capacity. Each matrix block is stored contiguously in column-major order and the storage space required for each matrix block is less than or equal to the fast memory capacity. The decomposition module is used to take the leftmost and topmost matrix blocks of all matrix blocks as the target matrix blocks, perform serial QR decomposition on the target matrix blocks, and obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix block, and the b factors of the Householder reflection vectors, where b is the order of the current matrix block. The first update module is used to update the matrix blocks to the right of the target matrix block based on the b columns of Householder reflection vectors and b factors of the orthogonal matrix corresponding to the target matrix block, until all matrix blocks in the row where the target matrix block is located have been updated. The second update module is used to update the matrix blocks below the target matrix block based on the upper triangular matrix corresponding to the target matrix block, until all matrix blocks in the column where the target matrix block is located have been updated, and to update the upper triangular matrix of the target matrix block. The third update module is used to update the matrix blocks to the right of the current matrix block for each matrix block in the column where the target matrix block is located, based on the b columns of Householder reflection vectors and the b factors of Householder reflection vectors of the orthogonal matrix corresponding to the current matrix block, until all matrix blocks in the row where the current matrix block is located have been updated, where b is the column number of the current matrix block.
[0019] A third aspect of this application provides a computer device, including: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the above-mentioned large-scale matrix QR decomposition single-core serial calculation methods.
[0020] A fourth aspect of the embodiments of this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the large-scale matrix QR decomposition single-core serial computation method as described in any of the preceding claims.
[0021] Compared with the prior art, the technical solutions provided in this application have at least some or all of the following advantages: The large-scale matrix QR decomposition single-core serial computation method described in this application implements multi-stage matrix QR decomposition by dividing the matrix into blocks according to the size of the fast memory capacity. Compared with the single-core serial QR decomposition method, this application always accesses the matrix in rectangular blocks. In the computation steps, serial QR decomposition steps are performed within the diagonal matrix blocks, and Level-3 BLAS is used when updating the off-diagonal matrix blocks. This improves the computational complexity and memory access ratio within a single core and enhances the single-core computational efficiency. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram illustrating the storage methods for large-scale matrices in related technologies; Figure 2 A flowchart illustrating a large-scale matrix QR decomposition single-core serial computation method provided in one embodiment of this application; Figure 3 A schematic diagram illustrating a storage method for a large-scale matrix provided in one embodiment of this application; Figure 4 A schematic diagram illustrating a storage method for a large-scale matrix provided in another embodiment of this application; Figure 5 A flowchart of a large-scale matrix QR decomposition single-core serial computation method provided in another embodiment of this application; Figure 6 A schematic diagram of a single-core serial computing device for large-scale matrix QR decomposition provided in one embodiment of this application; Figure 7 This is a schematic diagram of a computer device structure provided in one embodiment of this application. Detailed Implementation
[0023] In the process of developing this application, the inventors discovered that current large-scale matrix QR decomposition methods are poor in terms of computational transfer ratio.
[0024] To address the aforementioned issues, this application provides a single-core serial computation method, apparatus, device, and storage medium for large-scale matrix QR decomposition, thereby improving the computation-to-transfer ratio of large-scale matrix QR decomposition.
[0025] The solutions in this application embodiment can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0026] To make the technical solutions and advantages of the embodiments of this application clearer, the exemplary embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not an exhaustive list of all embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.
[0027] Please see Figure 2 The large-scale matrix QR decomposition single-core serial computation method provided in this application includes the following steps S100~S500: S100: The target large-scale matrix is divided into multiple matrix blocks according to the fast memory capacity. Each matrix block is stored contiguously in column-major order and the storage space required for each matrix block is less than or equal to the fast memory capacity. S200, take the leftmost and topmost matrix blocks of all matrix blocks as the target matrix blocks, perform serial QR decomposition on the target matrix blocks to obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix blocks, and the b factors of the Householder reflection vectors, where b is the order of the current matrix block; S300, based on the b-column Householder reflection vectors and b factors of the orthogonal matrix corresponding to the target matrix block, update the matrix blocks to the right of the target matrix block until all matrix blocks in the row where the target matrix block is located have been updated. S400, based on the upper triangular matrix corresponding to the target matrix block, update the matrix blocks below the target matrix block until all matrix blocks in the column where the target matrix block is located have been updated, and update the upper triangular matrix of the target matrix block. S500, for each matrix block in the column where the target matrix block is located, based on the b columns of Householder reflection vectors and the b factors of Householder reflection vectors in the orthogonal matrix corresponding to the current matrix block, update the matrix blocks to the right of the current matrix block until all matrix blocks in the row where the current matrix block is located have been updated, where b is the column number of the current matrix block.
[0028] In an optional embodiment of this application, Figure 1 The storage solution in the middle is transformed into Figure 3 The matrix is divided into blocks based on the fast memory capacity and stored in column-major order within each block. Figure 3 The small and medium rectangles contain matrix elements stored in column-major order. This tightly integrates the algorithm with the data storage format in fast memory. This modification reduces the need for continuous data reading and writing of the complete matrix (stored in slow memory) during the QR decomposition process. At the same time, it requires corresponding modifications to the Householder's calculation process for matrix QR decomposition.
[0029] In an optional embodiment of this application, considering the limitations of fast memory, to minimize the number of times column vectors are stored, the process of accessing column vectors is converted into accessing square matrices, and the larfg and larf processes are performed within the square matrix. An access is performed only after the calculation of a square matrix is completed. The large-scale matrix QR decomposition single-core serial computation method of this application includes steps such as geqrt, larfb, ptqrt, and ssrfb to achieve the QR decomposition of the complete matrix; the steps involve matrix-shaped matrix access and triangular matrix access. It is assumed that the original matrix in shared memory is constructed according to pre-designed matrix blocks with a maximum fast memory capacity S, and each block of the matrix is stored consecutively in column-major order as follows: Figure 4 As shown, the original matrix size m× n The storage capacity required for the internal rectangular block matrix does not exceed S, where the storage required for the square matrix block is the upper limit of the fast memory capacity S (i.e., the size of the square matrix). b x b , b for ), the bottom and rightmost rectangular blocks ( () represents the special blocks remaining after the original matrix is partitioned according to the fast memory capacity S (each block's size does not exceed S). The geqrt step is as follows: for a matrix of size S... b x b Perform serial QR decomposition on the square matrix and output... R k,k The upper triangular matrix corresponding to the current block matrix; output V k,k It is stored in the lower triangular part of the square matrix, where, V k,k Includes the b-column Householder reflection vectors of the current block corresponding to the orthogonal matrix generated by the cumulative Householder process, stored using the compact WY method; output T k,k This is a factor for the b Householder reflection vectors that require additional space for storage. The larfb steps are: for the matrix A k,k Update the block matrix on the right, input A k,j ,V k,k ,T k,k j = k + 1,..., 3, Output A k,j Copy it to the corresponding position in the original matrix. The ptqrt steps are: for the matrix A k,k Update the lower block matrix, input A i,k ,R k,k j = k + 1,..., 3, Output and A i,k Matrix of consistent size V i,k Copy it to the corresponding position in the original matrix, where, V i,k Includes the use of upper triangular matrices R k,k Householder transformation elimination A i,k Transform it into the Householder vector corresponding to 0; output T i,k This is a factor for the b Householder reflection vectors that require additional space for storage. This calculation step will be updated again. R k,k Compared with existing Householder-based serial computation QR decomposition methods, R k,kAfter the calculation is complete, the corresponding upper triangular parts are no longer updated. The ssrfb steps are: for the matrix... A i,k Update the block matrix on the right, input A i,j ,V i,k ,T i,k j = k + 1,..., 3, Output A i,j Copy it to the corresponding position in the original matrix.
[0030] like Figure 5 As shown, in a single-core processor, the device reads the contents of the matrix blocks and executes the four calculation steps described above in the following order from left to right and top to bottom. Each step of the calculation is performed in block form, and data is not read from slow memory or the fast memory of other devices during the calculation. This protects the integrity of local memory and adjusts the local operations to Level-3 BLAS, which greatly improves the calculation efficiency and the utilization of fast memory.
[0031] This application's large-scale matrix QR decomposition single-core serial computing method fully combines the matrix QR decomposition task within the computing node with the fast memory capacity within the core. By using a block-based approach, it reduces the number of times data is accessed from slow memory during single-core QR decomposition computing, improves the utilization rate of fast memory, and the block-based approach coupled with fast memory capacity has scalability. This block-based approach can be used in any type of computing chip (FPGA, GPU, CPU) to accelerate the efficiency of the QR decomposition task in that computing chip.
[0032] In an optional embodiment of this application, the step of performing serial QR decomposition on the target matrix blocks to obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix blocks, and the factors of the b Householder reflection vectors includes: For the target column of the target matrix block, calculate the norm of the target column, update the target column by division according to the norm, obtain the scaling factor and Householder reflection vector of the target column, and write the Householder reflection vector as the updated target column into the storage location corresponding to the target column. The updated target column is used to update the other columns of the target matrix block. The updated target column and other columns form the updated target matrix block, which serves as the upper triangular matrix corresponding to the target matrix block. The scaling factor and Householder reflection vector corresponding to all columns of the target matrix block are used as factors of the Householder reflection vector and Householder reflection vector corresponding to the target matrix block, respectively.
[0033] In an optional embodiment of this application, for a matrix of size... b x b Perform serial QR decomposition on the square matrix and output... R k,k The upper triangular matrix corresponding to the current block matrix; output V k,k It is stored in the lower triangular part of the square matrix, where, V k,k Includes the b-column Householder reflection vectors of the current block corresponding to the orthogonal matrix generated by the cumulative Householder process, stored using the compact WY method; output T k,k This is a factor for the b Householder reflection vectors that require additional space for storage.
[0034] The single-core serial computation method for large-scale matrix QR decomposition proposed in this application transforms the existing column vector QR decomposition into matrix block QR decomposition. When performing QR decomposition on the entire matrix block, only one data entry is required, making the QR decomposition of large-scale matrices simple and fast.
[0035] In an optional embodiment of this application, updating other columns of the target matrix block using the updated target column includes: The projection amount corresponding to the remaining columns of the target matrix block is determined based on the scaling factor corresponding to the target column, the Householder reflection vector, and the remaining columns of the target matrix block. The updated remaining columns are determined based on the remaining columns of the target matrix block, their corresponding projections, and the Householder reflection vectors corresponding to the target columns.
[0036] The large-scale matrix QR decomposition single-core serial computation method of this application first updates the target column within the matrix block, and then uses the updated target column to update other columns of the target matrix block, so that data between different columns can be updated without transmission, reducing transmission overhead.
[0037] In an optional embodiment of this application, the projection amount corresponding to the remaining columns of the target matrix block is determined by the following expression, based on the scaling factor corresponding to the target column, the Householder reflection vector, and the remaining columns of the target matrix block:
[0038] in, The remaining columns of the target matrix are divided into blocks. j The projection quantity corresponding to the column, The scaling factor is the value corresponding to the target column. For the target list i The conjugate transpose of the Householder reflection vector corresponding to the column. The remaining columns of the target matrix are divided into blocks. j Column vector, The updated remaining columns are determined using the following expression, based on the remaining columns of the target matrix block, their corresponding projections, and the Householder reflection vectors corresponding to the target columns:
[0039] in, For the remaining columns after the update j Column vector, The remaining columns of the target matrix are divided into blocks. j Column vector, The remaining columns of the target matrix are divided into blocks. j The projection quantity corresponding to the column, For the target list i The Householder reflection vector corresponding to the column.
[0040] The large-scale matrix QR decomposition single-core serial computation method of this application first updates the target column within the matrix block, and then uses the updated target column to update other columns of the target matrix block, so that data between different columns can be updated without transmission, reducing transmission overhead.
[0041] In an optional embodiment of this application, the matrix blocks to the right of the target matrix block are updated based on the b columns of Householder reflection vectors and the b factors of the orthogonal matrix corresponding to the target matrix block, using the following expression:
[0042] in, Divide the target matrix into blocks, and then divide the matrix into blocks on the right side of the updated matrix. Divide the matrix to the right of the target matrix into blocks. Householder reflection vectors of orthogonal matrices corresponding to blocks of the target matrix. Factors of the Householder reflection vector corresponding to the block partition of the target matrix.
[0043] The large-scale matrix QR decomposition single-core serial computation method of this application first performs QR decomposition on the target matrix block between matrix blocks to obtain the updated target matrix block, and then updates the matrix blocks to the right of the target matrix block based on the updated target matrix block, which can realize asynchronous parallel QR decomposition of large-scale matrices.
[0044] In an optional embodiment of this application, based on the upper triangular matrix corresponding to the target matrix block, the matrix blocks below the target matrix block are updated until all matrix blocks in the column where the target matrix block is located have been updated, and the upper triangular matrix of the target matrix block is updated, including: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null and the scaling factor corresponding to the current matrix block; Update the upper triangular matrix corresponding to the current matrix block and the target matrix block based on the Householder reflection vector and scaling factor.
[0045] In an optional embodiment of this application, when updating the matrix blocks below or to the right of the target matrix block, the method further includes: The target large-scale matrix is divided into multiple matrix blocks based on the fast memory capacity of each core; Multiple cores are arranged according to their capacity to obtain a two-dimensional core arrangement; Multiple matrices are divided and distributed into a two-dimensional core arrangement in a cyclical manner in both the horizontal and vertical directions; Based on the update principle, a task execution dependency graph is constructed between each matrix block in each core, so that each core executes the update task and transmission task of the matrix block according to the task execution dependency graph.
[0046] In an optional embodiment of this application, dividing the target large-scale matrix into multiple matrix blocks based on the fast memory capacity of each core includes: Get the fast memory capacity for each core; Select the smallest fast memory capacity among all fast memory capacities; The corresponding block matrix is determined based on the minimum fast memory capacity; The target large-scale matrix is divided into multiple matrix blocks using square matrices as the unit.
[0047] In an optional embodiment of this application, arranging multiple cores according to their capacity to obtain a two-dimensional core arrangement includes: Get the capacity of each core; Sort the cores by capacity from largest to smallest, and then arrange the cores corresponding to the sorted capacities to obtain a two-dimensional core arrangement. In the two-dimensional core arrangement, the capacity of the left core is greater than or equal to the capacity of the right core among the left and right adjacent cores, and the capacity of the upper core is greater than or equal to the capacity of the lower core among the upper and lower adjacent cores.
[0048] In an optional embodiment of this application, the step of distributing multiple matrix blocks into a two-dimensional core arrangement in a cyclical manner along both the horizontal and vertical directions includes: In the two-dimensional core, K N ×K M In the case of the arrangement, the matrix in the Mth column is divided into blocks and distributed from top to bottom in a vertically cyclic manner to the mod(M, K)th column of the two-dimensional core arrangement. M In the core column, M is from 1 to the number of columns in the matrix block arrangement; Divide the Nth row matrix into blocks and distribute them horizontally in a cyclical manner from left to right to the mod(N, K)th row of the two-dimensional core arrangement. N In the core row, N is the number of rows in the matrix block arrangement from 1 to 2.
[0049] In an optional embodiment of this application, the step of dividing the M-th column matrix into blocks and distributing them vertically in a cyclic manner from top to bottom to the mod(M, K)-th column of the two-dimensional core arrangement is... M The core of the column includes: Determine the block partition of the M-th column matrix and the mod(M, K)-th column matrix. M The quotient between the number of cores in each column; Based on this quotient, the corresponding blocks of the Mth column matrix are grouped to obtain multiple groups of matrix blocks; For each group of matrix blocks, the m-th matrix block in the current group of matrix blocks is assigned to the mod(M, K)-th matrix block. M ) The m-th core in column (M, K), where m is from 1 to the modulo (M, K) core. M ) Column core quantity.
[0050] In an optional embodiment of this application, the step of dividing the Nth row matrix into blocks and distributing them horizontally in a cyclic manner from left to right to the mod(N, K)th row of the two-dimensional core arrangement is... N The core of the column includes: Determine the Nth row matrix block and the mod(N, K)th row block. N The quotient between the number of core rows; Based on this quotient, the corresponding blocks of the Nth row matrix are grouped to obtain multiple groups of matrix blocks; For each group of matrix blocks, the nth matrix block in the current group of matrix blocks is assigned to the mod(N, K)th matrix block. NThe nth core in row ) where n is from 1 to the mod (N, K)th core. N ) number of core rows.
[0051] In an optional embodiment of this application, the step of constructing a task execution dependency graph between each matrix block in each core according to the update principle, so that each core executes the update task and transmission task of the matrix block according to the task execution dependency graph, includes: Update the first row matrix of each core in the first row of the core in blocks, and update the remaining submatrices of each core except the first row according to the update results; For the updated matrix blocks, the first column matrix block of each core in the first column is updated, and the remaining submatrices in each core except for the first column are updated according to the update result. In an optional embodiment of this application, geqrt at k=1 only decomposes the current matrix block. A 1,1 The QR decomposition yields the upper triangular matrix. R 1,1 The matrix is not a complete matrix. R correspond A 1,1 The value of the upper triangular matrix required for the block position is only available after the tpqrt calculation steps for the matrix partitioning corresponding to k=1, i=4, j=1 have been completed. R 1,1 That is the complete matrix A correspond A 1,1 The upper triangular part of the matrix block.
[0052] The large-scale matrix QR decomposition single-core serial computation method of this application, for the first row matrix block in the same column matrix block, R 1,1 Each time the matrix blocks in the same column are updated, except for the first row matrix block, the corresponding first row matrix block is updated again. R 1,1 This process continues until the last row of the matrix block in the same column is updated, ensuring that the decomposition result is the same as that obtained from the existing QR decomposition while reducing the number of data accesses.
[0053] In an optional embodiment of this application, determining the Householder reflection vector that nullifies the current matrix block and the scaling factor corresponding to the current matrix block for each matrix block below the target matrix block includes: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null; The scaling factor corresponding to the current matrix block is determined based on the Householder reflection vector using the following expression: τ = 2 / (1 + ||v||²) where τ is the scaling factor corresponding to the current matrix block and v is the Householder reflection vector corresponding to the current matrix block.
[0054] The single-core serial computation method for large-scale matrix QR decomposition proposed in this application first performs QR decomposition on the target matrix block between matrix blocks to obtain the updated target matrix block, and then updates the matrix blocks below the target matrix block based on the updated target matrix block, which can realize asynchronous parallel QR decomposition of large-scale matrices.
[0055] In an optional embodiment of this application, the block-based method of this application does not allow larfb and ptqrt to simultaneously access the same matrix block during serial computation. In a multi-core computing unit, these two parts can also run in parallel, requiring only the maintenance of the computational logic between each matrix block: once the prerequisite tasks for the current matrix block have been completed, the task for the current matrix block can be executed. Maintaining the computational dependencies between matrix blocks can be extended to graph-based scheduling methods. As long as the computational relationships between matrix blocks are determined, and the execution order between matrix blocks is dynamically maintained, the aforementioned four computational steps can be executed asynchronously within the current block matrix. The block-based method of this application can be widely applied to asynchronous parallel QR decomposition of large-scale matrices.
[0056] It should be understood that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order constraint on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the diagram may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0057] Please see Figure 6 One embodiment of this application provides a large-scale matrix QR decomposition single-core serial computing device 600, comprising: The partitioning module 610 is used to divide the target large-scale matrix into multiple matrix blocks according to the fast memory capacity, wherein each matrix block is stored contiguously in column-major order and the storage space required for each matrix block is less than or equal to the fast memory capacity. The decomposition module 620 is used to take the leftmost and topmost matrix blocks of all matrix blocks as the target matrix blocks, perform serial QR decomposition on the target matrix blocks, and obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix blocks, and the b factors of the Householder reflection vectors, where b is the order of the current matrix block. The first update module 630 is used to update the matrix blocks to the right of the target matrix block based on the b columns of Householder reflection vectors and b factors of the orthogonal matrix corresponding to the target matrix block, until all matrix blocks in the row where the target matrix block is located have been updated. The second update module 640 is used to update the matrix blocks below the target matrix block based on the upper triangular matrix corresponding to the target matrix block, until all matrix blocks in the column where the target matrix block is located have been updated, and to update the upper triangular matrix of the target matrix block. The third update module 650 is used to update the matrix blocks to the right of the current matrix block for each matrix block in the column where the target matrix block is located, based on the b columns of Householder reflection vectors and the b factors of Householder reflection vectors of the orthogonal matrix corresponding to the current matrix block, until all matrix blocks in the row where the current matrix block is located have been updated, where b is the column number of the current matrix block.
[0058] Specific limitations regarding the aforementioned device 600 can be found in the above description of the limitations of the single-core serial computation method for large-scale matrix QR decomposition, and will not be repeated here. Each module in the aforementioned device 600 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in a computer device, or stored in software in the memory of a computer device, so that the processor can call and execute the operations corresponding to each module.
[0059] In one embodiment, a computer device is provided, the internal structure of which can be as shown in the figure. Figure 7As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements the above-described large-scale matrix QR decomposition single-core serial computation method. It includes: memory and a processor; the memory stores the computer program; and the processor executes the computer program to implement any step of the above-described large-scale matrix QR decomposition single-core serial computation method.
[0060] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, can perform any step of the above-described large-scale matrix QR decomposition single-core serial computation method.
[0061] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0062] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0063] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0064] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0065] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0066] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A single-core serial computation method for large-scale matrix QR decomposition, characterized in that, include: The target large-scale matrix is divided into multiple matrix blocks according to the fast memory capacity. Each matrix block is stored contiguously in column-major order and the storage space required for each matrix block is less than or equal to the fast memory capacity. Take the leftmost and topmost matrix blocks of all matrix blocks as the target matrix blocks, perform serial QR decomposition on the target matrix blocks, and obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix blocks, and the b factors of the Householder reflection vectors, where b is the order of the current matrix block. Based on the b-column Householder reflection vectors and b factors of the orthogonal matrix corresponding to the target matrix block, the matrix blocks to the right of the target matrix block are updated until all matrix blocks in the row containing the target matrix block have been updated. Based on the upper triangular matrix corresponding to the target matrix block, update the matrix blocks below the target matrix block until all matrix blocks in the column where the target matrix block is located have been updated, and then update the upper triangular matrix of the target matrix block. For each matrix block in the column containing the target matrix block, based on the b columns of Householder reflection vectors and the b factors of Householder reflection vectors in the orthogonal matrix corresponding to the current matrix block, the matrix blocks to the right of the current matrix block are updated until all matrix blocks in the row containing the current matrix block have been updated, where b is the column number of the current matrix block.
2. The method according to claim 1, characterized in that, The step of performing serial QR decomposition on the target matrix blocks to obtain the b columns of Householder reflection vectors and b factors of the upper triangular matrix and orthogonal matrix corresponding to the target matrix blocks includes: For the target column of the target matrix block, calculate the norm of the target column, update the target column by division according to the norm, obtain the scaling factor and Householder reflection vector of the target column, and write the Householder reflection vector as the updated target column into the storage location corresponding to the target column. The updated target column is used to update the other columns of the target matrix block. The updated target column and other columns form the updated target matrix block, which serves as the upper triangular matrix corresponding to the target matrix block. The scaling factor and Householder reflection vector corresponding to all columns of the target matrix block are used as factors of the Householder reflection vector and Householder reflection vector corresponding to the target matrix block, respectively.
3. The method according to claim 1, characterized in that, The step of updating other columns of the target matrix block using the updated target column includes: The projection amount corresponding to the remaining columns of the target matrix block is determined based on the scaling factor corresponding to the target column, the Householder reflection vector, and the remaining columns of the target matrix block. The updated remaining columns are determined based on the remaining columns of the target matrix block, their corresponding projections, and the Householder reflection vectors corresponding to the target columns.
4. The method according to claim 3, characterized in that, The projection amounts corresponding to the remaining columns of the target matrix block are determined using the following expression, based on the scaling factor corresponding to the target column, the Householder reflection vector, and the remaining columns of the target matrix block: ; in, The projection quantity corresponding to the j-th column in the remaining columns of the target matrix block. The scaling factor is the value corresponding to the target column. Let be the conjugate transpose of the Householder reflection vector corresponding to the i-th column of the target column. The vector in the j-th column of the remaining columns of the target matrix is used to divide the matrix into blocks. The updated remaining columns are determined using the following expression, based on the remaining columns of the target matrix block, their corresponding projections, and the Householder reflection vectors corresponding to the target columns: ; in, For the updated vector of the j-th column, The vector in the j-th column of the remaining columns of the target matrix is used to divide the matrix into blocks. The projection quantity corresponding to the j-th column in the remaining columns of the target matrix block. The Householder reflection vector corresponding to the i-th column of the target column.
5. The method according to claim 1, characterized in that, The matrix blocks to the right of the target matrix block are updated using the following expression, based on the b columns of Householder reflection vectors and the b factors of the orthogonal matrix corresponding to the target matrix block: ; in, Divide the target matrix into blocks, and then divide the matrix into blocks on the right side of the updated matrix. Divide the matrix to the right of the target matrix into blocks. Householder reflection vectors of orthogonal matrices corresponding to blocks of the target matrix. Factors of the Householder reflection vector corresponding to the block partition of the target matrix.
6. The method according to claim 1, characterized in that, Based on the upper triangular matrix corresponding to the target matrix block, update the matrix blocks below the target matrix block until all matrix blocks in the column containing the target matrix block have been updated. Then update the upper triangular matrix of the target matrix block, including: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null and the scaling factor corresponding to the current matrix block; Update the upper triangular matrix corresponding to the current matrix block and the target matrix block based on the Householder reflection vector and scaling factor.
7. The method according to claim 6, characterized in that, For each matrix block below the target matrix block, determining the Householder reflection vector that nullifies the current matrix block and the scaling factor corresponding to the current matrix block includes: For each matrix block below the target matrix block, determine the Householder reflection vector that makes the current matrix block null; The scaling factor corresponding to the current matrix block is determined based on the Householder reflection vector using the following expression: τ = 2 / (1 + ||v||²); Where τ is the scaling factor corresponding to the current matrix block, and v is the Householder reflection vector corresponding to the current matrix block.
8. A large-scale matrix QR decomposition single-core serial computing device, characterized in that, include: The partitioning module is used to divide the target large-scale matrix into multiple matrix blocks according to the fast memory capacity. Each matrix block is stored contiguously in column-major order and the storage space required for each matrix block is less than or equal to the fast memory capacity. The decomposition module is used to take the leftmost and topmost matrix blocks of all matrix blocks as the target matrix blocks, perform serial QR decomposition on the target matrix blocks, and obtain the upper triangular matrix, the b columns of Householder reflection vectors of the orthogonal matrix corresponding to the target matrix block, and the b factors of the Householder reflection vectors, where b is the order of the current matrix block. The first update module is used to update the matrix blocks to the right of the target matrix block based on the b columns of Householder reflection vectors and b factors of the orthogonal matrix corresponding to the target matrix block, until all matrix blocks in the row where the target matrix block is located have been updated. The second update module is used to update the matrix blocks below the target matrix block based on the upper triangular matrix corresponding to the target matrix block, until all matrix blocks in the column where the target matrix block is located have been updated, and to update the upper triangular matrix of the target matrix block. The third update module is used to update the matrix blocks to the right of the current matrix block for each matrix block in the column where the target matrix block is located, based on the b columns of Householder reflection vectors and the b factors of Householder reflection vectors of the orthogonal matrix corresponding to the current matrix block, until all matrix blocks in the row where the current matrix block is located have been updated, where b is the column number of the current matrix block.
9. A computer device, comprising: A memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the large-scale matrix QR decomposition single-core serial computation method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the single-core serial computation method for large-scale matrix QR decomposition as described in any one of claims 1 to 7.