Solution method of triangular matrix, computer device and storage medium

CN122594634APending Publication Date: 2026-08-18SHANGHAI SMARTLOGIC TECHNOLOGY LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610942804.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0003]然而,现有的分布式内存三角矩阵求解方法中,容易出现并行效率低以及负载不均衡等问题

Benefits of technology

[0016] The above-mentioned method for solving triangular matrices is suitable for solving triangular matrix problems with various distributions. By executing computational or communication tasks in parallel across different process columns (or rows), it achieves high parallelism in the solution process. At the same time, the computational or communication tasks executed in parallel have the same structure and similar scale, which also achieves high load balancing in the solution process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122594634A_ABST
    Figure CN122594634A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a method for solving a triangular matrix, a computer device and a storage medium, comprising: obtaining a local relative process column sequence number, communicating data of a first matrix in column direction order to obtain a first communication matrix; based on the local relative process column sequence number, performing a solving operation in each round under control of a preset number of cycles; in the current round, if a current process holds a diagonal block of a second matrix, solving a corresponding triangular equation set, and broadcasting the solving result to a same column process; communicating the solving result to a process where corresponding data of the first matrix is located, and updating the first communication matrix; if the current process does not hold the diagonal block of the second matrix, updating the first communication matrix based on the obtained solving result; after each round of calculation, performing inter-column cyclic communication in a column direction to perform a solving operation in a next round; and repeating the operations until the preset number of cycles is completed. Thus, high parallelism and load balancing of the solving process are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of high-performance computing technology, and more specifically, to a method for solving triangular matrices, a computer device, and a storage medium. Background Technology

[0002] Currently, distributed memory triangular matrix solving is a common operator in the field of high-performance computing, and it has significant effects on solving large-scale scientific and engineering problems. For example, it has wide applications in scientific computing and engineering simulation, data analysis and machine learning, communication and signal processing.

[0003] However, existing methods for solving distributed memory triangular matrices are prone to problems such as low parallel efficiency and unbalanced load. Summary of the Invention

[0004] This application provides a method for solving triangular matrices, a computer device, and a storage medium, which can improve the parallel efficiency of the triangular matrix solving process and achieve load balancing.

[0005] The first aspect of this application provides a method for solving a triangular matrix, applicable to a two-dimensional process mesh composed of multiple processes, including: Obtain the local relative process column number, and communicate the data of the first matrix in column order to obtain the first communication matrix, so that the data of the first matrix and the corresponding block of the second matrix are in the same process; Based on the local relative process column index, the following solution operation is performed round by round under the control of a preset number of iterations: In the current round, if the current process holds the diagonal block of the second matrix, it solves the corresponding trigonometric equations locally and broadcasts the solution to the processes in the same column. The broadcast solution results are communicated to the process containing the corresponding data in the first matrix, and the first communication matrix is ​​updated. If the current process does not hold the diagonal block of the second matrix, the first communication matrix is ​​updated based on the obtained solution results; After each round of calculation, inter-column circular communication is performed along the column direction to communicate the updated first communication matrix to the adjacent column process in order to perform the next round of solution operation; Repeat the solution operation until the preset number of iterations is completed to obtain the final solution matrix.

[0006] In an optional embodiment of this application, the above-mentioned communication of the data of the first matrix in column order includes: using a point-to-point communication method to communicate the data of the first matrix in column order, wherein the communication process is executed in parallel between different column processes.

[0007] In an optional embodiment of this application, the condition for performing the solution operation round by round based on the local relative process column number includes: the value of the current round and the value of the local relative process column number satisfy a preset relationship.

[0008] In an optional embodiment of this application, if the value of the current round and the value of the local relative process column number do not satisfy a preset relationship, the method further includes: performing a wait until inter-column cyclic communication is performed along the column direction to communicate the updated first communication matrix to the adjacent column process.

[0009] In an optional embodiment of this application, the above-mentioned communication of the broadcast solution result to the process containing the corresponding data in the first matrix includes: communicating the solution result point-to-point to the process containing the corresponding data in the first matrix, and overwriting the corresponding data in the first matrix.

[0010] In an optional embodiment of this application, the above-mentioned inter-column circular communication method includes: each process sending the updated first communication matrix to the processes with the same row number and adjacent column numbers, and receiving data from the processes with the same row number and adjacent column numbers.

[0011] In an optional embodiment of this application, the above-mentioned broadcasting of the solution result to processes in the same column includes: broadcasting within the process group corresponding to the local relative process column number, without cross-column communication.

[0012] In an optional embodiment of this application, both the first matrix and the second matrix are two-dimensional block cyclic distributions, with the first matrix being a (mt, nt) block and the second matrix being a (mt, mt) block; The step of communicating the data of the first matrix in column order to obtain the first communication matrix includes: for each block B(ii, jj) in the first matrix, communicating to the process corresponding to block A(ii, (nt-jj+2)mod nt) in the second matrix to obtain the first communication matrix.

