Symmetric sparse matrix vector multiplication hybrid acceleration method, device and equipment

Through symmetric CSR format and graph division technology, a task dependency tree is built, combined with a hybrid acceleration strategy, the problem of insufficient parallelism of symmetric sparse matrices is solved, and the computing performance and storage efficiency are improved.

CN119089101AActive Publication Date: 2024-12-06NAT UNIV OF DEFENSE TECH

Patent Information

Application Number
CN202411227262.1
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

In the prior art, although the symmetrical properties can reduce storage space when processing symmetric sparse matrices, the calculation performance is poor due to insufficient parallelism, especially in the case of many conflicts.

Method used

Sparse matrix is ​​stored in a symmetric CSR format, and by constructing conflict graphs, molecular graphs and isolation areas, using graph division tools to sort and recursively divide, forming a task-dependent tree, and combining a hybrid acceleration strategy based on symmetric CSR formats and CSR formats for parallelism calculate.

Benefits of technology

It reduces storage memory consumption, improves the calculation and memory access ratio, and improves the computing performance of symmetric sparse matrices for more conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119089101A_ABST
    Figure CN119089101A_ABST
Patent Text Reader

Abstract

The invention relates to a hybrid acceleration method, device and equipment for symmetric sparse matrix vector multiplication. The method comprises the following steps: storing a symmetric sparse matrix by adopting a symmetric CSR format SSS; constructing a conflict graph according to the symmetric sparse matrix vector multiplied by a data competition relationship between rows; dividing the conflict graph into a plurality of sub-graphs and isolation areas between adjacent sub-graphs by adopting a graph division tool; recursively dividing the isolation region layer by layer until the number of divided layers reaches a preset number, and obtaining a task dependency tree; decomposing the vector multiplication task according to the task dependency tree and distributing the decomposed vector multiplication task to a processor; the processor performs parallel computing by adopting a hybrid acceleration strategy; the hybrid acceleration strategy is a hybrid of a row-by-row parallel strategy based on the symmetric CSR format SSS and a row-by-row parallel strategy based on the CSR. According to the method, the advantages of two strategies are combined, the consumption of a storage memory is reduced, and the calculation memory access ratio is increased; and a CSR row parallel strategy is used for the part with more conflicts and poorer symmetric parallelism, so that the overall performance is improved.
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 symmetric sparse matrix-vector multiplication hybrid acceleration method, device and equipment. Background Art

[0002] Sparse matrix-vector multiplication (SpMV) multiplies a sparse matrix by a vector. A sparse matrix is ​​a matrix where most of the elements are zero. The vector itself can be sparse, but is usually dense. Sparse matrix-vector multiplication is a general operation that is widely used in scientific applications, economic models, data mining, and information retrieval. For example, it is used in solving sparse linear equations and eigenvalue problems using iteration.

[0003] For sparse matrices, usually only non-zero elements are stored to save storage space and improve computing efficiency. People have proposed a variety of sparse matrix storage formats, and there are three main sparse matrix storage formats: COO, CSR, and CSC. In addition to the above mainstream formats, existing research results have also proposed some special formats to meet the requirements of different types of sparse matrices and parallel computing. There are different matrix-vector multiplication parallel algorithms for different storage formats. At present, the most common algorithm is a row-by-row parallel algorithm based on the CSR format. This algorithm is suitable for situations where non-zero elements in sparse matrices are relatively evenly distributed, and has poor effects on 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] In practical applications, 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, for symmetric sparse matrices with more conflicts, due to their own lack of parallelism, the effect will be worse than when symmetry is not used. Summary of the invention

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

[0006] A symmetric sparse matrix-vector hybrid acceleration method, the method is 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 division layers reaches the preset number, and the division is stopped to obtain the task dependency tree.

