Parallel acceleration method, device and equipment for multiplying symmetric sparse matrix vector by shared memory

Through the construction of symmetric CSR format and task dependency tree, the data competition problem in sparse matrix vector multiplication is solved, the computing performance and memory access ratio are improved, memory usage is optimized, and efficient parallel computing of symmetric sparse matrix vector multiplication is realized.

CN119089102AActive Publication Date: 2024-12-06NAT UNIV OF DEFENSE TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411227263.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-12-06
Estimated Expiration
2044-09-03

AI Technical Summary

Technical Problem

The existing sparse matrix vector multiplication algorithms are limited in parallel computing, especially the data competition problem of symmetric sparse matrices is difficult to effectively solve, resulting in poor memory fetch performance and high memory consumption.

Method used

Sparse matrix is ​​stored using a symmetric CSR format, a conflict graph is constructed, and the molecular graph and isolation area are divided through the graph division tool is formed, a task dependency tree is decomposed, and the tasks are allocated to the processor for calculations, and the symmetric nature of the matrix is ​​used to reduce storage and improve the memory access ratio.

Benefits of technology

It greatly improves the computing performance of symmetric sparse matrix vector multiplication, optimizes the memory access performance, reduces the consumption of storage memory resources, and improves the parallel scalability of computer devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119089102A_ABST
    Figure CN119089102A_ABST
Patent Text Reader

Abstract

The invention relates to a symmetric sparse matrix vector multiplication shared memory parallel acceleration method, device and equipment. The method comprises the following steps: constructing a conflict graph according to a symmetric sparse matrix vector multiplied by a data competition relationship between rows; calling a graph division tool to divide the conflict graph into a plurality of sub-graphs and isolation regions between the adjacent sub-graphs, and sorting nodes of each sub-graph; recursively dividing the isolation region layer by layer, re-sequencing all sub-graphs and nodes of the isolation region, and organizing and storing in a task tree form until the row number of a matrix corresponding to the isolation region is smaller than a specific threshold value; and firstly calculating all sub-graphs in the task tree and then calculating the isolation area by adopting an SSS in a symmetric CSR format according to a row parallel mode. According to the method, the symmetric property of the matrix is utilized, the isolation area is arranged, the calculation performance of symmetric sparse matrix vector multiplication calculation processing is greatly improved, the calculation access-memory ratio is increased, the access-memory performance is optimized, and meanwhile consumption of storage memory resources is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of parallel computing technology, and in particular to a method, device and equipment for parallel acceleration of symmetric sparse matrix-vector multiplication with shared memory. Background Art

[0002] Sparse matrix-vector multiplication is an important technology in computer science and one of the basic operators of scientific computing. It is widely used in machine learning, image processing, network analysis, and solving systems of equations. A sparse matrix is ​​a matrix in which most of the elements are zero, and vector multiplication refers to the operation of multiplying a vector by a matrix. For sparse matrices, usually only non-zero elements are stored to save storage space and improve computing efficiency. People have invented a variety of sparse matrix storage formats, and there are three main sparse matrix storage formats: COO, CSR, and CSC. The COO format is also called the coordinate format. It stores the row, column coordinates, and values ​​of all non-zero elements in the matrix in three arrays. Its advantage is that it is simple to store and is suitable for storing sparse matrices with fewer non-zero elements, but its disadvantage is that it does not support fast row or column access. The CSR format is a format that compresses sparse matrices by row. It stores the non-zero elements of the matrix by row in a one-dimensional array, and uses two one-dimensional arrays to store the position of the first non-zero element of each row in the compressed array and the column coordinates of the non-zero elements. Its advantage is that it supports fast row access and is suitable for matrix-vector multiplication algorithms, but its disadvantage is that converting to CSR format requires additional space and computational complexity. The CSC format is similar to the CSR format, except that row compression is changed to column compression.

