Solution method of simulation software

By calling the central processor to preprocess the simulation matrix in the simulation software and dynamically adjusting the storage format, combined with the parallel computing power of the graphics processor, the problem of inefficient computing of the existing simulation software is solved, and a more efficient simulation solution is achieved.

CN119558089BActive Publication Date: 2025-04-25WU CHUANG XIN YAN KE JI (WU HAN) YOU XIAN GONG SI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510091635.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-04-25
Estimated Expiration
2045-01-21

AI Technical Summary

Technical Problem

When existing simulation software deals with large-scale and high-complex simulation calculations, the calculation efficiency is low, resource consumption is high, and the waiting time is long, which seriously affects the application scope and effect of the simulation software.

Method used

By calling the central processor to preprocess the simulation matrix, the coordinate format submatrix is ​​obtained, and the storage format is dynamically adjusted according to its distribution characteristics to generate a compressed submatrix. Then, the graphics processor is called to complete the simulation solution of the compressor matrix.

Benefits of technology

It significantly improves the speed during matrix construction, avoids the no-load of CPU subthreads, improves the processing efficiency of the graphics processor, shortens the simulation cycle, and improves the overall performance of the simulation software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558089B_ABST
    Figure CN119558089B_ABST
Patent Text Reader

Abstract

The present invention provides a solution method for simulation software, including: calling a central processing unit to pre-process a simulation matrix to obtain a coordinate format submatrix; the coordinate format submatrix is ​​represented by a row index array, a column index array, and a non-zero element value array; according to the distribution characteristics of the coordinate format submatrix, calling a central processing unit to re-determine the storage format of the coordinate format submatrix to obtain transmission data of a compressed submatrix; the compressed submatrix includes at least one of a coordinate format submatrix, a sparse row format submatrix, and a sparse column format submatrix; calling a graphics processor to complete simulation solution for the compressed submatrix. The present invention improves simulation solution efficiency through CPU-GPU collaborative work, specifically, using a thread pool to construct a subthread on the CPU, dynamically determining the storage format of the matrix and transmitting it to the GPU in a corresponding manner; and using GPU parallel processing to improve processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer simulation, and more specifically to a solution method of simulation software. Background Art

[0002] In the application process of simulation software, as the complexity of simulation models increases, the demand for computing resources also increases, resulting in the processing efficiency of simulation calculations becoming a key factor restricting the development of simulation technology. Existing simulation software often faces problems such as low computing efficiency, high resource consumption, and long waiting time when dealing with large-scale and highly complex simulation calculations. Often a complex calculation may take several days or even months. These problems seriously affect the application scope and effect of simulation software. Summary of the invention

[0003] In view of the above problems, the present invention provides a solution method for simulation software that utilizes CPU and GPU to optimize thread pool task allocation and scheduling and memory storage process in a matrix construction process.

[0004] The present invention provides a solution method for simulation software, comprising: calling a central processing unit to pre-process a simulation matrix to obtain a coordinate format sub-matrix; the coordinate format sub-matrix is ​​represented by a row index array, a column index array and a non-zero element value array; according to the distribution characteristics of the coordinate format sub-matrix, calling the central processing unit to re-determine the storage format of the coordinate format sub-matrix to obtain transmission data of a compressed sub-matrix; the compressed sub-matrix includes at least one of a coordinate format sub-matrix, a sparse row format sub-matrix and a sparse column format sub-matrix; calling a graphics processor to complete simulation solution for the compressed sub-matrix.

[0005] According to an embodiment of the present invention, a central processing unit is called to pre-process a simulation matrix to obtain a coordinate format sub-matrix, including: calling a main thread of the central processing unit to divide the simulation matrix into sub-matrices and perform index marking; and allocating the sub-matrices to sub-threads in a central processing unit thread pool for storing the sub-matrices as coordinate format sub-matrices.

[0006] According to an embodiment of the present invention, based on the distribution characteristics of the coordinate format submatrix, a central processing unit is called to re-determine the storage format of the coordinate format submatrix to obtain the transmission data of the compressed submatrix, including: judging whether the density of the coordinate format submatrix is ​​greater than a preset threshold; wherein the density of the coordinate format submatrix is ​​confirmed by the ratio of non-zero elements to the total number of elements; if the density of the coordinate format submatrix is ​​greater than the preset threshold, judging the density type of the coordinate format submatrix; the dense type includes at least a row-dense matrix and a column-dense matrix; if the coordinate format submatrix is ​​a row-dense matrix, converting the coordinate format submatrix into the transmission data of a sparse row-format submatrix for a graphics processor to generate a compressed submatrix; if the coordinate format submatrix is ​​a column-dense matrix, converting the coordinate format submatrix into the transmission data of a sparse column-format submatrix for a graphics processor to generate a compressed submatrix; if the density of the coordinate format submatrix is ​​less than the preset threshold, using the coordinate format submatrix as a compressed submatrix.

