Optimization method for sparse matrix vector multiplication of multiple same structure matrices

By accessing the non-zero elements of multiple sparse matrices with the same structure in a single traversal, and combining this with a compressed sparse column format, the problem of repeated index access and loop control in sparse matrix-vector multiplication in existing technologies is solved, thus improving computational efficiency.

CN122286064APending Publication Date: 2026-06-26BEIJING HUADA JIUTIAN IND SOFTWARE RESEARCH INSTITUTE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610390753.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-27
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing techniques suffer from repetitive index access and loop control overhead when handling matrix-vector multiplication operations on multiple sparse matrices with the same structure. This fails to fully utilize the similarity of the matrix structures, resulting in a lack of further improvement in computational efficiency.

Method used

By accessing the non-zero elements of multiple sparse matrices with the same structure simultaneously in a single traversal, and combining this with a compressed sparse column format, the multiplication and accumulation operations of multiple matrices can be implemented, reducing the repetitive execution of loop control operations.

Benefits of technology

It significantly reduces loop control overhead such as column pointer increment and row index reading, and improves the efficiency of matrix-vector multiplication operations, especially in large-scale sparse matrix scenarios, with an overall speed improvement of about 20%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122286064A_ABST
    Figure CN122286064A_ABST
Patent Text Reader

Abstract

An optimization method for sparse matrix-vector multiplication of multiple matrices with the same structure is applied to the iterative solution process of harmonic balance methods in radio frequency circuit simulation. The method includes: obtaining a first sparse matrix and a second sparse matrix of the circuit, wherein the first and second sparse matrices have the same structure and are used to characterize the nonlinear conductance and nonlinear capacitance characteristics of the circuit, respectively; in response to performing matrix-vector multiplication, in one traversal, simultaneously accessing the non-zero elements located at the same position in both the first and second sparse matrices, and performing multiplication and accumulation operations with the corresponding input vector elements to obtain the output vectors of the corresponding first and second sparse matrices; wherein the input vector is the harmonic component vector of the circuit node voltage. This invention, based on the combined access of multiple matrices with the same sparse structure, significantly reduces loop control overhead, thereby improving the overall efficiency of matrix-vector multiplication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of radio frequency circuit simulation technology, and in particular to an optimization method for sparse matrix-vector multiplication of multiple identical structure matrices. Background Technology