[0003] In addition to the above mainstream formats, many researchers have also proposed some special formats to cope with different types of sparse matrices and parallel computing requirements. There are different matrix-vector multiplication parallel algorithms for different storage formats. At present, the most common algorithm is the row-by-row parallel algorithm based on the CSR format. Specifically, the sparse matrix in the CSR format is divided by rows and assigned to different threads for calculation. Each thread is responsible for calculating the product of the non-zero elements of certain rows and the vector, and accumulating the results to the final result. This algorithm is suitable for situations where the non-zero elements in the sparse matrix are relatively evenly distributed, and the effect is poor for matrices with uneven distribution. In addition, there are parallel algorithms based on the CSR5 format, parallel algorithms based on the CSB format, and block parallel algorithms.

[0004] Although the research on parallel algorithms for sparse matrix-vector multiplication is very mature and there are many algorithms with good performance, sparse matrix-vector multiplication is still a memory-constrained algorithm, and its performance is limited by memory access performance. In practical applications, the sparse matrices involved in many fields are symmetrical, and symmetric sparse matrices can reduce memory usage and increase the computational memory access ratio by storing only the upper (lower) triangular matrices, thereby improving computing performance. Although the symmetric properties of sparse matrices can be used to reduce storage space, symmetric positions need to participate in the calculation at the same time during parallel computing, which may cause data contention. Existing solutions such as atomic locks, copy reduction, and coloring can solve the problem of data contention in shared memory parallelism, but their parallel scalability is poor. Summary of the invention

[0005] Based on this, it is necessary to provide a symmetric sparse matrix-vector multiplication shared memory parallel acceleration method, device and equipment to address the above technical problems.

[0006] A method for parallel acceleration of symmetric sparse matrix-vector multiplication in shared memory, the method being applicable to a shared memory architecture computer, the method comprising:

[0007] The symmetric CSR format SSS (Sparse Symmetric Skyline) is used to store the symmetric sparse matrix to be vector multiplication.

[0008] A conflict graph is constructed based on the data competition relationship between rows in the symmetric sparse matrix-vector multiplication.

[0009] The call graph partitioning tool logically divides the conflict graph into several subgraphs and isolation areas between adjacent subgraphs, and sorts the nodes in each subgraph.

[0010] The isolation area is recursively divided layer by layer and all subgraphs and nodes in the isolation area are reordered, organized and stored in the shared memory in the form of a tree until the number of matrix rows corresponding to the isolation area is less than the preset threshold, and the task dependency tree TDT (Task Dedependency Tree) is obtained.

[0011] The task of symmetric sparse matrix-vector multiplication is decomposed according to the task dependency tree, and the decomposed tasks are assigned to the corresponding processors.

[0012] All processors first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

[0013] In one embodiment, the symmetric CSR format SSS includes four arrays: row pointer position, column coordinates, non-zero element values, and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of the non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

[0014] In one embodiment, calling a mesh partitioning tool to logically partition the conflict graph into a plurality of subgraphs and isolation regions between adjacent subgraphs, and sorting the nodes in each subgraph, includes:

[0015] Call the METIS graph partitioning tool to divide the conflict graph into several sub-graphs.

[0016] Traverse all nodes in the subgraph and check whether they have edges with nodes in other subgraphs.

[0017] For points that are connected to points in other subgraphs, the point is removed from the original subgraph and divided into the isolation area.

[0018] Points that do not have edges with points in other subgraphs are not processed.

[0019] The nodes in each subgraph and isolated area are reordered so that the node numbers in each area are continuous.

[0020] In one embodiment, the isolation area is recursively divided layer by layer and all subgraphs and nodes in the isolation area are reordered and organized and stored in the form of a tree until the number of matrix rows corresponding to the isolation area is less than a preset threshold, thereby obtaining a task dependency tree, including:

[0021] After merging all isolation areas, they are recursively divided layer by layer. After each division, the nodes in the subgraph and isolation area are reordered and organized and stored in the form of a tree until the number of rows in the final isolation area is less than the preset threshold, and the task dependency tree is obtained.

[0022] A symmetric sparse matrix-vector multiplication shared memory parallel acceleration device, the device comprising:

[0023] The symmetric sparse matrix storage module is used to store the symmetric sparse matrix to be vector multiplication operation in symmetric CSR format SSS.

[0024] The conflict graph construction module is used to construct a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix-vector multiplication.