[0007] According to an embodiment of the present invention, determining the density type of a coordinate format submatrix includes: for each row of the coordinate format submatrix, solving the row density to determine a dense row; a dense row is a row whose row density is greater than the density of the coordinate format submatrix; for each column of the coordinate format submatrix, solving the column density to determine a dense column; a dense column is a column whose column density is greater than the density of the coordinate format submatrix; determining whether the number of dense rows is greater than the number of dense columns; if so, the dense type of the coordinate format submatrix is ​​a row dense matrix; if not, the dense type of the coordinate format submatrix is ​​a column dense matrix.

[0008] According to an embodiment of the present invention, a coordinate format submatrix is ​​converted into transmission data of a sparse row format submatrix for a graphics processor to generate a compressed submatrix, including: determining the number of non-zero elements of each row according to a row index array for the graphics processor to confirm a row pointer array; and composing the transmission data of the compressed submatrix using the number of non-zero elements of each row, a column index array, and an array of non-zero element values.

[0009] According to an embodiment of the present invention, a coordinate format submatrix is ​​converted into transmission data of a sparse column format submatrix for a graphics processor to generate a compressed submatrix, including: determining the number of non-zero elements in each column according to a column index array for the graphics processor to confirm a column pointer array; and using a row index array, the number of non-zero elements in each column, and a non-zero element value array to form the transmission data of the compressed submatrix.

[0010] According to an embodiment of the present invention, calling a graphics processor to complete simulation solution of a compressed submatrix includes: generating a compressed submatrix in a memory of the graphics processor according to transmission data of the compressed submatrix; performing simulation solution on the compressed submatrix to obtain a compressed submatrix after operation; calling a central processing unit to determine whether the distribution characteristics of the compressed submatrix after operation have changed; if so, in response to the simulation solution not being completed, calling the central processing unit to redetermine the storage format of the compressed submatrix to obtain a processed compressed submatrix; re-executing the step of performing simulation solution on the compressed submatrix to obtain a compressed submatrix after operation; if not, in response to the simulation solution not being completed, re-executing the step of performing simulation solution on the compressed submatrix to obtain a compressed submatrix after operation.

[0011] According to an embodiment of the present invention, a compressed submatrix is ​​generated in a memory of a graphics processor according to transmission data of the compressed submatrix, including: in response to the compressed submatrix being a coordinate format submatrix, using a graphics processor thread to store row indexes, column indexes and non-zero element values ​​into a row index array, a column index array and a non-zero element value array respectively; in response to the compressed submatrix being a sparse row format submatrix, using a graphics processor thread to perform the following operations for each row in the sparse row format submatrix: writing non-zero element values ​​and corresponding column indexes into a non-zero element value array and a column index array; according to the number of non-zero elements in each row, calculating the starting position index of each row in parallel for filling to obtain a row pointer array; in response to the compressed submatrix being a sparse column format submatrix, using a graphics processor thread to perform the following operations for each column in the sparse column format submatrix: writing non-zero element values ​​and corresponding row indexes into a non-zero element value array and a row index array; according to the number of non-zero elements in each column, calculating the starting position index of each column in parallel for filling the column pointer array.

[0012] According to an embodiment of the present invention, a central processing unit is called to determine whether the distribution characteristics of the compressed submatrix after the operation have changed, including: in response to a change in the density of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation have changed; the change in density includes one of the density changing from greater than a preset threshold to less than a preset threshold and the density changing from less than a preset threshold to greater than a preset threshold; in response to a change in the density type of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation have changed; the density type at least includes a row dense matrix and a column dense matrix.

[0013] The second aspect of the present invention provides a solution device for simulation software, which can be used to implement the solution method of the above-mentioned simulation software, including: a matrix partitioning module, used to call a central processing unit to preprocess the simulation matrix to obtain a coordinate format sub-matrix; the coordinate format sub-matrix is ​​represented by a row index array, a column index array and a non-zero element value array; a format confirmation module, used to call the central processing unit to redetermine the storage format of the coordinate format sub-matrix according to the distribution characteristics of the coordinate format sub-matrix, and obtain the transmission data of the compressed sub-matrix; the compressed sub-matrix includes at least one of the coordinate format sub-matrix, a sparse row format sub-matrix and a sparse column format sub-matrix; a simulation solution module, used to call a graphics processor to complete simulation solution for the compressed sub-matrix.