[0013] A second aspect of this application provides a apparatus for solving triangular matrices, comprising: An initialization module is used to obtain the local relative process column number and communicate the data of the first matrix in column order to obtain the first communication matrix, so that the data of the first matrix and the corresponding block of the second matrix are in the same process; The solution module is used to perform the following solution operations round by round, based on the local relative process column number and under the control of a preset number of loops: In the current round, if the current process holds the diagonal block of the second matrix, the corresponding trigonometric equations are solved locally, and the solution result is broadcast to the processes in the same column; the broadcast solution result is communicated to the process where the corresponding data in the first matrix is ​​located, and the first communication matrix is ​​updated; if the current process does not hold the diagonal block of the second matrix, the first communication matrix is ​​updated based on the obtained solution result; after each round of calculation, inter-column cyclic communication is performed along the column direction, and the updated first communication matrix is ​​communicated to the adjacent column processes to perform the solution operation in the next round; the solution operation is repeated until the preset number of loops is completed to obtain the final solution matrix.

[0014] A third aspect of this application provides a computer device, including: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the above methods.

[0015] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any of the preceding claims.

[0016] The above-mentioned method for solving triangular matrices is suitable for solving triangular matrix problems with various distributions. By executing computational or communication tasks in parallel across different process columns (or rows), it achieves high parallelism in the solution process. At the same time, the computational or communication tasks executed in parallel have the same structure and similar scale, which also achieves high load balancing in the solution process. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A schematic diagram illustrating the distribution of matrices A and B as an example for related technologies; Figure 2 A schematic diagram illustrating an example of a triangular matrix solving process provided for related technologies; Figure 3 A schematic diagram illustrating another example of a triangular matrix solving process provided for related technologies; Figure 4 A schematic diagram illustrating the distribution of matrix A, matrix B, and the process grid as provided in an embodiment of this application; Figure 5 A flowchart illustrating an example of a method for solving a triangular matrix provided in an embodiment of this application; Figure 6 A schematic diagram illustrating the data correspondence after communication between matrix B and matrix A is completed, as provided in an embodiment of this application. Figure 7 A flowchart illustrating another method for solving a triangular matrix provided in this application embodiment; Figure 8 A schematic diagram illustrating the process data for solving X(kk,j) in an example provided by an embodiment of this application; Figure 9 A schematic diagram illustrating an example of a broadcast method provided in an embodiment of this application; Figure 10 A schematic diagram illustrating an example of communicating the solution result to a first matrix, provided as an embodiment of this application; Figure 11 A schematic diagram illustrating an example of updating a first communication matrix, provided as an embodiment of this application; Figure 12 A schematic diagram illustrating an example of inter-column circular communication provided in an embodiment of this application; Figure 13 This is a schematic diagram illustrating the correspondence between different loop iterations k, different local relative process column numbers c, and the executed branches, provided for embodiments of this application. Figure 14 A schematic diagram of a triangular matrix solving device provided in one embodiment of this application; Figure 15 This is a schematic diagram of a computer device structure provided in one embodiment of this application. Detailed Implementation

[0018] Currently, distributed memory triangular matrix solving is a common operator in the field of high-performance computing, and it is widely used in scientific computing and engineering simulation, data analysis and machine learning, communication and signal processing. However, in the process of implementing distributed memory triangular matrix solving, the inventors found that the current solution method has problems such as low parallel efficiency and unbalanced load. Specifically, (1) there is no data dependency between multiple rounds of tasks, but they cannot be executed in parallel due to algorithm design and process occupation conflicts, so the parallel efficiency is low; (2) when executing computing tasks or communication tasks, usually only one process column (row) is executing the task at any given time, while other processes are idle, so the load is unbalanced.

[0019] For example, taking the case of solving AX=B as an example, the traditional algorithm assumes that A is a lower triangular matrix with mt=8 columns (rows) and B has mt=8 rows and nt=8 columns. Matrix A and B are distributed in a two-dimensional block cyclic pattern, and the process grid is (3,4). The traditional algorithm generally executes the following steps: len_interation=nt / / Number of column blocks whose outer loop iteration is B len_k=mt / / Number of columns (rows) in the inner loop, with the loop iterates A times. for idx_pc=1:len_interation=nt Send B to the first column of A for k=1:mt solve AX=B broadcast X in this column Update B with A and X / / Update results immediately pass updated B to next column of A Send X to B end end Based on the above traditional algorithm, assuming the distributions of matrices A and B are as follows: Figure 1 As shown, taking the solution process for a single column block in matrix B as an example (i.e., the solution process for one round of the task), as follows: Figure 2 As shown in the diagram, the upper grid is the process grid, and the processes executing this round of tasks are highlighted in the bold lines. The specific implementation process is as follows: ① Send the B column block to the process containing the first column block of A; ②Solve ; ③ Broadcast on the column and calculate update ; ④ The updated Send to the column after A; ⑤ The results Send to Location and replacement.