[0025] The task dependency tree construction module is used to call the graph partitioning tool to logically divide the conflict graph into several subgraphs and isolation areas between adjacent subgraphs, and sort the nodes in each subgraph; recursively divide the isolation areas layer by layer and re-sort the nodes in all subgraphs and isolation areas, and organize and store them in the form of a tree in the shared memory until the number of matrix rows corresponding to the isolation area is less than the preset threshold, and the task dependency tree is obtained.

[0026] The task dependency tree execution module is used to decompose the task of symmetric sparse matrix-vector multiplication according to the task dependency tree and assign the decomposed tasks to the corresponding processors; all processors use the symmetric CSR format SSS in a row-parallel manner to first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

[0027] In one embodiment, the symmetric CSR format SSS in the symmetric sparse matrix storage module includes four arrays: row pointer position, column coordinates, non-zero element values ​​and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of the non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

[0028] In one of the embodiments, a task dependency tree construction module is used to call the METIS graph partitioning tool to divide the conflict graph into several subgraphs; traverse the nodes in all subgraphs and detect whether they have edges with the nodes of other subgraphs; for points that have edges with points in other subgraphs, remove the points from the original subgraph and divide them into isolation areas; do not process points that do not have edges with points in other subgraphs; reorder the nodes in each subgraph and isolation area so that the node numbers in each area are continuous.

[0029] In one of the embodiments, a task dependency tree construction module is used to merge all isolation areas and then recursively partition them. After each partition, the nodes in the subgraph and isolation area are reordered and organized and stored in the form of a tree until the number of rows in the final isolation area is less than a set threshold.

[0030] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.

[0031] The above-mentioned symmetric sparse matrix vector multiplication shared memory parallel acceleration method, device and equipment, the method includes: constructing a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix vector multiplication; calling the graph partitioning tool to logically divide the conflict graph into several subgraphs and isolation areas between adjacent subgraphs, and sorting the nodes in each subgraph; recursively partitioning the isolation area layer by layer and re-sorting all subgraphs and nodes in the isolation area, and organizing and storing them in the form of a TDT tree until the number of matrix rows corresponding to the isolation area is less than a specific threshold; using the symmetric CSR format SSS in a row-by-row parallel manner, first calculating all subgraphs in the TDT tree, and then calculating the isolation area. This method utilizes the matrix symmetry and sets the isolation area, greatly improving the computing performance of the symmetric sparse matrix vector multiplication calculation processing, increasing the computing memory access ratio, optimizing the memory access performance, and greatly reducing the consumption of storage memory resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A schematic diagram of a flow chart of a method for parallel acceleration of symmetric sparse matrix-vector multiplication with shared memory in one embodiment;

[0033] Figure 2 A non-zero element position distribution diagram of a symmetric sparse matrix and a conflict graph generated corresponding to the symmetric sparse matrix in one embodiment, wherein (a) is a non-zero element position distribution diagram of the symmetric sparse matrix, and (b) is a conflict graph generated corresponding to the symmetric sparse matrix;

[0034] Figure 3 In one embodiment, a sparse matrix corresponds to a conflict graph after being divided once;

[0035] Figure 4 A schematic diagram of a TDT tree structure obtained after recursion twice in another embodiment;

[0036] Figure 5 A structural block diagram of a symmetric sparse matrix-vector multiplication shared memory parallel acceleration device in one embodiment;

[0037] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0039] For sparse matrices, they usually have large dimensions, sometimes so large that the entire matrix (zero elements) takes up most of the memory. Using a two-dimensional array storage method wastes a lot of storage units to store zero elements, and also wastes a lot of time in the calculation to perform invalid operations on zero elements. Therefore, it is necessary to consider compressing the storage of sparse matrices (only storing non-zero elements).

[0040] The full name of CSR format is Compressed Sparse Row Matrix. CSR format includes three arrays: data, indices and indptr. The specific meanings are as follows: data array indicates that the non-zero elements of each row are stored in sequence according to the starting number of the row; indices array indicates the column index value of each non-zero element; indptr array indicates the index value of the first non-zero element of each row in the data array (note: only the first non-zero element of each row is counted).