[0002] Sparse matrix-vector multiplication (SpMV) is a fundamental operation crucial in scientific computing and engineering simulation, widely applied in high-performance computing fields such as structural mechanics, electromagnetic field simulation, integrated circuit simulation, image processing, and machine learning. Its core lies in reducing memory usage and computational overhead by compressing storage formats (such as Compressed Sparse Rows (CSR), Compressed Sparse Columns (CSC), or Coordinate Lists (COO), thereby improving the solution efficiency of large-scale sparse systems.

[0003] In integrated circuit simulation, especially radio frequency (RF) circuit simulation, the Harmonic Balance (HB) method is the mainstream technique for analyzing the steady-state response of nonlinear RF circuits. This method typically requires solving a large-scale system of nonlinear equations using iterative methods (such as the Generalized Residual Minimum Method, GMRES). In each iteration, frequent matrix-vector multiplication operations are required to construct the Kirlov subspace, which can be mathematically expressed as: in, The harmonic component vector of the circuit node voltage is the unknown quantity to be solved. Nonlinear error function At the current iteration point The Jacobian matrix at that point is derived from the time-domain admittance matrix of the circuit. and time-domain capacitance matrix Fourier transform and Jacobian matrix of frequency domain devices Composed of various elements; and These are the Fourier transform matrix and its inverse matrix, used to realize the conversion between the time domain and the frequency domain; This is a frequency domain differential operator matrix, corresponding to differential operations in the time domain. In iterative solvers such as GMRES, matrix-vector multiplication needs to be repeatedly calculated. (in The efficiency of this operation directly determines the overall simulation performance. In RF simulation circuits, the admittance matrix... and capacitance matrix Derived from the same circuit topology, the two have completely identical non-zero element distributions, that is, the matrix structures are the same but the values ​​are different, and therefore they have completely identical sparse structures.

[0004] Existing techniques, when processing the aforementioned matrix-vector multiplication, typically... and Two independent SpMV operations are performed. Each operation requires a complete traversal of the non-zero elements of the matrix, repeatedly performing loop control operations such as column pointer comparisons and row index readings. For large-scale sparse matrices, this control overhead is comparable to that of multiply-accumulate operations. Furthermore, in scenarios such as small-signal analysis or parallel solution of sub-circuits, the right-multiplication vectors may differ, and even matrix transpose operations may be required, further exacerbating the repetitive execution of control logic and limiting the improvement of simulation efficiency. Therefore, existing SpMV methods suffer from repeated index accesses and loop control overhead when processing multiple sparse matrices with identical structures, failing to fully utilize the similarity of matrix structures to optimize the computational flow, resulting in computational efficiency that still needs further improvement. Summary of the Invention

[0005] To address the shortcomings of existing technologies, the present invention aims to provide an optimization method for sparse matrix-vector multiplication of multiple matrices with the same structure, thereby improving the computational efficiency of matrix-vector multiplication in circuit simulation.

[0006] To achieve the above objectives, this invention provides an optimization method for sparse matrix-vector multiplication of multiple identical structure matrices, applied to the iterative solution process of harmonic balance methods in radio frequency circuit simulation, including: Obtain the first sparse matrix and the second sparse matrix of the circuit. The first sparse matrix and the second sparse matrix have the same structure and are used to characterize the nonlinear conductance and nonlinear capacitance characteristics of the circuit, respectively. In response to performing matrix-vector multiplication, during a single traversal, non-zero elements at the same position in the first sparse matrix and the second sparse matrix are accessed simultaneously, and multiplication and accumulation operations are performed with the corresponding input vector elements to obtain the output vectors of the first sparse matrix and the second sparse matrix. The input vector is the harmonic component vector of the circuit node voltage.

[0007] Furthermore, the step of simultaneously accessing the non-zero elements at the same position in the first sparse matrix and the second sparse matrix in one traversal also includes: sequentially obtaining the row index corresponding to the current processing unit according to a preset traversal order; Based on the row index, the corresponding element is extracted from the first input vector and multiplied and accumulated with the current non-zero element value of the first sparse matrix, and then stored in the corresponding position of the first output vector. At the same time, based on the same row index, the corresponding element is taken from the second input vector and multiplied and accumulated with the current non-zero element value of the second sparse matrix, and stored in the corresponding position of the second output vector; Wherein, the first input vector and the second input vector are harmonic component vectors of the circuit node voltages, respectively.

[0008] Furthermore, the step of sequentially obtaining the row index corresponding to the current processing unit according to the preset traversal order also includes: the preset traversal order is column traversal, the current processing unit is the current column, and the first sparse matrix and the second sparse matrix are stored in a compressed sparse column format.

[0009] Furthermore, the first input vector and the second input vector are the same vector.

[0010] Furthermore, the first input vector and the second input vector are different vectors.

[0011] Furthermore, the first sparse matrix and the second sparse matrix are the time-domain admittance matrix and the time-domain capacitance matrix in the RF circuit simulation.

[0012] Furthermore, the matrix-vector multiplication operation is the matrix-vector multiplication operation in the iterative solution process of the generalized residual minimization method in the harmonic balance method.

[0013] Furthermore, the step of obtaining the first sparse matrix and the second sparse matrix further includes: For simulation scenarios involving multiple sub-circuits, the original sparse matrices with the same sparse structure in each sub-circuit are expanded to the same size by zero-padding, and a unified row index list is constructed for the matrices of all sub-circuits; wherein, the extended time-domain admittance matrix of each sub-circuit is used as the first sparse matrix, and the extended time-domain capacitance matrix of each sub-circuit is used as the second sparse matrix.

[0014] To achieve the above objectives, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to execute the computer program stored in the memory to implement the sparse matrix-vector multiplication optimization method for multiple matrices with the same structure as described above.

[0015] To achieve the above objectives, the present invention also provides a computer-readable storage medium storing a computer program, which is loaded and executed by a processor to implement the sparse matrix-vector multiplication optimization method for multiple identical structure matrices as described above.

[0016] The sparse matrix-vector multiplication optimization method provided by this invention is based on the merged access of multiple matrices with the same sparse structure. In a single traversal, the loop control operation is executed only once, and the multiplication and accumulation operation is performed on multiple matrices simultaneously. This significantly reduces the loop control overhead such as column pointer increment and row index reading, and improves the efficiency of the overall matrix-vector multiplication operation, especially in large-scale sparse matrix scenarios.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. Attached Figure Description

[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the sparse structure of the time-domain admittance matrix in an embodiment of the present invention; Figure 2 This is a schematic diagram of the sparse structure of the time-domain capacitance matrix in an embodiment of the present invention; Figure 3 This is a schematic diagram of the matrix structure after merging the admittance matrix and the capacitance matrix in an embodiment of the present invention; Figure 4 This is a schematic diagram of the matrix structure of multiple sub-circuits in an embodiment of the present invention; Figure 5 This is a schematic diagram of the matrix structure after merging multiple sub-circuits in an embodiment of the present invention; Figure 6 This is a schematic diagram of an electronic device structure according to an embodiment of the present invention. Detailed Implementation

[0019] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0020] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.

[0021] The term "comprising" and its variations as used in this invention are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0022] It should be noted that the concepts of "first" and "second" may be mentioned in this invention only to distinguish different devices, components or parts, and are not used to limit the order of the functions performed by these devices, components or parts or their interdependence.

[0023] It should be noted that the terms "one" and "multiple" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless explicitly stated otherwise in the context, they should be understood as "one or more". "Multiple" should be understood as two or more.

[0024] A sparse matrix is ​​a matrix in which the number of non-zero elements is much less than the number of zero elements, and the distribution of non-zero elements is irregular.

[0025] Sparse matrix-vector multiplication (SpMV): refers to the multiplication operation between a sparse matrix and a dense vector.

[0026] Compressed Sparse Column (CSC) format: A sparse matrix storage format that uses three arrays for storage: values ​​stores non-zero element values, idx stores non-zero element row indices, and ptr stores pointers to the starting position of each column.

[0027] Harmonic Balance (HB) Method: A frequency domain simulation method for analyzing the steady-state response of nonlinear radio frequency circuits.

[0028] Generalized Residual Minimum Method (GMRES): An iterative method for solving large-scale asymmetric linear systems.

[0029] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0030] Example 1 This embodiment provides an optimization method for sparse matrix-vector multiplication of multiple matrices with the same structure, which is suitable for large signal analysis scenarios. The two sparse matrices have the same sparse structure and the right multiplication vectors are the same.