[0020] For each column block in matrix A, repeat steps ② to ⑤, that is, loop through the column blocks of A a certain number of times. For example, for the next column block of matrix A, the execution process is as follows: Figure 3 As shown in the diagram. For each column block in matrix B, this round of tasks is executed, for a total of [number] column blocks of B. As can be seen from the solution process of the traditional algorithm described above, only one process is executing tasks at any given time, which leads to low parallel efficiency and unbalanced load.

[0021] To address the aforementioned issues, this application provides a high-load-balanced solution method for distributed memory triangular matrices, aiming to solve the problems of low parallel efficiency and unbalanced load in traditional distributed memory triangular matrix solution methods.

[0022] First, let us briefly introduce the technical terms involved in the embodiments of this application: 1. Solving triangular matrices: Solve the linear system of equations op(A)×X=B or X×op(A)=B, where matrix A is a triangular matrix (lower triangular or upper triangular), and op(A) represents the untranspose, transpose, or conjugate transpose of matrix A.

[0023] 2. Distributed memory: The triangular matrix is ​​distributed and stored in multiple process nodes in a cyclical manner as two-dimensional blocks, and data is exchanged between processes.

[0024] 3. 2D Block-Cyclic Distribution: A strategy for storing and processing dense matrices in a distributed memory system. It divides the matrix into Mb×Nb blocks and then distributes them to processes in a cyclical manner. This method combines the advantages of block distribution and cyclic distribution: it ensures local data continuity while achieving load balancing.

[0025] 4. Update priority: After obtaining the intermediate result, the data that needs the intermediate result is updated first through communication and calculation. In the triangular matrix solving problem of this application embodiment, the adjacent next column (row) block is updated first.

[0026] Secondly, the triangular matrix solving method provided in this application decomposes the overall triangular matrix solving task into multiple rounds of tasks based on the distribution of the triangular matrix (such as upper and lower triangles, left and right multiplication, transpose, etc.), with no dependencies between rounds. Each round is further decomposed into multiple loop tasks, with dependencies between loops and execution in a loop. Each loop task is further decomposed into multiple subtasks, with dependencies between subtasks and execution in sequence. By staggering the start times of each round, the process columns (rows) occupied by each round do not conflict, thus allowing for pipelined execution of multiple rounds. At any given moment, each process column (row) is executing one loop task from each round. At the same time, subtasks of each loop task are executed in parallel or merged with similar subtasks in other process columns (rows), and these similar subtasks have the same structure, similar size, and similar execution time, enabling the overall triangular matrix solving task to be executed in parallel pipeline while maintaining load balancing. Therefore, this method can be used for triangular matrices with two-dimensional block cyclic distribution, achieving distributed triangular matrix solving with high parallelism and high load balancing.

[0027] It is understood that the solutions in the embodiments of this application can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0028] To make the technical solutions and advantages of the embodiments of this application clearer, the exemplary embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not an exhaustive list of all embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.

[0029] The following embodiments use a computer device as the execution subject to specifically illustrate the method for solving triangular matrices provided in this application. When decomposing the solution task into multiple rounds based on the triangular matrix, considering that triangular matrices can have upper and lower triangles, left and right multiplications, transposes, etc., this application can use similar decomposition methods for these different triangular matrices, but with different loop directions.

[0030] For example, in the left-multiplication and right-multiplication case (SIDE), 'L' indicates left multiplication of A (e.g., AX=B), and 'R' indicates right multiplication of A (e.g., XA=B); in the upper-triangular case (UPLO), 'U' indicates that A is an upper triangular matrix, and 'L' indicates that A is a lower triangular matrix; in the transpose case (TRANSA), 'N' indicates that A is not transposed (e.g., XA=B), 'T' indicates that A is transposed (e.g., ATX=B), and 'C' indicates that A is conjugate transpose (e.g., XAH=B); using the notation SUT to represent the above cases, the decomposition methods based on SUT are: LLN: Triangular matrix A is divided into columns, and the cycle starts from the first column of A and proceeds backwards; B is divided into columns. LUN: Triangular matrix A is divided into columns, and the cycle starts from the last column of A and moves forward. B is divided into columns. LLT / LLC: A is divided into rows, and the loop starts from the last row of A and moves forward; B is divided into columns. LUT / LUC: A is divided into rows, and the loop starts from the first row of A and proceeds backwards; B is divided into columns. RLN: Triangular matrix A is divided into rows and blocks, and the loop starts from the last row of A and moves forward. B is also divided into rows and blocks. RUN: Triangular matrix A is divided into rows and blocks, and the loop starts from the first row of A and proceeds backwards. B is also divided into rows and blocks. RLT / RLC: A is divided into columns, and the cycle starts from the first column of A and proceeds backwards; B is divided into rows. RUT / RUC: A is divided into column blocks, and the loop starts from the last column of A and moves forward; B is divided into row blocks. Therefore, the decomposition methods for the upper and lower triangular matrices are similar, but the cyclic direction is reversed. The following embodiments will exemplify the solution method for the triangular matrices of this application in the cases of lower triangular matrices, left multiplication, and no transpose. Taking the solution of AX=B as an example, matrices A and B are both two-dimensional block cyclic distributions. Matrix A is a (mt, mt) block, matrix B is a (mt, nt) block, and the process grid is (Pr, Pc). The distribution of matrices A, matrix B, and the process grid can be found in [reference needed]. Figure 4 The triangular matrix to be solved is: · =

