Sparse matrix parallel solution method and device based on upper and lower triangular decomposition
By reordering sparse matrices and constructing matrix elimination trees on a parallel computing platform, using multiple processors for parallel computing, and using the communication mechanism between processors, the problem of low efficiency in parallel solving of sparse matrices is solved, and high efficiency is achieved. Solving the power system.
Patent Information
- Application Number
- CN202111532120.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Existing technology is difficult to efficiently solve sparse matrices in parallel. Especially in the scenario of solving each branch current and node voltage in a power system, the method based on upper and lower triangular decomposition is inefficient.
By receiving the input matrix and storing its non-zero elements column-by-column on the parallel computing platform, reordering is performed to reduce the filling of LU decomposition and increase the absolute value of the diagonal elements, construct the matrix elimination tree and task queue, and utilize Multiple processors perform parallel calculations and use inter-processor communication mechanisms to transmit dependent data to minimize memory access overhead.
It improves the computational efficiency of sparse matrix parallel solving, reduces memory access overhead, and achieves more efficient calculation of power system solution results.
Smart Images

Figure CN114329327B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for parallel solving of sparse matrices based on upper and lower triangular decomposition. Background Art
[0002] With the development of computer technology, the demand for large-scale scientific computing is gradually increasing. Many fields of scientific computing, such as structural mechanics calculations and fluid mechanics calculations, require solving large-scale sparse linear equations.
[0003] The direct solution of the linear equations is the most numerically stable method and the most effective method for utilizing the floating-point computing power of the processor. This solution is inseparable from the upper and lower triangular decomposition (LU Factorization, abbreviated as LU) of the coefficient matrix. Furthermore, the union of sparse matrices is solved based on the upper and lower triangular decomposition.
[0004] In the scenario of solving the branch current and node voltage of the power system, it is necessary to perform parallel solution of sparse matrices based on upper and lower triangular decomposition. At present, finding an efficient method for parallel solution of sparse matrices based on upper and lower triangular decomposition is an important issue that needs to be solved in the industry. Summary of the invention
[0005] The present invention provides a method and device for parallel solution of sparse matrices based on upper and lower triangular decomposition. By rationally utilizing the communication between processors, synchronous operation and data sharing between processors can be quickly and effectively realized, thereby improving the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition.
[0006] The present invention provides a sparse matrix parallel solution method based on upper and lower triangular decomposition. The method is applied to a parallel computing platform, which includes multiple processors. The method includes: receiving an input matrix and storing non-zero elements of the input matrix column by column; reordering the input matrix to obtain a reordered matrix, wherein, in the reordered matrix, the filling of LU decomposition is less than a first number, and the absolute value of the non-zero elements at the diagonal position is greater than a first threshold; constructing a matrix elimination tree based on the reordered matrix, and constructing a subtree and a task queue based on the matrix elimination tree; performing parallel calculations on multiple subtrees and multiple task queues based on multiple processors, and obtaining an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix with respect to the input matrix; and obtaining a solution result with respect to the input matrix based on the output matrix.
[0007] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the matrix elimination tree includes multiple nodes, the nodes include root nodes and leaf nodes, and the subtrees and task queues are constructed based on the matrix elimination tree, including: taking the root node as the starting point and the leaf node as the end point, dividing the matrix elimination tree into multiple subtrees, wherein the number of the subtrees is greater than the number of the processors; determining independent nodes, and constructing the task queue based on the independent nodes, wherein the independent nodes are nodes in the matrix elimination tree that are not classified into the subtrees.
[0008] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the parallel calculation of the multiple subtrees based on the multiple processors includes: based on a greedy algorithm, allocating the multiple subtrees to the multiple processors; and performing parallel calculation of the multiple subtrees based on the multiple processors.
[0009] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the processor includes a cache memory, the node of the subtree includes multiple child nodes, and the processor calculates the subtree in the following manner: based on the capacity of the cache memory, determining a reading method for reading the child node; based on the processor calculating the read child node, obtaining a node value about the node; based on the node value, obtaining a calculation result about the subtree.
[0010] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the method for reading the child nodes is determined based on the capacity of the cache memory, including: arranging the child nodes in descending order according to the distance from the nodes of the subtree to obtain a child node queue; taking the beginning of the child node queue as the starting point, selecting a preset number of child nodes in the child node queue in turn, and reading the preset number of child nodes through the cache memory, wherein the preset number is less than or equal to the capacity of the cache memory; based on the processor, reading other child nodes in the child node queue except the preset number of child nodes.
[0011] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the parallel calculation of the multiple task queues based on the multiple processors includes: determining a scheduling processor and multiple execution processors in the processor, wherein the execution processor is other processors in the processor except the scheduling processor; based on communication transmission, the multiple task queues are sent to the multiple execution processors through the scheduling processor; based on the multiple execution processors, the multiple task queues are calculated in parallel.
[0012] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the execution processor calculates the task queue in the following manner, including: based on the scheduling processor, determining the calculation status of the task queue in real time; in response to the execution processor requesting to obtain the task queue for calculation, judging the calculation status of the task queue requested by the execution processor based on the scheduling processor; based on the calculation status of the task queue, calculating the task queue through the execution processor.
[0013] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, the calculation state of the task queue includes the calculation state of a node used to determine the calculation result of the task queue, and the task queue is calculated by the execution processor based on the calculation state of the task queue, including: if the calculation state of the node used to determine the calculation result of the task queue is an uncompleted calculation, based on the sub-nodes of the node that have been calculated, the task queue is initially calculated by the execution processor; if the calculation state of the node used to determine the calculation result of the task queue is a completed calculation, the task queue is calculated by the execution processor based on the node.
[0014] According to a parallel solution method for sparse matrices in upper and lower triangular decomposition provided by the present invention, after the task queue is initially calculated by the execution processor based on the sub-nodes in the node that have been calculated, the method also includes: based on the scheduling processor, real-time determination of the calculation status of the sub-nodes in the node that have not been calculated; in response to the calculation status of the sub-nodes that have not been calculated at the current moment being calculated, based on the sub-nodes that have not been calculated, updating the result of the initial calculation by the execution processor.
[0015] According to a method for parallel solution of sparse matrices in upper and lower triangular decomposition provided by the present invention, the method also includes: based on multiple processors, parallel calculation of the same first subtree and / or the same first task queue, wherein the first subtree is a subtree connected to the root of the matrix elimination tree, and the first task queue is a task queue connected to the root of the matrix elimination tree.
[0016] The present invention also provides a parallel solution device for sparse matrices in upper and lower triangular decomposition, the device is applied to a parallel computing platform, the parallel computing platform includes multiple processors, the device includes: a receiving module, used to receive an input matrix, and store the non-zero elements of the input matrix column by column; a reordering module, used to reorder the input matrix to obtain a reordered matrix, wherein, in the reordered matrix, the filling of LU decomposition is less than a first number, and the absolute value of the non-zero elements in the diagonal position is greater than a first threshold; a construction module, used to construct a matrix elimination tree based on the reordered matrix, and construct a subtree and a task queue based on the matrix elimination tree; a processing module, used to perform parallel calculations on multiple subtrees and multiple task queues based on multiple processors, and obtain an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix with respect to the input matrix; a generation module, used to obtain a solution result with respect to the input matrix based on the output matrix.
[0017] According to a sparse matrix parallel solution device based on upper and lower triangular decomposition provided by the present invention, the matrix elimination tree includes multiple nodes, and the nodes include root nodes and leaf nodes. The construction module constructs subtrees and task queues based on the matrix elimination tree in the following manner: taking the root node as the starting point and the leaf node as the end point, the matrix elimination tree is divided into multiple subtrees, wherein the number of the subtrees is greater than the number of the processors; and determining independent nodes, and constructing the task queue based on the independent nodes, wherein the independent nodes are nodes in the matrix elimination tree that are not included in the subtrees.
[0018] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the sparse matrix parallel solution method based on upper and lower triangular decomposition as described in any one of the above are implemented.
[0019] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described methods for parallel solution of sparse matrices based on upper and lower triangular decomposition.
[0020] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned sparse matrix parallel solution methods based on upper and lower triangular decomposition.
[0021] The present invention provides a method and device for parallel solution of sparse matrices based on upper and lower triangular decomposition, constructs a subtree and a task queue about an input matrix, performs parallel calculation on the subtree and the task queue by multiple processors, and obtains an output matrix based on the calculation result. In the present invention, the parallel calculation is performed by the processors, so that the computational efficiency of parallel solution of sparse matrices can be improved, and in the process of parallel calculation of the subtree and the task queue by multiple processors, the dependent data of each operation is transmitted by using the communication mechanism between the processors, so that the memory access overhead can be minimized, thereby improving the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is one of the flow charts of the sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the present invention;
[0024] Figure 2 It is one of the schematic diagrams of LU decomposition of a sparse matrix provided by the present invention;
[0025] Figure 3 It is one of the flowcharts of the present invention for eliminating the tree based on the matrix, constructing the subtree and the task queue;
[0026] Figure 4 It is one of the structural schematic diagrams of the matrix elimination tree for performing LU decomposition on a sparse matrix provided by the present invention;
[0027] Figure 5 It is one of the flowcharts of performing parallel calculation on multiple subtrees based on multiple processors provided by the present invention;
[0028] Figure 6 It is one of the flowcharts of calculating a subtree based on a processor provided by the present invention;
[0029] Figure 7 It is one of the flow charts of determining the reading mode of reading a sub-node based on the capacity of a cache memory provided by the present invention;
[0030] Figure 8 It is one of the flowcharts of performing parallel computing on multiple task queues based on multiple processors provided by the present invention;
[0031] Fig. 9It is one of the flowcharts of calculating the task queue based on the processor provided by the present invention;
[0032] Fig.10 It is a structural schematic diagram of a sparse matrix parallel solution device based on upper and lower triangular decomposition provided by the present invention;
[0033] Fig.11 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] With the development of computer technology, the demand for large-scale scientific computing is gradually increasing. Many fields of scientific computing, such as structural mechanics calculations and fluid mechanics calculations, require solving large-scale sparse linear equations.
[0036] The direct solution of the linear equations is the most numerically stable method and the most effective method for utilizing the floating-point computing power of the processor. This solution is inseparable from the upper and lower triangular decomposition (LU Factorization, abbreviated as LU) of the coefficient matrix. Furthermore, the union of sparse matrices is solved based on the upper and lower triangular decomposition.
[0037] In the scenario of solving the branch current and node voltage of the power system, it is necessary to perform parallel solution of sparse matrices based on upper and lower triangular decomposition. At present, finding an efficient method for parallel solution of sparse matrices based on upper and lower triangular decomposition is an important issue that needs to be solved in the industry.
[0038] In the present invention, for any sparse matrix, the result after LU decomposition is: the sparsity of L matrix and U matrix will have some filling compared with the original matrix, and through certain reordering, these fillings will make the output matrix present a locally dense feature. Therefore, in the LU decomposition of the sparse matrix, a dense sub-block of the sparse matrix is usually regarded as a computing task, and the dense linear algebra solution method is used for these dense sub-blocks. If a row or a column is regarded as a task node and a matrix elimination tree is constructed, these dense sub-blocks correspond to supernodes formed by the fusion of multiple adjacent nodes, so these dense sub-blocks are also called supernodes. In the present invention, the matrix elimination tree mentioned refers to the elimination tree after node fusion, and the "node" on the matrix elimination tree refers to a supernode composed of a dense sub-block.
[0039] The development of high-performance technology has made it possible for multiple processors to operate in coordination and to efficiently use parallel units for computing and memory access. Compared with the powerful computing power provided by multiple processors, the performance of many programs is limited by the access speed of system memory. For this reason, the processor's own on-chip memory can store a small portion of data and provide a fast access mode. How to effectively use the on-chip memory space and reduce the number of main memory accesses poses a challenge to program developers. There is often a high-speed data communication mode between multiple processors in a high-performance computer system. Taking the domestically produced new generation Shenwei multi-core processor as an example, the 64 slave cores on a single-core group have remote memory access (Remote Memory Access), which can directly access the on-chip memory of other slave cores, and the access latency and bandwidth are much faster than direct access to the main memory.
[0040] The sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the present invention reasonably utilizes the communication mechanism between processors to quickly and effectively realize the synchronous operation and data sharing between processors. In the process of parallel calculation of subtrees and task queues based on multiple processors, the dependent data of each calculation is transmitted by utilizing the communication mechanism between processors, the memory access overhead is minimized, and the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition is improved.
[0041] It should be noted that the sparse matrix parallel solution method provided by the present invention can be applied to the scenario of solving each branch current and each node voltage in the power system. By solving the sparse matrix based on upper and lower triangular decomposition in the power system scenario in parallel, the branch current and each node voltage in the circuit can be obtained.
[0042] The present invention will illustrate the process of parallel solution of sparse matrices based on upper and lower triangular decomposition in conjunction with the following embodiments.
[0043] Figure 1 It is one of the flow charts of the sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the present invention.
[0044] In an exemplary embodiment of the present invention, the parallel solution of sparse matrices based on upper and lower triangular decomposition can be applied to a parallel computing platform, wherein the parallel computing platform may include multiple processors. Figure 1 As shown, the sparse matrix parallel solution method based on upper and lower triangular decomposition may include steps 110 to 150, and each step will be introduced below.
[0045] In step 110, an input matrix is received, and non-zero elements of the input matrix are stored column by column.
[0046] In one embodiment, the input matrix can be understood as a matrix that needs to be solved in parallel based on the upper and lower triangular decomposition. The input matrix can be a sparse matrix. In one embodiment, the input matrix can be the impedance of a circuit in solving a problem related to a power system. By solving the sparse matrix based on the upper and lower triangular decomposition in the power system scenario in parallel, the current of each branch and the voltage of each node in the circuit can be obtained.
[0047] In one embodiment, the input matrix may include an input size. In one example, the input matrix may be an N*N sparse matrix A. The input matrix A stores non-zero elements in a column-by-column order in the memory of the processor. In the case of storing non-zero elements row by row, it can be regarded as a transposed matrix A in a column-by-column storage order. T Based on the solution method provided by the present invention, A T Perform LU decomposition to achieve the purpose of solving the problem.
[0048] In one embodiment, the input matrix A is represented in a compressed sparse column format. In one example, the input matrix A may include: an array V containing all non-zero values A , an integer array I containing all non-zero column indices A , the position of the first non-zero element in each row is P A . In V A and I A In , all non-zero elements are arranged in order. A is a non-negative non-decreasing integer, I A is a non-negative integer, and there are no repeated subscripts in the same row of the matrix. A The subscripts in do not exceed N.
[0049] In step 120, the input matrix is reordered to obtain a reordered matrix, wherein in the reordered matrix, the filling of the LU decomposition is less than a first quantity, and the absolute value of the non-zero element at the diagonal position is greater than a first threshold.
[0050] In one embodiment, the input matrix A can be reordered so that the filling of LU decomposition is as small as possible and the absolute value of the diagonal elements is as large as possible. In one example, the input matrix can be reordered to obtain a reordered matrix. Among them, in the reordered matrix, the filling of LU decomposition is less than the first number, and the absolute value of the non-zero element at the diagonal position is greater than the first threshold. It can be understood that the first number can be adjusted according to actual conditions and is not specifically limited in this embodiment. By limiting the filling of LU decomposition to be less than the first number, the filling of LU decomposition can be as small as possible. Correspondingly, the first threshold can also be adjusted according to actual conditions and is not specifically limited in this embodiment. By limiting the absolute value of the non-zero element at the diagonal position to be greater than the first threshold, the absolute value of the diagonal elements can be as large as possible.
[0051] In another embodiment, the input matrix may be first rearranged in rows so that the elements with larger absolute values in each column are arranged on the diagonal; and then the input matrix may be rearranged in rows and columns symmetrically so that the LU decomposition fill-in is minimized. In the application process, the matrix elimination tree may be sorted according to the post-order traversal order so that the LU decomposition result is more likely to generate dense supernodes and the calculation of the subtree has better data locality.
[0052] In another embodiment, the input matrix is reordered to obtain a reordered matrix, which can be completed by open source software such as SuiteSparse-AMD, METIS, HSL-MC64, etc. In one example, HSL-MC64 can be used to reorder the rows so that the absolute values of the diagonal elements are as large as possible; and METIS can be used to symmetrically reorder the rows and columns so that the filling of the LU decomposition is as small as possible.
[0053] In step 130, a matrix elimination tree is constructed based on the reordering matrix, and a subtree and a task queue are constructed based on the matrix elimination tree.
[0054] In one embodiment, the matrix structure of the reordering matrix can be analyzed, and a matrix elimination tree can be constructed based on the matrix structure of the reordering matrix. Further, based on the matrix elimination tree, a subtree, a task queue, and a sparse structure of the output matrix can be constructed. Among them, each node in the matrix elimination tree can be regarded as a computing task, which depends on its child nodes. Therefore, in the process of calculating each node, it can start from the leaf node and end at the root node. It can be explained that each node in the matrix elimination tree can be a super node corresponding to a dense sub-block.
[0055] In step 140, multiple processors are used to perform parallel calculations on multiple subtrees and multiple task queues, and an output matrix is obtained based on the calculation results, wherein the output matrix is an LU decomposition matrix of the input matrix.
[0056] In one embodiment, multiple processors can be started to calculate multiple subtrees and multiple task queues in parallel, and an output matrix can be obtained based on the calculation results. Among them, the output matrix is an LU decomposition matrix about the input matrix. It can be understood that in the scenario of solving power system problems, the output matrix is an LU decomposition matrix about the impedance of the circuit. Further, based on the LU decomposition matrix about the impedance of the circuit, each branch current and each node voltage in the circuit can be solved. In one example, all processors can be started for execution, and each thread is bound to a processor. For example, P processors can be started and P threads can be bound. In the application process, in the process of parallel calculation of subtrees and task queues by multiple processors, the dependent data of each operation in the subtree and task queue can be transmitted by the communication mechanism between processors to minimize the memory access overhead, thereby improving the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition.
[0057] Combination Figure 2 It can be seen that the 12×12 input matrix (left) is divided into 5 super nodes, that is, 5 tasks after LU decomposition (right). The small squares in the input matrix represent their respective non-zero elements. The non-zero elements in the input matrix (left) are different from the non-zero elements after LU decomposition (right). It can be understood that Figure 2 The right figure in the figure is the LU decomposition matrix obtained after reordering and then decomposition. In this embodiment, the L matrix and the U matrix are represented by a total of 10 arrays, which are the starting column S of each supernode, the supernode number C to which each column belongs, and the non-zero value V of L. L , each supernode in V L The starting position P in VL , each supernode in L has a non-zero row subscript I L , each supernode in I L The starting position P in IL , the non-zero value V of U U , each segment in V U The starting position G of each fragment is the row subscript I U , the starting fragment position of each column is P U For convenience of representation, the diagonal blocks are not separated into upper and lower triangular parts, but are stored in V L In, V U Only the non-diagonal block part in U is stored, and each column in this part contains several non-zero fragments, each fragment corresponds to a diagonal block.
[0058] In step 150, based on the output matrix, a solution result with respect to the input matrix is obtained.
[0059] In one embodiment, the solution result of the input matrix can be obtained based on the output matrix, that is, the LU decomposition matrix of the input matrix. In one example, in the scenario of solving power system problems, the output matrix is the LU decomposition matrix of the impedance of the circuit. Further, based on the LU decomposition matrix of the impedance of the circuit, each branch current and each node voltage corresponding to the impedance in the circuit can be solved.
[0060] The present invention provides a method and device for parallel solution of sparse matrices based on upper and lower triangular decomposition, constructs a subtree and a task queue about an input matrix, performs parallel calculations on the subtree and the task queue by multiple processors, and obtains an output matrix based on the calculation results. In the present invention, the processors are used to perform parallel calculations, so that the computational efficiency of parallel solution of sparse matrices can be improved, and in the process of performing parallel calculations on the subtrees and the task queues by multiple processors, the dependent data of each operation is transmitted by using the communication mechanism between processors, so that the memory access overhead can be minimized, thereby improving the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition.
[0061] The present invention will illustrate the process of eliminating the tree based on the matrix, constructing the subtree and the task queue in conjunction with the following embodiments.
[0062] Figure 3 It is one of the flowcharts of the matrix elimination tree, subtree construction and task queue provided by the present invention.
[0063] In an exemplary embodiment of the present invention, the matrix elimination tree may include multiple nodes, wherein each node is regarded as a computing task. Further, the node may include child nodes, and the child nodes may include at least a root node and a leaf node. It is understandable that the computing task corresponding to a node may be obtained based on the child nodes it depends on.
[0064] like Figure 3 As shown, based on the matrix elimination tree, constructing the subtree and the task queue may include step 310 and step 320, and each step will be introduced below.
[0065] In step 310, the matrix elimination tree is divided into a plurality of subtrees with the root node as the starting point and the leaf node as the end point, wherein the number of the subtrees is greater than the number of processors.
[0066] In one embodiment, the matrix elimination tree can be divided into multiple subtrees by searching for bifurcation points from the root node of the matrix elimination tree until the leaf node is reached. The number of subtrees can be greater than the number of processors. In this way, it can be ensured that each processor can have a subtree for calculation and processing, so as to achieve reasonable utilization of the processor and improve the solution efficiency.
[0067] It is understandable that each node in the matrix elimination tree can be regarded as a computing task, which depends on its child nodes. Therefore, the computing process starts from the leaf node and ends at the root node. In one embodiment, before dividing the subtree, the weight of the subtree can be determined according to the calculation amount of the subtree. It is understandable that the larger the calculation amount of the subtree, the larger its corresponding weight. In the initial state of division, the entire matrix elimination tree can be regarded as a subtree. Starting from the root node of the matrix elimination tree, find the bifurcation point, generate a new subtree, and continue to find the bifurcation point from the root node of the current maximum weight subtree until s*P subtrees are generated (s is a constant greater than 1, and P is the number of processors).
[0068] In step 320, independent nodes are determined, and a task queue is constructed based on the independent nodes. The independent nodes are nodes in the matrix elimination tree that are not classified into subtrees.
[0069] In one embodiment, after the subtrees are divided, the parts that are not divided into any subtree can be used as task queues and added to the global task queue for dynamic scheduling. The queue order can be based on a bottom-up hierarchy. Figure 4 It can be seen that for Figure 4 The matrix elimination tree in can be divided into 18 computing tasks, which are divided into 4 subtrees and 4 task queues. Among them, computing tasks 1 to 3 constitute subtree 1; computing tasks 4 to 7 constitute subtree 2; computing tasks 9 to 11 constitute subtree 3; computing tasks 13 to 16 constitute subtree 4. Computing tasks 8, 12, 17, and 18 each constitute a task queue.
[0070] The present invention will illustrate the process of multiple processors performing parallel calculations on multiple subtrees in conjunction with the following embodiments.
[0071] Figure 5 This is one of the flowchart diagrams of performing parallel calculations on multiple subtrees based on multiple processors provided by the present invention.
[0072] In an exemplary embodiment of the present invention, Figure 5 As shown, performing parallel calculation on subtrees based on multiple processors may include step 510 and step 520, and each step will be introduced below.
[0073] In step 510, multiple subtrees are allocated to multiple processors based on a greedy algorithm.
[0074] In step 520, multiple subtrees are calculated in parallel based on multiple processors.
[0075] In one embodiment, the above-mentioned generation of s*P subtrees is used as an example for explanation. In the application process, a greedy algorithm can be used to assign s*P subtrees to P processors for parallel processing, that is, the remaining subtrees with the largest weights are continuously assigned to the processor core with the lightest current task. In this way, it can be ensured that each processor has a subtree for calculation and processing, so as to achieve reasonable utilization of the processor and improve the solution efficiency.
[0076] The present invention will illustrate the process of calculating the subtree based on the processor in conjunction with the following embodiments.
[0077] Figure 6 This is one of the flowchart diagrams of calculating a subtree based on a processor provided by the present invention.
[0078] In an exemplary embodiment of the present invention, the processor may include a cache memory, and the node of the subtree may include multiple subnodes. Calculating the subtree based on the processor may include steps 610 to 630, and each step will be described below.
[0079] In step 610, a reading method for reading the child node is determined based on the capacity of the cache memory.
[0080] In step 620, the processor calculates the read child nodes to obtain a node value of the node.
[0081] In step 630, a calculation result on the subtree is obtained based on the node value.
[0082] In one embodiment, the reading method of reading the child node can be determined according to the capacity of the cache memory, and the node value of the node can be obtained by calculating the read child node based on the processor. Further, based on the node value, the calculation result of the subtree can be obtained, and then the solution result of the input matrix can be obtained. It should be noted that, according to the capacity of the cache memory, the reading method of reading the child node can be determined to ensure that the child node is read in a reasonable and effective manner, so as to improve the efficiency of data reading, and then improve the solution efficiency.
[0083] In order to further introduce the present invention, the process of determining the reading method of the reading subnode based on the capacity of the cache memory will be described below.
[0084] Figure 7 This is one of the flowchart diagrams of determining the reading method of the reading subnode based on the capacity of the cache memory provided by the present invention.
[0085] In an exemplary embodiment of the present invention, Figure 7As shown, based on the capacity of the cache memory, determining the reading method of the subnode may include steps 710 to 730, and each step will be introduced below.
[0086] In step 710, the child nodes are arranged in descending order according to the distances from the nodes of the subtree to obtain a child node queue.
[0087] In one embodiment, the child nodes can be arranged in descending order according to the distance from the node of the subtree to obtain a child node queue. It can be understood that the node of the subtree is the root node of the child node. In one example, the child node closer to the node can be obtained according to the child node farther from the node.
[0088] In step 720, starting from the beginning of the child node queue, a preset number of child nodes are selected in sequence from the child node queue, and the preset number of child nodes are read through the cache memory, wherein the preset number is less than or equal to the capacity of the cache memory.
[0089] In step 730, based on the processor, the other child nodes in the child node queue except for the preset number of child nodes are read.
[0090] In one embodiment, each processor can record the amount of data of the previously calculated nodes when calculating a certain node in the subtree. Furthermore, according to the capacity of the cache memory, when reading the most recently calculated node, it can be read through the cache. It is understandable that the most recently calculated node can correspond to the beginning of the child node queue as the starting point, and a preset number of child nodes are selected in sequence in the child node queue. When reading a farther node, according to the memory access mechanism of the processor, a memory access method that does not destroy the existing data in the cache as much as possible can be selected for reading, wherein the farther node can correspond to other child nodes in the child node queue except the preset number of child nodes. In this way, the cache memory can be fully utilized for data reading, which reduces the memory access overhead and improves the utilization rate of computing resources.
[0091] The present invention will illustrate the process of performing parallel computing on multiple task queues based on multiple processors in conjunction with the following embodiments.
[0092] Figure 8 This is one of the flowchart diagrams of performing parallel computing on multiple task queues based on multiple processors provided by the present invention.
[0093] In an exemplary embodiment of the present invention, Figure 8 As shown, performing parallel computing on multiple task queues based on multiple processors may include steps 810 to 830, and each step will be introduced below.
[0094] In step 810, a scheduling processor and a plurality of execution processors are determined in a processor, wherein the execution processor is other processors in the processor except the scheduling processor.
[0095] In step 820, based on the communication transmission, the multiple task queues are sent to the multiple execution processors through the scheduling processor.
[0096] In step 830, multiple task queues are computed in parallel based on multiple execution processors.
[0097] In one embodiment, when performing task queue calculation, a processor can act as a scheduler, and other processors can act as executors. In one example, a scheduling processor and multiple execution processors can be determined in the processor, wherein the execution processor is other processors in the processor except the scheduling processor. Further, the scheduling processor can receive the scheduling request of the execution processor through the communication transmission mechanism between processors, assign the task queue in the global task queue to the execution processor, and send a response through the communication between processors until the task queues in the global task queue are all assigned. In one example, multiple task queues can be calculated in parallel based on multiple execution processors. In the present embodiment, through the fast communication transmission between processors, the task queue can be sent to multiple execution processors to realize the parallel processing of the task queue. Because the communication transmission between processors is efficient, the efficiency of the task queue issuance can be improved, thereby improving the solution efficiency.
[0098] The present invention will illustrate the calculation process of the task queue based on the processor in conjunction with the following embodiments.
[0099] Fig. 9 This is one of the flowchart diagrams of the present invention for calculating the task queue based on the processor.
[0100] In an exemplary embodiment of the present invention, Fig. 9 As shown, calculating the task queue based on the processor may include steps 910 to 930, and each step will be introduced below.
[0101] In step 910, based on the scheduling processor, the computation status of the task queue is determined in real time.
[0102] In one embodiment, the computing state of the subtree and the computing state of the task queue can be determined in real time by the scheduling processor. Wherein, the computing state of the subtree can include the computing state of each node that the subtree depends on. The computing state of the task queue can include the computing state of each subtree that the task queue depends on.
[0103] In another embodiment, each execution processor can maintain the calculation state of the corresponding subtree when calculating the subtree. The calculation state can represent the node number fb_tree currently being calculated. The nodes before this number can be understood as the corresponding nodes have been calculated and can be read by other execution processors and used as calculation dependency data for calculating other nodes.
[0104] In yet another embodiment, the scheduling processor may maintain a series of states, including the first unfinished task number fb_queue in the task queue, and the number of unfinished child nodes of each node nb_child.
[0105] In step 920, in response to the execution processor requesting to obtain the task queue for calculation, the scheduling processor determines the calculation status of the task queue requested to be obtained by the execution processor.
[0106] In step 930 , based on the computation status of the task queue, the task queue is computed by executing the processor.
[0107] In one embodiment, in response to the execution processor requesting the scheduling processor to obtain the task queue for calculation, the scheduling processor can determine the calculation status of the task queue requested by the execution processor, and calculate the task queue through the execution processor according to the calculation status. In one example, when the scheduling processor receives a calculation request about the execution processor requesting to obtain the task queue, the previous task queue executed by the execution processor can be regarded as completed. At this time, the scheduling processor also needs to update the calculation status information it maintains. When the scheduling processor maintains the calculation status information of the task queue, some execution processors may still be performing calculations on subtrees. Since the subtree can be the dependent data for the task queue to perform calculations, therefore, when processing some requests about the execution processor for performing task queue calculations, the scheduling processor also needs to check the calculation status of the subtree, and update the calculation status of the subtree in time to facilitate the scheduling processor to calculate the corresponding task queue.
[0108] The present invention will explain the process of calculating the task queue by executing the processor based on the calculation state of the task queue in conjunction with the following embodiments.
[0109] In an exemplary embodiment of the present invention, the calculation state of the task queue may include the calculation state of the node for determining the calculation result of the task queue. It is understandable that the calculation of the task queue depends on the node, wherein the calculation state of the task queue may include the calculation state about the node, wherein the calculation of the node may depend on the subnode corresponding to the node, and therefore, the calculation state of the node is related to the calculation state of the corresponding subnode. Based on the calculation state of the task queue, calculating the task queue by executing the processor can be realized in the following manner: if the calculation state of the node for determining the calculation result of the task queue is uncompleted calculation, based on the subnodes that have been calculated in the node, the task queue is initially calculated by executing the processor; if the calculation state of the node for determining the calculation result of the task queue is completed calculation, based on the node, the task queue is calculated by executing the processor.
[0110] In one embodiment, when the execution processor receives the response of the scheduling processor, a certain task queue is sent to the execution processor for calculation. When the execution processor calculates a node related to the task queue, it is necessary to first update the current node with the child node of the current node. If nb_child is non-zero, then some of the child nodes have not yet completed the calculation. At this time, firstly according to the fb_tree value of each execution processor and the fb_queue value of the scheduling processor, it is judged whether each node relied on has completed the calculation, and the calculation result of the task queue is updated with the completed nodes, that is, the task queue is initially calculated. Then wait for nb_child to return to zero, and then continue to complete the update of the calculation result of the task queue with the nodes that have not been updated before, that is, the initial calculation of the task queue is updated to obtain the final calculation result. After all updates are completed, the node internal decomposition is performed again to obtain the non-zero element about the LU decomposition matrix, thereby determining the LU decomposition matrix. Further, based on the LU decomposition matrix, the solution result about the input matrix is obtained.
[0111] It should be noted that in the process of internal decomposition of each node, the column selection of the pivot can be performed inside the node. Since the block corresponding to the node in the U matrix is already considered dense, row exchange will not change its non-zero structure. This kind of pivot selection in the node cannot guarantee numerical stability, but through the means of pivot perturbation, by making the absolute value less than the threshold The pivot element is replaced by τ (where ε represents the floating point error caused by machine precision, and ||A||1 represents the 1-norm of matrix A). This can avoid the occurrence of vicious termination such as division by zero within a certain error range. The error caused by the pivot element perturbation can be eliminated by iterative precision calibration.
[0112] In another embodiment, if the calculation state of the node for determining the calculation result of the task queue is to have completed calculation, then directly based on the node, the task queue can be calculated by the execution processor to obtain the final calculation result about the task queue. Further, the node internal decomposition is carried out again to obtain the non-zero element about the LU decomposition matrix, thereby determining the LU decomposition matrix. Based on the LU decomposition matrix, the solution result about the input matrix is obtained.
[0113] In an exemplary embodiment of the present invention, after performing initial calculations on the task queue based on the child nodes in the node that have been calculated by the execution processor, the method further includes: determining the calculation status of the child nodes in the node that have not been calculated in real time based on the scheduling processor; in response to the calculation status of the child nodes that have not been calculated being calculated at the current moment, updating the results of the initial calculation based on the child nodes that have not been calculated by the execution processor.
[0114] In one embodiment, can be based on the scheduling processor, determine in real time the calculation state of the child node that has not been calculated in the node, it is understandable that, if the scheduling processor determines that nb_child returns to zero, the calculation state of the current moment of the child node that has not been calculated is calculated.At this moment, can continue to complete the calculation result update to the task queue with the child node that has not been completed before, namely the initial calculation of the task queue is updated, and the final calculation result is obtained.In the present embodiment, based on the execution processor, the calculation result of the task queue is preliminarily updated by the node that has completed the calculation, then according to the calculation state of the node that the task queue depends on, the calculation result of the task queue is further updated, and the final calculation result is obtained.By this way, the calculation task of the execution processor can be reasonably distributed, and the calculation load and the calculation duration of the execution processor can be optimized.
[0115] In order to further introduce the sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the present invention, it will be described in conjunction with the following embodiments.
[0116] In an exemplary embodiment of the present invention, the parallel solution method for sparse matrices based on upper and lower triangular decomposition may include, in addition to steps 110 to 150 described above, the following steps: based on multiple processors, parallel calculations are performed on the same first subtree and / or the same first task queue, wherein the first subtree is a subtree connected to the root of the matrix elimination tree, and the first task queue is a task queue connected to the root of the matrix elimination tree.
[0117] In one embodiment, the parallelism of the subtree or task queue near the root of the matrix elimination tree is low, such as the first subtree or the first task queue. The scheduling processor can distribute the same first subtree or the first task queue to multiple execution processors for parallel calculation according to the amount of subnode data included in the first subtree or the first task queue. Multiple execution processors can divide data by column, and each execution processor updates its own part respectively, and completes parallel decomposition through processor communication in the internal decomposition stage of the node (corresponding to the first subtree or the first task queue). It is understandable that the execution processor of the group can be used to calculate the calculation result of the same subtree or task queue at the same time in this stage. When the execution processor of the group sends a scheduling request next time, the scheduling processor will only regard the request of the last execution processor of the group as the previous task has been completed, that is, it will only update the calculation state about this stage according to the next request of the last execution processor of the group received.
[0118] In the present invention, based on the fast communication transmission between processors, the dependent data of each operation is transmitted, which can minimize the synchronization and memory access overhead and maximize the resource utilization.
[0119] According to the above description, the method and device for parallel solution of sparse matrices based on upper and lower triangular decomposition provided by the present invention construct subtrees and task queues about the input matrix, perform parallel calculations on the subtrees and task queues through multiple processors, and obtain an output matrix based on the calculation results. In the present invention, parallel calculations are performed by processors to improve the computational efficiency of parallel solution of sparse matrices, and in the process of parallel calculations of subtrees and task queues by multiple processors, the dependent data of each operation is transmitted by using the communication mechanism between processors, which can minimize the memory access overhead, thereby improving the computational efficiency of the parallel solution process of sparse matrices based on upper and lower triangular decomposition.
[0120] Based on the same concept, the present invention also provides a sparse matrix parallel solution device based on upper and lower triangular decomposition.
[0121] The sparse matrix parallel solution device based on upper and lower triangular decomposition provided by the present invention is described below. The sparse matrix parallel solution device based on upper and lower triangular decomposition described below and the sparse matrix parallel solution method based on upper and lower triangular decomposition described above can be referenced to each other.
[0122] Fig.10 It is a structural schematic diagram of a sparse matrix parallel solution device based on upper and lower triangular decomposition provided by the present invention.
[0123] In an exemplary embodiment of the present invention, a sparse matrix parallel solution device based on upper and lower triangular decomposition can be applied to a parallel computing platform, wherein the parallel computing platform may include multiple processors. The sparse matrix parallel solution device based on upper and lower triangular decomposition may include a receiving module 1010, a reordering module 1020, a construction module 1030, a processing module 1040, and a generation module 1050. Each module will be introduced below.
[0124] The receiving module 1010 may be configured to receive an input matrix and store non-zero elements of the input matrix column by column.
[0125] The reordering module 1020 may be configured to reorder the input matrix to obtain a reordered matrix, wherein in the reordered matrix, the fill-in of the LU decomposition is less than a first quantity, and the absolute value of the non-zero element at the diagonal position is greater than a first threshold.
[0126] The construction module 1030 may be configured to construct a matrix elimination tree based on the reordering matrix, and to construct a subtree and a task queue based on the matrix elimination tree.
[0127] The processing module 1040 may be configured to perform parallel calculations on multiple subtrees and multiple task queues based on multiple processors, and obtain an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix of the input matrix.
[0128] The generation module 1050 may be configured to obtain a solution result on the input matrix based on the output matrix.
[0129] In an exemplary embodiment of the present invention, the matrix elimination tree may include multiple nodes, and the nodes may include root nodes and leaf nodes. The construction module 1030 may construct subtrees and task queues based on the matrix elimination tree in the following manner: taking the root node as the starting point and the leaf node as the end point, the matrix elimination tree is divided into multiple subtrees, wherein the number of subtrees is greater than the number of processors; determining independent nodes, and constructing a task queue based on the independent nodes, wherein the independent nodes are nodes in the matrix elimination tree that are not classified into subtrees.
[0130] In an exemplary embodiment of the present invention, the processing module 1040 may perform parallel calculations on multiple subtrees based on multiple processors in the following manner: based on a greedy algorithm, assign multiple subtrees to multiple processors; perform parallel calculations on multiple subtrees based on multiple processors.
[0131] In an exemplary embodiment of the present invention, the processor may include a cache memory, the node of the subtree may include multiple child nodes, and the processing module 1040 may calculate the subtree through the processor in the following manner:
[0132] Based on the capacity of the cache memory, a reading method of reading the child node is determined; based on the processor, the read child node is calculated to obtain a node value about the node; based on the node value, a calculation result about the subtree is obtained.
[0133] In an exemplary embodiment of the present invention, the processing module 1040 may determine the reading method of the subnode based on the capacity of the cache memory in the following manner:
[0134] Arrange the child nodes in descending order according to the distance from the nodes of the subtree to obtain a child node queue; take the beginning of the child node queue as the starting point, select a preset number of child nodes in the child node queue in turn, and read the preset number of child nodes through the cache memory, wherein the preset number is less than or equal to the capacity of the cache memory; based on the processor, read the child nodes other than the preset number of child nodes in the child node queue.
[0135] In an exemplary embodiment of the present invention, the processing module 1040 may perform parallel calculations on multiple task queues based on multiple processors in the following manner:
[0136] A scheduling processor and multiple execution processors are determined in the processor, wherein the execution processors are other processors in the processor except the scheduling processor; based on communication transmission, multiple task queues are sent to multiple execution processors through the scheduling processor; based on the multiple execution processors, multiple task queues are calculated in parallel.
[0137] In an exemplary embodiment of the present invention, the processing module 1040 can calculate the task queue through the execution processor in the following manner: based on the scheduling processor, determine the calculation status of the task queue in real time; in response to the execution processor requesting to obtain the task queue for calculation, determine the calculation status of the task queue requested to be obtained by the execution processor based on the scheduling processor; based on the calculation status of the task queue, calculate the task queue through the execution processor.
[0138] In an exemplary embodiment of the present invention, the calculation state of the task queue may include the calculation state of the node used to determine the calculation result of the task queue, and the processing module 1040 may calculate the task queue by executing the processor based on the calculation state of the task queue in the following manner:
[0139] If the calculation status of the node used to determine the calculation result of the task queue is incomplete calculation, the task queue is initially calculated by executing the processor based on the sub-nodes in the node that have been calculated; if the calculation status of the node used to determine the calculation result of the task queue is completed calculation, the task queue is calculated by executing the processor based on the node.
[0140] In an exemplary embodiment of the present invention, the processing module 1040 can also be configured to determine in real time the calculation status of the uncompleting sub-nodes in the node based on the scheduling processor; in response to the calculation status of the uncompleting sub-nodes at the current moment being completed, the result of the initial calculation is updated based on the uncompleting sub-nodes by executing the processor.
[0141] In an exemplary embodiment of the present invention, the processing module 1040 can also be configured to perform parallel calculations on the same first subtree and / or the same first task queue based on multiple processors, wherein the first subtree is a subtree connected to the root of the matrix elimination tree, and the first task queue is a task queue connected to the root of the matrix elimination tree.
[0142] Fig.11 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.11 As shown, the electronic device may include: a processor (processor) 1110, a communication interface (Communications Interface) 1120, a memory (memory) 1130 and a communication bus 1140, wherein the processor 1110, the communication interface 1120, and the memory 1130 communicate with each other through the communication bus 1140. The processor 1110 can call the logic instructions in the memory 1130 to execute a parallel solution method for sparse matrices based on upper and lower triangular decomposition, wherein the parallel solution method for sparse matrices based on upper and lower triangular decomposition is applied to a parallel computing platform, and the parallel computing platform includes multiple processors, and the method includes: receiving an input matrix and storing the non-zero elements of the input matrix column by column; reordering the input matrix to obtain a reordered matrix, wherein, in the reordered matrix, the filling of LU decomposition is less than a first number, and the absolute value of the non-zero elements at the diagonal position is greater than a first threshold; based on the reordered matrix, constructing a matrix elimination tree, and based on the matrix elimination tree, constructing a subtree and a task queue; based on multiple processors, parallel calculations are performed on the subtrees and the task queues, and an output matrix is obtained based on the calculation results, wherein the output matrix is an LU decomposition matrix with respect to the input matrix; based on the output matrix, a solution result with respect to the input matrix is obtained.
[0143] In addition, the logic instructions in the above-mentioned memory 1130 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0144] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the above-mentioned methods, wherein the method is applied to a parallel computing platform, and the parallel computing platform includes multiple processors. The method includes: receiving an input matrix and storing the non-zero elements of the input matrix column by column; reordering the input matrix to obtain a reordered matrix, wherein, in the reordered matrix, the LU decomposition is filled in less than a first number, and the absolute value of the non-zero elements at the diagonal position is greater than a first threshold; based on the reordered matrix, constructing a matrix elimination tree, and based on the matrix elimination tree, constructing a subtree and a task queue; based on multiple processors, parallel calculations are performed on the subtrees and the task queues, and an output matrix is obtained based on the calculation results, wherein the output matrix is an LU decomposition matrix with respect to the input matrix; based on the output matrix, a solution result with respect to the input matrix is obtained.
[0145] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the sparse matrix parallel solution method based on upper and lower triangular decomposition provided by the above-mentioned methods, wherein the method is applied to a parallel computing platform, the parallel computing platform includes multiple processors, and the method includes: receiving an input matrix, and storing the non-zero elements of the input matrix column by column; reordering the input matrix to obtain a reordered matrix, wherein, in the reordered matrix, the LU decomposition is filled in less than a first number, and the absolute value of the non-zero elements at the diagonal position is greater than a first threshold; constructing a matrix elimination tree based on the reordered matrix, and constructing a subtree and a task queue based on the matrix elimination tree; performing parallel calculations on the subtrees and the task queues based on multiple processors, and obtaining an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix with respect to the input matrix; obtaining a solution result with respect to the input matrix based on the output matrix.
[0146] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0147] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A sparse matrix parallel solution method based on upper and lower triangular decomposition, characterized in that: The method is applied to a parallel computing platform, the parallel computing platform includes a plurality of processors, and the method includes: Receiving an input matrix, and storing non-zero elements of the input matrix column by column; Reordering the input matrix to obtain a reordered matrix, wherein in the reordered matrix, the filling of the LU decomposition is less than a first quantity, and the absolute value of the non-zero element at the diagonal position is greater than a first threshold; Based on the reordering matrix, construct a matrix elimination tree, and based on the matrix elimination tree, construct a subtree and a task queue; Performing parallel calculations on the plurality of subtrees and the plurality of task queues based on the plurality of processors, and obtaining an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix of the input matrix; Based on the output matrix, a solution result about the input matrix is obtained, wherein, The matrix elimination tree includes a plurality of nodes, wherein the nodes include a root node and a leaf node. Based on the matrix elimination tree, a subtree and a task queue are constructed, including: Taking the root node as a starting point and the leaf node as an end point, dividing the matrix elimination tree into a plurality of subtrees, wherein the number of the subtrees is greater than the number of the processors; Determine an independent node, and construct the task queue based on the independent node, wherein the independent node is a node in the matrix elimination tree that is not included in the subtree, wherein, The performing parallel calculation on the plurality of subtrees based on the plurality of processors comprises: Based on a greedy algorithm, allocating the plurality of subtrees to the plurality of processors; Based on the plurality of the processors, the plurality of the subtrees are calculated in parallel, wherein: The processor includes a cache memory, the node of the subtree includes a plurality of child nodes, and the processor calculates the subtree in the following manner: Determining a reading mode for reading the child node based on the capacity of the cache memory; Calculating the read child node based on the processor to obtain a node value of the node; Based on the node value, a calculation result on the subtree is obtained.
2. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 1 is characterized in that: The determining, based on the capacity of the cache memory, a reading mode of reading the child node comprises: Arrange the child nodes in descending order according to the distance from the node of the subtree to obtain a child node queue; Taking the beginning of the child node queue as the starting point, sequentially selecting a preset number of child nodes in the child node queue, and reading the preset number of child nodes through the cache memory, wherein the preset number is less than or equal to the capacity of the cache memory; Based on the processor, other sub-nodes in the sub-node queue except the preset number of sub-nodes are read.
3. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 1 is characterized in that: The performing parallel computing on the multiple task queues based on the multiple processors includes: Determining a scheduling processor and a plurality of execution processors in the processor, wherein the execution processor is other processors in the processor except the scheduling processor; Based on communication transmission, the plurality of task queues are sent to the plurality of execution processors through the scheduling processor; Based on the multiple execution processors, parallel calculations are performed on the multiple task queues.
4. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 3 is characterized in that: The execution processor calculates the task queue in the following manner, including: Based on the scheduling processor, determining the computing status of the task queue in real time; In response to the execution processor requesting to obtain the task queue for calculation, based on the scheduling processor, determining the calculation state of the task queue requested to be obtained by the execution processor; Based on the calculation state of the task queue, the task queue is calculated by the execution processor.
5. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 4 is characterized in that: The calculation state of the task queue includes the calculation state of a node used to determine the calculation result of the task queue, and the calculation of the task queue by the execution processor based on the calculation state of the task queue includes: If the calculation state of the node used to determine the calculation result of the task queue is incomplete calculation, based on the subnodes of the node that have been calculated, the execution processor performs initial calculation on the task queue; If the calculation status of the node used to determine the calculation result of the task queue is that the calculation has been completed, the task queue is calculated based on the node by the execution processor.
6. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 5, characterized in that: After the execution processor performs initial calculation on the task queue based on the subnodes of the node that have been calculated, the method further includes: Based on the scheduling processor, determining in real time the computing status of the child nodes of the node that have not been fully computed; In response to the calculation status of the incompletely calculated child node at the current moment being that the calculation is completed, the result of the initial calculation is updated by the execution processor based on the incompletely calculated child node.
7. The sparse matrix parallel solution method based on upper and lower triangular decomposition according to claim 1 is characterized in that: The method further comprises: Based on multiple processors, parallel calculation is performed on the same first subtree and / or the same first task queue, wherein the first subtree is a subtree connected to the root of the matrix elimination tree, and the first task queue is a task queue connected to the root of the matrix elimination tree.
8. A sparse matrix parallel solution device based on upper and lower triangular decomposition, characterized in that: The device is applied to a parallel computing platform, the parallel computing platform includes a plurality of processors, and the device includes: A receiving module, used for receiving an input matrix and storing non-zero elements of the input matrix column by column; A reordering module, configured to reorder the input matrix to obtain a reordered matrix, wherein in the reordered matrix, the filling of the LU decomposition is less than a first quantity, and the absolute value of the non-zero element at the diagonal position is greater than a first threshold; A construction module, used for constructing a matrix elimination tree based on the reordering matrix, and constructing a subtree and a task queue based on the matrix elimination tree; A processing module, used for performing parallel calculations on the plurality of subtrees and the plurality of task queues based on the plurality of processors, and obtaining an output matrix based on the calculation results, wherein the output matrix is an LU decomposition matrix of the input matrix; A generating module is used to obtain a solution result about the input matrix based on the output matrix, wherein: The matrix elimination tree includes a plurality of nodes, including a root node and a leaf node. The construction module constructs a subtree and a task queue based on the matrix elimination tree in the following manner: Taking the root node as a starting point and the leaf node as an end point, dividing the matrix elimination tree into a plurality of subtrees, wherein the number of the subtrees is greater than the number of the processors; Determine an independent node, and construct the task queue based on the independent node, wherein the independent node is a node in the matrix elimination tree that is not included in the subtree, wherein, The processing module performs parallel calculation on the multiple subtrees based on the multiple processors in the following manner: Based on a greedy algorithm, allocating the plurality of subtrees to the plurality of processors; Based on the plurality of the processors, the plurality of the subtrees are calculated in parallel, wherein: The processor includes a high-speed cache memory, the node of the subtree includes a plurality of subnodes, and the processing module calculates the subtree through the processor in the following manner: Determining a reading mode for reading the child node based on the capacity of the cache memory; Calculating the read child node based on the processor to obtain a node value of the node; Based on the node value, a calculation result on the subtree is obtained.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the sparse matrix parallel solution method based on upper and lower triangular decomposition as described in any one of claims 1 to 7 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the sparse matrix parallel solution method based on upper and lower triangular decomposition as claimed in any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the sparse matrix parallel solution method based on upper and lower triangular decomposition as claimed in any one of claims 1 to 7 are implemented.