[0031] In this embodiment, the harmonic balance method in radio frequency circuit simulation is used as the application scenario. During the GMRES iterative solution process of the harmonic balance method, matrix-vector multiplication needs to be repeatedly calculated. ,in It is the Jacobian matrix, derived from the time-domain admittance matrix of the circuit. and time-domain capacitance matrix Fourier transform of frequency domain devices and Jacobian matrix of frequency domain devices Composed of various elements; This is the harmonic component vector of the circuit node voltage.

[0032] To clearly illustrate the core idea of ​​this invention, a simplified derivation of matrix-vector multiplication in the harmonic balance method is first presented. In the Jacobian matrix ( In the context of frequency domain devices, the Jacobian matrix is... It typically occupies only a very small part of the overall matrix, and its structure is similar to the time-domain admittance matrix. and time-domain capacitance matrix Irrelevant, therefore, in discussing the present invention, and When considering methods to accelerate merging, these can be temporarily disregarded. The influence of this simplifies matrix-vector multiplication to: This simplified form highlights and The contribution of this invention facilitates understanding of the merging operation process. In practical applications, the merging operation can be completed first, and then... The contributions of each factor are added to the final result.

[0033] because and Derived from the same circuit topology (used to characterize the nonlinear conductance and nonlinear capacitance characteristics of the circuit, respectively), both have completely identical sparse structures, meaning the nonzero elements are in the same location, only their values ​​differ, such as... Figure 1 and Figure 2 As shown. Combining two sparse matrix-vector multiplications is equivalent to transforming its structure into the form shown. Figure 3 The structure shown (it should be noted that the appendix) Figures 1 to 5 In this context, x and / or y are used to refer to specific numerical values.

[0034] In this embodiment, by simultaneously accessing the non-zero elements of two matrices with the same sparse structure in a single traversal, the original requirement of accessing only the non-zero elements of two matrices with the same sparse structure is reduced. and The two separate SpMV operations are merged into one, which significantly reduces the overhead of loop control such as column pointer increment and row index reading.

[0035] Taking the CSC storage format as an example, in a single traversal, simultaneously accessing non-zero elements at the same position in the first sparse matrix and the second sparse matrix includes the following steps: Following a preset traversal order, sequentially obtain the row index corresponding to the current processing unit; based on the row index, extract the corresponding element from the first input vector and multiply and accumulate it with the current non-zero element value of the first sparse matrix, storing the result in the corresponding position of the first output vector; simultaneously, based on the same row index, extract the corresponding element from the second input vector and multiply and accumulate it with the current non-zero element value of the second sparse matrix, storing the result in the corresponding position of the second output vector. Here, the first input vector and the second input vector are the harmonic component vectors of the circuit node voltages, respectively.

[0036] Preferably, the step of sequentially obtaining the row index corresponding to the current processing unit according to a preset traversal order further includes: the preset traversal order is column traversal, the current processing unit is the current column, and the first sparse matrix and the second sparse matrix are stored in a compressed sparse column format.

[0037] For example, suppose and The column pointer arrays are both ptr (length n+1, where n is the number of columns), the row index arrays are idx_g and idx_c (length nnz, i.e., the total number of non-zero elements), and the value arrays are val_g and val_c (length nnz). Because and Since they have the same structure, idx_g and idx_c are completely identical, so only one row index array idx needs to be stored during actual storage. The specific steps for merging and traversing are as follows: 1) Initialize two output vectors and These are zero vectors, all of length n; 2) For each column i (i from 0 to n-1): a. Obtain the starting position p_start = ptr[i] and the ending position p_end = ptr[i+1] of the column in the row index array; b. For p from p_start to p_end-1: i. Read the row index row = idx[p]; ii. From the input vector iii. Extract the r-th element x_r from the set; iii. Perform multiplication and accumulation: iv. Perform multiplication and accumulation simultaneously: ; 3) After completing all columns, and That is and The result.