[0031] Specifically, such as Figure 5 As shown, the above method includes the following steps 501-507: Step 501: Obtain the local relative process column number and communicate the data of the first matrix in column order to obtain the first communication matrix, so that the data of the first matrix and the corresponding block of the second matrix are in the same process.

[0032] Taking a process in the process grid as an example, the computer device obtains the local relative process column number (c) corresponding to the process based on the process grid and prepares the communication data. Here, the data of the first matrix (i.e., matrix B) can be communicated to the process containing the corresponding block of the second matrix (i.e., matrix A) in column block order, so that the data of the first matrix and the corresponding block of the second matrix are in the same process. It can be understood that the computer device can also communicate the data of the second matrix (i.e., matrix A) to the process containing the corresponding block of the first matrix (i.e., matrix B) in column block order, generally choosing the method with the shorter communication time. After the communication is completed, the matrix obtained from communicating with the first matrix is ​​recorded as the first communication matrix (e.g., denoted as matrix). B ).

[0033] For example, with Figure 4 Taking matrices A and B as an example, the data correspondence after communication is as follows: Figure 6 As shown.

[0034] In some implementations, when computer devices communicate data in the first matrix in column order, a point-to-point communication method can be used, with different column processes executing the communication process in parallel.

[0035] Step 502: Based on the local relative process column number, and under the control of the preset number of loops, execute the solution operations of steps 503-507 round by round.

[0036] The computer device can be set with a preset number of iterations (P), for example, P=mt+nt-1. Under the control of this preset number of iterations, the computer device performs the following solution operation.

[0037] Step 503: In the current round, if the current process holds the diagonal block of the second matrix, it solves the corresponding trigonometric equations locally and broadcasts the solution to the processes in the same column.

[0038] Assuming the current round is k, if the current process (c) holds the diagonal block of the second matrix (e.g., A(kk, kk), 1 <= kk <= mt), then the computer device solves the corresponding trigonometric equation system locally, that is, solves A(kk, kk) X (kk, j) = B (kk, j). After the solution is completed, the computer will broadcast the solution X(kk, j) in the column.

[0039] Step 504: Communicate the broadcast solution results to the process containing the corresponding data in the first matrix, and update the first communication matrix.

[0040] After broadcasting, the computer device can communicate the solution X(kk,j) to the process containing the corresponding data B(kk,j) in the first matrix for subsequent calculations. Simultaneously, it can also update the first communication matrix, for example... B (i, j) = B (i,j)-A(i,kk)X(kk,j).

[0041] In some implementations, the computer device can communicate the solution results point-to-point to the process containing the data corresponding to the first matrix and overwrite the corresponding data in the first matrix, that is, overwrite B(kk,j).

[0042] Step 505: If the current process does not hold the diagonal block of the second matrix, then update the first communication matrix based on the obtained solution results.

[0043] If the current process (c) does not hold the diagonal block of the second matrix (such as A(kk, kk)), then the solution process of steps 503 and 504 above will not be executed, and the first communication matrix will only be updated based on the obtained solution results.

[0044] Step 506: After each round of calculation, perform inter-column circular communication along the column direction to communicate the updated first communication matrix to the adjacent column process in order to perform the next round of solution operation.

[0045] In other words, after updating the first communication matrix, the computer device needs to update the result. B (i, j) communicate with the adjacent column processes to perform the next round (k+1) of the solution operation.

[0046] In some implementations, the principle of inter-column circular communication is as follows: communication is divided into a sender and a receiver, with the sender communicating data to the receiver. For each process sending data (column number c), it needs to send data to the next process, therefore sending data to the process with the same row number and column number (c+1) mod Pc. For each process receiving data (column number c), it needs to receive data sent by the previous process, therefore receiving data from the process with the same row number and column number (c-1) mod Pc.

[0047] Step 507: Repeat the solution operation until the preset number of loops is completed to obtain the final solution matrix.

[0048] It is understandable that the computer device will repeatedly perform the above solution operation until the preset number of iterations (P) is completed, and the final solution matrix is ​​obtained. Due to the characteristics of distributed memory, the results distributed across multiple processes can be directly output. Therefore, the process is terminated directly after the preset number of iterations is completed, and the final solution matrix is ​​obtained.

