A LU decomposition hardware accelerator and acceleration method
By designing a LU decomposition hardware accelerator including a main controller, an arithmetic controller, a memory access controller and a maximum element comparator, an effective LU decomposition of arbitrary order matrix is achieved, and the insufficient support for selecting main and arbitrary order matrix in the prior art is solved. The problem of improving computing efficiency and accuracy.
Patent Information
- Application Number
- CN202411274307.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The lack of simultaneous support for selecting principal elements and arbitrary order matrices in the existing LU decomposition hardware accelerator designs, resulting in large calculation errors or the matrix orders being limited by memory, making it impossible to process larger-scale matrices.
A LU decomposition hardware accelerator is designed, including the main controller, an arithmetic controller, a memory access controller and a maximum meta comparator. Through the finite state machine management algorithm process, it supports batch reading of matrix element data and utilizes the maximum meta comparator. Select the element with the largest absolute value as the main element to realize the LU decomposition of any order matrix.
The effective LU decomposition of arbitrary order matrices is realized, which avoids the storage requirements of whole rows or whole columns of data, reduces calculation errors, and supports partial main selection, improving the universality and efficiency of hardware accelerators.
Smart Images

Figure CN118779007B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of matrix LU decomposition hardware accelerator for numerical solution of linear equations, and in particular to an LU decomposition hardware accelerator and an acceleration method. Background Art
[0002] Solving a system of linear equations is a common operation in scientific and engineering calculations, and is widely used in signal processing, numerical analysis, data mining and other fields. Solving a system of linear equations is to solve the value of the unknown vector x in the equation Ax = b. Its solution methods are divided into two categories: direct method and iterative method. The direct method calculates the exact solution of the unknown vector x by elimination or matrix decomposition and back substitution. The iterative method starts from an initial solution and approximates the exact solution through multiple iterations. In actual engineering, the direct method is used to calculate the exact solution. LU decomposition is a solution algorithm in the direct method.
[0003] LU decomposition is performed by decomposing the coefficient matrix A into the product of a lower triangular matrix (L matrix) and an upper triangular matrix (U matrix) A = LU, and then solving Ly = b and Ux = y respectively to obtain the solution of x. If A is a non-singular matrix and all ordered principal minors are not 0, and all the elements on the diagonal of the L matrix or the U matrix are 1, then the LU decomposition result of the matrix A exists and is unique. LU decomposition is a computationally intensive algorithm. For dense matrices, the time complexity of LU decomposition is O(n 3 ). Therefore, hardware acceleration of LU decomposition is a technology required in practical applications.
[0004] The existing method of hardware acceleration for LU decomposition is to implement all or part of the steps of LU decomposition with LU decomposition hardware accelerator, thereby achieving acceleration effect. The differences between various LU decomposition hardware accelerators mainly lie in hardware structure, operation process and other aspects.
[0005] In order to ensure the accuracy of numerical calculations in LU decomposition, it is necessary to select element data with larger absolute values as pivots during the LU decomposition process. There are two methods for selecting pivots: partial pivot selection and global pivot selection. Global pivot selection selects the element data with the largest absolute value from all the remaining matrix element data that have not yet completed the LU decomposition calculation, while partial pivot selection selects the element data with the largest absolute value from the current column in the LU decomposition process as the pivot. Compared with global pivot selection, partial pivot selection requires less calculation and data access.
[0006] The existing LU decomposition hardware accelerators have the following design deficiencies: (1) The design scheme of Chinese patent CN108763653A (published on November 6, 2018) requires that the internal memory of the LU decomposition hardware accelerator can store a whole row or column of data of the coefficient matrix in order to select the pivot; this requires that the order of matrix A does not exceed the size of a whole row or column that can be accommodated by the internal memory of the LU decomposition hardware accelerator; (2) The design scheme of Chinese patent CN107341133A (published on November 10, 2017) supports LU decomposition hardware acceleration of any order, but does not include the function of selecting the pivot, which may lead to large LU decomposition errors in some cases.
[0007] Therefore, a new LU decomposition hardware accelerator is urgently needed to solve the problem that the existing LU decomposition hardware accelerator design lacks simultaneous support for the selection of pivot elements and matrices of arbitrary orders. Summary of the invention
[0008] The purpose of the present invention is to provide a LU decomposition hardware accelerator and an acceleration method, which can realize LU decomposition of matrices of arbitrary order and support the selection of pivot elements at the same time.
[0009] To achieve the above object, the present invention provides the following solutions:
[0010] A LU decomposition hardware accelerator includes: a main controller, an operator, a memory access controller and a maximum element comparator;
[0011] The main controller communicates with the arithmetic unit, the memory access controller and the maximum element comparator respectively; the arithmetic unit communicates with the memory access controller and the maximum element comparator; the memory access controller communicates with the host CPU and the host memory; the comparison circuit in the maximum element comparator communicates with the maximum element register and the maximum element row number register;
[0012] The main controller includes a control circuit, which realizes the control of the process by a finite state machine, and is used to manage the operation of the operator, the memory access controller and the maximum element comparator, and control the algorithm process of LU decomposition;
[0013] The memory access controller is used to calculate the address of the matrix element data, read the matrix element data from the host memory in batches, and write the L matrix element data and U matrix element data calculated by the operator back to the host memory;
[0014] The operator is used to perform LU decomposition calculation on the matrix read by the memory access controller, and send the calculated L matrix element data and U matrix element data to the memory access controller, and send the calculated L matrix element data to the maximum element comparator;
[0015] The maximum element comparator includes: a comparison circuit, a maximum element register and a maximum element row number register; the maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register using the comparison circuit, and save the L matrix element data with the largest absolute value to the maximum element register, and at the same time save the row number corresponding to the L matrix element data with the largest absolute value to the maximum element row number register; the L matrix element data with the largest absolute value is the principal element.
[0016] Optionally, the main controller includes: a control circuit, a row number register corresponding to each computing unit in the operator, a loop counter, a row counter, a column counter, a multiplication-addition counter and a step register.
[0017] Optionally, the operator includes: a plurality of computing units; each computing unit is used to complete multiplication, addition, subtraction and division operations in LU decomposition; each computing unit includes: a register RL, a register RU, a register RA, a multiplier, an adder-subtractor and a divider;
[0018] Register RL is used to store the L matrix element data as the source operand;
[0019] Register RU is used to store the U matrix element data as the source operand;
[0020] Register RA is used as the accumulator register;
[0021] The multiplier is used to perform multiplication operation of L matrix element data and U matrix element data in LU decomposition calculation;
[0022] The adder-subtractor is used for performing addition and subtraction operations of L matrix element data and U matrix element data in LU decomposition calculation;
[0023] The divider is used to perform division operations between L matrix element data and U matrix element data in LU decomposition calculations.
[0024] Optionally, the operation mode between the multiple computing units is parallel operation, and the operation mode within each computing unit is pipeline operation.
[0025] Optionally, the calculation operation of the operator and the address calculation operation of the memory access controller are overlapped in time with the memory access operation of the memory access controller to optimize the total running time of multiple matrix element data calculations and memory accesses.
[0026] Optionally, the memory access controller includes: a row index array start address register, a start address register, an order register, a shifter, an integer multiplier, an integer adder, and a read-write operation circuit.
[0027] An acceleration method for a LU decomposition hardware accelerator is applied to the LU decomposition hardware accelerator; the acceleration method for the LU decomposition hardware accelerator comprises:
[0028] Initialize the LU decomposition hardware accelerator, clear all registers, and then set the value of the step register; the value of the step register is the number of computing units;
[0029] The host CPU sends the matrix starting address, the matrix order and the row index array starting address to the LU decomposition hardware accelerator, and saves them through the starting address register, order register and row index array starting address register of the memory access controller; sets the loop counter value to 1;
[0030] Use the main controller to obtain the current value of the loop counter;
[0031] When the current value of the loop counter is less than or equal to the order of the matrix, according to the formula Calculate the current column element data corresponding to the loop counter value in the L matrix; where, is the L matrix Line Column element data, and They are the contents read from the host memory into register RL and register RU by the memory access controller. To read the contents of register RA, is the number of executions, is the value of the multiply-add counter;
[0032] The maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register. If the absolute value of the value of the maximum element register is smaller, the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element register, and the row number corresponding to the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element row number register; the element data with the largest absolute value in the current column of the L matrix is the principal element; after completing the calculation of the L matrix element data in the current column corresponding to the loop counter value, the values of the element data corresponding to the loop counter and the maximum element row number in the row index array are exchanged to realize the operation of selecting the principal element; then according to the formula Calculate the current row element data of the U matrix corresponding to the loop counter value ; and They are the contents of register RL and register RU read from the host memory by the memory controller. To read the contents of register RA, is the value of the column counter, is the value of the maximum meta-register;
[0033] After completion, the next value of the loop counter is traversed until all element data of the L matrix and the U matrix are calculated.
[0034] An acceleration method for a LU decomposition hardware accelerator is applied to the LU decomposition hardware accelerator; the acceleration method for the LU decomposition hardware accelerator comprises:
[0035] When the LU decomposition hardware accelerator is specifically deployed, different deployment modes are adopted regarding the physical location of the LU decomposition hardware accelerator relative to the host CPU and the host memory: local connection or remote connection;
[0036] In the case of local connection, the host CPU and the host memory belong to the CPU and main memory of the computer where the LU decomposition hardware accelerator is deployed, respectively. The LU decomposition hardware accelerator is located on the same physical machine as the host CPU and the host memory, and no intermediate network transmission is required;
[0037] In the case of remote connection, the LU decomposition hardware accelerator, the host CPU, and the host memory are distributed on different physical machines. The LU decomposition hardware accelerator implements the remote connection through the RDMA technology and accesses the memory of the remote host across the network.
[0038] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0039] The present invention provides an LU decomposition hardware accelerator and acceleration method, which supports LU decomposition of arbitrary-order matrices. During decomposition, the entire coefficient matrix or its entire row or column data is not read into the LU decomposition hardware accelerator for calculation, but partial matrix element data is read from the host memory in batches, L matrix element data and U matrix element data are calculated, and written back to the host memory, thereby gradually completing the LU decomposition of the entire matrix. The process is implemented by the main controller step-by-step controlling the operator, the memory access controller and the maximum element comparator. Therefore, the LU decomposition hardware accelerator of the present invention does not limit the matrix order. The present invention supports partial pivot selection, which is implemented by the maximum element comparator. The maximum element comparator selects the pivot by comparing the current column element data of the L matrix being calculated. The comparison operation compares the current column element data of all the calculated L matrices in batches as the calculation process progresses, and finally obtains the element data with the largest absolute value of the current L matrix column element data being calculated as the pivot; after the pivot is selected, the current row of the matrix and the row where the pivot is located need to be exchanged. The present invention can support the selection of the pivot and the LU decomposition of arbitrary-order matrices at the same time.
[0040] The present invention can also realize that the physical location of the LU decomposition hardware accelerator relative to the host CPU and the host memory can be deployed in any of a local connection or a remote connection mode. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only 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.
[0042] Figure 1 A schematic diagram of the structure of a LU decomposition hardware accelerator provided by the present invention;
[0043] Figure 2 It is a schematic diagram of the computing unit structure;
[0044] Figure 3 It is a schematic diagram of the acceleration method flow chart;
[0045] Figure 4 Schematic diagram of the calculation order of L matrix element data and U matrix element data;
[0046] Figure 5 A schematic diagram of the overlap between address calculation operation and memory access operation in a memory access controller;
[0047] Figure 6 This is a schematic diagram showing the overlap between the calculation operation of the arithmetic unit and the memory access operation of the memory access controller. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0049] The purpose of the present invention is to provide a LU decomposition hardware accelerator and acceleration method, which can simultaneously support the selection of pivot elements and LU decomposition of matrices of arbitrary order.
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] Figure 1 A schematic diagram of the structure of a LU decomposition hardware accelerator provided by the present invention is shown in FIG. Figure 1 As shown, the LU decomposition hardware accelerator provided by the present invention includes: a main controller, an operator, a memory access controller and a maximum element comparator; the maximum element comparator includes a comparison circuit, a maximum element register and a maximum element row number register.
[0052] The main controller communicates with the operator, memory access controller and maximum element comparator respectively; the operator communicates with the memory access controller and maximum element comparator; the memory access controller communicates with the host CPU and host memory; the comparison circuit in the maximum element comparator communicates with the maximum element register and the maximum element row number register.
[0053] Without loss of generality, a general arithmetic unit is a component in a computer that performs various arithmetic and logical operations. The basic operations of the arithmetic unit include addition, subtraction, multiplication, and division, logical operations such as AND, OR, NOT, XOR, and operations such as shift, comparison, and transfer, also known as an arithmetic logic unit (ALU). In the context of the present invention, the arithmetic unit includes but is not limited to: multiple computing units; each computing unit is used to complete multiplication, addition, subtraction, and division operations in LU decomposition; such as Figure 2 As shown, each computing unit includes: a register RL, a register RU, a register RA, a multiplier, an adder-subtractor, and a divider.
[0054] The main controller includes a control circuit, which uses a finite state machine to control the process, and is used to manage the operation of the operator, the memory access controller and the maximum element comparator, and control the algorithm process of LU decomposition.
[0055] The memory access controller is used to calculate the address of the matrix element data, read the matrix element data from the host memory in batches, and write the L matrix element data and U matrix element data calculated by the operator back to the host memory.
[0056] The operator is used to perform LU decomposition calculation on the matrix read by the memory access controller, and send the calculated L matrix element data and U matrix element data to the memory access controller, and at the same time send the calculated L matrix element data to the maximum element comparator.
[0057] The maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register using a comparison circuit, and save the L matrix element data with the largest absolute value to the maximum element register, and at the same time save the row number corresponding to the L matrix element data with the largest absolute value to the maximum element row number register; the L matrix element data with the largest absolute value is the principal element.
[0058] The input of the maximum element comparator is the output of each computing unit, the row number currently corresponding to each computing unit, and the current value of the maximum element register and the maximum element row number register, and the output is the new main element value and its corresponding row number. In order to complete the maximum element comparison as quickly as possible, the maximum element comparator of this example adopts a combinational logic design.
[0059] The present invention supports partial selection of pivot elements, which is implemented by a maximum element comparator. The maximum element comparator selects the maximum element by comparing the L matrix column element data being calculated. The comparison operation compares the current column element data of all the L matrices being calculated in batches as the calculation process progresses, and finally obtains the element data with the largest absolute value of the current calculated column element data as the pivot element. After the pivot element is selected, it is necessary to exchange the current row of the matrix and the row where the pivot element is located. To avoid moving the entire row of data, this row exchange is recorded by the row index array. The row index array is The element data stores the nominal first The actual row number corresponding to the row, that is, the nominal The row number of the row in the storage location of matrix A. For example, if the nominal 2nd row of matrix A is actually stored in the 9th row of the storage location of matrix A, then the value stored in the second element of the row index array is 9. In this way, row swapping does not require swapping two rows of data, but only requires swapping the values of two elements in the row index array. The number of element data in the row index array is the same as the order of matrix A.
[0060] The main controller completes system initialization, loop control, and overlapping control functions of calculation operations and memory access operations. Specifically, the main controller includes: a control circuit, a row number register corresponding to multiple calculation units in the operator, 1 loop counter, 1 row counter, 1 column counter, 1 multiplication and addition counter, and 1 step register.
[0061] like Figure 2 As shown, the operator includes: multiple computing units; each computing unit is used to complete multiplication, addition, subtraction and division operations in LU decomposition; each computing unit includes: register RL, register RU, register RA, multiplier, adder-subtractor and divider.
[0062] Among them, register RL is used to store L matrix element data as source operand. Register RU is used to store U matrix element data as source operand. Register RA is used as an accumulator register. Multiplier is used to perform multiplication operation of L matrix element data and U matrix element data.
[0063] The multiplier and adder-subtractor of the computing unit complete the calculation of the following L matrix element data: .
[0064] The multiplier, adder, subtractor and divider of the computing unit complete the calculation of the following U matrix element data: .
[0065] In calculation hour, and The memory controller reads the data from the host memory into registers RL and RU respectively. Read into register RA; is the number of executions, The value of the multiplication and addition counter. After the contents of registers RL and RU pass through the multiplier, they are subtracted from the contents of register RA and the result is stored back in register RA. -1 times the above calculation, the result at the end of the loop is .
[0066] In calculation hour, and The memory controller reads the data from the host memory into registers RL and RU respectively. Read into register RA. After the contents of register RL and register RU pass through the multiplier, they are subtracted from the contents of register RA and the result is stored back in register RA. Loop execution -1 times the above calculation, after which the value of register RA is equal to the value of the maximum element register ( ) and store the result back into register RA. The result is .
[0067] like Figure 3 As shown, an acceleration method for a LU decomposition hardware accelerator provided by the present invention is applied to the LU decomposition hardware accelerator; the acceleration method includes the following steps.
[0068] Initialize the LU decomposition hardware accelerator, clear all registers, and then set the value of the step register; the value of the step register is the number of computing units.
[0069] The host CPU sends the matrix starting address, the matrix order (the matrix order refers to the number of rows or columns of a square matrix. The so-called square matrix refers to a matrix with equal numbers of rows and columns. The LU decomposition hardware accelerator of the present invention assumes that the number of rows and columns of the matrix is equal unless otherwise specified), and the row index array starting address to the LU decomposition hardware accelerator, and saves them through the starting address register, order register and row index array starting address register of the memory access controller; the loop counter value is set to 1.
[0070] The main controller is used to obtain the current value of the loop counter; when the current value of the loop counter is less than or equal to the order of the matrix, the current column element data corresponding to the loop counter value in the L matrix is calculated according to the following formula: .
[0071] The maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register. If the absolute value of the value of the maximum element register is smaller, the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element register, and the row number corresponding to the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element row number register; the element data with the largest absolute value in the current column of the L matrix is the principal element; after completing the calculation of the L matrix element data in the current column corresponding to the loop counter value, the values of the element data corresponding to the loop counter and the maximum element row number in the row index array are exchanged to realize the operation of selecting the principal element; then according to the formula Calculate the current row element data of the U matrix corresponding to the loop counter value.
[0072] After completion, traverse the next value of the loop counter and repeat the above process until the current value of the loop counter is greater than the order of the matrix, indicating that the LU decomposition calculation is completed. The LU decomposition hardware accelerator returns to the initialization state and waits for the host's LU decomposition task.
[0073] As a specific embodiment, the memory access controller includes: 1 row index array starting address register, 1 starting address register, 1 order register, 3 shifters, 1 integer multiplier and 3 integer adders and read and write operation circuits.
[0074] The implementation process of the acceleration method of the LU decomposition hardware accelerator of the present invention is as follows:
[0075] Step 1: Initialize the LU decomposition hardware accelerator, clear all registers, and then set the value of the step register; the value of the step register is the number of computing units; wait for the LU decomposition task.
[0076] Step 2: The host CPU sends the starting address of matrix A and the order of matrix A to the LU decomposition hardware accelerator. , row index array starting address The memory controller receives and saves this data and converts the order Sent to the main controller, which sets the current loop counter value =1, that is, the element data of L matrix and U matrix are calculated starting from the 1st row and 1st column of the matrix.
[0077] Step 3: The main controller determines whether ≤ If yes, go to step 4, if no, go to step 1.
[0078] Step 4: Calculate the element data of L matrix according to the following formula = L[i][k], where is the value of the column counter, which is taken from ~ , that is, calculate the L matrix Column from Go to The element data of the row L[k][k]~L[n][k];
[0079] ;
[0080] in, It is the value of the multiplication and addition counter, ranging from 1 to -1. The above formula indicates that L[i][k] is =A[i][k] minus L matrix Before departure -1 column element data and U matrix Front -1 The corresponding product sum of the row element data is obtained.
[0081] The main controller controls the memory access controller to read A[i][k] first, and then reads the values of L[i][m] and U[m][k] from the positions of A[i][m] and A[m][k] in matrix A according to the value m of the multiplication and addition counter (L[i][m] and U[m][k] are obtained in the previous calculation, see Figure 4 The calculation order of Figure 4 The numbers on the diagonal are the values of loop counter k. Each loop of k calculates the element data of the kth column of the L matrix and the kth row of the U matrix. The element data of the kth column of the L matrix is calculated first, and then the element data of the kth row of the U matrix is calculated. The calculated element data of the L matrix and the element data of the U matrix are stored in the matrix A), and then the calculation units in the control operator multiply them two by two and accumulate them (invert and accumulate) to A[i][k]. When m=k-1, the accumulation is completed and the value of L[i][k] is obtained. The maximum element comparator compares the value of L[i][k] obtained by the operator with the value of the maximum element register. If the absolute value of the value of the maximum element register is greater than or equal to the absolute value of L[i][k], the maximum element is not updated. Otherwise, the maximum element register is updated to the value of L[i][k], and the value of the maximum element row number register is updated to i. Then, under the control of the main controller, the memory access controller saves the value of L[i][k] obtained by the operator to the position A[i][k] in the matrix A, overwriting the original value of A[i][k]. Finally, if i=n, then the pivot element selection of the kth column of the L matrix is completed, and the row exchange caused by the pivot element selection is recorded, that is, the main controller controls the memory access controller to write the value piv of the maximum element row number register to the row index array element data P[k], and writes k to the row index array element data P[piv].
[0082] Step 5: Calculate the element data U[k][j] of the U matrix according to the following formula, where j is the value of the column counter, ranging from k+1 to n, that is, calculate the element data U[k][k+1]~U[k][n] from the kth row and the k+1th column to the nth column of the U matrix.
[0083] ;in It is the value of the multiplication and addition counter, ranging from 1 to -1. The above formula means that U[k][j] is equal to A[k][j] minus the product of the k-th row and k-1 columns of the L matrix and the j-th row and k-1 columns of the U matrix, divided by L[k][k].
[0084] The main controller controls the memory access controller to read A[k][j] first, and then reads the values of L[k][m] and U[m][j] from the positions of A[k][m] and A[m][j] in matrix A according to the value m of the multiplication and addition counter (the values of L[k][m] and U[m][j] are obtained in the previous calculation, see Figure 4 Calculation order, Figure 4 The numbers on the diagonal are the values of loop counter k. Each loop of k calculates the element data of the kth column of the L matrix and the kth row of the U matrix. The element data of the kth column of the L matrix is calculated first, and then the element data of the kth row of the U matrix is calculated. The calculated element data of the L matrix and the element data of the U matrix are stored in the matrix A. Then the computing units in the control unit multiply them two by two and accumulate them (invert and add them) to A[k][j]. When m=k-1, the accumulation and subtraction is completed, and then divided by the value of the maximum element register (after selecting the main element, the value of the maximum element register is equal to the value of L[k][k]) to obtain the value of U[k][j]. Finally, under the control of the main controller, the memory access controller saves the value of U[k][j] obtained by the operator to the position A[k][j] in the matrix A, overwriting the original value of A[k][j].
[0085] Step 6: The main controller sets the value of the current loop counter k=k+1, returns to step 3, and continues to calculate the element data of the kth column of the L matrix and the kth row of the U matrix.
[0086] After the above steps are completed, the row index array P stores the row wrapping results caused by the selection of the main element during the LU decomposition process. The original data in the matrix A is overwritten by the L and U matrix element data to obtain the required merged matrix of L and U.
[0087] In order to improve the calculation efficiency, the LU decomposition hardware accelerator of the present invention adopts the method of parallelization and overlapping of calculation and memory access for the calculation of the fourth and fifth steps.
[0088] Parallelization is to use multiple computing units, each computing unit calculates a value of L[i][k] or U[k][j]. The number of computing units is determined according to the available hardware resource scale when designing the LU decomposition hardware accelerator. Assuming that the hardware resources support w (w>1) computing units, the main controller controls the operator to perform the calculation of up to w L or U matrix element data in parallel on w computing units. Specifically, when calculating the L matrix element data in the fourth step, the main controller controls the operator to calculate L[i][k], L[i+1][k], ..., L[i+d-1][k] in parallel, and each element data is calculated by a computing unit. Among them, d=min(w, ni), w is the number of computing units, and n is the order of matrix A. The reason why d L matrix element data are calculated in parallel each time instead of w is that the matrix order n may not be an integer multiple of w. Therefore, the number of L matrix element data actually calculated in parallel is given by the calculation formula d=min(w, ni).
[0089] The parallel calculation method for calculating the U matrix element data U[k][j] in step 5 is similar to the above. Specifically, the main controller controls the operator to calculate U[k][j], U[k][j+1], ..., U[k][j+d-1] in parallel, where d=min(w, nj), w is the number of calculation units, and n is the order of matrix A.
[0090] The overlap of calculation operations and memory access operations optimizes the total running time of multiple matrix element data calculation and memory access operations. First, for the memory access controller, since the present invention uses a row index array, before reading and writing the matrix A element data, it is necessary to obtain the actual row number of the matrix A element data, that is, for the nominal row number h of the matrix A element data, the memory access controller first reads the row index array element data P[h], and the read P[h] value is the actual row number. Secondly, access to the row index array element data and the matrix element data requires address calculation first. The address calculation of the row index array element data (the default array subscript starting value is 1) is: row index array element data P[h] address = row index array starting address P+(h-1) Row number data size; the address of matrix element data A[p][q] (stored in row priority) = matrix starting address A+(p-1) n Matrix element data size + (q-1) Matrix element data size; the address of matrix element data A[p][q] (stored in column priority) = matrix starting address A+(q-1) n Matrix element data size + (p-1) Matrix element data size; the row number data size refers to the number of integer data bytes storing the row number, and the matrix element data size refers to the number of floating-point data bytes storing the matrix element data.
[0091] In summary, reading or writing matrix element data requires (1) calculating the row index array element data address, (2) reading the row index array element data as the actual row number, (3) calculating the matrix element data address, and (4) performing the read or write memory access operation. To improve efficiency, the memory access controller separates the above address calculation and read and write operations and performs them alternately, resulting in overlapping address calculation and read and write operations. Taking the reading of matrix element data A[i][j] and A[h][c] as an example, the row index array address calculation, row index array element data reading, matrix element data address calculation, and matrix element data reading of the two element data are all performed alternately, so that the calculation and memory access operations overlap to improve efficiency, such as Figure 5 shown.
[0092] For the arithmetic unit, the goal of overlapping the calculation operation with the memory access operation is to ensure that the calculation unit will not be unable to process the data read by the memory access controller in time due to busy calculation. Specifically, the calculation operation of the calculation unit and the memory access operation overlap each other by overlapping the multiplication and accumulation (negated accumulation) calculation operations with the memory access operation, so that the multiplication and accumulation (negated accumulation) calculations of different element data can be overlapped, such as Figure 6 As shown. When a computing unit starts to calculate L[i][k], the memory access controller continuously reads L[i][m] and U[m][k] under the control of the main controller, where m ranges from 1 to k-1. The computing unit performs multiplication and inverted accumulation operations on each pair of L[i][m] and U[m][k] read. The calculations between different L[i][m] and U[m][k] can be partially overlapped because the calculations and memory access operations of the computing unit overlap. The design of the overlapping calculation and memory access operations of the computing unit for U[k][j] calculation is the same as above.
[0093] Computing unit pipeline stages The design is based on the ratio of memory access delay to computation delay. Assume that the minimum delay between the memory access controller reading two sets of L[i][m] and U[m][k] is t m , the delay of the computing unit pipeline to complete the multiplication and accumulation (negation accumulation) operation is t c , then the delay of the computation unit pipeline for calculating the two groups L[i][m] and U[m][k] is In order to satisfy the computing unit to process the data read by the memory access controller in time, it can be obtained: ; That is, the number of pipeline stages of the computing unit should be greater than or equal to the total delay of the computing unit multiplication and accumulation (negation accumulation) operations divided by the delay between the memory controller reading the two groups L[i][m] and U[m][k], see Figure 6 For example, assuming that the computational unit pipeline completes multiplication and accumulation (negation accumulation) operations with a latency of 200 ns, and the minimum latency between the memory controller reading the two groups of L[i][m] and U[m][k] is 60 ns, then the number of pipeline stages is at least 4 (rounded up).
[0094] In the present invention, the parallelization of the LU decomposition hardware accelerator and the overlapping design of the calculation and memory access operations take into account the balance of the calculation and memory access performance. Specifically, it can be seen from the calculation formula of L[i][k] that the calculation needs to read the memory 2 (k-1)+1 times, write once, perform multiplication k-1 times, accumulate k-1 times. The calculation of U[k][j] is similar, and requires reading memory 2 (k-1)+1, write 1 time, multiply k-1 times, accumulate k-1 times, divide 1 time. Ignoring the division of computing U[k][j], the arithmetic intensity Q of computing L[i][k] or U[k][j] is (when k is relatively large): ;in s is the number of bytes of the floating point data type.
[0095] Assume that the operating frequency of the LU decomposition hardware accelerator computing unit is , the number of pipeline stages is , a total of w computing units, the peak performance of the operator is w Assume that the memory access bandwidth of the LU decomposition hardware accelerator is BW Bytes per second, then when designing, the hardware resources should be used reasonably so that the following equation is true: .
[0096] That is, the peak performance of the operator should be less than or equal to the memory access bandwidth multiplied by the arithmetic intensity. For example, if the maximum bandwidth of a memory is 24G bytes per second, the length of a single-precision floating point number is 4 bytes, the operating frequency of the operator of the LU decomposition hardware accelerator is 100MHz, and the computing unit adopts a 6-stage pipeline, then the number of computing units should not exceed 10 during design. Otherwise, there may be too many computing units, and the memory access controller may not be able to read enough data in a limited time so that each computing unit has data calculation, thus wasting the extra idle computing units.
[0097] According to the above acceleration method, the present invention provides six specific implementation schemes.
[0098] Implementation plan 1:
[0099] The LU decomposition hardware accelerator is designed to operate at a frequency of 100MHz and supports matrix LU decomposition of double-precision floating point numbers (8 bytes). The multipliers and adders of the computing unit are pipelined, and the total delay of multiplication and accumulation (negation and accumulation) is 200ns. The host memory bandwidth can reach up to 38.4G bytes per second with a delay of 55ns. According to the design method of overlapping calculation and memory access operations in the specification, the pipeline level of the computing unit is designed to be 200 / 55 rounded up to 4 levels. The number of computing units is designed to be 38.4G / (100M 4 8)=12.
[0100] The processing steps of the process part are as follows.
[0101] Step 1: Initialize the LU decomposition hardware accelerator, clear all registers, set the value of the step register w=12, that is, save the number of computing units, and wait for the LU decomposition task.
[0102] Step 2: The host CPU sends the starting address of matrix A, the order of matrix A n, and the starting address P of the row index array to the LU decomposition hardware accelerator. The memory access controller saves these data to the matrix A starting address register, the matrix A order register, and the row index array starting address register. The host controller sets the loop counter k=1.
[0103] Step 3: If k≤n, go to step 4, otherwise, go to step 1.
[0104] Step 4: Calculate the element data L[i][k] of the L matrix according to the following steps, where i ranges from k to n.
[0105] 4.1 First set the row counter i=k and clear the maximum element register v .
[0106] 4.2If i>n, go to 4.8.
[0107] 4.3 The memory access controller reads d=min{w,ni} element data from the kth column of the matrix A indicated by the loop counter k, that is, reads the element data A[P[i]][k]~A[P[i+d-1]][k], and writes it into the register RA of the first d computing units. Let the multiplication and addition counter m=1.
[0108] 4.4If m>k-1, go to 4.6.
[0109] 4.5 The memory controller reads the element data A[P[i]][m]~A[P[i+d-1]][m] in matrix A and writes them into the registers RL of the first d computing units. The memory controller reads the element data A[P[m]][k] in matrix A and writes them into the registers RU of all computing units. Each computing unit multiplies the values of registers RL and RU, then subtracts the product from the value of register RA and writes the result back to register RA. Then set m=m+1 and go to 4.4.
[0110] 4.6 The values of the first d calculation unit registers RA are compared with the value of the maximum element register v through the maximum element comparator, and the element data with the largest absolute value is selected and saved to the maximum element register v. At the same time, the corresponding row number of the value is saved to the maximum element row number register q. The memory access controller writes the values of the first d calculation unit registers RA back to the corresponding element data positions A[P[i]][k]~A[P[i+d-1]][k] in the matrix A.
[0111] 4.7 Let i=i+d, return to 4.2 and continue the loop.
[0112] 4.8 The maximum element register v stores the data of the element with the maximum absolute value in the column, and the corresponding row number is in the maximum element row number register q. The memory access controller swaps the contents of positions k and q in the row index array, that is, P[k] P[q] completes the operation of selecting the pivot.
[0113] Step 5: Calculate the element data U[k][k+1]~U[k][n] of the U matrix according to the following steps.
[0114] 5.1 First, the main controller sets the column counter j=k+1.
[0115] 5.2If j>n, go to step 6.
[0116] 5.3 The memory access controller reads d=min{w,nj} element data from the kth row of the matrix A indicated by the loop counter k, that is, reads the element data A[P[k]][j]~A[P[k]][j+d-1], and writes them into the register RA of the first d computing units. The main controller sets the multiplication and addition counter m=1.
[0117] 5.4If m>k-1, go to 5.6.
[0118] 5.5 The memory access controller reads the element data A[P[k]][m] in matrix A and writes it to the registers RL of all computing units. Read the element data A[P[m]][j]~A[P[m]][j+d-1] in matrix A and write them to the registers RU of the first d computing units respectively. Each computing unit multiplies the values of registers RL and RU, then subtracts the product from the value of register RA and writes the result back to register RA. The main controller then sets m=m+1 and goes to 5.4.
[0119] 5.6 The values of register RA in the first d computational units are divided by the value of the maximum element register v and written back to register RA. The memory access controller writes the values of register RA in the first d computational units back to the corresponding element data positions A[P[k]][j] to A[P[k]][j+d-1] in matrix A.
[0120] 5.7 The main controller sets j=j+d and returns to 5.2 to continue calculating the next batch of U matrix element data.
[0121] Step 6: The main controller sets k=k+1, returns to step 3, and continues to calculate the element data of the kth column of the L matrix and the kth row of the U matrix.
[0122] Implementation Plan 2:
[0123] Modify the calculation process to achieve LU decomposition with the main diagonal of the L matrix all equal to 1, that is:
[0124] .
[0125] The processing steps of the process part are as follows:
[0126] Step 1: Initialize the LU decomposition hardware accelerator, clear all registers, set the value of the step register w=12, that is, save the number of computing units, and wait for the LU decomposition task.
[0127] Step 2: The host CPU sends the starting address of matrix A, the order of matrix A n, and the starting address P of the row index array to the LU decomposition hardware accelerator. The memory access controller saves these data to the matrix A starting address register, the matrix A order register, and the row index array starting address register. The host controller sets the loop counter k=1.
[0128] Step 3: If k≤n, go to step 4, otherwise, go to step 1.
[0129] Step 4: Select the element with the largest absolute value from the element data A[k][k]~A[n][k] in the k-th column of matrix A as the pivot element according to the following steps, and exchange the row where the pivot element is located with the k-th row of matrix A.
[0130] 4.1 First set the row counter i=k and clear the maximum element registerv .
[0131] 4.2If i>n, go to 4.6.
[0132] 4.3 The memory access controller reads d=min{w,ni} element data from the k-th column of the matrix A indicated by the loop counter k, that is, reads the element data A[P[i]][k]~A[P[i+d-1]][k], and writes it into the register RA of the first d computing units.
[0133] 4.4 The values of the first d calculation unit registers RA are compared with the value of the maximum element register v through the maximum element comparator, and the element data with the largest absolute value is selected and saved to the maximum element register v. At the same time, the corresponding row number of the value is saved to the maximum element row number register q.
[0134] 4.5 Let i=i+d, return to 4.2 and continue the loop.
[0135] 4.6 The maximum element register v stores the data of the element with the maximum absolute value in the column, and the corresponding row number is in the maximum element row number register q. The memory controller swaps the contents of positions k and q in the row index array, that is, P[k+1] P[q] completes the operation of selecting the pivot.
[0136] Step 5: Calculate the element data U[k][k]~U[k][n] of the U matrix according to the following steps.
[0137] 5.1 First the main controller sets the column counter j=k.
[0138] 5.2 If j>n or k<2, go to step 6.
[0139] 5.3 The memory access controller reads d=min{w,nj} element data from the kth row of the matrix A indicated by the loop counter k, that is, reads the element data A[P[k]][j]~A[P[k]][j+d-1], and writes them into the register RA of the first d computing units. The main controller sets the multiplication and addition counter m=1.
[0140] 5.4If m>k-1, go to 5.6.
[0141] 5.5 The memory access controller reads the element data A[P[k]][m] in matrix A and writes it to the registers RL of all computing units. Read the element data A[P[m]][j]~A[P[m]][j+d-1] in matrix A and write them to the registers RU of the first d computing units respectively. Each computing unit multiplies the values of registers RL and RU, then subtracts the product from the value of register RA and writes the result back to register RA. The main controller then sets m=m+1 and goes to 5.4.
[0142] 5.6 The main controller sets j=j+d and returns to 5.2 to continue calculating the next batch of U matrix element data.
[0143] Step 6: Calculate the element data L[i][k] of the L matrix according to the following steps, where i ranges from k+1 to n.
[0144] 6.1 First set the row counter i=k+1.
[0145] 6.2 If i>n, go to step 7.
[0146] 6.3 The memory access controller reads d=min{w,ni} element data from the kth column of the matrix A indicated by the loop counter k, that is, reads the element data A[P[i]][k]~A[P[i+d-1]][k], and writes it into the register RA of the first d computing units. Let the multiplication and addition counter m=1.
[0147] 6.4If m>k-1, go to 6.6.
[0148] 6.5 The memory controller reads the element data A[P[i]][m]~A[P[i+d-1]][m] in matrix A and writes them to the registers RL of the first d computing units. The memory controller reads the element data A[P[m]][k] in matrix A and writes them to the registers RU of all computing units. Each computing unit multiplies the values of registers RL and RU, then subtracts the product from the value of register RA and writes the result back to register RA. Then set m=m+1 and go to 6.4.
[0149] 6.6 The values of the first d calculation unit registers RA are divided by the value of the largest element register (i.e., the value of U[k][k]), and the results are written back to register RA; the memory access controller writes the values of the first d calculation unit registers RA back to the corresponding element data positions A[P[i]][k]~A[P[i+d-1]][k] in the matrix A.
[0150] 6.7 Let i=i+d, return to 6.2 and continue the loop.
[0151] Step 7: The main controller sets k=k+1, returns to step 3, and continues to calculate the element data of the kth row of the U matrix and the kth column of the L matrix.
[0152] After the above process is completed, the L and U merge matrices in the following form will be obtained:
[0153] .
[0154] Implementation plan three:
[0155] When the matrix LU decomposition hardware accelerator of the present invention is specifically deployed, the following different deployment methods are adopted according to whether the LU decomposition hardware accelerator can directly access the memory through the memory controller:
[0156] (1) The LU decomposition hardware accelerator cannot access the memory directly through the memory controller and needs to be added to the host system as an external device. For example, in an X86 host system, the LU decomposition hardware accelerator uses a PCIE interface to connect to the host CPU and memory. To improve memory access efficiency, the host configures two DMA channels for the LU decomposition hardware accelerator, one DMA channel for accessing matrix A and one DMA channel for accessing the row index array.
[0157] (2) The LU decomposition hardware accelerator can directly access the memory through the memory controller and join the host system as a coprocessor. For example, in an ARM host system, the LU decomposition hardware accelerator acts as a coprocessor of the ARM processor and is responsible for executing coprocessor instructions. When the user program is compiled, the calculation and memory access operations in the matrix LU decomposition process are converted into coprocessor instructions. During the execution of the user program, the host ARM CPU sends the coprocessor instructions to the LU decomposition hardware accelerator. The main controller of the LU decomposition hardware accelerator is responsible for decoding these coprocessor instructions, generating control signals, and controlling the operator, maximum element comparator, and memory access controller to complete the calculation and memory access operations.
[0158] (3) Connected through a DMA (Direct Memory Access) controller, the LU decomposition hardware accelerator communicates with the host memory through the DMA controller and uses the DMA channel to directly read or write data in the host memory without performing data transfer through the host CPU.
[0159] Application scenario: This method does not rely on PCIe, but transmits data through other buses or interfaces. In this case, DMA is a concept and functional module independent of PCIe. It improves data transmission efficiency and is suitable for situations where the LU decomposition hardware accelerator needs to frequently access the host memory but does not want to occupy too many CPU resources.
[0160] The different deployment methods of the above-mentioned LU decomposition hardware accelerator only affect the connection between the main controller and the memory access controller of the LU decomposition hardware accelerator and the host. The operator and the maximum element comparator are consistent with implementation plan one or implementation plan two (depending on whether LU decomposition selects U as the unit upper triangular matrix or selects L as the unit lower triangular matrix).
[0161] Implementation Plan 4:
[0162] The matrix LU decomposition hardware accelerator of the present invention can be used for circuit simulation software acceleration. Circuit simulation software is an important electronic design automation (EDA) software, which mainly simulates the DC, AC and transient responses of the circuit and is one of the essential software tools for circuit design engineers.
[0163] When the matrix LU decomposition hardware accelerator of the present invention is used for circuit simulation software acceleration, according to the selection of the LU decomposition result, that is, whether the main diagonal element data of the L matrix is 1 or the main diagonal element data of the U matrix is 1, after the selection, the LU decomposition hardware accelerator adopts the algorithm flow of implementation scheme one or implementation scheme two. Then, according to the limitation of the computer running the circuit simulation software on the deployment mode of the LU decomposition hardware accelerator, one of the two deployment modes in implementation scheme three is selected to connect with the CPU and the main memory (that is, the LU decomposition hardware accelerator is added to the system as an external device or as a coprocessor). The matrix LU decomposition part code in the circuit simulation software is replaced by the code using the LU decomposition hardware accelerator, that is, the CPU sends the starting address of the matrix A, the order of the matrix A and the starting address of the row index array to the LU decomposition hardware accelerator, and the LU decomposition hardware accelerator completes the matrix LU decomposition according to the selected calculation process, notifies the CPU, and the CPU can continue to complete the circuit simulation using the result of the LU decomposition.
[0164] Implementation Plan 5:
[0165] The matrix LU decomposition hardware accelerator of the present invention can be used to accelerate the operation of network simulation software. Network simulation software is a network system simulation software that simulates the performance and behavior of a real complex network on a computer. The software uses collected or input data as the input of the simulation model, establishes mathematical models of services and communication links through a variety of mathematical theoretical models, obtains a digital twin of the real physical network through computational simulation, and then performs planning simulations and existing network analysis and processing such as topology restoration, protocol visualization, routing simulation, path simulation, traffic simulation, topology planning, capacity planning, and network optimization on it, which is a powerful tool for network analysis and optimization.
[0166] When the matrix LU decomposition hardware accelerator of the present invention is used to accelerate the network simulation software, the whole network topology map is first obtained, and the flow data between each network node and the adjacent nodes are represented by the flow matrix element data. In this way, the flow data of the whole domain can form a huge flow matrix, and the LU decomposition is applied to the flow matrix. Then, according to the selection of the LU decomposition result, that is, the main diagonal element data of the L matrix is selected as 1 or the main diagonal element data of the U matrix is selected as 1, after the selection, the LU decomposition hardware accelerator adopts the algorithm flow of implementation scheme one or implementation scheme two. Then, according to the limitation of the deployment mode of the LU decomposition hardware accelerator on the computer running the network simulation software, one of the two deployment modes in implementation scheme three is selected to connect with the CPU and main memory (that is, the LU decomposition hardware accelerator is added to the system as an external device or as a coprocessor). The matrix LU decomposition part code in the network simulation software is replaced by the code using the LU decomposition hardware accelerator, that is, the CPU sends the starting address of matrix A, the order of matrix A and the starting address of the row index array to the LU decomposition hardware accelerator, and the LU decomposition hardware accelerator completes the matrix LU decomposition calculation according to the selected calculation process, such as converting the port load of each node on the network into each element data in the traffic matrix, and executing the estimation algorithm of the traffic matrix. This estimation algorithm will use the triangular matrix decomposition of the traffic matrix; after completing the LU decomposition calculation of the traffic matrix, the CPU is notified, and the CPU can use the result of the LU decomposition to continue to complete the simulation calculation.
[0167] With the above hardware and software solution, the algorithm time performance will be improved by at least one order of magnitude compared to the solution without LU decomposition hardware accelerator, the memory overhead will be reduced, and the functional specifications will remain consistent.
[0168] Implementation Plan 6:
[0169] When the matrix LU decomposition hardware accelerator of the present invention is specifically deployed, different deployment methods can be adopted with respect to the physical location of the LU decomposition hardware accelerator relative to the host CPU and the host memory:
[0170] (1) Local connection. In this case, the LU decomposition hardware accelerator can be located on the same physical machine as the host CPU. This layout is usually suitable for the LU decomposition hardware accelerator to read and write data directly in the local host's memory via RDMA without the need for intermediate network transmission.
[0171] (2) Remote connection. The LU decomposition hardware accelerator and host memory can be distributed on different physical machines. For example, the LU decomposition hardware accelerator may be located on one server, while the host memory is located on another server. This scenario often occurs in data centers or high-performance computing (HPC) environments, where the LU decomposition hardware accelerator accesses the memory of the remote host through an RDMA (Remote Direct Memory Access) network such as InfiniBand, RoCE, or iWARP. RDMA allows the LU decomposition hardware accelerator to directly access the host memory without the host CPU being involved in data transfer. Through RDMA, the LU decomposition hardware accelerator can directly read or write data blocks in the host memory, greatly reducing the latency and CPU load of data transfer.
[0172] In this scenario, the connection types are: InfiniBand, RoCE, and iWARP. InfiniBand connection mode, RDMA is usually implemented through the high-bandwidth, low-latency InfiniBand network. InfiniBand is a network technology widely used in data centers and high-performance computing (HPC). RoCE (RDMA over Converged Ethernet) connection mode, RDMA can also be implemented through RoCE in an Ethernet environment, which is becoming more and more common in modern data center applications. iWARP connection mode is another way to implement RDMA on a standard Ethernet network, which does not require special hardware to support RoCE.
[0173] Application scenarios of the RDMA connection method include: high-performance computing (HPC), such as large-scale matrix computing, distributed databases, deep learning acceleration, etc.; data-intensive applications, such as big data analysis, financial trading systems; and storage acceleration, which reduces data access latency by directly accessing remote storage.
[0174] In summary, when the LU decomposition hardware accelerator is deployed, different deployment methods can be used regarding the physical location of the LU decomposition hardware accelerator relative to the host CPU and host memory: local connection or remote connection. In the case of local connection, the LU decomposition hardware accelerator is located on the same physical machine as the host CPU and host memory, and no intermediate network transmission is required; in the case of remote connection, the LU decomposition hardware accelerator and the host CPU and host memory are distributed on different physical machines. The LU decomposition hardware accelerator uses the RDMA (Remote Direct Memory Access) technology to achieve the remote connection and access the remote host's memory across the network. RDMA can be implemented through a variety of network technologies, including InfiniBand, RoCE (RDMA over Converged Ethernet), and iWARP (Internet Wide Area RDMA Protocol). The RDMA method allows the LU decomposition hardware accelerator to directly access local or remote host memory.
[0175] When the LU decomposition hardware accelerator is specifically deployed, different deployment modes are adopted regarding the physical location of the LU decomposition hardware accelerator relative to the host CPU and the host memory: local connection or remote connection; in the case of local connection, the host CPU and the host memory respectively belong to the CPU and the main memory on the computer where the LU decomposition hardware accelerator is deployed, and the LU decomposition hardware accelerator is located on the same physical machine as the host CPU and the host memory, and no intermediate network transmission is required; in the case of remote connection, the LU decomposition hardware accelerator and the host CPU and the host memory are distributed on different physical machines, and the LU decomposition hardware accelerator realizes the remote connection through the RDMA technology, and accesses the memory of the remote host across the network.
[0176] In particular, if the RDMA method is used for the LU decomposition hardware accelerator, the LU decomposition hardware accelerator can directly access the matrix data in the local or remote massive host memory with extremely low latency, and write the L matrix element data calculated by the operator directly back to the host memory. This method is particularly suitable for large matrix decomposition, especially when a large amount of data needs to be processed and fast access to the host memory is required.
[0177] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. The scheme of the present invention can be used for both chip design and FPGA design. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0178] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A LU decomposition hardware accelerator, characterized in that: include: Main controller, arithmetic unit, memory access controller and maximum element comparator; The main controller communicates with the arithmetic unit, the memory access controller and the maximum element comparator respectively; the arithmetic unit communicates with the memory access controller and the maximum element comparator; the memory access controller communicates with the host CPU and the host memory; the comparison circuit in the maximum element comparator communicates with the maximum element register and the maximum element row number register; The main controller includes a control circuit, which realizes the control of the process by a finite state machine, and is used to manage the operation of the operator, the memory access controller and the maximum element comparator, and control the algorithm process of LU decomposition; The memory access controller is used to calculate the address of the matrix element data, read the matrix element data from the host memory in batches, and write the L matrix element data and U matrix element data calculated by the operator back to the host memory; The operator is used to perform LU decomposition calculation on the matrix read by the memory access controller, and send the calculated L matrix element data and U matrix element data to the memory access controller, and send the calculated L matrix element data to the maximum element comparator; The maximum element comparator comprises: a comparison circuit, a maximum element register and a maximum element row number register; The maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register using a comparison circuit, and save the L matrix element data with the largest absolute value to the maximum element register, and at the same time save the row number corresponding to the L matrix element data with the largest absolute value to the maximum element row number register; the L matrix element data with the largest absolute value is the principal element.
2. The LU decomposition hardware accelerator according to claim 1, characterized in that: The main controller comprises: a control circuit, a row number register corresponding to each computing unit in the operator, a loop counter, a row counter, a column counter, a multiplication-addition counter and a step register.
3. The LU decomposition hardware accelerator according to claim 1, characterized in that: The operator comprises: a plurality of computing units; each computing unit is used to complete multiplication, addition, subtraction and division operations in LU decomposition; each computing unit comprises: a register RL, a register RU, a register RA, a multiplier, an adder-subtractor and a divider; Register RL is used to store the L matrix element data as the source operand; Register RU is used to store the U matrix element data as the source operand; Register RA is used as the accumulator register; The multiplier is used to perform multiplication operation of L matrix element data and U matrix element data in LU decomposition calculation; The adder-subtractor is used for performing addition and subtraction operations of L matrix element data and U matrix element data in LU decomposition calculation; The divider is used to perform division operations between L matrix element data and U matrix element data in LU decomposition calculations.
4. The LU decomposition hardware accelerator according to claim 3, characterized in that: The operation mode between the multiple computing units is parallel operation, and the operation mode within each computing unit is pipeline operation.
5. The LU decomposition hardware accelerator according to claim 3, characterized in that: The calculation operation of the operator and the address calculation operation of the memory access controller are overlapped in time with the memory access operation of the memory access controller, thereby optimizing the total running time of multiple matrix element data calculation and memory access.
6. The LU decomposition hardware accelerator according to claim 1, characterized in that: The memory access controller comprises: a row index array start address register, a start address register, an order register, a shifter, an integer multiplier, an integer adder and a read-write operation circuit.
7. An acceleration method for a LU decomposition hardware accelerator, applied to a LU decomposition hardware accelerator as claimed in any one of claims 1 to 6; characterized in that: The acceleration method of the LU decomposition hardware accelerator comprises: Initialize the LU decomposition hardware accelerator, clear all registers, and then set the value of the step register; the value of the step register is the number of computing units; The host CPU sends the matrix starting address, the matrix order and the row index array starting address to the LU decomposition hardware accelerator, and saves them through the starting address register, order register and row index array starting address register of the memory access controller; sets the loop counter value to 1; Use the main controller to obtain the current value of the loop counter; When the current value of the loop counter is less than or equal to the order of the matrix, according to the formula Calculate the current column element data corresponding to the loop counter value in the L matrix; where, is the L matrix Line Column element data, and They are the contents of register RL and register RU read from the host memory by the memory access controller. To read the contents of register RA, is the number of executions, is the value of the multiply-add counter, is the value of the row counter; The maximum element comparator is used to compare the absolute value of the L matrix element data calculated by the operator with the value of the maximum element register. If the absolute value of the value of the maximum element register is smaller, the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element register, and the row number corresponding to the element data with the largest absolute value in the current column of the L matrix is saved to the maximum element row number register; the element data with the largest absolute value in the current column of the L matrix is the principal element; after completing the calculation of the L matrix element data in the current column corresponding to the loop counter value, the values of the element data corresponding to the loop counter and the maximum element row number in the row index array are exchanged to realize the operation of selecting the principal element; then according to the formula Calculate the current row element data of the U matrix corresponding to the loop counter value; is the U matrix Line Column element data; and They are the contents of register RL and register RU read from the host memory by the memory controller. To read the contents of register RA, is the value of the column counter, is the value of the maximum meta-register; After completion, the next value of the loop counter is traversed until all element data of the L matrix and the U matrix are calculated.
8. An acceleration method for a LU decomposition hardware accelerator, applied to a LU decomposition hardware accelerator as claimed in any one of claims 1 to 6; characterized in that: The acceleration method of the LU decomposition hardware accelerator comprises: When the LU decomposition hardware accelerator is specifically deployed, different deployment modes are adopted regarding the physical location of the LU decomposition hardware accelerator relative to the host CPU and the host memory: local connection or remote connection; In the case of local connection, the host CPU and the host memory belong to the CPU and main memory of the computer where the LU decomposition hardware accelerator is deployed, respectively. The LU decomposition hardware accelerator is located on the same physical machine as the host CPU and the host memory, and no intermediate network transmission is required; In the case of remote connection, the LU decomposition hardware accelerator, the host CPU, and the host memory are distributed on different physical machines. The LU decomposition hardware accelerator implements the remote connection through the RDMA technology and accesses the memory of the remote host across the network.