[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 use a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a mixture of a row-by-row parallel strategy based on the symmetric CSR format SSS and a row-by-row parallel strategy based on the CSR format.

[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, all processors use a hybrid acceleration strategy for parallel computing, including:

[0015] Each processor first uses the symmetric CSR format SSS row-by-row parallel strategy to calculate the tasks corresponding to all subgraphs of the task dependency tree in the assigned task, and then uses the CSR format row-by-row parallel strategy to calculate the tasks corresponding to the isolation area.

[0016] 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:

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

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

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

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

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

[0022] 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 a shared memory in the form of a tree until the number of division layers reaches a preset number of layers, and the division is stopped to obtain a task dependency tree, including:

[0023] After all isolation areas are merged, they are recursively divided layer by layer. After each division, the nodes in the subgraph and isolation area are reordered, organized and stored in the shared memory in the form of a tree until the number of division layers reaches the preset number, and the division is stopped to obtain the task dependency tree.

[0024] A symmetric sparse matrix-vector multiplication hybrid acceleration device, comprising:

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

[0026] 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.

[0027] 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 area 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 division layers reaches the preset number of layers, then stop the division and obtain the task dependency tree.

[0028] 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 adopt a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a mixture of a row-by-row parallel strategy based on the symmetric CSR format SSS and a row-by-row parallel strategy based on the CSR format.

[0029] 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.

[0030] In one of the embodiments, the task dependency tree execution module is also used for each processor to first calculate the tasks corresponding to all subgraphs of the task dependency tree in the assigned task using a symmetric CSR format SSS row-by-row parallel strategy, and then calculate the tasks corresponding to the isolation area using the CSR format row-by-row parallel strategy.

[0031] 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.

[0032] 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.

[0033] The above-mentioned hybrid acceleration method, device and equipment for sparse matrix vector multiplication include: using symmetric CSR format SSS to store symmetric sparse matrices to be vector multiplied; constructing a conflict graph according to the data competition relationship between rows in the symmetric sparse matrix vector multiplication; calling a 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 reordering the nodes in all subgraphs and isolation areas, and organizing and storing them in a shared memory in the form of a tree until the number of partitioning layers reaches a preset number of layers and the partitioning is stopped to obtain 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 the corresponding processors; all processors use a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a hybrid of a row-by-row parallel strategy based on a symmetric CSR format SSS and a row-by-row parallel strategy based on a CSR format. This method combines the advantages of the two strategies, reduces the consumption of storage memory, and increases the computing memory access ratio; the CSR row parallel strategy is used for parts with more conflicts and poor symmetric parallelism to improve overall performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of a flow chart of a symmetric sparse matrix-vector multiplication hybrid acceleration method in one embodiment;

[0035] Figure 2A 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;

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

[0037] Figure 4 It is a schematic diagram of a tree structure after TDT is constructed under a hybrid acceleration strategy in another embodiment;

[0038] Figure 5 A structural block diagram of a symmetric sparse matrix-vector multiplication hybrid acceleration device in one embodiment;

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

[0040] 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.

[0041] 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).

[0042] 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).

[0043] From the pseudocode of the serial algorithm of symmetric sparse matrix-vector multiplication in SSS format (Sparse Symmetric Skyline, called symmetric CSR format), 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 should 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 method to solve this data competition problem.

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

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

[0046] x∈RN: input vector;

[0047] y∈RN: output vector;

[0048]

[0049] In one embodiment, Figure 1 As shown, a symmetric sparse matrix-vector multiplication hybrid acceleration method is provided, which includes the following steps:

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

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

[0052] 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.

[0053] Figure 2 (a) shows the distribution of non-zero elements in a symmetric sparse matrix, where a black dot indicates a non-zero element. 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.

[0054] 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.

[0055] 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.

[0056] Figure 3 Shown Figure 2 The effect diagram after the conflict graph generated by the symmetric sparse matrix is ​​divided once. Figure 3 As 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.

[0057] Step 106: recursively partition the isolation area layer by layer and reorder all subgraphs and nodes in the isolation area, and organize and store them in the form of a tree in the shared memory until the number of partition layers reaches a preset number, then stop partitioning to obtain a task dependency tree.