[0049] In the above embodiments, the computer device executes computing or communication tasks in parallel across different process columns (rows) through a triangular matrix solving process, achieving high parallelism. The computing or communication tasks executed in parallel have the same structure and similar scale, achieving high load balancing. At the same time, prioritizing the updating of matrix data during the solving process can also improve read and write efficiency and increase bandwidth utilization.

[0050] To facilitate understanding of the process in the above embodiments, the following description uses the execution of the k-th round of loop operation with the local relative process column number (c) as an example. Figure 7 As shown, it includes the following steps: Step 71: Obtain the local relative process column number and communicate the data of the first matrix in column order to obtain the first communication matrix.

[0051] Specifically, the computer device obtains the local relative process column number (c), and for each block B (ii, jj) of the first matrix, communicates to the process corresponding to block A (ii, (nt-jj+2) mod nt) of the second matrix, thus obtaining the first communication matrix. B .

[0052] It can be understood that B(ii, jj) refers to the block in the ii-th row and jj-th column of the first matrix, and A(ii, (nt-jj+2) mod nt) refers to the block in the ii-th row and (nt-jj+2) mod nt-th column of the second matrix. The data correspondence after communication is as described above. Figure 6 As shown.

[0053] Step 72, set a preset number of loops \(P\) and a local number of loops \(Q\), and initialize the loop round \(k\).

[0054] Among them, the computer device sets the preset number of loops \(P = mt + nt - 1\), the local number of loops \(Q = mt + c - 1\), and initializes the loop round \(k = 0\).

[0055] It can be understood that the setting basis of \(P\) is as follows: The task corresponding to the \(nt\)-th column block is the last task to start. It waits for the tasks of the previous \((nt - 1)\) column blocks before starting to execute. Therefore, the corresponding \(k\) at the start time is \(nt - 1\). And each column block task requires \(mt\) loops. Therefore, when each task is completed as a whole, a total of \((mt + nt - 1)\) loops are required in the end, and this value is set as the value of \(P\).

[0056] Step 73, check if \(k\) is less than \(P\). If yes, execute Step 74; if not, terminate the process.

[0057] Step 74, check if \(k\) is less than \(Q\). If yes, execute Step 75; if not, terminate the process.

[0058] Step 75, check if \(k\) is less than \(c - 1\). If yes, it means that the task of not performing the update B is executed, so wait until Step 81 is executed. If not, execute Step 76.

[0059] Among them, judging whether \(k\) is less than \(c - 1\) is to judge whether the value of the current round and the value of the local relative process column serial number satisfy a preset relational expression. If \(k\) is not less than \(c - 1\), it is determined that the preset relational expression is satisfied, and the computer device executes the following solution operation. If \(k\) is less than \(c - 1\), it is determined that the preset relational expression is not satisfied, and the computer device waits until the process of performing column - to - column cyclic communication in Step 81.