[0014] According to the simulation software solution method provided by the present invention, the speed of the graphics processing unit (GPU) matrix construction is improved by dynamically adjusting the storage format of the matrix to be solved by using the central processing unit (CPU). Since the CPU subthread is effectively avoided from being idle, the graphics processing unit is more efficient. Therefore, the technical problem of the long simulation cycle is at least partially solved, and the technical effect of fully utilizing the CPU's capabilities to improve the simulation solution efficiency is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 A flowchart of a solution method of simulation software according to an embodiment of the present invention is schematically shown;

[0016] Figure 2 Schematically shows a flowchart of CPU-GPU collaborative work according to an embodiment of the present invention;

[0017] Figure 3 A structural block diagram of a solution device of simulation software according to an embodiment of the present invention is schematically shown;

[0018] Figure 4 A block diagram of an electronic device suitable for implementing a solution method of simulation software according to an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION

[0019] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0020] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0021] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0022] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0023] First, the technical terms involved in the present invention are explained as follows:

[0024] Coordinate format submatrix: A matrix in the COO (Coordinate Format) storage format uses the following three vectors to store the sparse elements of the matrix: row index array (rowIndices): stores the row index of each non-zero element; column index array (columnIndices): stores the column index of each non-zero element; non-zero element array (nonZeroValues): stores the value of each non-zero element.

[0025] Sparse row format submatrix: A matrix in CSR (Compressed Sparse Row Format) storage format uses the following three vectors to store the sparse elements of the matrix: row pointer array (rowPointer): stores the starting position of the non-zero elements of each row in the values ​​array; column index array (columnIndices): stores the column index corresponding to each non-zero element; non-zero element array (nonZeroValues): stores the non-zero elements of the matrix in row order.

[0026] Sparse column format submatrix: A matrix in CSC (Compressed Sparse Column Format) storage format uses the following three vectors to store the sparse elements of the matrix: row index array (rowIndices): stores the row index of each non-zero element; column pointer array (columnPointer): stores the starting position of the non-zero elements of each column in the values ​​array; non-zero element array (nonZeroValues): stores the values ​​of all non-zero elements in column order.

[0027] Most existing GPU-accelerated matrix construction solutions usually have fixed matrix storage formats (such as COO, CSR, CSC) and do not make dynamic adjustments. Although some technologies may consider choosing the best format, they usually determine the storage format at the beginning of matrix construction and once selected, it remains fixed. In addition, most existing GPU-accelerated matrix construction relies on the GPU to perform computing tasks throughout the process, and the CPU is only responsible for preprocessing or transmitting data, lacking efficient management of details such as task division and format selection. Many solutions ignore the CPU's scheduling and control capabilities and the ability to use thread pools to fully utilize the CPU, and simply rely on the GPU's parallel computing.

[0028] The purpose of the present invention is to provide a method for improving the computational processing efficiency of CAE simulation software, which adopts a hybrid acceleration platform based on CPU-GPU collaboration and combines the corresponding CPU-GPU optimization scheduling algorithm to significantly improve the speed of the matrix construction process. By optimizing the dynamic adjustment mechanism, task division and scheduling strategy of the matrix storage format, the simulation cycle is effectively shortened, thereby improving the overall performance, practicality and market competitiveness of the simulation software.

[0029] Figure 1 A flowchart of a solution method of a simulation software according to an embodiment of the present invention is schematically shown. Figure 1 As shown, an embodiment of the present invention provides a solution method for simulation software, including: calling a central processing unit to preprocess a simulation matrix to obtain a coordinate format submatrix; the coordinate format submatrix is ​​represented by a row index array, a column index array and a non-zero element value array; according to the distribution characteristics of the coordinate format submatrix, calling the central processing unit to re-determine the storage format of the coordinate format submatrix to obtain transmission data of the compressed submatrix; the compressed submatrix includes at least one of a coordinate format submatrix, a sparse row format submatrix and a sparse column format submatrix; calling a graphics processor to complete simulation solution for the compressed submatrix.

[0030] In this embodiment, the programming model adopts CUDA which supports CPU-GPU collaboration.

[0031] In this embodiment, Figure 2A flowchart of CPU-GPU collaboration according to an embodiment of the present disclosure is schematically shown. Figure 2 As shown, the CPU is responsible for the following operations: the main thread divides the matrix and indexes the mark, assigns the tasks of the sub-matrix to the sub-threads in the thread pool and stores them in the COO format; when the density of non-zero elements exceeds 20%, the storage format is dynamically adjusted; if the row direction is denser, the CSR format is selected; if the column direction is denser, the CSC format is selected; after confirming the storage format, the data is transferred to the GPU; and the GPU performs subsequent parallel calculations.

[0032] Through the embodiments of the present invention, the storage format is dynamically adjusted according to different matrix characteristics by making full use of the multi-core performance of the CPU to ensure that the optimal storage method is always used; the speed of simulation solution is improved by the parallel computing capability of the GPU. This dynamic storage format adjustment mechanism combines the logical processing capability of the CPU and the parallel computing capability of the GPU, which not only significantly improves the computational efficiency of matrix construction, but also effectively avoids calculations in inappropriate storage formats, thereby optimizing the utilization of computing and storage resources, greatly reducing the computer solution time of the simulation task, while maintaining the accuracy and reliability of the simulation results, and improving the overall processing performance.