[0041] From the pseudocode of the serial algorithm of symmetric sparse matrix-vector multiplication in SSS format (a CSR format for storing symmetric sparse matrices), we can see that the calculation is performed row by row in the order of rows. Line 6 in the pseudocode y[col]+=A.values[j].x[i] means that for each non-zero element, not only its position but also its symmetric position must be calculated. This means that when we parallelize by row, the i-th row will not only update the i-th position of the output vector, but may also update other positions of the output vector. This will cause two different rows to update the same row at the same time, that is, data competition will occur, resulting in incorrect results. For this reason, we propose a symmetric sparse matrix-vector multiplication shared storage parallel acceleration method to solve this data competition problem.

[0042] The pseudo code for the serial algorithm of symmetric sparse matrix-vector multiplication in SSS format is:

[0043] A∈R N×N : matrix in SSS format;

[0044] x∈R N : input vector;

[0045] y∈R N : output vector;

[0046]

[0047] In one embodiment, Figure 1 As shown, a method for parallel acceleration of symmetric sparse matrix-vector multiplication shared memory is provided, which is applicable to a shared memory architecture computer and includes the following steps:

[0048] Step 100: Use the symmetric CSR format SSS to store the symmetric sparse matrix to be vector multiplied.

[0049] Specifically, the symmetric properties of the matrix are utilized to reduce the consumption of storage memory, increase the computational access-to-memory ratio, and optimize the memory access performance, so that the overall algorithm can break through the memory limitation and achieve faster running speed.

[0050] Step 102: Construct a conflict graph based on the data competition relationship between rows in the symmetric sparse matrix-vector multiplication.

[0051] Specifically, assuming that there is a non-zero element in the 2nd column of the 1st row, then when calculating this position, its symmetric position should be calculated at the same time, that is, the non-zero element in the 1st row will modify the 1st and 2nd positions of the output vector at the same time. Therefore, the 1st row will have data competition with the 2nd row and all other rows that will modify the 1st and 2nd positions of the output vector. This method constructs a conflict graph based on the competition relationship. The points in the graph correspond to a row of the matrix, and the edges correspond to a set of data competition relationships.

[0052] Figure 2 (a) shows the distribution of non-zero elements in a symmetric sparse matrix, where a point indicates that there is a non-zero element at that position. Figure 2 (b) is the conflict graph generated by this matrix. The points in the conflict graph represent the rows of the matrix, the number of the points corresponds to the number of the rows, and the edges represent conflicts. For example, there are three non-zero elements in the 0th row, in the 0th, 1st, and 8th columns, which means that there is data contention between the 0th row and the 1st and 8th rows, so node 0 is connected to node 1 and node 8 by edges.

[0053] Step 104: Calling a graph partitioning tool to logically partition the conflict graph into a number of subgraphs and isolation areas between adjacent subgraphs, and sorting the nodes in each subgraph.

[0054] Specifically, for the constructed conflict graph, by calling a grid partitioning tool such as METIS, the conflict graph is logically divided into several subgraphs and isolators between these subgraphs, so that after each partition, there is no data competition between all subgraphs except the isolators, and parallel processing can be performed. Use a sorting algorithm to sort the nodes (rows of sparse matrices) in each subgraph generated after the conflict graph is partitioned, so that the row numbers are continuous.

[0055] Figure 3 Shown Figure 2 The effect diagram after the conflict graph generated by the symmetric sparse matrix is ​​divided once. Figure 3As can be seen in the figure, the original conflict graph is divided into 4 subgraphs distinguished by 4 colors, and there are isolators between the 4 subgraphs. After the division, there is no direct edge connecting the 4 subgraphs, so the 4 subgraphs can be calculated in parallel. However, there is data contention between the isolator and the 4 subgraphs (the edges in the graph have been deleted, but there is still contention), so the isolator should be calculated after the subgraph calculation is completed.

[0056] Compared with the existing symmetric sparse matrix-vector multiplication method, this method sets up isolation areas so that there is no data competition between subgraphs, achieving large-scale parallel acceleration of the code. At the same time, the rows corresponding to the nodes in each subgraph are not far apart physically, which has a better memory access locality advantage.

[0057] Set up isolation zones to significantly improve the computing performance of symmetric sparse matrix-vector multiplication processing and significantly reduce the consumption of storage memory resources

[0058] Step 106: recursively divide the isolation area layer by layer and reorder all subgraphs and nodes in the isolation area, and organize and store them in the shared memory in the form of a tree until the number of matrix rows corresponding to the isolation area is less than a preset threshold, thereby obtaining a task dependency tree.