[0060] When \(k < c - 1\), B \((kk, j)\) is not in the same process as \(A(1, 1)\), so the first solution task \(A(1, 1)X(1, j)= B \((1, j)\) has not been executed. And subsequent solution tasks all depend on the calculation result \(X(1, j)\). Therefore, when \(k < c - 1\), it is necessary to wait for several subsequent loops, B until communicating to the first column block of \(A\) (corresponding to \(k = nt - 1\)) can start executing the solution task, that is, only communicate B without updating B .

[0061] Step 76, check if the current process holds the diagonal block of the second matrix. If yes, execute Step 77; if not, execute Step 80.

[0062] In the case where the current process (c) holds the diagonal block of the second matrix (such as A(kk, kk), 1<=kk<=mt), it means that kk mod Pc=c, that is, kk=c+t×Pc and 1<=kk<=mt, then the subsequent solution operation is started.

[0063] It can be understood that the principle behind this data is as follows: based on the characteristics of the cyclic distribution of two-dimensional blocks, the matrix blocks are distributed to each process in the process grid in a row-column cyclic manner.

[0064] For a process queue with c=1, there are only A(any, 1) blocks, A(any, 1+Pc) blocks, ..., A(any, 1+t×Pc) blocks (where the value of t is all cases where 1<=1+t×Pc<=mt), i.e., kk mod Pc=1; For a process queue with c=2, there are only A(any,2) blocks, A(any,2+Pc) blocks, ..., A(any,2+t×Pc) blocks (where the value of t is all cases where 1<=2+t×Pc<=mt), i.e., kk mod Pc=2; ... For any sequence of processes c, there are exactly A(any, c) blocks, A(any, c+Pc) blocks, ..., A(any, c+t×Pc) blocks (where the value of t is all cases where 1<=c+t×Pc<=mt), i.e., kk mod Pc=c.

[0065] Therefore, for a local relative process sequence number (c), if there is a diagonal block, i.e., A(kk, kk), then according to the above form, kk needs to satisfy the form c+t×Pc and 1<=kk=c+t×Pc <=mt, i.e., kk mod Pc=c.

[0066] Step 77: Solve the corresponding trigonometric equations locally.

[0067] In other words, to solve A(kk, kk)X(kk, j) = B (kk, j), where j mod Pc = (k+2-c) mod Pc, that is, j = k+2-c + s×Pc and max(1, k-mt+2) <= j <= min(k+1, nt).

[0068] The underlying principle of this data is as follows: Given the local relative process column number (c) and the loop variable k, calculate A(kk, kk)X(kk, j) = B (kk, j), depending on the previous loop B (kk,j) communicates to this process.

[0069] After step 71,B The data corresponding to (kk, j) is in the process where block A(kk, (2-j) mod nt) resides, and in each loop... B The data corresponding to (kk, j) is communicated to the next process in a loop. Therefore, when the loop variable is k, B The data corresponding to (kk, j) is located in the process of block A(kk, (2-j) mod nt), which is the local relative process column number (c). Therefore, k-j+2≡c (mod Pc), j≡k+2-c (mod Pc). That is, j mod Pc=(k+2-c) mod Pc.

[0070] Furthermore, regarding the range of values ​​for j when the loop variable is k, firstly, 1 <= j <= nt. Secondly, when k is small, the range of values ​​for j corresponding to larger values ​​is... B (kk, j) has not yet communicated with the process containing the first column block of matrix A, and therefore has not executed the first solution task. Specifically, considering the process column with c=1, then j=(k+1), and j>k+1. B The (kk, j) column block has not yet started its solution task, therefore j <= (k+1) for executing the solution task. Then, when k is large, j takes a smaller value corresponding to... B (kk, j) has finished its operation with the last block of A, and therefore will no longer perform the solution task. Specifically, considering the process column where c ≡ mt (mod Pc) (the process column containing the last block of A), then j = (k - mt + 2), and therefore j < (k - mt + 2). B The (kk,j) column block has completed its solution task, therefore the j that performs the solution task is greater than or equal to (k-mt+2).

[0071] For example, the process data for solving X(kk,j) is as follows: Figure 8 As shown, the blue boxes represent the processes that perform the corresponding computation or communication tasks, and the red boxes represent the matrix blocks that participate in the corresponding computation or communication tasks.

[0072] Step 78: Broadcast the solution results within the column.

[0073] That is, the computer device broadcasts the solution result X(kk,j). Here, the solution result is only broadcast within the process group corresponding to the local relative process column index, and no cross-column communication is performed. For example, the broadcast method is as follows: Figure 9 As shown, the arrows in the blue boxes indicate the direction of communication.

[0074] Step 79: Communicate the broadcast solution results to the process containing the corresponding data in the first matrix, and overwrite the first matrix.

[0075] That is, the computer device communicates the solution X(kk,j) point-to-point to the process containing the corresponding data B(kk,j) in the first matrix. An exemplary diagram illustrating the communication of the solution result to the first matrix is ​​shown below. Figure 10 As shown, the arrow in the red box indicates the communication direction. For the data in matrix B, the blue box represents the calculation result of this loop. The dark block in the upper left of the blue box represents the solution result X of the previous loop that has overwritten the data of the original matrix B. The light box below represents the data of the original matrix B that has not yet been solved and overwritten.

[0076] Step 80: Update the first communication matrix.

[0077] Computer equipment can be B (i, j) = B The first communication matrix is ​​updated using the method (i,j)-A(i,kk)X(kk,j). B Where, kk mod Pc = c, that is, kk = c + t × Pc and 1 <= kk <= mt, j mod Pc = (k + 2 - c) mod Pc, that is, j = k + 2 - c + s × Pc and max(1, k - mt + 2) <= j <= min(k + 1, nt), kk + 1 <= i <= mt. An exemplary diagram illustrating the updating of the first communication matrix is ​​shown below. Figure 11 As shown.

[0078] Step 81: Perform inter-column circular communication along the column direction to communicate the updated first communication matrix to the adjacent column processes.

[0079] The computer equipment can communicate with the first communication matrix according to the principle of inter-column cyclic communication described above. B (i, j) communicate. For example, a schematic diagram of the inter-column circular communication process is shown below. Figure 12 As shown, (a) represents the matrix distribution before communication, and (b) represents the matrix distribution after communication.

[0080] Step 82: Execute the preset number of loops. Once the first matrix is ​​overwritten, the process terminates.

[0081] That is, after the computer device executes the above-mentioned preset number of loops (P), the process terminates and the solution matrix is ​​output.

[0082] Based on the process described in the above embodiments, we can denote process branches where k is less than c-1 as branch α, process branches where k is not less than c-1 as branch β, and process branches where k is not less than Q as branch γ. Then, in different loop iterations k, processes corresponding to different local relative process column numbers (c) may execute different branches. For example, the correspondence between different loop iterations k, different local relative process column numbers c, and the executed branches is as follows: Figure 13 As shown, all processes can obtain the process column number c simultaneously, but the loop variable k corresponding to the start of branch β for each process column is different. That is, the start times can be staggered, and the parallelism of different processes is reflected in the fact that when k takes a certain value, different processes are all executing the task of the corresponding branch.

[0083] Thus, through the triangular matrix solving process, computer devices can simultaneously execute computing or communication tasks in parallel across different process columns (rows), achieving high parallelism. The computing or communication tasks executed in parallel have the same structure and similar scale, achieving high load balancing. At the same time, prioritizing the updating of matrix data during the solving process can also improve read and write efficiency and increase bandwidth utilization.

[0084] It should be understood that although the steps in the flowchart are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order constraint on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the diagram may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0085] Please see Figure 14 One embodiment of this application provides a triangular matrix solving device, including: an initialization module 141 and a solving module 142.