[0058] Specifically, after the isolators are merged, the division in step 103 is continuously and recursively performed, the graph is continuously decomposed layer by layer, and the graph is organized and stored in the form of a tree until the number of division layers reaches a preset number, and the division is stopped, and finally a task dependency tree (TDT) is constructed. The recursive process will be organized and saved in the form of a tree.

[0059] 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.

[0060] Step 110: All processors adopt a hybrid acceleration strategy to perform parallel computing; the hybrid acceleration strategy is a mixture of a row-by-row parallel strategy based on the symmetric CSR format SSS and a row-by-row parallel strategy based on the CSR format.

[0061] Specifically, the two parts of the matrix are accelerated using the SSS row parallel algorithm with symmetric properties and the CSR row parallel algorithm without symmetric properties, which is called a hybrid acceleration strategy; the hybrid acceleration strategy is mainly used for symmetric sparse matrices with a large number of conflicts, densely generated conflict graphs, and small symmetric parallelism. This strategy combines the advantages of the two methods, that is, it uses symmetry to calculate a part of the matrix rows, and uses CSR row parallelism to implement the part with more conflicts and poor symmetric parallelism, so that the overall performance is further improved.

[0062] The above-mentioned hybrid acceleration method of sparse matrix vector multiplication includes: using symmetric CSR format SSS to store symmetric sparse matrices to be vector multiplied; constructing a conflict graph according to the data competition relationship between rows in symmetric sparse matrix vector multiplication; calling a 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 reordering the nodes in all subgraphs and isolation areas, and organizing and storing them in the shared memory in the form of a tree until the number of partitioning layers reaches a preset number of layers and the partitioning is stopped to obtain 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 the corresponding processors; all processors use a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a hybrid of a row-by-row parallel strategy based on a symmetric CSR format SSS and a row-by-row parallel strategy based on a CSR format. This method combines the advantages of the two strategies, reduces the consumption of storage memory, and increases the computing memory access ratio; the CSR row parallel strategy is used for parts with more conflicts and poor symmetric parallelism to improve overall performance.

[0063] In one embodiment, the symmetric CSR format SSS in step 100 includes four arrays of 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.

[0064] 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.

[0065] In one embodiment, step 110 includes: each processor first calculates the tasks corresponding to all subgraphs of the task dependency tree in the assigned task using a symmetric CSR format SSS row-parallel strategy, and then calculates the isolation area.

[0066] In one embodiment, step 102 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; for points that have no edges with points in other subgraphs, no processing is performed; and the nodes in each subgraph and the isolation area are reordered so that the node numbers in each area are continuous.

[0067] In one embodiment, step 104 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 in a shared memory until the number of division layers reaches a preset number and the division is stopped to obtain a task dependency tree.

[0068] Specifically, Figure 4 Schematic diagram of the tree structure after TDT construction is completed under the hybrid acceleration strategy. The hybrid acceleration strategy refers to a hybrid strategy of the SSS row parallel algorithm that uses symmetric properties and the CSR row parallel algorithm that does not use symmetric properties. Although the SSS row parallel algorithm that uses symmetric properties can use symmetry to improve the computational memory access ratio and thus improve performance, for symmetric sparse matrices with many conflicts, due to its own lack of parallelism, the effect will be worse than when symmetry is not used. A hybrid acceleration strategy is proposed to address this type of problem. Figure 4 Each node in represents a subgraph, which contains continuous row intervals. Figure 3 The four subgraphs in Figure 4 The four nodes on the left 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 will be reordered so that each node corresponds to a continuous row interval. Continue to recursively divide the isolation area. When the number of division layers reaches K, stop dividing. The remaining isolation areas will no longer use the symmetric property, but directly use the CSR format for parallel calculation by row. The recursive process will be organized and saved in the form of a tree, which we call a task tree (TDT).

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

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

[0071] 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);

[0072] 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;

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

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

[0075] 6) Store the above information in the tree and continue to recursively perform operations 1 to 5 on the isolation area until the division is stopped when the number of division levels reaches K.

[0076] 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.

[0077] 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 1 At 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.