[0033] On the basis of the above embodiment, the central processing unit is called to pre-process the simulation matrix to obtain a coordinate format sub-matrix, including: calling the main thread of the central processing unit to divide the simulation matrix into sub-matrices and perform index marking; allocating the sub-matrix to a sub-thread in the central processing unit thread pool for storing the sub-matrix as a coordinate format sub-matrix.

[0034] In this embodiment, the CPU uses a thread pool, and the main thread is responsible for dividing the entire matrix into multiple smaller blocks and indexing them, and each block can be processed independently. The main thread assigns tasks to sub-threads in the thread pool for processing. Each sub-thread will execute the next processing flow in parallel.

[0035] Through the embodiments of the present invention, in the initial stage of matrix construction, the simulation matrix is ​​divided into sub-matrices and organized by index tags, and then the CPU uses the COO format to store the matrix. The COO format sub-matrices are easy to understand and operate, which helps to reduce the complexity of matrix processing and improve the efficiency of subsequent processing.

[0036] On the basis of the above embodiment, according to the distribution characteristics of the coordinate format submatrix, the central processing unit is called to re-determine the storage format of the coordinate format submatrix to obtain the transmission data of the compressed submatrix, including: judging whether the density of the coordinate format submatrix is ​​greater than a preset threshold; wherein the density of the coordinate format submatrix is ​​confirmed by the ratio of non-zero elements to the total number of elements; if the density of the coordinate format submatrix is ​​greater than the preset threshold, then judging the density type of the coordinate format submatrix; the dense type includes at least a row-dense matrix and a column-dense matrix; if the coordinate format submatrix is ​​a row-dense matrix, then converting the coordinate format submatrix into the transmission data of a sparse row-format submatrix for the graphics processor to generate the compressed submatrix; if the coordinate format submatrix is ​​a column-dense matrix, then converting the coordinate format submatrix into the transmission data of a sparse column-format submatrix for the graphics processor to generate the compressed submatrix; if the density of the coordinate format submatrix is ​​less than the preset threshold, then using the coordinate format submatrix as a compressed submatrix.

[0037] In this embodiment, a thread pool is used to construct a subthread on the CPU to dynamically determine the storage format of the matrix. Specifically, the CPU selects a suitable storage format in real time according to the sparsity of the matrix and the density of non-zero elements, and submits the matrix data to the GPU for processing.

[0038] For example, during the matrix construction process, each sub-thread will not fix the matrix storage format, nor will it be handed over to the GPU for calculation after selecting the storage format. Instead, the sub-thread in the CPU will first assume that the matrix is ​​extremely sparse (that is, using the COO format). As the number of non-zero elements increases, the sub-thread will dynamically adjust the storage format according to the density. When the density of non-zero elements exceeds the threshold (for example, set to 20%), the CPU will dynamically select the appropriate storage format based on the row and column density: if the matrix is ​​dense in the row direction and sparse in the column direction, the CSR format is selected; if the matrix is ​​dense in the column direction and sparse in the row direction, the CSC format is selected. After confirming the storage format, the data is transferred to the GPU for subsequent calculations. This can effectively avoid idle sub-threads in the CPU and dynamically adjust the storage format in subsequent planning.

[0039] Through the embodiments of the present invention, according to the density and density type of the coordinate format submatrix, the storage format is dynamically adjusted to determine the transmission format of the compressed submatrix, so that the sparsity of the matrix can be fully utilized, the memory usage can be reduced, and the calculation efficiency can be improved. At the same time, by dynamically adjusting the storage format, different matrix characteristics can be adapted to ensure that the optimal storage method is always used during the calculation process.

[0040] On the basis of the above embodiment, determining the density type of the coordinate format submatrix includes: for each row of the coordinate format submatrix, solving the row density to determine the dense row; the dense row is the row whose row density is greater than the density of the coordinate format submatrix; for each column of the coordinate format submatrix, solving the column density to determine the dense column; the dense column is the column whose column density is greater than the density of the coordinate format submatrix; determining whether the number of dense rows is greater than the number of dense columns; if so, the dense type of the coordinate format submatrix is ​​a row dense matrix; if not, the dense type of the coordinate format submatrix is ​​a column dense matrix.

[0041] In this embodiment, when the density of non-zero elements exceeds a set threshold, the CPU adjusts the storage format (such as switching from COO to CSR or CSC) and transmits the updated data to the GPU for further calculation. During the adjustment process, an incremental update mechanism is also used to transmit only the newly added non-zero elements instead of rebuilding the entire matrix, which more effectively avoids unnecessary calculation and storage waste.