[0038] The corresponding pseudo-code is as follows. Just call it once to complete the SpMV operations on and : Text1 / / size: The number of columns of the matrix, corresponding to the number of circuit nodes / / ptr: The column pointer array, ptr[i] represents the starting position of the i-th column / / idx: The row index array, idx[p] represents the row number of the p-th non-zero element / / val_g, val_c: The numerical arrays of matrices g and c / / x: The input vector, x[i] is the input element corresponding to the i-th column / / y1, y2: The output vectors, y1[row] is the output element corresponding to the row number row for (int i = 0; i < size; i++) { / / Traverse each column for (int p = ptr[i]; p < ptr[i + 1]; p++) { / / Traverse all non-zero elements in this column int row = idx[p]; / / Get the row number of the current non-zero element y1[row] += val_g [p] * x[i]; / / Multiply-accumulate for matrix g y2[row] += val_c [p] * x[i]; / / Multiply-accumulate for matrix c } } [[ID=3-4]]In the above process, for each column, only one increment operation of p and one comparison operation with p_end are required, rather than one in each of the two independent operations. Since the control overhead is comparable to the multiply-accumulate overhead, merging the traversals can significantly reduce the total operation time.

[0039] The general implementation steps of the present invention are as follows: a) For RF simulation, establish a time-domain admittance matrix with a consistent sparse structure according to the circuit structure and a time-domain capacitance matrix ; b) For each column, fix its column number and prepare to traverse by column; [[ID=-47]]c) Read the first row element of the current column from the row index array, and at the same time take out and the numerical values at this position, and take numbers from the corresponding input vector according to the simulation scenario (large signal or small signal), perform the multiply-accumulate operation, and store the result in the corresponding output vector; d) Repeat step c until all non-zero elements in the column have been processed; e) Repeat steps bd until all columns have been processed, completing the entire matrix-vector multiplication operation.