[0059] Specifically, after the isolators are merged, the division in step 103 is continuously recursively performed, the graph is continuously decomposed layer by layer, and organized and stored in the form of a tree until the number of matrix rows corresponding to the isolator is less than a specific threshold, and finally a task tree TDT is constructed. The recursive process will be organized and saved in the form of a tree.

[0060] Compared with the current symmetric sparse matrix-vector multiplication method, this method sets up isolation areas so that there is no data competition between subgraphs, achieving large-scale parallel acceleration of the code. At the same time, the rows corresponding to the nodes in each subgraph are not far apart physically, which has a better memory access locality advantage.

[0061] Step 108: Decompose the task of symmetric sparse matrix-vector multiplication according to the task dependency tree, and assign the decomposed tasks to corresponding processors.

[0062] Step 110: All processors use the symmetric CSR format SSS in a row-by-row parallel manner to first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

[0063] In the above-mentioned symmetric sparse matrix vector multiplication shared memory parallel acceleration method, the method includes: constructing a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix vector multiplication; calling the graph partitioning tool to logically divide the conflict graph into several subgraphs and isolation areas between adjacent subgraphs, and sorting the nodes in each subgraph; recursively partitioning the isolation area layer by layer and re-sorting all subgraphs and nodes in the isolation area, and organizing and storing them in the form of a TDT tree until the number of matrix rows corresponding to the isolation area is less than a specific threshold; using the symmetric CSR format SSS in a row-by-row parallel manner, first calculating all subgraphs in the TDT tree, and then calculating the isolation area. This method utilizes the matrix symmetry and sets the isolation area to greatly improve the computing performance of the symmetric sparse matrix vector multiplication calculation processing, increase the computing memory access ratio, optimize the memory access performance, and greatly reduce the consumption of storage memory resources.

[0064] This method

[0065] In one embodiment, the symmetric CSR format SSS in step 100 includes four arrays of row pointer position, column coordinates, non-zero element values ​​and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of the non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

[0066] Specifically, through the four arrays of row pointer positions, column coordinates, non-zero element values, and diagonal values, the SSS format can compactly store symmetric sparse matrices and retain the symmetric properties, thereby reducing the storage space requirements. At the same time, the SSS format still provides fast access to matrix elements.

[0067] In one embodiment, step 104 includes: calling the METIS graph partitioning tool to divide the conflict graph into several subgraphs; traversing the nodes in all subgraphs and detecting whether they have edges with the nodes of other subgraphs; for points that have edges with points in other subgraphs, removing the points from the original subgraph and dividing them into isolation areas; not processing points that have no edges with points in other subgraphs; reordering the nodes in each subgraph and the isolation area so that the node numbers in each area are continuous.

[0068] In one embodiment, step 106 includes: merging all isolation areas and performing recursive division layer by layer, reordering the nodes in the subgraph and isolation area after each division, and organizing and storing them in the form of a tree until the number of rows in the final isolation area is less than a preset threshold, thereby obtaining a task dependency tree.

[0069] Specifically, Figure 4This is a diagram of the tree structure after two recursive TDT constructions. Figure 4 Each node in represents a subgraph, and the subgraph contains continuous row intervals. Figure 3 The four subgraphs in Figure 4 In the left 4 nodes of the second layer, several isolation areas can be merged into a subgraph corresponding to the last node of the second layer. After each division, the rows in the subgraph and isolation area are reordered so that each node corresponds to a continuous row interval. The device will continue to recursively divide the isolation area until the number of rows in the final isolation area is less than the set threshold. The recursive process will be organized and saved in the form of a tree, which we call the Task Dependency Tree (TDT). Figure 4 Two recursions were performed in the process, and finally the number of rows in the isolation area was less than the threshold.

[0070] In one embodiment, TDT construction is divided into the following steps:

[0071] 1) Use graph partitioning tools such as METIS to divide the current graph into several subgraphs;

[0072] 2) Traverse all nodes in the subgraph and check whether they have edges with nodes in other subgraphs (that is, the two points on an edge belong to different subgraphs);