[0042] Through the embodiments of the present invention, by solving the row density and column density, the density type of the coordinate format submatrix is ​​determined, which provides a basis for the subsequent selection of the storage format and helps to optimize the storage format.

[0043] Based on the above embodiment, the coordinate format sub-matrix is ​​converted into the transmission data of the sparse row format sub-matrix for the graphics processor to generate the compressed sub-matrix, including: according to the row index array, determining the number of non-zero elements of each row for the graphics processor to confirm the row pointer array; using the number of non-zero elements of each row, the column index array and the non-zero element value array to form the transmission data of the compressed sub-matrix.

[0044] In this embodiment, the CPU sorts the non-zero elements by row according to rowIndices and colIndices to ensure that they can be stored in values ​​and columnIndices in order; counts the number of non-zero elements in each row according to rowIndices; fills values ​​and columnIndices: fills the non-zero elements in nonZeroValues ​​into the values ​​array in row order, and records the column index of each non-zero element in columnIndices.

[0045] Based on the above embodiment, the coordinate format submatrix is ​​converted into the transmission data of the sparse column format submatrix for the graphics processor to generate the compressed submatrix, including: according to the column index array, determining the number of non-zero elements in each column for the graphics processor to confirm the column pointer array; using the row index array, the number of non-zero elements in each column and the non-zero element value array to form the transmission data of the compressed submatrix.

[0046] In this embodiment, the CPU sorts the non-zero elements by column according to colIndices to ensure that they can be stored in values ​​and rowIndices in order by counting the number of non-zero elements in each column in colIndices; fill values ​​and rowIndices: fill the non-zero elements in nonZeroValues ​​into the values ​​array in column order, and record the corresponding row index in rowIndices.

[0047] Through the embodiments of the present invention, the CPU determines the density of non-zero elements in the row direction or the column direction and selects to use the corresponding storage format, thereby specifically reducing memory usage and improving computing efficiency.

[0048] On the basis of the above-mentioned embodiment, a graphics processor is used to complete simulation and solving of a compressed submatrix, including: generating a compressed submatrix in a memory of a graphics processor according to transmission data of the compressed submatrix; performing simulation and solving of the compressed submatrix to obtain a compressed submatrix after operation; calling a central processing unit to determine whether the distribution characteristics of the compressed submatrix after operation have changed; if so, in response to the simulation and solving being incomplete, calling the central processing unit to redetermine the storage format of the compressed submatrix to obtain a processed compressed submatrix; re-executing the step of performing simulation and solving of the compressed submatrix to obtain a compressed submatrix after operation; if not, in response to the simulation and solving being incomplete, re-executing the step of performing simulation and solving of the compressed submatrix to obtain a compressed submatrix after operation.

[0049] In this embodiment, during GPU processing, the CPU continues to monitor changes in matrix sparsity and dynamically adjusts the storage format based on real-time conditions.

[0050] Through the embodiments of the present invention, the CPU adjusts the storage format in real time to optimize the data transmission process and improve the computing efficiency; the compressed sub-matrix is ​​transmitted to the GPU memory, and the parallel computing capability of the GPU is used to perform simulation and solving. The highly parallel computing capability of the GPU can significantly speed up the simulation and solving speed.

[0051] On the basis of the above embodiment, according to the transmission data of the compressed sub-matrix, a compressed sub-matrix is ​​generated in the memory of the graphics processor, including: in response to the compressed sub-matrix being a coordinate format sub-matrix, using a graphics processor thread to store the row index, column index and non-zero element value into the row index array, column index array and non-zero element value array respectively; in response to the compressed sub-matrix being a sparse row format sub-matrix, using a graphics processor thread to perform the following operations for each row in the sparse row format sub-matrix: writing the non-zero element value and the corresponding column index into the non-zero element value array and the column index array; according to the number of non-zero elements in each row, calculating the starting position index of each row in parallel for filling to obtain a row pointer array; in response to the compressed sub-matrix being a sparse column format sub-matrix, using a graphics processor thread to perform the following operations for each column in the sparse column format sub-matrix: writing the non-zero element value and the corresponding row index into the non-zero element value array and the row index array; according to the number of non-zero elements in each column, calculating the starting position index of each column in parallel for filling the column pointer array.

[0052] In this embodiment, when the density of non-zero elements of the matrix exceeds a threshold of 20%, the CPU transfers the initialized matrix data from the CPU memory to the GPU memory so that the GPU can perform subsequent calculations. The data transfer uses the cudaMemcpy function to copy the data (rowIndices, colIndices, nonZeroValues) on the CPU to the corresponding arrays (dRowIndices, dColIndices, dNonZeroValues) in the GPU memory. At this time, the GPU can perform parallel filling and operations on the matrix through the advantage of multi-threading.