[0078] In one embodiment, Figure 5 As shown, a symmetric sparse matrix-vector multiplication hybrid acceleration device is provided, comprising: 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:

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

[0080] 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.

[0081] 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 area 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 division layers reaches the preset number of layers, then stop the division and obtain the task dependency tree.

[0082] 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 adopt a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a mixture of a strategy based on row parallelism in the symmetric CSR format SSS and a strategy based on row parallelism in the CSR format.

[0083] 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.

[0084] In one of the embodiments, the task dependency tree execution module is also used for each processor to first calculate the tasks corresponding to all subgraphs of the task dependency tree in the assigned task using a symmetric CSR format SSS row-by-row parallel strategy, and then calculate the tasks corresponding to the isolation area using the CSR format row-by-row parallel strategy.

[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 the isolation areas and then recursively divide them layer by layer. After each division, the nodes in the subgraph and the isolation area are reordered and organized and stored in the shared memory in the form of a tree until the number of division layers reaches a preset number and the division is stopped to obtain the task dependency tree.

[0087] For the specific definition of the symmetric sparse matrix-vector multiplication hybrid acceleration device, please refer to the definition of the symmetric sparse matrix-vector multiplication hybrid acceleration method mentioned above, which will not be repeated here. Each module in the above-mentioned symmetric sparse matrix-vector multiplication hybrid 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 hybrid 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 6 The 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 hybrid 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 divide the isolation area layer by layer and reorder all subgraphs and nodes in the isolation area, organize and store them in the shared memory in the form of a tree until the number of division layers reaches the preset number, and then stop dividing to obtain the task dependency tree; Decompose the task of symmetric sparse matrix-vector multiplication according to the task dependency tree, and assign the decomposed tasks to corresponding processors; All processors adopt a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a mixture of a row-by-row parallel strategy based on a symmetric CSR format SSS and a row-by-row parallel strategy based on a CSR format.

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 All processors use a hybrid acceleration strategy for parallel computing, including: Each processor first calculates the tasks corresponding to all subgraphs of the task dependency tree in the assigned tasks using a row-by-row parallel strategy based on the symmetric CSR format SSS, and then calculates the tasks corresponding to the isolation area using a row-by-row parallel strategy based on the CSR format.

4. 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.

5. The method according to claim 1, characterized in that Recursively divide the isolation area layer by layer and reorder all subgraphs and nodes in the isolation area, organize and store them in the shared memory in the form of a tree until the number of division layers reaches the preset number, and then stop dividing to obtain the task dependency tree, including: After all isolation areas are merged, they are recursively divided layer by layer. After each division, the nodes in the subgraph and isolation area are reordered, organized and stored in the shared memory in the form of a tree until the number of division layers reaches the preset number, and the division is stopped to obtain the task dependency tree.

6. A symmetric sparse matrix-vector multiplication hybrid accelerator, 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 form of a tree in a shared memory until the number of partition layers reaches a preset number, and then stop partitioning to obtain a task dependency tree; A 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 adopt a hybrid acceleration strategy for parallel computing; the hybrid acceleration strategy is a mixture of a row-by-row parallel strategy based on the symmetric CSR format SSS and a row-by-row parallel strategy based on the CSR format.

7. The device according to claim 6, 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.

8. The device according to claim 6, characterized in that The task dependency tree execution module is also used for each processor to first calculate the tasks corresponding to all subgraphs of the task dependency tree in the assigned tasks using a row-by-row parallel strategy based on the symmetric CSR format SSS, and then calculate the tasks corresponding to the isolation area using the CSR format row-by-row parallel strategy.

9. 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.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

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

    CN114048035A

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

    CN116257209A

  • Sparse matrix vector multiplication method and device based on heterogeneous many-core processor

    CN116910432A

  • GPU acceleration optimization method and device based on sparse matrix vector multiplication

    CN117495651A

  • Parallel processing method and system for sparse dense matrix data

    CN118245206A

Cited By

  • Sampling-based graph neural network acceleration method and device

    CN120745691A