[0086] Specifically, the initialization module 141 is used to obtain the local relative process column number and communicate the data of the first matrix in column order to obtain the first communication matrix, so that the data of the first matrix and the corresponding block of the second matrix are in the same process; The solver module 142 is used to perform the following solver operations round by round based on the local relative process column number and under the control of a preset number of loops: In the current round, if the current process holds the diagonal block of the second matrix, it solves the corresponding trigonometric equation system locally and broadcasts the solution result to the processes in the same column; it communicates the broadcast solution result to the process where the corresponding data in the first matrix is ​​located and updates the first communication matrix; if the current process does not hold the diagonal block of the second matrix, it updates the first communication matrix based on the obtained solution result; after each round of calculation, it performs inter-column cyclic communication along the column direction and communicates the updated first communication matrix to the adjacent column processes to perform the solver operation in the next round; it repeats the solver operation until the preset number of loops is completed to obtain the final solver matrix.

[0087] In some embodiments, the initialization module 141 is specifically used to communicate the data of the first matrix in column order using a point-to-point communication method, wherein the communication process is executed in parallel between different column processes.

[0088] In some embodiments, the condition for performing the solution operation round by round based on the local relative process column number includes: the value of the current round and the value of the local relative process column number satisfy a preset relationship.

[0089] In some embodiments, if the value of the current round does not satisfy the preset relationship with the value of the local relative process column number, the solving module 142 is also used to wait until the column-direction inter-column cyclic communication is performed to communicate the updated first communication matrix to the adjacent column process.

[0090] In some embodiments, the solving module 142 is specifically used to communicate the solution result point-to-point to the process where the corresponding data of the first matrix is ​​located, and to overwrite the corresponding data in the first matrix.

[0091] In some embodiments, the inter-column circular communication method includes: each process sending the updated first communication matrix to the processes with the same row number and adjacent column number, and receiving data from the processes with the same row number and adjacent column number.

[0092] In some embodiments, the solver module 142 is specifically used to broadcast the solution results within the process group corresponding to the local relative process column number, without performing cross-column communication.

[0093] In some embodiments, the first matrix and the second matrix are both two-dimensional block cyclic distributions, the first matrix is ​​a (mt, nt) block, and the second matrix is ​​a (mt, mt) block; the initialization module 141 is specifically used to communicate each block B (ii, jj) in the first matrix to the process corresponding to block A (ii, (nt-jj+2) mod nt) in the second matrix to obtain the first communication matrix.

[0094] If the aforementioned two-dimensional process network consists of multiple processors, then the above method for solving the triangular matrix can be implemented through the following steps: The first matrix, the second matrix, and the third matrix are distributed on the two-dimensional process grid in a cyclic manner using two-dimensional blocks; The target communication mode is determined based on the size of the first matrix, the size of the second matrix, the size of the third matrix, and the size of the two-dimensional process grid. In the target communication mode, a cyclic staggered iteration method is adopted to map the block data corresponding to the first matrix, the second matrix and the third matrix to each target processor to perform data processing operations, wherein different target processors correspond to different iteration round offsets; Each target processor communicates the calculation results and outputs the data processing results.

[0095] Optionally, determining the target communication mode based on the size of the first matrix, the size of the second matrix, the size of the third matrix, and the size of the two-dimensional process grid includes: determining the communication volume of a first communication mode based on the size of the first matrix, the size of the second matrix, and the size of the two-dimensional process grid; determining the communication volume of a second communication mode based on the size of the first matrix, the size of the third matrix, and the size of the two-dimensional process grid; determining the communication volume of a third communication mode based on the size of the second matrix, the size of the third matrix, and the size of the two-dimensional process grid; and selecting the communication mode with the smallest communication volume from the first communication mode, the second communication mode, and the third communication mode as the target communication mode.

[0096] Optionally, in the target communication mode, the method of using a cyclic staggered iteration to map the block data corresponding to the first matrix, the second matrix, and the third matrix to each target processor for data processing operations includes: when the target communication mode is the first communication mode, using a cyclic staggered iteration to send the block data corresponding to the first matrix and the block data corresponding to the second matrix to the target processor where the block data of the third matrix is ​​located, and completing the calculation.