[0053] For example, in the COO format, each GPU thread is responsible for one or more non-zero elements and stores their row index, column index, and value into the corresponding array.

[0054] For example, in the CSR format, GPU threads are responsible for different rows. Each thread writes the value of the non-zero element and the corresponding column index in the row it is responsible for into the values ​​and columnIndices arrays. Based on the number of non-zero elements in each row, the GPU can calculate and fill the starting position index of each row in the rowPointer array in parallel to ensure the fast construction of the row pointer array.

[0055] For example, in the CSC format, each GPU thread is responsible for one or more columns, writes the values ​​of non-zero elements and their corresponding row indices into the values ​​and rowIndices arrays, generates columnPointer in parallel, and quickly determines the starting position of each column by calculating the number of non-zero elements in each column in parallel, and fills it into the columnPointer array to ensure efficient construction of the column pointer array.

[0056] Through the embodiments of the present invention, the transmission data is correctly organized into the memory of the GPU according to the storage format of the compressed sub-matrix, and the construction of the matrix is ​​completed.

[0057] On the basis of the above embodiment, the central processing unit is called to determine whether the distribution characteristics of the compressed submatrix after the operation have changed, including: in response to the change in the density of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation have changed; the change in density includes one of the density changing from greater than a preset threshold to less than a preset threshold and the density changing from less than the preset threshold to greater than the preset threshold; in response to the change in the density type of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation have changed; the density type at least includes a row dense matrix and a column dense matrix.

[0058] In this embodiment, while the GPU is performing calculations, the CPU is still building and updating the sparse matrix. If, during further operations, the child thread detects that the density or distribution characteristics of the non-zero elements in the responsible part have changed significantly, causing the current storage format (such as CSR or CSC) to no longer be suitable, a new storage format adjustment will be prepared.

[0059] In this embodiment, the child thread reorders and formats the current sparse matrix data (for example, switching from CSR to CSC or vice versa), and transfers the adjusted data to the GPU again through cudaMemcpy, overwriting the original stored data. The CPU will set a dedicated int-type variable flag to mark the matrix during the update process (for example, 0 corresponds to COO, 1 corresponds to CSR, 2 corresponds to CSC, and 3 corresponds to incremental update). If the sparsity of the matrix changes slightly, for example, only some new rows or columns of non-zero elements are added, the marking type is incremental update, and the data at this time only transfers the newly added non-zero elements to the GPU. For example, if a row (or column) becomes dense, only the new non-zero elements in this row (or column) need to be transferred to the GPU, rather than rebuilding the entire matrix and updating the indexes rowIndices and columnIndices.

[0060] Through the embodiments of the present invention, once the CPU neutron thread determines that the storage format of the matrix needs to be updated, the CPU neutron thread will notify the GPU through a synchronization mechanism to suspend the current calculation and wait for the data to be retransmitted. This can prevent the GPU from performing inefficient operations in an inappropriate storage format. After receiving the updated data, the GPU will continue parallel operations using the new storage format to ensure higher computing efficiency and more optimized resource utilization. Through this dynamic monitoring and format adjustment mechanism, the resources of the CPU and GPU are fully utilized, the CPU avoids idling waiting, and the GPU performs parallel operations in a suitable storage format, thereby improving the performance of the entire sparse matrix construction process.

[0061] Based on the above-mentioned simulation software solution method, the present invention also provides a simulation software solution device, which can be used to implement the above-mentioned simulation software solution method. Figure 3 The device is described in detail.

[0062] Figure 3 The structural block diagram of the solving device of the simulation software according to the embodiment of the present invention is schematically shown.

[0063] like Figure 3 As shown, the solution device of the simulation software of this embodiment includes a matrix division module, a format confirmation module and a simulation solution module.

[0064] The matrix partitioning module is used to call the central processing unit to pre-process the simulation matrix to obtain a coordinate format sub-matrix; the coordinate format sub-matrix is ​​represented by a row index array, a column index array and a non-zero element value array.

[0065] The format confirmation module is used to call the central processing unit to re-determine the storage format of the coordinate format submatrix according to the distribution characteristics of the coordinate format submatrix, and obtain the transmission data of the compressed submatrix; the compressed submatrix includes at least one of the coordinate format submatrix, the sparse row format submatrix and the sparse column format submatrix.

[0066] The simulation solution module is used to call the graphics processor to complete the simulation solution of the compressed sub-matrix.

[0067] Figure 4 A block diagram of an electronic device suitable for implementing a solution method of simulation software according to an embodiment of the present invention is schematically shown.