[0073] 3) For points that are connected to points in other subgraphs, remove the points from the original subgraph and divide them into the isolation area;

[0074] 4) Points that do not have edges with other subgraphs are not processed (they still belong to the atomic graph);

[0075] 5) Reorder the nodes in each subgraph and isolated area so that the node numbers in each area are continuous;

[0076] 6) Store the above information in a tree and continue to recursively perform operations 1 to 5 on the isolated area until the number of rows in the isolated area is less than a specific threshold.

[0077] Finally, it can be constructed as Figure 4 In the TDT shown, each node of the tree corresponds to a row of a continuous interval of the original matrix.

[0078] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0079] In one embodiment, Figure 5 As shown, a symmetric sparse matrix vector multiplication shared memory parallel acceleration device is provided, including: a symmetric sparse matrix storage module, a conflict graph construction module, a task dependency tree construction module and a task dependency tree execution module, wherein:

[0080] A symmetric sparse matrix storage module is used to store symmetric sparse matrices to be vector multiplied in a symmetric CSR format SSS;

[0081] A conflict graph construction module is used to construct a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix vector multiplication;

[0082] The task dependency tree construction module is used to call the graph partitioning tool to logically divide the conflict graph into several subgraphs and isolation zones between adjacent subgraphs, and sort the nodes in each subgraph; recursively partition the isolation zones layer by layer and re-sort the nodes in all subgraphs and isolation zones, and organize and store them in the shared memory in the form of a tree until the number of matrix rows corresponding to the isolation zone is less than the preset threshold, and the task dependency tree is obtained;

[0083] The task dependency tree execution module is used to decompose the task of symmetric sparse matrix-vector multiplication according to the task dependency tree and assign the decomposed tasks to the corresponding processors; all processors use the symmetric CSR format SSS in a row-parallel manner to first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

[0084] In one embodiment, the symmetric CSR format SSS in the symmetric sparse matrix storage module includes four arrays: row pointer position, column coordinates, non-zero element values ​​and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of the non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

[0085] In one of the embodiments, the task dependency tree construction module is also used to call the METIS graph partitioning tool to divide the conflict graph into several subgraphs; traverse the nodes in all subgraphs and detect whether they have edges with the nodes of other subgraphs; for points that have edges with points in other subgraphs, remove the points from the original subgraph and divide them into isolation areas; do not process points that have no edges with points in other subgraphs; reorder the nodes in each subgraph and isolation area so that the node numbers in each area are continuous.

[0086] In one of the embodiments, the task dependency tree construction module is also used to merge all isolation areas and then recursively divide them. After each division, the nodes in the subgraph and isolation area are reordered and organized and stored in the form of a tree until the number of rows in the final isolation area is less than a set threshold.

[0087] For the specific definition of the symmetric sparse matrix vector multiplication shared memory parallel acceleration device, please refer to the definition of the symmetric sparse matrix vector multiplication shared memory parallel acceleration method mentioned above, which will not be repeated here. Each module in the above-mentioned symmetric sparse matrix vector multiplication shared memory parallel acceleration device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0088] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a symmetric sparse matrix vector multiplication shared memory parallel acceleration method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0089] Those skilled in the art will understand that Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0090] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.

[0091] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0092] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A symmetric sparse matrix-vector multiplication shared memory parallel acceleration method, characterized in that: The method is applicable to a shared storage architecture computer, and the method comprises: The symmetric CSR format SSS is used to store the symmetric sparse matrix to be vector multiplied. Construct a conflict graph based on the data competition relationship between rows in the symmetric sparse matrix-vector multiplication; The call graph partitioning tool logically divides the conflict graph into a plurality of subgraphs and isolation areas between adjacent subgraphs, and sorts the nodes in each of the subgraphs; Recursively dividing the isolation area layer by layer and reordering all subgraphs and nodes in the isolation area, and organizing and storing them in a shared memory in the form of a tree until the number of matrix rows corresponding to the isolation area is less than a preset threshold, thereby obtaining a task dependency tree; Decomposing the task of symmetric sparse matrix-vector multiplication according to the task dependency tree, and assigning the decomposed tasks to corresponding processors; All processors use the symmetric CSR format SSS in a row-parallel manner to first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