[0040] Example 2 The difference between this embodiment and Embodiment 1 is that it provides an optimization method for sparse matrix-vector multiplication of multiple identical structure matrices applicable to small signal analysis scenarios, wherein the two sparse matrices have the same sparse structure but different right-multiplication vectors.

[0041] In small-signal analysis, the form of matrix-vector multiplication may involve transpose operations, for example: at this time and The transpose of the matrix is ​​multiplied by different vectors. Let the input vectors be respectively... and The output vectors are respectively and The steps for merging and traversing are as follows: 1) Initialization and It is a zero vector; 2) For each column i (i from 0 to n-1): a. Get p_start = ptr[i], p_end = ptr[i+1]; b. For p from p_start to p_end-1: i. Read the row index row = idx[p]; ii. Extract the i-th element x1_i from the input vector x1 (Note that in the transpose scenario, as shown below) In this context, the indices of the input vector correspond to column indices, not row indices; the specific data retrieval logic should be determined based on the actual mathematical form); iii. Perform multiplication and accumulation: iv. Extract the i-th element x2_i from the input vector x2; v. Perform multiplication and accumulation: ; 3) After completing all columns, the result is... and This is the result of the corresponding matrix-vector multiplication.

[0042] The corresponding pseudocode is as follows: Text2 / / size: The number of columns in the matrix, corresponding to the number of circuit nodes. / / ptr: Array of column pointers, ptr[i] represents the starting position of the i-th column. / / idx: Array of row indices, idx[p] represents the row number of the p-th non-zero element (g and c share the same row indices) / / val_g, val_c: Numeric arrays of matrices g and c / / x1, x2: The first input vector and the second input vector, corresponding to the voltage harmonic components under different excitations in small-signal analysis respectively / / y1, y2: Two output vectors, storing the results of g * x1 and c * x2 respectively for (int i = 0; i<size; i++) { / / Traverse each column for (int p = ptr[i]; p<ptr[i+1]; p++) { / / Traverse all non-zero elements in this column int row = idx[p]; / / Obtain the row number of the current non-zero element y1[row] += val_g [p]* x1[i]; / / Multiply-accumulate matrix g and x1 y2[row] += val_c [p]* x2[i]; / / Multiply-accumulate matrix c and x2 } } Compared with the large-signal scenario, the main difference lies in the small-signal analysis scenario and the right-multiplied vectors are inconsistent

[0043] This embodiment shows that even if the right-multiplied vectors are different, the present invention can still complete two matrix-vector multiplication operations in one traversal, avoiding two independent traversals

[0044] Embodiment 3 The difference between this embodiment and the above embodiments is that it provides a sparse matrix-vector multiplication optimization method for multiple matrices with the same structure applicable to parallel solution of sub-circuits

[0045] In circuit simulation, the circuit is often divided into multiple sub-circuits for parallel solution. For each sub-circuit, its time-domain admittance matrix and time-domain capacitance matrix have the same sparse structure. Moreover, since all sub-circuits are divided from the same original circuit topology, between the matrices of different sub-circuits (and between the matrices of different sub-circuits) also have the same sparse structure

[0046] However, the matrix sizes of different sub - circuits may be different (e.g., the number of nodes is different). To perform the merging operation, the matrices of each sub - circuit need to be expanded to the same size by padding with zeros first. Specifically, let the maximum number of nodes in all sub - circuits be N_max. For a sub - circuit with the number of nodes less than N_max, append all - zero rows at the end of its matrix to make it an N_max×N_max matrix.

[0047] After padding with zeros, construct a unified row index list for all sub - circuit matrices participating in the merging (including the matrix sum matrix). This list is based on the row index sequence corresponding to the maximum number of non - zero elements in each column among all sub - circuits. Each matrix aligns its values according to this unified list (keep the value if there is a value at the original position, and pad with zero if there is no value). At this time, the number of non - zero elements in each column of all matrices is the same, and the row numbers of non - zero elements in each column are inconsistent, but they share the same set of row index lists, thus enabling one - pass traversal and simultaneous access.