[0068] like Figure 4As shown, the electronic device 400 according to an embodiment of the present invention includes a processor 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 to a random access memory (RAM) 403. The processor 401 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 401 may also include an onboard memory for caching purposes. The processor 401 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0069] In RAM 403, various programs and data required for the operation of electronic device 400 are stored. Processor 401, ROM 402 and RAM 403 are connected to each other via bus 404. Processor 401 performs various operations of the method flow according to the embodiment of the present invention by executing the programs in ROM 402 and / or RAM 403. It should be noted that the program can also be stored in one or more memories other than ROM 402 and RAM 403. Processor 401 can also perform various operations of the method flow according to the embodiment of the present invention by executing the programs stored in the one or more memories.

[0070] According to an embodiment of the present invention, the electronic device 400 may further include an input / output (I / O) interface 405, which is also connected to the bus 404. The electronic device 400 may further include one or more of the following components connected to the I / O interface 405: an input portion 406 including a keyboard, a mouse, etc.; an output portion 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 408 including a hard disk, etc.; and a communication portion 409 including a network interface card such as a LAN card, a modem, etc. The communication portion 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage portion 408 as needed.

[0071] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0072] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present invention.

[0073] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0074] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0075] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways, even if such combinations and / or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All of these combinations and / or combinations fall within the scope of the present invention.

[0076] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination. The scope of the present invention is defined by the attached claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A solution method for simulation software, characterized in that: include: Call the central processing unit to pre-process the simulation matrix to obtain a coordinate format sub-matrix; The coordinate format submatrix is ​​represented by a row index array, a column index array, and a non-zero element value array; The method of calling the central processor to pre-process the simulation matrix to obtain a coordinate format sub-matrix includes: calling the main thread of the central processor to divide the simulation matrix into sub-matrices and perform index marking; allocating the sub-matrix to a sub-thread in a central processor thread pool for storing the sub-matrix as a coordinate format sub-matrix; According to the distribution characteristics of the coordinate format submatrix, calling the central processing unit to redetermine the storage format of the coordinate format submatrix to obtain the transmission data of the compressed submatrix; the compressed submatrix includes at least one of the coordinate format submatrix, the sparse row format submatrix and the sparse column format submatrix; according to the distribution characteristics of the coordinate format submatrix, calling the central processing unit to redetermine the storage format of the coordinate format submatrix to obtain the transmission data of the compressed submatrix, including: judging whether the density of the coordinate format submatrix is ​​greater than a preset threshold; wherein the density of the coordinate format submatrix is ​​confirmed by the ratio of non-zero elements to the total number of elements; if the coordinate format submatrix is ​​greater than a preset threshold, the density of the coordinate format submatrix is ​​determined ... If the density of the coordinate format submatrix is ​​greater than a preset threshold, the density type of the coordinate format submatrix is ​​determined; the dense type includes at least a row-dense matrix and a column-dense matrix; if the coordinate format submatrix is ​​a row-dense matrix, the coordinate format submatrix is ​​converted into transmission data of a sparse row-format submatrix for a graphics processor to generate a compressed submatrix; if the coordinate format submatrix is ​​a column-dense matrix, the coordinate format submatrix is ​​converted into transmission data of a sparse column-format submatrix for a graphics processor to generate a compressed submatrix; if the density of the coordinate format submatrix is ​​less than a preset threshold, the coordinate format submatrix is ​​used as a compressed submatrix; A graphics processor is called to perform simulation solution on the compressed sub-matrix.

2. The method according to claim 1, wherein: The determining the dense type of the coordinate format submatrix includes: For each row of the coordinate format submatrix, solving the row density to determine a dense row; the dense row is a row whose row density is greater than the density of the coordinate format submatrix; For each column of the coordinate format submatrix, solving the column density to determine a dense column; the dense column is a column whose column density is greater than the density of the coordinate format submatrix; It is determined whether the number of dense rows is greater than the number of dense columns; if so, the dense type of the coordinate format submatrix is ​​a row dense matrix; if not, the dense type of the coordinate format submatrix is ​​a column dense matrix.

3. The method according to claim 1, wherein: The step of converting the coordinate format submatrix into transmission data of a sparse row format submatrix for a graphics processor to generate a compressed submatrix includes: According to the row index array, determining the number of non-zero elements of each row for the graphics processor to confirm the row pointer array; The transmission data of the compressed sub-matrix is ​​composed using the number of non-zero elements in each row, the column index array, and the non-zero element value array.

4. The method according to claim 1, wherein: The step of converting the coordinate format submatrix into transmission data of a sparse column format submatrix for use as a graphics processor to generate a compressed submatrix includes: According to the column index array, determining the number of non-zero elements of each column for the graphics processor to confirm the column pointer array; The transmission data of the compressed sub-matrix is ​​composed by using the row index array, the number of non-zero elements in each column and the non-zero element value array.

