A matrix bidirectional linked list compression storage computing device
By using matrix bidirectional linked list compressed storage format in trend calculation, the problem that the matrix storage format in the prior art cannot quickly locate element values, and efficient matrix computing and resource saving are achieved.
Patent Information
- Application Number
- CN202510221449.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-02-27
AI Technical Summary
In the current trend calculation, the matrix storage format cannot quickly locate the element values of a row or column in the matrix, resulting in slow matrix computing speed and high storage resource consumption.
The matrix bidirectional linked list compressed storage format is adopted. By defining register variables such as line linked list header pointers, column linked list header pointers, non-zero element number registers and data element registers, we can quickly locate and store matrix elements, and design the process of adding, deleting and overwriting data elements.
The matrix computing speed is accelerated, the consumption of storage resources is saved, and the matrix computing efficiency and resource utilization are improved.
Smart Images

Figure CN119691235B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power flow calculation, and in particular to a matrix bidirectional linked list compression storage calculation device. Background Art
[0002] Power flow calculation is a very important analysis and calculation of the power system. It calculates the electrical quantities of the power system under steady-state operation according to the power system wiring mode, parameters and operating conditions, including the distribution of active power, reactive power and voltage in the power grid. Power flow calculation is also the basis for system safety, stability and reliability analysis, and is used to study various problems raised in system planning and operation. For the power system under planning, power flow calculation can be used to verify whether the proposed power system planning scheme can meet the requirements of various operating modes; for the power system under operation, power flow calculation can be used to predict whether various load changes and changes in network structure will endanger the safety of the system, whether the voltage of all buses in the system is within the allowable range, whether various components in the system (lines, transformers, etc.) will be overloaded, and what preventive measures should be taken in advance when overload may occur.
[0003] A large number of matrix calculations are involved in power flow calculations, including the calculation process of forming the Jacobian matrix and solving the linear equations. In the current traditional solution method, row compression storage, column compression storage or triple storage format is usually used to compress and store the two-dimensional matrix. Although this storage method can reduce a certain amount of storage resource overhead, its disadvantage is that it can only locate the non-zero element value of a row or column in the original matrix, and cannot quickly locate the element value of another dimension. If you need to obtain the element value of a row or column in the matrix at the same time, you need to compare the element label value with the target label value one by one through the matrix offset vector, and then store the required elements in the register.
[0004] The existing patent document CN112084198A discloses a method and device for directly writing columns of node admittance matrix in a compressed storage form, which is essentially a "one-dimensional" compressed storage format containing only row information, and the compressed storage includes three matrix column vectors, namely, a numerical column vector, a column index column vector, and a row offset column vector. Although this storage method can compress and store a two-dimensional matrix by row, it requires additional storage of column index column vectors and row offset column vectors. Therefore, this processing flow has two disadvantages: first, it is necessary to open a new storage register to store the target column vector found, which increases the additional storage resource overhead; second, to find the label value of the target vector, it is necessary to repeatedly extract the element value and the index label value from the original column index column vector and the row offset column vector for comparison and judgment, which takes a huge amount of time and is difficult to be applied to occasions such as power flow calculations that require high effectiveness. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a matrix bidirectional linked list compression storage calculation device, which can speed up the matrix operation speed during power flow calculation, while saving the consumption of storage resources on the chip, and improving the matrix calculation efficiency and resource utilization.
[0006] The technical solution adopted by the present invention to solve the technical problem is: to provide a matrix bidirectional linked list compression storage calculation device, comprising:
[0007] A definition module is used to define multiple register variables to represent the bidirectional linked list compression storage of the matrix;
[0008] A matrix data element processing module, used for deleting, inserting and / or overwriting matrix data elements in the Jacobian matrix;
[0009] A matrix operation module, used for performing multiplication calculation of the Jacobian matrix and the column vector when the Jacobian matrix is a sparse matrix;
[0010] A matrix block resource allocation calculation module is used to calculate a product result component based on a matrix block of the Jacobian matrix when the Jacobian matrix is a non-sparse matrix. The product result component is a result obtained by dividing the product result of the Jacobian matrix and the column vector into blocks by rows.
[0011] The definition module defines multiple register variables to represent the bidirectional linked list compression storage of the matrix in the following manner:
[0012] Define the row list head pointer of the first non-zero element in each row and column of the matrix with dimension n*n as row_ptr_head[31:0][N-1:0] and the column list head pointer as col_ptr_head[31:0][N-1:0]. The register variables of the number of non-zero elements in each row and column are num_row[31:0][n-1:0] and num_col[31:0][n-1:0] respectively. The register variable of the non-zero data element of the matrix is data[31:0][N-1:0]. The row and column coordinates of the original matrix where the non-zero elements of the matrix are located are The index number data_col_row[63:0][N-1:0] is marked, where data_col_row[31:0] and data_col_row[63:32] represent the numbers of coordinates i and j respectively, and the register variable of the row index number of the next row and column non-zero element address corresponding to each element in the matrix is row_prt[31:0][N-1:0] and the register variable of the column index number is col_prt[31:0][N-1:0], where N is the maximum number of non-zero elements when the Jacobian matrix is a sparse matrix.
[0013] The matrix data element processing module comprises:
[0014] A data element deletion unit, configured to delete the data element at the (i, j) position in the Jacobian matrix, and update the vacant positions and index numbers generated in the relevant registers;
[0015] A data element addition unit, configured to add a data element to the Jacobian matrix and update the pointer list;
[0016] A data element replacement unit, configured to replace the data element at the (i, j) position in the Jacobian matrix.
[0017] The data element deletion unit deletes the data element at the (i, j) position in the Jacobian matrix and updates the vacant positions and index numbers generated in the relevant registers in the following manner:
[0018] Take out the index values of the column linked list and the row linked list corresponding to the (i, j) position in the Jacobian matrix, and assign the row index address position of the (i, j) position in the Jacobian matrix to the current data index number data_id;
[0019] Assign the data element at the current data index number data_id address to the value pointed to by the current index current_data;
[0020] If the value pointed to by the current index current_data is the same as the (i, j) position in the Jacobian matrix, then update the row linked list head pointer register and the column linked list head pointer register to null pointers. At the same time, adjust the current data index number data_id to the position pointed to by the column linked list head pointer register, and adjust the value pointed to by the current index current_data to the data at the current data index number data_id address;
[0021] Record the column index number current_j of the first position element pointed to by the row linked list head pointer register. If the column index number current_j < j, then set the index value of the node pointed to by the current data index number data_id to the parent node row-column value, and record the column index number value of the current node; if the column index number current_j = j, then store the current position into the missing position number register vacancy_M, and at the same time update the number of non-zero elements in the row and column where the (i, j) position is located in the Jacobian matrix.
[0022] The data element addition unit adds a data element to the Jacobian matrix and updates the pointer list in the following manner:
[0023] Judge whether the missing position number register vacancy_M is empty;
[0024] If the missing position number register vacancy_M is empty, add a data element at the address pointed to by data_rear, where data_rear represents the address of the last data element stored in the data register, and update the row and column value numbers at the location of the added data element; if the missing position number register vacancy_M is not empty, take out the insertion address insert_id pointed to by the first element from the missing position number register vacancy_M, and add a data element at the insertion address insert_id position.
[0025] The data element replacement unit replaces the data element at position (i, j) in the Jacobian matrix in the following manner:
[0026] Determine the position number of the data element at the replacement position (i, j) in the Jacobian matrix, take out the element position data_id pointed to by the row linked list head pointer of the replacement position (i, j) in the Jacobian matrix, and record the column index number current_j. If the column index number current_j=j, directly overwrite the element at the element position data_id; if the column index number current_j≠j, take out the next element address of the row pointed to by the element position data_id, and record the column index number current_j, and then repeat the above steps until the column index number current_j=j is satisfied, overwrite the data element at the position [i, current_j].
[0027] The matrix operation module performs the multiplication calculation of the Jacobian matrix and the column vector in the following manner:
[0028] Divide the Jacobian matrix into block matrices by row;
[0029] Store the block matrix in the FIFO_M_row_data queue in order, and store the column number values of the non-zero elements of the block matrix in FIFO_M_col_id;
[0030] Store the column vector in column compression format, where data_x stores the non-zero elements of the column vector in order, and row_id_x stores the row position number of the non-zero elements in the column vector;
[0031] Take out the i-th row data and column label value from FIFO_M_row_data and FIFO_M_col_id respectively, and take out the non-zero data and row label value of the column vector from data_x and row_id_x;
[0032] If the retrieved column index value and row index value are equal, the retrieved i-th row data is multiplied by the non-zero data of the column vector.
[0033] The matrix block resource allocation calculation module includes:
[0034] A matrix block unit, used for dividing the Jacobian matrix into blocks by rows to obtain a plurality of matrix blocks;
[0035] A row-block parallel computing unit is used to obtain a product result component based on the matrix block, and the product result component is a result obtained by dividing the product result of the Jacobian matrix and the column vector into row blocks.
[0036] The row-block parallel computing unit obtains the product result component based on the matrix block in the following manner:
[0037] Calculate the number of rows of the i-th matrix block, and find out the computational components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on;
[0038] If the number of calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is zero, directly multiply the k-th row of the i-th matrix block by the column vector to obtain the product result component;
[0039] If the number of calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is greater than zero, then find the numbers of the calculation components of the other dependent block parallel computing units, multiply the k-th row of the i-th matrix block with the column vector to obtain a first result, then multiply the k-th row of the i-th matrix block with the calculation components of the other dependent block parallel computing units and accumulate to obtain a second result, sum the first result and the second result to obtain the product result component.
[0040] The calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on are specifically:
[0041] Get the address of the first non-zero element in the k-th row of the ith matrix block, record the column number col_id, and record the current split point pointer as current_p;
[0042] Find the segmentation point interval number to which the column label value col_id belongs, and record the address of the current segmentation point pointer current_p;
[0043] Sequentially take out the non-zero elements in the k-th row of the i-th matrix block, and record the address data_id and column label value col_id of the current first row of non-zero elements;
[0044] If the column number value col_id is less than or equal to the end point end_point of the segmentation vector interval, and greater than or equal to the start point start_point of the segmentation vector interval, and the column segmentation point pointer address is not equal to the matrix block number i, then the segmentation point pointer address is recorded to register w ik , and update the address of the currently pointed matrix block;
[0045] Repeat the above steps to complete the search of all block parallel computing units, and obtain the computing components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on.
[0046] Beneficial Effects
[0047] Due to the adoption of the above technical solution, the present invention has the following advantages and positive effects compared with the prior art: the present invention can quickly locate the element values of a row or a column in the matrix through the row pointer list and the column pointer list by defining the bidirectional linked list compression storage format of the matrix, thereby accelerating the efficiency of matrix element storage and reading in the traditional method. At the same time, the process of adding, deleting and overwriting the elements of the bidirectional linked list matrix is also designed. Considering the characteristics of matrix operations in power flow calculation, in order to accelerate the speed of matrix parallel operation, the resource allocation process and method of matrix-vector multiplication and block matrix are designed. The present invention can accelerate the matrix operation speed during power flow calculation, while saving the consumption of storage resources on the chip, and improving the matrix calculation efficiency and resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a block diagram of a matrix bidirectional linked list compression storage computing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.
[0050] The embodiment of the present invention relates to a matrix bidirectional linked list compression storage computing device, which is responsible for receiving the Jacobian matrix M and the power imbalance matrix b, and performing compression storage and matrix operations. Figure 1 As shown, the matrix bidirectional linked list compression storage calculation device of this embodiment includes a definition module, a matrix data element processing module, a matrix operation module and a matrix block resource allocation calculation module.
[0051] The definition module is used to define different register variables to represent the bidirectional linked list compression storage of the matrix. In this implementation, 8 register variables are defined to represent the bidirectional linked list compression storage of the matrix. Assuming that the matrix dimension is n*n, n is a positive integer, the specific definition is as follows:
[0052] The row list head pointer of the first non-zero element in each row and column of the matrix is row_ptr_head[31:0][N-1:0] and the column list head pointer is col_ptr_head[31:0][N-1:0]. The register variables for the number of non-zero elements in each row and column are num_row[31:0][n-1:0] and num_col[31:0][n-1:0] respectively. The register variable for the non-zero data element of the matrix is data[31:0][N-1:0]. The row and column coordinate index number of the original matrix where the non-zero element of the matrix is located is data_col_row[63:0][N-1:0], where data_col_row[31:0] and data_col_row[63:32] represent the numbers of coordinates i and j respectively, the register variable of the row index number of the next row and column non-zero element address corresponding to each element in the matrix is row_prt[31:0][N-1:0] and the register variable of the column index number is col_prt[31:0][N-1:0], where N is the maximum number of non-zero elements when the Jacobian matrix is a sparse matrix.
[0053] In this embodiment, the matrix data element processing module is used to delete, insert and / or overwrite matrix data elements in the Jacobian matrix. The matrix data element processing module includes: a data element deletion unit, which is used to delete the data element at the position (i, j) in the Jacobian matrix and update the vacant position and index number generated in the relevant register; a data element addition unit, which is used to add data elements in the Jacobian matrix and update the pointer list; a data element replacement unit, which is used to replace the data element at the position (i, j) in the Jacobian matrix.
[0054] After deleting the data element at position (i, j) in the Jacobian matrix, the data element deletion unit needs to update the vacant position and index number generated in the relevant register, where i≤n, j≤n. In this implementation, the missing position number register vacancy_M[31:0][N-1:0] in the Jacobian matrix M is defined. The missing position number register vacancy_M is responsible for recording the position index of the deleted element in data. When waiting for a new element to be inserted, if there is a vacant position in the missing position number register vacancy_M, it is preferentially stored sequentially in data to save storage space. The specific process is as follows:
[0055] First, extract the index values of the column linked list and row linked list corresponding to the (i, j) position in the Jacobian matrix, and assign the row index address position of the (i, j) position in the Jacobian matrix to the current data index number data_id, that is, data_id ← row_ptr_head[i].
[0056] Then, assign the data element at the current data index number data_id address to the value pointed to by the current index, that is, current_data ← data[data_id]; if the value pointed to by the current index current_data is the same as the (i, j) position in the Jacobian matrix, that is, current_data = M[i, j], then update the row and column linked list head pointer registers to null pointers, that is, row_ptr_head[i] ← null, col_ptr_head[j] ← null, and at the same time adjust the current data index number data_id to the position pointed to by the column linked list head pointer register, and adjust the value pointed to by the current index current_data to the data at the current data index number data_id address, that is, data_id ← col_ptr_head[j], current_data ← data[data_id].
[0057] After that, record the column index number current_j of the first position element pointed to by the row linked list head pointer register, that is, current_j ← data_col_row[data_id][63:32]; if the column index number current_j < j, then set the index value of the node pointed to by the current data index number data_id to the parent node row and column values, that is, parent_col ← col_ptr[data_id], parent_row ← row_ptr[data_id], and record the column index number value current_j of the current node, that is, current_j ← data_col_row[data_id][63:32]; if the column index number current_j = j, then store the current position in the missing position number register vacancy_M, that is, vacancy_M[k] ← data_id, and at the same time update the number of non-zero elements in the row and column where the (i, j) position is located in the Jacobian matrix, that is, num_row[i] ← num_row[i] + 1, num_col[i] ← num_col[i] + 1, k ← k + 1.
[0058] Finally, modify the position of the linked list pointer to determine whether (i, j) is at the end node of the row and column linked lists. Specifically: determine the row linked list. If the row index pointed to by the current element is a null pointer, that is, row_ptr[data_id]=null, then the next row index of the parent node is assigned a null pointer, that is, row_ptr[parent_row]←null. Otherwise, update the next node row index address next_row_id and the row index number register row_ptr, and point the next node row index address next_row_id of the current node data_id to the parent node, that is, next_row_id←row_ptr[data_id], row_ptr[parent_row]←next_row_id; determine the column linked list. If the column index pointed to by the current element is a null pointer, that is, col_ptr[data_id]=null, then the next column index of the parent node is assigned a null pointer, that is, col_ptr[parent_col]←null. Otherwise, update the next node column index address next_col_id And the register col_ptr of the column index number, points the next node column index address next_col_id of the current node data_id to the parent node, that is, next_col_id←col_ptr[data_id], col_ptr[parent_col]←next_col_id.
[0059] The process of adding new data M[i,j] in the Jacobian matrix M by the data element adding unit is as follows:
[0060] Determine whether the missing position number register vacancy_M is empty. If the missing position number register vacancy_M is empty, add M[i,j] to the end of data, otherwise, overwrite the data element at the previously deleted position in data. Specifically, it includes updating the row pointer linked list and the column pointer linked list.
[0061] (1) Update the row pointer list.
[0062] If the position number register vacancy_M is empty, add the new data M[i, j] at the address pointed to by data_rear, where data_rear represents the address of the last data element stored in the data register, that is, data[data_rear] ← M[i, j]. At the same time, update the row and column value numbers data_col_row at the position of M[i, j], that is, data_col_row[data_rear][31:0] ← i, data_col_row[data_rear][63:32] ← j. Determine whether the i-th row is empty. If num_row[i] = 0, modify the data element address pointed to by data_rear, that is, row_ptr_head[i] ← data_rear, row_ptr[data_rear] ← null. If num_row[i] > 0, it is necessary to find the position of the parent node element in the row where M[i, j] is located and modify the row pointer linked list. Denote first_id as the address of the first row element pointed to by the i-th row, that is, first_id ← row_ptr_head[i], and record the column label value first_col_id of the first row element, that is, first_col_id ← data_col_row[first_id][63:32]. i) If first_col_id > j, the insertion position of M[i, j] is at the first position in this row, and modify the row linked list head pointer to point to the data position of data_rear, that is, row_ptr_head[i] ← data_rear, row_ptr[data_rear] ← first_id. ii) If first_col_id < j, it is necessary to determine whether there are other data elements in this row after first_id, and take out the position number of the next data element of first_id, that is, next_row_id ← row_ptr[first_id]. If next_row_id = null, point the element at first_id to data_rear, that is, row_ptr[first_id] ← data_rear, row_ptr[data_rear] ← null. Otherwise, next_row_id ≠ null, take out the next row data index number next_new_row of first_id, that is, next_new_row ← row_ptr[first_id], and modify the data position address pointed to in the row pointer linked list row_ptr, that is, row[first_id] ← data_rear, row_ptr[data_rear] ← next_new_row.Finally, update the address of data_rear, data_rear←data_rear+1, and modify the number of non-zero elements in the row and column where M(i,j) is located, num_col[j]←num_col[j]+1, num_row[i]←num_row[i]+1.
[0063] If the missing position number register vacancy_M is not empty, take out the insertion address insert_id pointed to by the first element from the missing position number register vacancy_M, that is, insert_id←Read[vacancy_M], and insert new data M[i,j] at the insertion address insert_id. The insertion process is the same as above, except that data_rear is replaced by insert_id.
[0064] (2) Update column pointer list
[0065] If the position number register vacancy_M is empty, add the new data M[i,j] at the address pointed to by data_rear, i.e., data[data_rear] ← M[i,j]. Meanwhile, update the row and column value numbers data_col_cow at the position of M[i,j], that is, data_col_cow[data_rear][31:0] ← i, data_col_cow[data_rear][63:32] ← j. Determine whether the j-th column is empty. If num_col[j] = 0, modify the data element address pointed to by data_rear, i.e., col_ptr_head[j] ← data_rear, col_ptr[data_rear] ← null. If num_col[j] > 0, it is necessary to find the position of the parent node element in the row where M[i,j] is located and modify the row pointer linked list. Denote first_id as the address of the first column element pointed to by the j-th column, i.e., first_id ← col_ptr_head[j], and record the row label value first_row_id of the first row element, i.e., first_row_id ← data_col_row[first_id][31:0]. If first_row_id > j, the insertion position of M[i,j] is at the first position in this column, and modify the column linked list head pointer to point to the data position of data_rear, i.e., col_ptr_head[j] ← data_rear, col_ptr[data_rear] ← first_id. If first_row_id < i, it is necessary to determine whether there are other data elements in this column after first_id. Take out the position number of the next data element of first_id, i.e., next_row_id ← col_ptr[first_id]. If next_col_id = null, point the element at first_id to data_rear, i.e., col_ptr[first_id] ← data_rear, col_ptr[data_rear] ← null. If next_col_id ≠ null, take out the next column data index number of first_id, i.e., next_new_col, next_new_col ← col_ptr[first_id], and modify the data position address pointed to in the column pointer linked list col_ptr, i.e., col[first_id] ← data_rear, col_ptr[data_rear] ← next_new_col.Finally, update the address of data_rear, that is, data_rear←data_rear+1, and modify the column where M(i,j) is located and the number of non-zero elements in the column, that is, num_col[j]←num_col[j]+1, num_row[i]←num_row[i]+1.
[0066] If the missing position number register vacancy_M is not empty, take out the insertion address insert_id pointed to by the first element from the missing position number register vacancy_M queue, that is, insert_id←Read[vacancy_M], and insert new data M[i,j] at the insertion address insert_id. The insertion process is the same as above, except that data_rear is replaced by insert_id.
[0067] The process of the data element replacement unit replacing the existing element M[i,j] at the position (i,j) in the Jacobian matrix M is as follows:
[0068] Determine the position number of the data element at the replacement position (i, j) in the Jacobian matrix, take out the element position data_id pointed to by the row linked list head pointer at the replacement position (i, j) in the Jacobian matrix, that is, data_id←row_ptr_head[i], and record the column index number current_j, that is, current_j←data_col_row[data_id][63:32]. If the column index number current_j=j, then directly overwrite the element at the element position data_id, that is, data[data_id]←M[i,j]; if the column index number current_j≠j, then take out the next element address of the row pointed to by the element position data_id, that is, data_id←row_ptr[data_id], and record the column index number current_j, current_j←data_col_row[data_id][63:32]. Then repeat the above steps until the column index number current_j=j is satisfied, and overwrite the data element at the position [i,current_j].
[0069] It is not difficult to find that the process of adding, deleting and overwriting elements in the bidirectional linked list adopted in this implementation can improve data access efficiency.
[0070] The matrix operation module in this implementation is used to perform a multiplication calculation of the Jacobian matrix and the column vector when the Jacobian matrix is a sparse matrix.
[0071] When calculating y=M*b, where M is an n*n-dimensional Jacobian matrix, b is an n*1-dimensional column vector, and y is an n*1-dimensional column vector. First, divide the Jacobian matrix M into block matrices by row, as shown below:
[0072] ;
[0073] Among them, M i Represents the row vector composed of the i-th row elements of the Jacobian matrix M, that is, the block matrix. i Store them in the FIFO_M_row_data queue in order, and store the block matrix M i The non-zero element column index values are stored in FIFO_M_col_id, then the i-th component in y can be expressed as: , where num_row represents the number of non-zero elements in each row of the Jacobian matrix M, and the vector x is stored in column-compressed storage format, where data_x[31:0][n-1:0] stores the non-zero elements in vector x in sequence, row_id_x[31:0][n-1:0] stores the row position number of the non-zero elements in vector x, and num_x stores the number of non-zero elements in vector x.
[0074] For i=1 to n, take out the i-th row in the Jacobian matrix M in turn, and multiply it with the vector x to perform the inner product operation. Read the number of elements in the i-th row current_row_num from num_row_M in turn, that is, current_row_num←num_row_M[i], to control the data row number read from FIFO_M_row_data.
[0075] For k1 from 1 to current_row_num, the i-th row data and column label value are taken from FIFO_M_row_data and FIFO_M_col_id respectively. At the same time, for k2 from 1 to num_x, the non-zero data and row label value in x are taken from data_x and row_id_x respectively. Only when the column label value and row label value are equal, that is, FIFO_M_col_id=row_id_x, the i-th row data FIFO_M_row_data taken out is multiplied with the non-zero data data_x of the column vector. The details are as follows:
[0076] Initially set address pointers k1 and k2, k1←1, k2←1, y i ←0. Set the ptr_data_y address pointer to point to the first address of the current data_y, ptr_data_y←1. Read out the block matrix M respectively iThe non-zero data M_data and column position label M_id in the vector, as well as the non-zero data x_data and row label value x_id in the vector x, that is, M_data←Read[FIFO_M_row_data], M_id←Read[FIFO_M_col_id], x_data←data_x[k2], x_id←row_id_x[k2].
[0077] Determine the position numbering order of the column position label M_id and the row label value x_id. If the column position label M_id < the row label value x_id, and k1 ≤ current_row_num, then take out the block matrix M i The next non-zero element and position number in the vector x, that is, M_data←Read[FIFO_M_row_data], M_id←Read[FIFO_M_col_id], and k1←k1+1. If the column position label M_id> the row label value x_id, and k2≤num_x, then take out the next non-zero element and position number in the vector x, that is, x_data←data_x[k2+1], x_id←row_id_x[k2+1], and k2←k2+1. If the column position label M_id=row label value x_id, calculate the product of the non-zero data M_data and the non-zero data x_data, and accumulate and store them in y i , that is, y i ←y i +M_data*x_data.
[0078] Repeat the above steps until k1=current_row_num and k2=num_x. i ≠0, then the calculated y i Stored in data_y and row_id_y in the column compression storage format, that is, data_y[ptr_data_y]←y i , row_id_y[ptr_data_y]←i, and ptr_data_y←ptr_data_y+1.
[0079] The matrix block resource allocation calculation module in this embodiment is used to calculate the product result component based on the matrix block of the Jacobian matrix when the Jacobian matrix is a non-sparse matrix. The product result component is the result obtained by dividing the product result of the Jacobian matrix and the column vector into row blocks.
[0080] In this implementation, the matrix block resource allocation calculation module includes: a matrix blocking unit, used to block the Jacobian matrix by rows to obtain a plurality of matrix blocks; a row blocking parallel calculation unit, used to obtain a product result component based on the matrix block, and the product result component is a result obtained by dividing the product result of the Jacobian matrix and the column vector by row blocks.
[0081] Assume that the n*n dimensional Jacobian matrix M, the n-dimensional column vector x, and the result vector y have been decomposed into the following form according to the above matrix block unit process:
[0082] , , ,
[0083] Among them, M i 、x i and i The number of components contained is s i =q i+1 -q i ,q i The matrix is divided into blocks and the point vector q=[q0,q1,…,q n+1 ], and the Jacobian matrix M and column vector x have been stored in c independent computing units in a bidirectional linked list compression format. The registers for matrix storage in the i-th computing unit are the row list head pointer register row_ptr_head_i and the column list head pointer register col_ptr_head_i, the row element number register num_row_i and the column element number register num_col_i, the data element register data_i, the data row and column number value register data_col_row_i, and the row and column address index pointer registers row_ptr_i and col_ptr_i pointing to the next element. The storage format of the column vector x is column compression storage, which are the column vector dimension register n_x_i, the non-zero metadata data_x_i in the column vector, and the position number id_x_i of the non-zero data.
[0084] Therefore, in order to find the matrix y=M*x, y can be solved independently in each calculation module. i , and then combine the calculation results, y i The calculation can be expressed as:
[0085] ;
[0086] The resulting vector y i The dimension is s i ×1 dimension. Among them,
[0087]
[0088] Since each computing unit only stores the block matrix M i and column vector blocks x i , in order to calculate the result vector y i , first, it is necessary to calculate the number of rows of the i-th matrix block, and find out the calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on, where k is a positive integer and k≤c. If the number of calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is zero, directly multiply the k-th row of the i-th matrix block with the column vector to obtain the product result component; if the number of calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is greater than zero, then find out the numbers of the calculation components of the other dependent block parallel computing units, multiply the k-th row of the i-th matrix block with the column vector to obtain a first result, and then multiply the k-th row of the i-th matrix block with the calculation components of other dependent block parallel computing units and accumulate to obtain a second result, and sum the first result and the second result to obtain the product result component.
[0089] The process of finding the computational components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is as follows:
[0090] For each block matrix M i Each row in k=1 to s i , and set the segmentation point vector address pointer ptr_p←0, and perform the following steps:
[0091] Take out the block matrix M row by row i The element column label values in the matrix are divided into blocks [q i ,q i+1 -1], if the column index value falls within the interval [q i ,q i+1 -1], the column vector blocks x in the row-block parallel computing unit are required. i . Note register w ik Storage block matrix M i The kth row of needs the component number of the column vector x in other computational units, and ptr_w is the pointer to w ik The address of ptr_w←0.
[0092] Take out the first non-zero element address data_id of row k, data_id←row_ptr_head[k], and record the column number value col_id, that is, col_id←data_col_row[data_id][63:32], and record the current split point pointer as current_p, current_p←0. Execute the following process:
[0093] Take out the segmentation point interval number q in sequence a and q b ,q a ←q[ptr_p],q b ←q[ptr_p+1]-1. If the column number value col_id≥q a and col_id≤q b , then record the address of the current column split pointer ptr_p to register w ik In, that is, register w ik [ptr_w]←ptr_p, otherwise, ptr_p←ptr_p+1. Repeat the above process until the corresponding interval number is found. Then record the address of the current segmentation point pointer current_p, that is, current_p←ptr_p.
[0094] In this embodiment, register w ik Store in row-compressed format, and store the block matrix M in sequence i From line 1 to s i The component number in other calculation modules that the row needs to rely on, register w ik The maximum dimension is s i *(c-1), and also defines register w ik Register row_id_register w of the row number ik , row_id_register w ik ←0, row_id_register w ik The dimension is s i .
[0095] For each k-th row of the block matrix, from r=1 to num_row_i[k], take out the non-zero elements in turn and perform the following steps:
[0096] Record the address of the non-zero element in the current first row data_id, that is, data_id←row_ptr_head_i[k], and record the column label value col_id, that is, col_id←data_col_row_i[data_id][63:32], and assign the relevant address pointers ptr_p←0, current_p←0, and record the number of non-zero elements in the kth row num_w ik ←0. The block segmentation address pointer ptr_p is changed from current_p to c, and the following process is executed:
[0097] Take out the end endpoints start_point and end_point of the segmentation vector interval, that is, start_point←q[ptr_p], end_point←q[ptr_p+1]-1. If the column number value col_id≤end_point and col_id≥start_point, and the column segmentation point pointer address is not equal to the current block number i, ptr_p≠i, then record the segmentation point pointer address to register w ik , that is, w ik [ptr_w]←ptr_p, ptr_w←ptr_w+1, and update the current block address current_p, that is, current_p←ptr_p, num_w ik ←num_w ik +1. Repeat the above process until the remaining calculation modules are searched. Then update the address data_id of the next element in row k, data_id←row_ptr_i[data_id]. When r=num_row_i[k], all elements in row k are searched, and the number of other calculation module components required for row k is updated row_id_w ik [k], row_id_w ik [k]←num_w ik +row_id_w ik [k-1].
[0098] Repeat the above steps. After searching all the calculation units, the component numbers of other calculation units required in each calculation unit can be found and stored in register w ik middle.
[0099] The sparse matrix and vector multiplication and block matrix resource allocation calculation adopted in this implementation can speed up the matrix operation speed during power flow calculation.
[0100] It can be seen that the present invention can save the on-chip storage resources required for large-scale node network power flow calculations, and realize efficient compressed storage and reading of matrix elements. Compared with the non-compression method used in traditional power flow calculations, which has the disadvantage of high storage resource consumption, the matrix bidirectional linked list compression storage used in the present invention can save on-chip storage resources and improve resource utilization.
Claims
1. A matrix bidirectional linked list compression storage computing device, characterized in that: The matrix bidirectional linked list compression storage computing device is used for power flow computing, and comprises: A definition module is used to define multiple register variables to represent the bidirectional linked list compression storage of the matrix; the definition module defines multiple register variables to represent the bidirectional linked list compression storage of the matrix in the following manner: Define the row list head pointer of the first non-zero element in each row and column of the matrix with dimension n*n as row_ptr_head[31:0][N-1:0] and the column list head pointer as col_ptr_head[31:0][N-1:0]. The register variables of the number of non-zero elements in each row and column are num_row[31:0][n-1:0] and num_col[31:0][n-1:0] respectively. The register variable of the non-zero data element of the matrix is data[31:0][N-1:0]. The row and column coordinates of the original matrix where the non-zero elements of the matrix are located are The index number data_col_row[63:0][N-1:0] is marked, where data_col_row[31:0] and data_col_row[63:32] represent the numbers of coordinates i and j respectively, and the register variable of the row index number of the next row and column non-zero element address corresponding to each element in the matrix is row_prt[31:0][N-1:0] and the register variable of the column index number is col_prt[31:0][N-1:0], where N is the maximum number of non-zero elements when the Jacobian matrix is a sparse matrix. A matrix data element processing module, used for deleting, inserting and / or overwriting matrix data elements in the Jacobian matrix; A matrix operation module, used for performing multiplication calculation of the Jacobian matrix and the column vector when the Jacobian matrix is a sparse matrix; A matrix block resource allocation calculation module is used to calculate a product result component based on a matrix block of the Jacobian matrix when the Jacobian matrix is a non-sparse matrix. The product result component is a result obtained by dividing the product result of the Jacobian matrix and the column vector into blocks by rows.
2. The matrix bidirectional linked list compression storage computing device according to claim 1, characterized in that: The matrix data element processing module comprises: A data element deletion unit, used to delete the data element at the position (i, j) in the Jacobian matrix and update the vacant position and index number generated in the relevant register; A data element adding unit, used for adding data elements to the Jacobian matrix and updating the pointer list; The data element replacement unit is used to replace the data element at the (i, j) position in the Jacobian matrix.
3. The matrix bidirectional linked list compression storage computing device according to claim 2, characterized in that: The data element deletion unit deletes the data element at the position (i, j) in the Jacobian matrix and updates the vacant position and index number generated in the relevant register in the following manner: Take out the index values of the column list and row list corresponding to the position (i, j) in the Jacobian matrix, and assign the row index address position of the position (i, j) in the Jacobian matrix to the current data index number data_id; Assign the data element at the address of the current data index number data_id to the value current_data pointed to by the current index; If the value current_data pointed to by the current index is the same as the value at the (i, j) position in the Jacobian matrix, update the row linked list head pointer register and the column linked list head pointer register to null pointers. At the same time, adjust the current data index number data_id to the position pointed to by the column linked list head pointer register, and adjust the value current_data pointed to by the current index to the data at the address of the current data index number data_id; Record the column index number current_j of the first position element pointed to by the row linked list head pointer register. If the column index number current_j < j, set the index value of the node pointed to by the current data index number data_id to the row and column values of the parent node, and record the column index number value of the current node. If the column index number current_j = j, store the current position into the missing position number register vacancy_M, and at the same time update the number of non-zero elements in the row and column where the (i, j) position is located in the Jacobian matrix.
4. The matrix bidirectional linked list compression storage computing device according to claim 2, characterized in that: The data element addition unit adds data elements to the Jacobian matrix and updates the pointer list in the following way: Judge whether the missing position number register vacancy_M is empty; If the missing position number register vacancy_M is empty, add a data element at the address pointed to by data_rear, where data_rear represents the address of the last data element stored in the data register, and at the same time update the row and column value numbers at the position where the added data element is located. If the missing position number register vacancy_M is not empty, take out the insertion address insert_id pointed to by the first element from the missing position number register vacancy_M, and add a data element at the insertion address insert_id position.
5. The matrix bidirectional linked list compression storage computing device according to claim 2, characterized in that: The data element replacement unit replaces the data element at the (i, j) position in the Jacobian matrix in the following way: Determine the position number of the data element to replace the (i, j) position in the Jacobian matrix, take out the element position data_id pointed to by the row linked list head pointer of the (i, j) position to be replaced in the Jacobian matrix, and record the column index number current_j. If the column index number current_j = j, directly overwrite the element at the element position data_id. If the column index number current_j ≠ j, take out the address of the next element in the row pointed to by the element position data_id, and record the column index number current_j, and then repeat the above steps until the column index number current_j = j is satisfied, and overwrite the data element at the [i, current_j] position.
6. The matrix bidirectional linked list compression storage computing device according to claim 1, characterized in that: The matrix operation module performs the multiplication calculation of the Jacobian matrix and the column vector in the following way: Divide the Jacobian matrix into block matrices by rows; Store the block matrices into the FIFO_M_row_data queue in sequence, and store the column label values of the non-zero elements of the block matrices into the FIFO_M_col_id; The column vector is stored in a column-compressed storage format, where data_x stores the non-zero elements of the column vector in order. row_id_x stores the row position number of the non-zero elements in the column vector; Take out the i-th row data and column label value from FIFO_M_row_data and FIFO_M_col_id respectively, and take out the non-zero data and row label value of the column vector from data_x and row_id_x; If the retrieved column index value and row index value are equal, the retrieved i-th row data is multiplied by the non-zero data of the column vector.
7. The matrix bidirectional linked list compression storage computing device according to claim 1, characterized in that: The matrix block resource allocation calculation module includes: A matrix block unit, used for dividing the Jacobian matrix into blocks by rows to obtain a plurality of matrix blocks; A row-block parallel computing unit is used to obtain a product result component based on the matrix block, and the product result component is a result obtained by dividing the product result of the Jacobian matrix and the column vector into row blocks.
8. The matrix bidirectional linked list compression storage computing device according to claim 7, characterized in that: The row-block parallel computing unit obtains the product result component based on the matrix block in the following manner: Calculate the number of rows of the i-th matrix block, and find out the computational components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on; If the number of computational components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is zero, Directly multiply the kth row of the i-th matrix block with the column vector to obtain the product result component; If the number of calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on is greater than zero, then find the numbers of the calculation components of the other dependent block parallel computing units, multiply the k-th row of the i-th matrix block with the column vector to obtain a first result, then multiply the k-th row of the i-th matrix block with the calculation components of the other dependent block parallel computing units and accumulate to obtain a second result, sum the first result and the second result to obtain the product result component.
9. The matrix bidirectional linked list compression storage computing device according to claim 8, characterized in that: The calculation components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on are specifically: Get the address of the first non-zero element in the k-th row of the ith matrix block, record the column number col_id, and record the current split point pointer as current_p; Find the segmentation point interval number to which the column label value col_id belongs, and record the address of the current segmentation point pointer current_p; Sequentially take out the non-zero elements in the k-th row of the i-th matrix block, and record the address data_id and column label value col_id of the current first row of non-zero elements; If the column number value col_id is less than or equal to the end point end_point of the segmentation vector interval, and greater than or equal to the start point start_point of the segmentation vector interval, and the column segmentation point pointer address is not equal to the matrix block number i, then the segmentation point pointer address is recorded to register w ik , and update the address of the currently pointed matrix block; Repeat the above steps to complete the search of all block parallel computing units, and obtain the computing components of other block parallel computing units that the k-th row of the i-th matrix block needs to rely on.
Citation Information
Patent Citations
Node admittance matrix direct listing method and device in compressed storage form
CN112084198A
Field programmable gate array (FPGA) load flow calculation system in matrix compression storage format
CN117828242A
Flexible block ILU factorization
IN201617020367A