2. The method according to claim 1, characterized in that: The symmetric CSR format SSS includes four arrays: row pointer position, column coordinates, non-zero element values ​​and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

3. The method according to claim 1, characterized in that Calling a grid partitioning tool to logically partition the conflict graph into a plurality of subgraphs and isolation zones between adjacent subgraphs, and sorting the nodes in each subgraph, including: Calling the METIS graph partitioning tool to partition the conflict graph into a plurality of sub-graphs; Traverse all nodes in the subgraph and check whether they have edges with nodes in other subgraphs; For points that are connected to points in other subgraphs, remove the point from the original subgraph and divide it into the isolation area; Points that do not have edges with other subgraphs are not processed; The nodes in each subgraph and the isolation area are reordered so that the node numbers in each area are continuous.

4. The method according to claim 1, characterized in that: The isolation area is recursively divided layer by layer and all subgraphs and nodes in the isolation area are reordered, and organized and stored in the form of a tree until the number of matrix rows corresponding to the isolation area is less than a preset threshold, and a task dependency tree is obtained, including: After merging all isolation areas, they are recursively divided layer by layer. After each division, the nodes in the subgraph and isolation area are reordered and organized and stored in the form of a tree until the number of rows in the final isolation area is less than the preset threshold, and the task dependency tree is obtained.

5. A symmetric sparse matrix-vector multiplication shared memory parallel acceleration device, characterized in that: The device comprises: A symmetric sparse matrix storage module is used to store symmetric sparse matrices to be vector multiplied in a symmetric CSR format SSS; A conflict graph construction module is used to construct a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix vector multiplication; The task dependency tree construction module is used to call the graph partitioning tool to logically divide the conflict graph into a number of subgraphs and isolation areas between adjacent subgraphs, and sort the nodes in each subgraph; recursively partition the isolation areas layer by layer and re-sort the nodes in all subgraphs and isolation areas, and organize and store them in the shared memory in the form of a tree until the number of matrix rows corresponding to the isolation area is less than a preset threshold, thereby obtaining a task dependency tree; The task dependency tree execution module is used to decompose the task of symmetric sparse matrix-vector multiplication according to the task dependency tree, and assign the decomposed tasks to the corresponding processors; all processors use the symmetric CSR format SSS in a row-parallel manner to first calculate the tasks corresponding to all subgraphs in the task dependency tree, and then calculate the tasks corresponding to the isolation area.

6. The device according to claim 5, characterized in that The symmetric CSR format SSS in the symmetric sparse matrix storage module includes four arrays: row pointer position, column coordinates, non-zero element values ​​and diagonal value arrays; wherein the row pointer position array is used to record the index of the position of the first non-zero element in each row in the non-zero value array; the column coordinate array is used to store the column index of each non-zero element; the non-zero element value array is used to store the values ​​of non-zero elements; and the diagonal value array is used to store the values ​​of the diagonal elements of the symmetric matrix.

7. The device according to claim 5, characterized in that The task dependency tree construction module is also used to call the METIS graph partitioning tool to divide the conflict graph into several subgraphs; traverse the nodes in all subgraphs and detect whether they have edges with the nodes of other subgraphs; for points that have edges with points in other subgraphs, remove the points from the original subgraph and divide them into isolation areas; do not process points that have no edges with points in other subgraphs; reorder the nodes in each subgraph and the isolation area so that the node numbers in each area are continuous.

8. The device according to claim 5, characterized in that The task dependency tree construction module is also used to merge all isolation areas and then recursively divide them. After each division, the nodes in the subgraph and isolation area are reordered and organized and stored in the form of a tree until the number of rows in the final isolation area is less than the set threshold.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method optimizing sparse matrix vector multiplication to improve incompressible pipe flow simulation efficiency

    CN103984527A

  • Optimization method for sparse dense matrix multiplication parallel algorithm based on CSR characteristics

    CN114048035A

  • Techniques for accelerating matrix multiplication calculations using hierarchical representations of sparse matrices

    CN115374396A

  • Compression storage of sparse matrix and parallel processing method of vector multiplication of sparse matrix

    CN116257209A

  • Data processing method for large-scale complex sparse matrix acceleration calculation of improved CSR

    CN118296289A