5. The method according to claim 1, wherein: The calling of the graphics processor to complete simulation solution of the compressed sub-matrix includes: generating a compressed sub-matrix in a memory of a graphics processor according to the transmission data of the compressed sub-matrix; The compressed submatrix is ​​simulated and solved to obtain the compressed submatrix after operation; Calling the central processing unit to determine whether the distribution characteristics of the compressed submatrix after the operation have changed; if so, in response to the simulation solution not being completed, calling the central processing unit to redetermine the storage format of the compressed submatrix to obtain the processed compressed submatrix; re-performing the simulation solution of the compressed submatrix to obtain the step of the compressed submatrix after the operation; If not, in response to the simulation solution not being completed, the step of performing simulation solution on the compressed sub-matrix is ​​re-executed to obtain the compressed sub-matrix after operation.

6. The method according to claim 5, wherein: Generating a compressed sub-matrix in a memory of a graphics processor according to the transmission data of the compressed sub-matrix includes: In response to the compressed sub-matrix being a coordinate format sub-matrix, using a graphics processor thread to store row indexes, column indexes and non-zero element values ​​into a row index array, a column index array and a non-zero element value array respectively; In response to the compressed submatrix being a sparse row format submatrix, using a graphics processor thread to perform the following operations for each row in the sparse row format submatrix: writing non-zero element values ​​and corresponding column indexes into a non-zero element value array and a column index array; and calculating the starting position index of each row in parallel according to the number of non-zero elements in each row for filling to obtain a row pointer array; In response to the compressed sub-matrix being a sparse column format sub-matrix, a graphics processor thread is used to perform the following operations for each column in the sparse column format sub-matrix: writing non-zero element values ​​and corresponding row indexes into a non-zero element value array and a row index array; and calculating the starting position index of each column in parallel according to the number of non-zero elements in each column for filling a column pointer array.

7. The method according to claim 5, wherein: The calling of the central processing unit to determine whether the distribution characteristics of the compressed submatrix after the operation have changed includes: In response to a change in the density of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation change; the change in density includes one of a change from a density greater than a preset threshold to a density less than a preset threshold and a change from a density less than a preset threshold to a density greater than a preset threshold; In response to a change in the density type of the compressed submatrix after the operation, the distribution characteristics of the compressed submatrix after the operation change; the dense type includes at least a row dense matrix and a column dense matrix.

8. A solution device for simulation software, characterized in that: The device can be used to implement the method according to any one of claims 1 to 7, and the device comprises: The matrix partitioning module is used to call the central processing unit to pre-process the simulation matrix to obtain a coordinate format sub-matrix; the coordinate format sub-matrix is ​​represented by a row index array, a column index array and a non-zero element value array; the calling the central processing unit to pre-process the simulation matrix to obtain the coordinate format sub-matrix includes: calling the main thread of the central processing unit to divide the simulation matrix into sub-matrices and perform index marking; allocating the sub-matrix to a sub-thread in the central processing unit thread pool for storing the sub-matrix as a coordinate format sub-matrix; A format confirmation module, for calling a central processor to redetermine the storage format of the coordinate format submatrix according to the distribution characteristics of the coordinate format submatrix, and obtaining the transmission data of the compressed submatrix; the compressed submatrix includes at least one of a coordinate format submatrix, a sparse row format submatrix, and a sparse column format submatrix; calling a central processor to redetermine the storage format of the coordinate format submatrix according to the distribution characteristics of the coordinate format submatrix, and obtaining the transmission data of the compressed submatrix, including: determining whether the density of the coordinate format submatrix is ​​greater than a preset threshold; wherein the density of the coordinate format submatrix is ​​confirmed by the ratio of non-zero elements to the total number of elements; If the density of the coordinate format submatrix is ​​greater than a preset threshold, the density type of the coordinate format submatrix is ​​determined; the dense type includes at least a row-dense matrix and a column-dense matrix; if the coordinate format submatrix is ​​a row-dense matrix, the coordinate format submatrix is ​​converted into transmission data of a sparse row-format submatrix for a graphics processor to generate a compressed submatrix; if the coordinate format submatrix is ​​a column-dense matrix, the coordinate format submatrix is ​​converted into transmission data of a sparse column-format submatrix for a graphics processor to generate a compressed submatrix; if the density of the coordinate format submatrix is ​​less than a preset threshold, the coordinate format submatrix is ​​used as a compressed submatrix; The simulation solution module is used to call a graphics processor to complete simulation solution of the compressed sub-matrix.

Citation Information

Patent Citations

  • A GPU acceleration method for multiplying a large-scale sparse matrix by a transposed matrix of the large-scale sparse matrix

    CN109597691A

  • Feature detection method and device based on sparse matrix vector multiplication and medium

    CN116186526A