LU decomposition method and device based on sparse matrix operator, equipment and medium
Through the selection of sparse LU chunking algorithm and sparse kernel function, the problem of insufficient decomposition performance of sparse matrix LU in the prior art is solved, and more efficient computing performance and better sparse utilization are achieved.
Patent Information
- Application Number
- CN202410812127.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-11-05
AI Technical Summary
Existing multi-wave front algorithms and supernode methods cannot effectively utilize processor parallelism in large-scale sparse matrix LU decomposition, resulting in insufficient computing performance, especially on heterogeneous processors, which is difficult to select appropriate algorithms to fully utilize parallelism.
Use sparse matrix operator instead of dense matrix operator, and divide the original sparse matrix into multiple sparse blocks through sparse LU chunking algorithm, and select the optimal sparse kernel function for sparse LU decomposition for different sparse block structures to realize sparse calculation method Ask for solution.
It improves the computing performance of sparse matrix LU decomposition, enhances the sparseness utilization of sparse matrix, reduces computational overhead and storage requirements, and is suitable for large-scale parallel computing environments.
Smart Images

Figure CN118897938A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a LU decomposition method, device, equipment and medium based on a sparse matrix operator. Background Art
[0002] The purpose of sparse matrix LU decomposition is to calculate the solution vector X of the linear system AX=B, where A is a sparse matrix and B is a dense vector. There are two different ways to solve AX=B. One is to directly obtain the exact solution in a limited number of steps (direct method), and the other is to obtain the exact solution continuously through iteration (iterative method). The direct method of LU decomposition algorithm can obtain more accurate solutions, so it is widely used in many fields such as scientific computing and simulation.
[0003] Since the LU decomposition stage is time-consuming, it has received more attention. The LU decomposition stage can be divided into the symbolic decomposition stage and the numerical decomposition stage. The symbolic decomposition is to fill the rearranged matrix to open up the required space for the numerical decomposition stage; the numerical decomposition stage is to perform actual floating-point operations.
[0004] At present, there are many LU algorithms that use various methods to accelerate the numerical decomposition stage. Faced with the ever-increasing size of the matrix to be solved and the increasing amount of memory required, a single processor can no longer meet the computing needs. Although these large-scale supercomputing methods have a certain degree of parallelism, there are still three problems that have not been well solved: (1) How to distribute irregular floating-point calculations to each processor in a balanced manner and reduce the synchronization overhead between processors; (2) How to design a suitable algorithm within the processor to fully parallelize the calculation; (3) With the emergence of heterogeneous processors, how to choose the appropriate algorithm for different matrices to fully utilize the parallelism of heterogeneous processors.
[0005] Currently, many decomposition methods can be used to improve the parallelism of the numerical decomposition stage. Two of the more effective methods are the multi-front method and the supernode method and the corresponding software packages MUMPS (Massively Parallel Sparse Direct Solver) and SuperLU. This type of method is to find columns with the same structure in the matrix and combine them into multiple multi-fronts or super-fronts, using multi-fronts and super-fronts as the basic operation units, and then adjusting the calculation order of these multi-fronts and super-fronts by eliminating the tree. Multi-fronts and super-fronts are composed of compressed columns of the same structure and can be regarded as dense matrices, so they can use BLAS (Basic Linear Algebra Subprograms) for calculation and communication.
[0006] However, in most matrices of the read world, multi-wavefront algorithms and supernode methods often cannot provide sufficient performance and have difficulty in solving the following three problems: (1) In some extreme cases, it is almost impossible to find multi-wavefronts and supernodes on a matrix; (2) For some matrices composed of columns with little structural difference, in order to assemble the maximum possible single fronts and super fronts using BLAS calculations, many unnecessary elements need to be filled in, resulting in additional computational overhead; (3) For data structures such as multi-wavefronts and supernodes, scalability on supercomputers may not be ideal.
[0007] Therefore, how to perform sparse matrix LU decomposition to improve computing performance is an urgent problem to be solved. Summary of the invention
[0008] The present invention provides a LU decomposition method, device, equipment and medium based on a sparse matrix operator, which is used to solve the defect that the multi-wavefront algorithm and the super-node method in the prior art cannot provide sufficient computing performance, and realizes the use of sparse matrix operators instead of dense matrix operators to perform major calculations, thereby increasing the utilization of the sparsity of the sparse matrix and improving the computing performance of the sparse matrix LU decomposition.
[0009] The present invention provides a LU decomposition method based on a sparse matrix operator, comprising:
[0010] Get the original sparse matrix;
[0011] The original sparse matrix is divided into a plurality of sparse blocks by using a sparse LU block algorithm, and sparse LU decomposition is performed on the sparse blocks.
[0012] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the original sparse matrix is divided into a plurality of sparse blocks, and sparse LU decomposition is performed on the sparse blocks, comprising:
[0013] Splitting the original sparse matrix into a plurality of sparse blocks and storing them in a sparse storage format;
[0014] Perform sparse LU decomposition on the sparse blocks stored in the sparse storage format.
[0015] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the sparse LU decomposition of a sparse block stored in a sparse storage format comprises:
[0016] For various sparse blocks with different matrix structures stored in a sparse storage format, sparse LU solving processes corresponding to various sparse kernel functions are executed.
[0017] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the sparse LU solution process corresponding to various sparse kernel functions is executed for various sparse blocks with different matrix structures stored in a sparse storage format, including:
[0018] According to the matrix structure of the sparse block, a decision tree is used to select a target sparse kernel function with the fastest calculation speed from a plurality of sparse kernel functions;
[0019] According to the target sparse kernel function, a sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block.
[0020] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block according to the target sparse kernel function, including:
[0021] When the target sparse kernel function is a GETRF kernel function, a sparse LU solving process corresponding to the GETRF kernel function is performed on the sparse block according to the GETRF kernel function.
[0022] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block according to the target sparse kernel function, including:
[0023] When the target sparse kernel function is a GESSM kernel function, according to the GESSM kernel function, a sparse LU solution process corresponding to the GESSM kernel function is performed on the sparse block; or,
[0024] In the case where the target sparse kernel function is a TSTFR kernel function, a sparse LU solving process corresponding to the TSTFR kernel function is performed on the sparse block according to the TSTFR kernel function.
[0025] According to an LU decomposition method based on a sparse matrix operator provided by the present invention, the sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block according to the target sparse kernel function, including:
[0026] When the target sparse kernel function is the SSSSM kernel function, the sparse LU solution process corresponding to the SSSSM kernel function is performed on the sparse block according to the SSSSM kernel function.
[0027] The present invention also provides a LU decomposition device based on a sparse matrix operator, comprising:
[0028] An acquisition module is used to obtain the original sparse matrix;
[0029] The decomposition module is used to divide the original sparse matrix into multiple sparse blocks by using a sparse LU block algorithm, and perform sparse LU decomposition on the sparse blocks.
[0030] 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 LU decomposition method based on a sparse matrix operator as described in any one of the above items are implemented.
[0031] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the LU decomposition method based on a sparse matrix operator as described in any one of the above items are implemented.
[0032] The LU decomposition method, device, equipment and medium based on the sparse matrix operator provided by the present invention obtain the original sparse matrix, use the sparse LU block algorithm to divide the original sparse matrix into multiple sparse blocks, and perform sparse LU decomposition on the sparse blocks. It is possible to use sparse matrix operators instead of dense matrix operators to perform major calculations, thereby completely using sparse computing methods to solve the sparse LU decomposition algorithm, and increase the utilization of the sparsity of the sparse matrix, which can improve the computing performance of the sparse matrix LU decomposition. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] 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.
[0034] Figure 1 It is a flowchart of the LU decomposition method based on the sparse matrix operator provided by an embodiment of the present invention;
[0035] Figure 2 It is a schematic diagram of cutting the original sparse matrix and saving it in a sparse storage format provided by an embodiment of the present invention;
[0036] Figure 3 It is a schematic diagram of the pseudo code of GETRF provided by an embodiment of the present invention;
[0037] Figure 4 It is a schematic diagram of TSTRF / GESSM pseudo code provided by an embodiment of the present invention;
[0038] Figure 5 is a schematic diagram of the SSSSM pseudo code provided by an embodiment of the present invention;
[0039] Figure 6 It is a schematic diagram of the experimental comparison of the sparse LU block algorithm provided by an embodiment of the present invention;
[0040] Figure 7 It is a structural schematic diagram of an LU decomposition device based on a sparse matrix operator provided in an embodiment of the present invention;
[0041] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0042] 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.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0044] It should be further noted that, in this article, the terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0045] In the present invention, "at least one" means one or more, and "more than one" means two or more than two. The terms "first", "second", "third", "fourth", etc. (if any) in the present invention are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0046] In the embodiments of the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0047] Figure 1 Schematic diagram of the flow of the LU decomposition method based on the sparse matrix operator provided by the embodiment of the present invention. Figure 1 The embodiment of the present invention provides a LU decomposition method based on a sparse matrix operator, and the method may specifically include the following steps:
[0048] Step 101, obtaining the original sparse matrix.
[0049] It should be noted that the execution subject of the LU decomposition method based on the sparse matrix operator provided in the embodiment of the present invention can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a wearable device, an ultra-mobile personal computer (Ultra-mobile Personal Computer, UMPC), a netbook or a personal digital assistant (Personal Digital Assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (Personal Computer, PC), a television (Television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present invention does not specifically limit this.
[0050] The following embodiment of the present invention is described with the server as the execution subject. In the embodiment of the present invention, the original sparse matrix can be first obtained, and the original sparse matrix can be divided into multiple sparse blocks using the sparse LU block algorithm, and the multiple sparse blocks can be sparsely decomposed to achieve the use of sparse matrix operators instead of previous dense matrix operators for main calculations, thereby using sparse calculation methods to solve sparse problems, and increasing the use of the sparsity of the sparse matrix, which can improve the computing performance of the sparse matrix LU decomposition.
[0051] Among them, a sparse matrix refers to a matrix in which most of the elements are 0. In practical applications, data such as images, social networks, and text can be represented as sparse matrices.
[0052] Step 102: Use a sparse LU block algorithm to divide the original sparse matrix into multiple sparse blocks, and perform sparse LU decomposition on the sparse blocks.
[0053] The sparse LU block algorithm divides the original sparse matrix into blocks according to certain rules, and performs LU decomposition on each sparse block. By properly selecting the block rules, the L and U matrices obtained after matrix decomposition can still maintain a certain sparsity, so that when solving linear equations, the characteristics of sparse matrices can be used to reduce the amount of calculation and storage overhead.
[0054] In an embodiment of the present invention, the sparse LU blocking algorithm can be regarded as a sparse version of the block algorithm widely used in LU decomposition. The original sparse matrix can be divided into multiple sparse blocks of equal size and stored in different processes, and sparse BLAS can be used for calculation, thereby better solving the problems encountered by using the multi-wavefront method and the super-node method.
[0055] The embodiment of the present invention obtains the original sparse matrix, divides the original sparse matrix into multiple sparse blocks using the sparse LU block algorithm, and performs sparse LU decomposition on the sparse blocks. It can realize the use of sparse matrix operators instead of dense matrix operators to perform major calculations, thereby completely solving the sparse LU decomposition algorithm using sparse computing methods, and increasing the utilization of the sparsity of the sparse matrix, which can improve the computing performance of the sparse matrix LU decomposition.
[0056] In an optional embodiment, dividing the original sparse matrix into multiple sparse blocks and performing sparse LU decomposition on the sparse blocks includes: dividing the original sparse matrix into multiple sparse blocks and storing them in a sparse storage format; performing sparse LU decomposition on the sparse blocks stored in the sparse storage format.
[0057] Figure 2 Schematic diagram of cutting the original sparse matrix and saving it in a sparse storage format provided by an embodiment of the present invention. Figure 2 , through the sparse LU block algorithm, the original sparse matrix can be divided into multiple sparse blocks of equal size and stored in a two-layer sparse storage format, and then sparse LU decomposition operations are performed on these sparse blocks stored in the two-layer sparse storage format.
[0058] The embodiment of the present invention stores multiple sparse blocks in a sparse storage format and performs sparse LU decomposition operations on the sparse blocks stored in the sparse storage format, thereby retaining the sparse characteristics of the original sparse matrix and optimizing storage and computing performance.
[0059] In an optional embodiment, the sparse LU decomposition of the sparse block includes: executing sparse LU solution processes corresponding to various sparse kernel functions for various sparse blocks with different matrix structures stored in a sparse storage format.
[0060] A sparse kernel function refers to a kernel function used to process sparse matrices, which can be mainly used to operate and optimize sparse matrices in sparse LU decomposition tasks. Different sparse kernel functions have different specific and usage ranges. In an embodiment of the present invention, the original sparse matrix is cut to obtain multiple sparse blocks with different sparsity and sparse structure. Different sparse kernel functions can be used for different sparse matrix structures, and the sparse LU solution processes corresponding to different sparse kernel functions are respectively executed for various sparse blocks with different sparse structures stored in a sparse storage format.
[0061] The embodiments of the present invention can accelerate the calculation speed of sparse LU decomposition and improve the accuracy by executing sparse LU solution processes corresponding to various sparse kernel functions for various sparse blocks with different matrix structures stored in a sparse storage format, thereby achieving better performance when solving large-scale sparse linear equations.
[0062] In an optional embodiment, the sparse LU solution process corresponding to various sparse kernel functions is executed for various sparse blocks with different matrix structures stored in a sparse storage format, including: according to the matrix structure of the sparse block, using a decision tree to select the fastest target sparse kernel function from a variety of sparse kernel functions; according to the target sparse kernel function, executing the sparse LU solution process corresponding to the target sparse kernel function on the sparse block.
[0063] In an embodiment of the present invention, a variety of sparse kernel functions can be used for calculation in the second-layer sparse layout of the sparse LU blocking algorithm. The various sparse kernel functions can be used to accelerate calculations for different sparse matrix structures and improve calculation efficiency.
[0064] Sparse BLAS may include multiple sparse kernel functions. Since the matrix structures of multiple sparse blocks may be different, the computational efficiency of executing the same sparse kernel function on different sparse blocks may also be different. Since the computational efficiency of different sparse kernel functions may be different, the computational rates of multiple sparse kernel functions executed on the same sparse block may also be different. In an embodiment of the present invention, a decision tree may be used to select the fastest target sparse kernel function for the sparse block from multiple sparse kernel functions based on the matrix structure of each sparse block, thereby executing the sparse LU solution process corresponding to the target sparse kernel function on the sparse block to be decomposed into sparse LU according to the target sparse kernel function.
[0065] It should be noted that when a decision tree is used to select the fastest target sparse kernel function for one or more sparse blocks from multiple sparse kernel functions as the same sparse kernel function, the sparse LU solution process corresponding to the same sparse kernel function can be performed on one or more sparse blocks.
[0066] The embodiment of the present invention adopts a decision tree and selects the fastest target sparse kernel function to perform sparse LU decomposition on the sparse block according to the matrix structure of the sparse block. The calculation speed of the sparse LU decomposition can be accelerated at a fine-grained level, thereby accelerating the calculation speed of the sparse LU decomposition as a whole, and improving the computational performance of the sparse matrix LU decomposition.
[0067] In an optional embodiment, the sparse LU solution process corresponding to various sparse kernel functions is executed for various sparse blocks with different matrix structures stored in a sparse storage format, including: according to the matrix structure of the sparse block, using a decision tree to select the fastest target sparse kernel function from a variety of sparse kernel functions; according to the target sparse kernel function, executing the sparse LU solution process corresponding to the target sparse kernel function on the sparse block.
[0068] In an embodiment of the present invention, when the fastest target sparse kernel function selected by the decision tree is the GETRF (Gaussian Elimination with Partial Pivoting) kernel function, the sparse LU solution process corresponding to the GETRF kernel function can be performed on the sparse block according to the GETRF kernel function.
[0069] Figure 3 GETRF pseudo code diagram provided by the embodiment of the present invention. Figure 3 ,GETRF kernel is a sparse LU decomposition algorithm. Through A=LU decomposition, the sparse matrix block A can be decomposed into the product of a unit lower triangular sparse matrix L and an upper triangular sparse matrix U.
[0070] Specifically, the GETRF kernel is a synchronization-free sparse LU decomposition algorithm based on the "left-looking" algorithm. It can use the degree of a global integer array to tell the computer when to perform elimination. In each iteration, there is no need to wait for all elements to be updated before the next iteration. That is, whenever the estimated value of an element is updated, it can be immediately used for the calculation of the next element, thereby improving the efficiency of the iteration, reducing the amount of calculation, and improving the computing performance.
[0071] In the prior art, synchronization is usually the bottleneck of parallel sparse LU decomposition on GPU (Graphics Processing Unit). The embodiment of the present invention can reduce the synchronization cost in the parallel algorithm by executing the sparse LU solution process corresponding to the GETRF kernel function on the sparse block according to the GETRF kernel function.
[0072] In an optional embodiment, the sparse LU solution process corresponding to the target sparse kernel function is executed on the sparse block according to the target sparse kernel function, including: when the target sparse kernel function is a GESSM kernel function, according to the GESSM kernel function, the sparse LU solution process corresponding to the GESSM kernel function is executed on the sparse block; or, when the target sparse kernel function is a TSTFR kernel function, according to the TSTFR kernel function, the sparse LU solution process corresponding to the TSTFR kernel function is executed on the sparse block.
[0073] In an embodiment of the present invention, when the fastest target sparse kernel function selected by the decision tree is the GESSM (Gaussian Elimination with Sparse Matrix) kernel function, the sparse LU solution process corresponding to the GESSM kernel function can be performed on the sparse block according to the GESSM kernel function.
[0074] When the fastest target sparse kernel function selected by the decision tree is a TSTFR (Thresholded Sparse Triangular Factorization, used for triangular factorization of sparse matrices) kernel function, the sparse LU solution process corresponding to the TSTFR kernel function can be executed on the sparse block according to the TSTFR kernel function.
[0075] Figure 4 Schematic diagram of TSTRF / GESSM pseudo code provided by an embodiment of the present invention. Figure 4 , GESSM solves LX = A, and TSTRF solves XU = A. Both kernels are SpTRSM (Sparse Triangular Solve with Multiple Right-hand Sides) algorithms, which can be used to solve triangular equations between sparse blocks and sparse vectors. By utilizing the characteristics of sparse blocks and their triangular structures, efficient solutions can be achieved.
[0076] TSTRF can be regarded as a special LX=A. By transposing, only the diagonal elements of this special L are not 1, so the solutions of TSTRF and GESSM can be regarded as the same problem.
[0077] X and A are the same sparse matrix, while X and A are both dense matrices in the traditional SpTRSM. However, it is difficult for the traditional sparse triangle solving method to obtain good performance. The embodiment of the present invention adopts the efficient sparse right-hand matrix algorithm TSTRF / GESSM, which can directly address and reduce the high cost of this part of the search compared to other traditional dense right-hand matrix SpTRSV algorithms.
[0078] The embodiment of the present invention can be used to process large-scale sparse matrix problems through the implementation of TSTRF / GESSM kernel, and utilize parallel computing technology to accelerate the computing process.
[0079] In an optional embodiment, the sparse LU solution process corresponding to the target sparse kernel function is executed on the sparse block according to the target sparse kernel function, including: when the target sparse kernel function is the SSSSM kernel function, the sparse LU solution process corresponding to the SSSSM kernel function is executed on the sparse block according to the SSSSM kernel function.
[0080] In an embodiment of the present invention, when the target sparse kernel function with the fastest calculation selected by the decision tree is the SSSSM (Small Single-Session Sparse Matrix, LU decomposition algorithm for small sparse matrices) kernel function, the sparse LU solution process corresponding to the SSSSM kernel function can be executed on the sparse block according to the SSSSM kernel function.
[0081] Figure 5 Schematic diagram of SSSSM pseudo code provided by an embodiment of the present invention. Figure 5 The function of SSSSM is to update the operation of the sub-matrix block, and the main operation is SpGEMM (Sparse Matrix Multiplication).
[0082] Specifically, the number of non-zero elements in each row of the sparse matrix block C can be divided into three categories, each of which can be effectively parallelized. For rows with only one non-zero element, each row of the sparse matrix block C can be updated by only one thread; for rows with 2-128 non-zero elements, thread-level processing can be used.
[0083] In the case where each row of the sparse matrix block C is updated by one thread, the length of the shared memory in the kernel can be determined based on the maximum number of non-zero elements of each type. For rows with more non-zero bits, block-level processing can be used.
[0084] In the case where each row of the sparse matrix block C is updated by one block, the number of threads in each block and the length of the shared memory in the kernel can be determined based on the maximum number of non-zero bits of elements in each class.
[0085] The embodiment of the present invention can better utilize computer resources and significantly improve the calculation speed of sparse LU decomposition by adopting SSSSM kernel to perform sparse LU decomposition.
[0086] Figure 6This is a schematic diagram of the experimental comparison of the sparse LU partitioning algorithm provided by the embodiment of the present invention. In the embodiment of the present invention, the sparse method can be used to solve the sparse LU decomposition algorithm, and the experiment can be carried out on 4 nodes (each node is 2x10 core Intel Xeon Silver 4210 + 8 NVIDIA RTX (Ray Tracing eXtension, ray tracing extension) 2060super) and a machine connected by 10 Gigabit network. Figure 6 , which is a schematic diagram of the experimental effect of the sparse LU block algorithm. Compared with the existing LU algorithm, the embodiment of the present invention can improve the computing performance of sparse LU decomposition by selecting multiple kernels for sparse LU decomposition.
[0087] The embodiment of the present invention obtains the original sparse matrix, divides the original sparse matrix into multiple sparse blocks using the sparse LU block algorithm, and performs sparse LU decomposition on the sparse blocks. It can realize the use of sparse matrix operators instead of dense matrix operators to perform major calculations, thereby completely solving the sparse LU decomposition algorithm using sparse computing methods, and increasing the utilization of the sparsity of the sparse matrix, which can improve the computing performance of the sparse matrix LU decomposition.
[0088] The LU decomposition device based on a sparse matrix operator provided by the present invention is described below. The LU decomposition device based on a sparse matrix operator described below and the LU decomposition method based on a sparse matrix operator described above can be referred to each other.
[0089] Figure 7 Schematic diagram of the structure of the LU decomposition device based on the sparse matrix operator provided by the embodiment of the present invention. Figure 7 The embodiment of the present invention provides a LU decomposition device based on a sparse matrix operator, and the device may specifically include the following modules:
[0090] An acquisition module 701 is used to acquire an original sparse matrix;
[0091] The decomposition module 702 is used to divide the original sparse matrix into multiple sparse blocks by using a sparse LU block algorithm, and perform sparse LU decomposition on the sparse blocks.
[0092] In an optional embodiment, the decomposition module is specifically used to:
[0093] Splitting the original sparse matrix into a plurality of sparse blocks and storing them in a sparse storage format;
[0094] Perform sparse LU decomposition on the sparse blocks stored in the sparse storage format.
[0095] In an optional embodiment, the decomposition module is specifically used to:
[0096] For various sparse blocks with different matrix structures stored in a sparse storage format, sparse LU solving processes corresponding to various sparse kernel functions are executed.
[0097] In an optional embodiment, the decomposition module is specifically used to:
[0098] According to the matrix structure of the sparse block, a decision tree is used to select a target sparse kernel function with the fastest calculation speed from a plurality of sparse kernel functions;
[0099] According to the target sparse kernel function, a sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block.
[0100] In an optional embodiment, the decomposition module is specifically used to:
[0101] When the target sparse kernel function is a GETRF kernel function, a sparse LU solving process corresponding to the GETRF kernel function is performed on the sparse block according to the GETRF kernel function.
[0102] In an optional embodiment, the decomposition module is specifically used to:
[0103] When the target sparse kernel function is a GESSM kernel function, according to the GESSM kernel function, a sparse LU solution process corresponding to the GESSM kernel function is performed on the sparse block; or,
[0104] In the case where the target sparse kernel function is a TSTFR kernel function, a sparse LU solving process corresponding to the TSTFR kernel function is performed on the sparse block according to the TSTFR kernel function.
[0105] In an optional embodiment, the decomposition module is specifically used to:
[0106] When the target sparse kernel function is the SSSSM kernel function, the sparse LU solution process corresponding to the SSSSM kernel function is performed on the sparse block according to the SSSSM kernel function.
[0107] The embodiment of the present invention obtains the original sparse matrix, divides the original sparse matrix into multiple sparse blocks using the sparse LU block algorithm, and performs sparse LU decomposition on the sparse blocks. It can realize the use of sparse matrix operators instead of dense matrix operators to perform major calculations, thereby completely solving the sparse LU decomposition algorithm using sparse computing methods, and increasing the utilization of the sparsity of the sparse matrix, which can improve the computing performance of the sparse matrix LU decomposition.
[0108] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the LU decomposition method based on the sparse matrix operator, and the method includes:
[0109] Get the original sparse matrix;
[0110] The original sparse matrix is divided into a plurality of sparse blocks by using a sparse LU block algorithm, and sparse LU decomposition is performed on the sparse blocks.
[0111] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is 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.
[0112] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the LU decomposition method based on the sparse matrix operator provided by the above methods, the method comprising:
[0113] Get the original sparse matrix;
[0114] The original sparse matrix is divided into a plurality of sparse blocks by using a sparse LU block algorithm, and sparse LU decomposition is performed on the sparse blocks.
[0115] 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.
[0116] 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.
[0117] 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 LU decomposition method based on a sparse matrix operator, characterized in that: include: Get the original sparse matrix; The original sparse matrix is divided into a plurality of sparse blocks by using a sparse LU block algorithm, and sparse LU decomposition is performed on the sparse blocks.
2. The method according to claim 1, characterized in that: The step of dividing the original sparse matrix into a plurality of sparse blocks and performing sparse LU decomposition on the sparse blocks comprises: Splitting the original sparse matrix into a plurality of sparse blocks and storing them in a sparse storage format; Perform sparse LU decomposition on the sparse blocks stored in the sparse storage format.
3. The method according to claim 2, characterized in that The step of performing sparse LU decomposition on the sparse blocks stored in the sparse storage format includes: For various sparse blocks with different matrix structures stored in a sparse storage format, sparse LU solving processes corresponding to various sparse kernel functions are executed.
4. The method according to claim 3, characterized in that The sparse LU solution process corresponding to various sparse kernel functions is performed for various sparse blocks with different matrix structures stored in a sparse storage format, including: According to the matrix structure of the sparse block, a decision tree is used to select a target sparse kernel function with the fastest calculation speed from a plurality of sparse kernel functions; According to the target sparse kernel function, a sparse LU solution process corresponding to the target sparse kernel function is performed on the sparse block.
5. The method according to claim 4, characterized in that The step of performing a sparse LU solution process corresponding to the target sparse kernel function on the sparse block according to the target sparse kernel function includes: When the target sparse kernel function is a GETRF kernel function, a sparse LU solving process corresponding to the GETRF kernel function is performed on the sparse block according to the GETRF kernel function.
6. The method according to claim 4, characterized in that The step of performing a sparse LU solution process corresponding to the target sparse kernel function on the sparse block according to the target sparse kernel function includes: When the target sparse kernel function is a GESSM kernel function, according to the GESSM kernel function, a sparse LU solution process corresponding to the GESSM kernel function is performed on the sparse block; or, In the case where the target sparse kernel function is a TSTFR kernel function, a sparse LU solving process corresponding to the TSTFR kernel function is performed on the sparse block according to the TSTFR kernel function.
7. The method according to claim 4, characterized in that The step of performing a sparse LU solution process corresponding to the target sparse kernel function on the sparse block according to the target sparse kernel function includes: When the target sparse kernel function is the SSSSM kernel function, the sparse LU solution process corresponding to the SSSSM kernel function is performed on the sparse block according to the SSSSM kernel function.
8. A LU decomposition device based on a sparse matrix operator, characterized in that: include: An acquisition module is used to obtain the original sparse matrix; The decomposition module is used to divide the original sparse matrix into multiple sparse blocks by using a sparse LU block algorithm, and perform sparse LU decomposition on the sparse blocks.
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 LU decomposition method based on the sparse matrix operator as described in any one of claims 1 to 7 is 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 LU decomposition method based on a sparse matrix operator as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Operator optimization method and device for hybrid expert model, equipment, medium and program
CN119830976A
Sparse matrix efficient storage and decomposition device and method for super nodes
CN120011700A