[0048] At this time, these 2k matrices can be regarded as the "first sparse matrix" to the "2k - th sparse matrix" of the present invention. In one - pass traversal, simultaneously access the non - zero elements of all matrices, and multiply and accumulate them with the corresponding elements of the input vector respectively to obtain the output vectors of each sub - circuit.

[0049] The corresponding pseudo - code is as follows: Text3 / / size: The number of columns of the matrix, corresponding to the number of columns of each sub - circuit matrix after unified expansion / / ptr: Array of column pointers, ptr[i] represents the starting position of the i - th column (all sub - circuits share the same column pointer) / / idx1, idx2: Arrays of row indices corresponding to sub - circuit 1 and sub - circuit 2 respectively / / (Since after unified alignment, the number of non - zero elements in each column of each sub - circuit is the same, but the row numbers may be different) / / val_g, val_c: Arrays of values corresponding to matrix g of sub - circuit 1 and matrix c of sub - circuit 2 respectively / / x1, x2: Vectors of input voltage harmonic components corresponding to sub - circuit 1 and sub - circuit 2 respectively / / y1, y2: Output vectors corresponding to sub - circuit 1 and sub - circuit 2 respectively for (int i = 0; i<size; i++) { / / Traverse each column for (int p = ptr[i]; p<ptr[i + 1]; p++) { / / Traverse all non - zero elements in this column (the number of non - zero elements in each column of each sub - circuit is the same) int row1 = idx1[p]; / / Get the row number of the current non-zero element in subcircuit 1 int row2 = idx2[p]; / / Get the row number of the current non-zero element in subcircuit 2 y1[row1] += val_g [p]* x1[i]; / / Matrix-vector multiplication and accumulation of subcircuit 1 y2[row2] += val_c[p]* x2[i]; / / Matrix-vector multiplication and accumulation of subcircuit 2 } } This embodiment demonstrates the combination of the method of the present invention with parallel simulation technology, which further improves the computational efficiency in multi-sub-circuit scenarios.

[0050] The working principle of this invention is based on merging access to multiple matrices with the same sparse structure. In sparse matrix-vector multiplication, the main computational overhead consists of two parts: loop control overhead (such as pointer increment and row index reading) and multiplication-accumulation overhead. For multiple matrices with the same structure, their non-zero element positions are identical; therefore, when traversing each column, the row index sequence of each matrix is ​​completely consistent. This invention utilizes this characteristic to merge multiple independent traversals of matrix-vector multiplication operations with the same matrix structure into a single traversal. During this single traversal, the loop control operation is executed only once, but the multiplication-accumulation operation is performed simultaneously on multiple matrices. Because the loop control overhead is distributed across multiple matrices, the total computation time is significantly reduced, especially in large-scale sparse matrix scenarios.

[0051] In cases where the right-multiplication vectors are different, this invention takes numbers from different input vectors in one traversal and accumulates them into different output vectors, thus achieving the merging of control overhead.

[0052] The sparse matrix-vector multiplication optimization method for multiple matrices with the same structure provided by this invention has the following beneficial effects: First, by accessing the non-zero elements of two matrices with the same sparse structure simultaneously in a single traversal, two independent loop control operations are merged into one, significantly reducing loop control overhead such as column pointer incrementing and row index reading. Real-world testing on the Intel Xeon 6354 platform shows that the ratio of loop control overhead to multiplication-accumulation operation overhead is approximately 2:3. By merging the traversals, about half of the control overhead can be saved, thereby improving the overall matrix-vector multiplication operation speed by about 20%.

[0053] Secondly, this invention is applicable not only to scenarios where the right-multiplication vectors are the same in large-signal analysis, but also to scenarios where the right-multiplication vectors are different in small-signal analysis or parallel solution of sub-circuits, demonstrating good versatility and adaptability. When the right-multiplication vectors are inconsistent, this invention takes the numbers from the two input vectors separately in one traversal and accumulates them into the two output vectors, avoiding the redundant overhead caused by performing two separate operations.

[0054] Third, this invention can be combined with the parallel solution technology for sub-circuits. By using zero-padding operations, the sparse matrix of multiple sub-circuits can be expanded into a matrix with the same number of non-zero elements in the same column, thereby achieving merging operations and further improving the computational efficiency in parallel simulation scenarios.