[0097] Optionally, in the target communication mode, a cyclic staggered iteration method is used to map the block data corresponding to the first matrix, the second matrix, and the third matrix to each target processor for data processing operations. This includes: when the target communication mode is the second communication mode, using inner and outer loops, in the inner loop, sending the block data corresponding to the first matrix to the target processor where the block data of the second matrix is ​​located, and having the target processor calculate intermediate results; in the outer loop, sending the intermediate results from the target processor where the block data of the second matrix is ​​located to the target processor where the block data of the third matrix is ​​located, and completing the calculation.

[0098] Optionally, in the target communication mode, a cyclic staggered iteration method is used to map the block data corresponding to the first matrix, the second matrix, and the third matrix to each target processor for data processing operations. This includes: when the target communication mode is the third communication mode, using inner and outer loops, in the inner loop, sending the block data corresponding to the second matrix to the target processor where the block data of the first matrix is ​​located, and having the target processor calculate an intermediate result; in the outer loop, sending the intermediate result from the target processor where the block data of the first matrix is ​​located to the target processor where the block data of the third matrix is ​​located, and completing the calculation.

[0099] Optionally, the number of iterations in the cyclic misalignment iteration method is determined based on the least common multiple of the number of rows and columns in the two-dimensional process grid.

[0100] Optionally, the data processing operation includes The matrix multiplication calculation of the relational expression, where A is the first matrix, B is the second matrix, and C is the third matrix.

[0101] Specific limitations regarding the apparatus for solving the aforementioned triangular matrix can be found in the limitations of the triangular matrix solving method described above, and will not be repeated here. Each module in the aforementioned apparatus for solving the triangular matrix can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0102] In one embodiment, a computer device is provided, the internal structure of which can be as shown in the figure. Figure 15 As shown, this computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for solving a triangular matrix as described above.

[0103] In one embodiment, the computer device described above may be a server, including but not limited to a single server, a server cluster, etc.

[0104] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, can perform any step of the method for solving the triangular matrix as described above.

[0105] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0109] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0110] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for solving a triangular matrix, characterized in that, Suitable for two-dimensional process grids consisting of multiple processes, including: Obtain the local relative process column number, and communicate the data of the first matrix in column order to obtain the first communication matrix, so that the data of the first matrix and the corresponding block of the second matrix are in the same process; Based on the local relative process column index, the following solution operation is performed round by round under the control of a preset number of iterations: In the current round, if the current process holds the diagonal block of the second matrix, it solves the corresponding trigonometric equations locally and broadcasts the solution to the processes in the same column. The broadcast solution results are communicated to the process containing the corresponding data in the first matrix, and the first communication matrix is ​​updated. If the current process does not hold the diagonal block of the second matrix, the first communication matrix is ​​updated based on the obtained solution results; After each round of calculation, inter-column circular communication is performed along the column direction to communicate the updated first communication matrix to the adjacent column process in order to perform the next round of solution operation; Repeat the solution operation until the preset number of iterations is completed to obtain the final solution matrix.

2. The method according to claim 1, characterized in that, The communication of data in the first matrix in column order includes: A point-to-point communication method is used to communicate the data of the first matrix in column order, wherein the communication process is executed in parallel between different column processes.

3. The method according to claim 1, characterized in that, Based on the local relative process column number, the conditions for performing the solution operation round by round include: the value of the current round and the value of the local relative process column number satisfy a preset relationship.

4. The method according to claim 3, characterized in that, If the value of the current round and the value of the local relative process column number do not satisfy a preset relationship, the method further includes: The process waits until it performs inter-column circular communication along the column direction, communicating the updated first communication matrix to the adjacent column process.

5. The method according to claim 1, characterized in that, The step of communicating the broadcast solution results to the process containing the corresponding data in the first matrix includes: The solution result is communicated point-to-point to the process containing the data corresponding to the first matrix, and the corresponding data in the first matrix is ​​overwritten.

6. The method according to claim 1, characterized in that, The inter-column circular communication methods include: Each process sends the updated first communication matrix to the processes with the same row number and adjacent column numbers, and receives data from the processes with the same row number and adjacent column numbers.

7. The method according to claim 1, characterized in that, The broadcasting of the solution results to other processes in the same queue includes: The solution result is broadcast within the process group corresponding to the local relative process column number, without cross-column communication.

8. The method according to any one of claims 1 to 7, characterized in that, Both the first matrix and the second matrix are two-dimensional block cyclic distributions, with the first matrix being a (mt, nt) block and the second matrix being a (mt, mt) block; The process of communicating the data of the first matrix in column order to obtain the first communication matrix includes: For each block B(ii, jj) in the first matrix, communicate with the process corresponding to block A(ii, (nt-jj+2)modnt) in the second matrix to obtain the first communication matrix.

9. A computer device, comprising: A memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method according to any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.