[0055] Fourth, this invention requires only a very low additional storage cost (such as a small increase in storage due to zero-padding operations) to obtain stable speedup benefits without sacrificing computational accuracy. It is compatible with conventional sparse matrix storage formats (such as CSR and CSC) and is easy to integrate into existing simulation tools.

[0056] Example 4 In embodiments of the present invention, an electronic device is also provided. Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention, such as... Figure 6 As shown, the electronic device of the present invention includes a processor 601 and a memory 602, wherein, The memory 602 stores a computer program, which, when read and executed by the processor 601, performs the steps in the sparse matrix-vector multiplication optimization method embodiment of multiple identical structure matrices as described above.

[0057] Example 5 In embodiments of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the steps in the embodiments of the sparse matrix-vector multiplication optimization method for multiple identical structure matrices as described above when running.

[0058] In this embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0059] It will be understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An optimization method for sparse matrix-vector multiplication of multiple matrices with the same structure, characterized in that, The iterative solution process of the harmonic balance method applied in RF circuit simulation includes: Obtain the first sparse matrix and the second sparse matrix of the circuit. The first sparse matrix and the second sparse matrix have the same structure and are used to characterize the nonlinear conductance and nonlinear capacitance characteristics of the circuit, respectively. In response to performing matrix-vector multiplication, during a single traversal, non-zero elements at the same position in the first sparse matrix and the second sparse matrix are accessed simultaneously, and multiplication and accumulation operations are performed with the corresponding input vector elements to obtain the output vectors of the first sparse matrix and the second sparse matrix. The input vector is the harmonic component vector of the circuit node voltage.

2. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 1, characterized in that, The step of simultaneously accessing the non-zero elements at the same position in the first sparse matrix and the second sparse matrix in one traversal further includes: sequentially obtaining the row index corresponding to the current processing unit according to a preset traversal order; Based on the row index, the corresponding element is extracted from the first input vector and multiplied and accumulated with the current non-zero element value of the first sparse matrix, and then stored in the corresponding position of the first output vector. At the same time, based on the same row index, the corresponding element is taken from the second input vector and multiplied and accumulated with the current non-zero element value of the second sparse matrix, and stored in the corresponding position of the second output vector; Wherein, the first input vector and the second input vector are harmonic component vectors of the circuit node voltages, respectively.

3. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 2, characterized in that, The step of sequentially obtaining the row index corresponding to the current processing unit according to the preset traversal order further includes: the preset traversal order is column traversal, the current processing unit is the current column, and the first sparse matrix and the second sparse matrix are stored in a compressed sparse column format.

4. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 2, characterized in that, The first input vector and the second input vector are the same vector.

5. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 2, characterized in that, The first input vector and the second input vector are different vectors.

6. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 1, characterized in that, The first sparse matrix and the second sparse matrix are the time-domain admittance matrix and the time-domain capacitance matrix in RF circuit simulation.

7. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 6, characterized in that, The matrix-vector multiplication operation is the matrix-vector multiplication operation in the iterative solution process of the generalized residual minimization method in the harmonic balance method.

8. The sparse matrix-vector multiplication optimization method for multiple identical structure matrices according to claim 1, characterized in that, The steps for obtaining the first sparse matrix and the second sparse matrix further include: For simulation scenarios involving multiple sub-circuits, the original sparse matrices with the same sparse structure in each sub-circuit are expanded to the same size by zero-padding, and a unified row index list is constructed for the matrices of all sub-circuits; wherein, the extended time-domain admittance matrix of each sub-circuit is used as the first sparse matrix, and the extended time-domain capacitance matrix of each sub-circuit is used as the second sparse matrix.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor is configured to execute a computer program stored in the memory to implement the sparse matrix-vector multiplication optimization method for multiple identical structure matrices as described in any one of claims 1 to 8.

10. A computer-readable storage medium storing a computer program, characterized in that, The computer program is loaded and executed by a processor to implement the sparse matrix-vector multiplication optimization method for multiple identical structure matrices as described in any one of claims 1 to 8.