Triangle counting implementation method and device of graphics processor

By building lock-free hash tree and index array in the graphics processor, identifying and processing the list of vertex neighbors in the graphics data, the problem of low computing power and memory fetching efficiency in triangle counting is solved, and more efficient calculations are achieved and memory access.

CN119474464AActive Publication Date: 2025-02-18WUHAN UNIV

Patent Information

Application Number
CN202411375676.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-18
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

During the triangle counting process, the GPU's computing power, computing efficiency and memory access efficiency are low, mainly due to branch divergence operations that cause thread waiting, and irregular memory access affects the performance of the GPU.

Method used

By obtaining the graphics data of the graphics processor, identifying the neighbor list of all vertices, and building a hash tree in a lock-free way, creating an indexed array to achieve triangle counting. This method avoids lock competition, alleviates branch divergence, and improves memory access efficiency.

Benefits of technology

It effectively improves the computing power, computing efficiency and memory access efficiency of GPU in triangle counting, and solves the performance bottlenecks caused by thread waiting and irregular memory access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474464A_ABST
    Figure CN119474464A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to a triangle counting implementation method and device for a graphics processor, and the method comprises the steps: obtaining graphic data of the graphics processor; recognizing neighbor lists of all the vertexes in the graphic data, constructing a hash tree without a lock according to the neighbor lists of all the vertexes, and establishing an index array of the hash tree corresponding to all the vertexes; when the vertex of the target graph is accessed, traversing all neighbor graph nodes of the vertex of the target graph in parallel, and mapping neighbor lists of all neighbor graph nodes to a continuous memory area; and realizing triangle counting based on the index array and the continuous memory region. Therefore, the problems of poor GPU computing power, computing efficiency, memory access efficiency and the like during triangle counting in related technologies are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method and device for implementing triangle counting of a graphics processor. Background Art

[0002] A triangle consists of three interconnected vertices in a graph. If a graph is represented by G = (V, E), where V and E are vertex and edge sets respectively, {s, v, t} ∈ V and {(s, v), (s, t), (v, t)} ∈ E. Triangle counting (TC) is one of the basic graph mining tasks widely used in social network analysis and pattern recognition applications. It is also regarded as a special case of counting short cycles or small groups.

[0003] Due to the increasing number of edges in real-world graphs, there has been significant research into improving the efficiency of parallel algorithms for computing exact and approximate triangle counts. Most of the current state-of-the-art work focuses on handling large-scale graphs and leveraging shared memory platforms to improve algorithm performance. Previous approaches have classified triangle counting algorithms into four categories such as set intersection, matrix multiplication, wedge sampling, and approximate methods.

[0004] In order to achieve triangle counting on large-scale graph data, GPUs (Graphics Processing Units) are widely used. However, due to the large number of branch divergence operations in the triangle counting process, there are a large number of thread waits during the execution on the GPU, which seriously limits the computing power and efficiency of the GPU. In addition, the GPU can only reach its peak performance in a data model with regular memory access, but there are a large number of irregular memory accesses in the triangle counting process, which seriously affects the memory access efficiency of the GPU. Summary of the invention

[0005] The present application provides a method and device for implementing triangle counting of a graphics processor to solve the problems of poor GPU computing power, computing efficiency and memory access efficiency when counting triangles in the related art.

[0006] The first aspect of the present application provides a method for implementing triangle counting of a graphics processor, comprising the following steps: obtaining graphics data of a graphics processor; identifying neighbor lists of all vertices in the graphics data, constructing a hash tree in a lock-free manner based on the neighbor lists of all vertices, and establishing an index array of the hash tree corresponding to all vertices; when accessing a target graph vertex, traversing all neighbor graph nodes of the target graph vertex in parallel, and mapping the neighbor lists of all neighbor graph nodes to a continuous memory area; and implementing triangle counting based on the index array and the continuous memory area.

[0007] Optionally, mapping the neighbor lists of all neighbor graph nodes to a continuous memory area includes: constructing at least one set of vertex pairs based on the target graph vertex and all neighbor graph nodes, and mapping the neighbor lists of the target graph vertex and the corresponding neighbor graph node in each set of vertex pairs to a continuous memory area.

[0008] Optionally, triangle counting is implemented based on an index array and a continuous memory area, including: determining a hash tree for each set of vertex pairs based on the index array; retrieving a neighbor list for each set of vertex pairs based on the hash tree to see if there are identical neighbors; if there are identical neighbors, taking the target graph vertices and neighbor graph nodes corresponding to the identical neighbors and vertex pairs as triplets, and implementing triangle counting based on the triplets.

[0009] Optionally, a hash tree is constructed in a lock-free manner based on the neighbor lists of all vertices, including: obtaining a target number of paths of the hash tree nodes; calculating the hash value of the vertex and the hash value of the neighbor graph node in the neighbor list of the vertex, and inserting the vertex and the neighbor graph node into the storage bucket of the corresponding hash tree node; if there are multiple neighbor graph nodes with the same hash value in the neighbor graph node of the vertex, then the multiple neighbor graph nodes are sequentially placed in the next position of the hash tree node until the number of nodes stored in the current hash tree reaches the target number of paths; if the number of nodes stored in the current hash tree reaches the target number of paths, then the multiple neighbor graph nodes with the same hash value are placed in a new storage bucket of the node of the current hash tree.

[0010] Optionally, an index array of hash trees corresponding to all vertices is established, including: obtaining the arrangement order of all vertices and the addresses of the nodes of the target level of the hash trees corresponding to all vertices; constructing an index array based on the arrangement order and the addresses of the nodes of the target level of the hash trees corresponding to all vertices, wherein each element in the index array is a pointer to a node of the target level of the hash tree.

[0011] Optionally, the neighbor list of each group of vertex pairs is retrieved based on the hash tree to see whether there are identical neighbors, including: obtaining the neighbor list of the corresponding neighbor graph node in each group of vertex pairs; loading the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array; determining the length of the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node; constructing a hash tree based on the neighbor list of shorter length, and determining the neighbor list of longer length as the search space; enumerating each element in the search space, and retrieving based on the hash tree whether there are identical elements, wherein identical elements are identical neighbors.

[0012] The second aspect of the present application provides a triangle counting implementation device for a graphics processor, including: an acquisition module, used to acquire graphics data of the graphics processor; a building module, used to identify the neighbor lists of all vertices in the graphics data, build a hash tree in a lock-free manner based on the neighbor lists of all vertices, and establish an index array of the hash tree corresponding to all vertices; a mapping module, used to traverse all neighbor graph nodes of the target graph vertex in parallel when accessing the target graph vertex, and map the neighbor lists of all neighbor graph nodes to a continuous memory area; an implementation module, used to implement triangle counting based on the index array and the continuous memory area.

[0013] Optionally, the mapping module is further used to: construct at least one set of vertex pairs based on the target graph vertex and all neighbor graph nodes, and map the neighbor list of the target graph vertex and the corresponding neighbor graph node in each set of vertex pairs to a continuous memory area.

[0014] Optionally, the implementation module is further used to: determine the hash tree of each group of vertex pairs based on the index array; retrieve the neighbor list of each group of vertex pairs based on the hash tree to see if there are identical neighbors; if there are identical neighbors, take the target graph vertices and neighbor graph nodes corresponding to the identical neighbors and vertex pairs as triplets, and implement triangle counting based on the triplets.

[0015] Optionally, the establishment module is further used to: obtain the target number of nodes in the hash tree; calculate the hash value of the vertex and the hash value of the neighbor graph node in the neighbor list of the vertex, and insert the vertex and the neighbor graph node into the storage bucket of the corresponding hash tree node; if there are multiple neighbor graph nodes with the same hash value in the neighbor graph node of the vertex, then the multiple neighbor graph nodes are placed in the next position of the node of the hash tree in sequence until the number of nodes stored in the current hash tree reaches the target number of nodes; if the number of nodes stored in the current hash tree reaches the target number of nodes, then the multiple neighbor graph nodes with the same hash value are placed in a new storage bucket of the node of the current hash tree.

[0016] Optionally, the establishment module is further used to: obtain the arrangement order of all vertices and the addresses of the target level nodes of the hash tree corresponding to all vertices; construct an index array based on the arrangement order and the addresses of the target level nodes of the hash tree corresponding to all vertices, wherein each element in the index array is a pointer to the node of the target level of the hash tree.

[0017] Optionally, the mapping module is further used to: obtain the neighbor list of the corresponding neighbor graph node in each group of vertex pairs; load the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array; determine the length of the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node; build a hash tree based on the neighbor list with short length, and determine the neighbor list with long length as the search space; enumerate each element in the search space, and retrieve whether there is an identical element based on the hash tree, wherein the identical elements are the same neighbors.

[0018] A third aspect of the present application provides a graphics processor, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to execute a triangle counting implementation method of the graphics processor as described in the above embodiment.

[0019] A fourth aspect of the present application provides a computer-readable storage medium having a computer program or instructions stored thereon, and the computer program or instructions are executed by a processor to execute a triangle counting implementation method for a graphics processor as in the above-mentioned embodiment.

[0020] The fifth aspect of the present application provides a computer program product, including a computer program or instructions. When the computer program or instructions are executed, the triangle counting implementation method of the graphics processor as in the above embodiment is implemented.

[0021] Therefore, this application has at least the following beneficial effects:

[0022] The embodiment of the present application can obtain the graphic data in the graphics processor, identify the neighbor list of all vertices, and build a hash tree in a lock-free manner according to the neighbor list of all vertices, thereby avoiding the performance bottleneck caused by lock competition in a multi-threaded or multi-GPU environment, alleviating the branch divergence in execution, and fully considering the size of the memory space on the GPU and the highly parallel characteristics. By establishing an index array of hash trees corresponding to all vertices, the neighbor list of each vertex can be quickly accessed, thereby improving the efficiency of subsequent operations. When accessing the target graph vertex, all neighbor vertices of the target vertex are traversed in parallel, and the neighbor list is mapped to a continuous memory area, which improves memory access efficiency and reduces memory access latency. Triangle counting is realized based on index arrays and continuous memory areas, effectively improving the computing power, computing efficiency and memory access efficiency of the GPU when applied to triangle counting. Therefore, the technical problems of poor GPU computing power, computing efficiency and memory access efficiency when counting triangles in the related technology are solved.

[0023] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0025] Figure 1 A flowchart of a method for implementing triangle counting of a graphics processor according to an embodiment of the present application;

[0026] Figure 2 A flowchart of a triangle counting method provided according to an embodiment of the present application;

[0027] Figure 3 A schematic diagram of constructing a lock-free hash tree according to an embodiment of the present application;

[0028] Figure 4 A schematic diagram of an index array provided according to an embodiment of the present application;

[0029] Figure 5 An exemplary diagram of a device for implementing triangle counting of a graphics processor according to an embodiment of the present application;

[0030] Figure 6 The figure is a schematic diagram of the structure of a graphics processor provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0031] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0032] The following describes a method and device for implementing triangle counting in a graphics processor according to an embodiment of the present application with reference to the accompanying drawings. In view of the problem mentioned in the background technology center that there are a large number of branch divergence operations in the triangle counting process, which causes a large number of thread waiting in the execution process on the GPU, thereby seriously limiting the computing power and computing efficiency of the GPU, and the GPU can only reach its performance peak in the data model of regular memory access, but there are a large number of irregular memory accesses in the triangle counting process, which seriously affects the memory access efficiency of the GPU. The present application provides a triangle counting implementation method for a graphics processor. In this method, by obtaining graphic data in the graphics processor and identifying the neighbor lists of all vertices, a hash tree is constructed in a lock-free manner according to the neighbor lists of all vertices, thereby avoiding performance bottlenecks caused by lock competition in a multi-threaded or multi-GPU environment, alleviating branch divergence in execution, fully considering the size of the memory space on the GPU and the highly parallel characteristics, and by establishing an index array of hash trees corresponding to all vertices, the neighbor list of each vertex can be quickly accessed, thereby improving the efficiency of subsequent operations. When accessing the target graph vertex, all neighbor vertices of the target vertex are traversed in parallel, and the neighbor list is mapped to a continuous memory area, thereby improving memory access efficiency, reducing memory access latency, and implementing triangle counting based on index arrays and continuous memory areas. Therefore, the problems of poor GPU computing power, computing efficiency and memory access efficiency when counting triangles in the related art are solved.

[0033] Specifically, Figure 1 A flowchart of a method for implementing triangle counting in a graphics processor provided in an embodiment of the present application.

[0034] like Figure 1 As shown, the triangle counting implementation method of the graphics processor includes the following steps:

[0035] In step S101 , graphics data of a graphics processor is acquired.

[0036] The graphic may be a polygon, and the graphic data may be vertices of the graphic and a neighbor list of the vertices.

[0037] In step S102, neighbor lists of all vertices in the graph data are identified, hash trees are constructed in a lock-free manner according to the neighbor lists of all vertices, and index arrays of the hash trees corresponding to all vertices are established.

[0038] It can be understood that the embodiments of the present application can identify the neighbor lists of all vertices in the graph data, and then construct a hash tree in a lock-free manner based on the neighbor lists of all vertices, and establish an index array of the hash tree corresponding to all vertices. By constructing the hash tree in a lock-free manner, hash conflicts are reduced, thereby alleviating branch divergences in subsequent executions. The specific method for constructing the hash tree is as follows.

[0039] For example, the vertices of the graph are A, B, C, D, and E, and the neighbor list of A is {B, C, D}, and then a hash tree is constructed based on [B, C, D].

[0040] In an embodiment of the present application, a hash tree is constructed in a lock-free manner based on the neighbor lists of all vertices, including: obtaining a target number of paths of the hash tree node; calculating the hash value of the vertex and the hash value of the neighbor graph node in the neighbor list of the vertex, and inserting the vertex and the neighbor graph node into the storage bucket of the corresponding hash tree node; if there are multiple neighbor graph nodes with the same hash value in the neighbor graph node of the vertex, then the multiple neighbor graph nodes are sequentially placed in the next position of the hash tree node until the number of nodes stored in the current hash tree reaches the target number of paths; if the number of nodes stored in the current hash tree reaches the target number of paths, then the multiple neighbor graph nodes with the same hash value are placed in a new storage bucket of the node of the current hash tree.

[0041] The target number of ways is the number of buckets that each hash tree can store vertices, represented by H. The hash tree defaults to a 32-way trie (ie, H=32). The width of the hash tree can also be set according to the number of CTA threads in different CTA thread organization methods, and there is no specific limitation on this.

[0042] It can be understood that the embodiments of the present application can calculate the hash values ​​of the vertex and the neighbor graph nodes in the neighbor list of the vertex, insert the vertex and the neighbor graph nodes into the storage bucket of the node of the corresponding hash tree, and if there are multiple neighbor graph nodes with the same hash value in the neighbor graph node of the vertex, then the multiple neighbor graph nodes are placed in the next position of the node of the hash tree in sequence until the number of nodes stored in the current hash tree reaches the target number, and if the number of nodes stored in the current hash tree reaches the target number, then the multiple neighbor graph nodes with the same hash value are placed in the new storage bucket of the node of the current hash tree.

[0043] That is, the embodiment of the present application adopts an optimistic strategy to handle conflicts that occur when building a hash trie without lock operations. This strategy places the conflicting items next to the original items at the next position of the same node without lock operations until the hash trie node is full, avoiding performance bottlenecks caused by lock contention in a multi-threaded or multi-GPU environment.

[0044] In an embodiment of the present application, an index array of a hash tree corresponding to all vertices is established, including: obtaining the arrangement order of all vertices and the addresses of the nodes of the target level of the hash tree corresponding to all vertices; constructing an index array based on the arrangement order and the addresses of the nodes of the target level of the hash tree corresponding to all vertices, wherein each element in the index array is a pointer to a node of the target level of the hash tree.

[0045] It can be understood that the embodiments of the present application can construct an index array based on the arrangement order of all vertices and the addresses of the target level nodes of the hash tree corresponding to all vertices, wherein each element in the index array is a pointer to the node of the target level of the hash tree, so that the neighbor list of each vertex can be quickly accessed based on the index array, thereby improving the efficiency of subsequent operations.

[0046] The embodiment of the present application uses an index array to compactly organize the index of the hash tree, and each element in the array is a pointer to a node at a certain level of the hash tree.

[0047] In step S103, when accessing a target graph vertex, all neighbor graph nodes of the target graph vertex are traversed in parallel, and neighbor lists of all neighbor graph nodes are mapped to a continuous memory area.

[0048] The target graph vertex is a graph vertex that is desired or required to be accessed, for example, the target graph vertex is vertex A in the graph.

[0049] It can be understood that the embodiments of the present application can traverse all neighbor graph nodes of the graph vertex in parallel when accessing the target graph vertex, and map the neighbor lists of all neighbor graph nodes to a continuous memory area, thereby improving memory access efficiency and reducing memory access latency, so as to facilitate subsequent implementation of triangle counting.

[0050] Among them, in the embodiment of the present application, all neighbor graph nodes of the target graph vertex can be traversed in parallel using CTA thread organization technology, including three strategies: Block Degree, Block Index and Warp Index, to adapt to different graphs.

[0051] A vertex v with degree d(v) is assigned in Block Degree (thread block-based thread organization with degree-based workload partitioning) blocks;

[0052] In Block Index (block-based thread organization with index-based workload partitioning), the vertex v associated with the target index of the index array is assigned blocks;

[0053] In Warp Index (thread organization based on thread warps with index-based workload partitioning), the vertex v associated with the target index of the horizontal array is assigned warps.

[0054] In an embodiment of the present application, before mapping the neighbor lists of all neighbor graph nodes to a continuous memory area, it also includes: constructing at least one set of vertex pairs based on the target graph vertex and all neighbor graph nodes, and mapping the neighbor lists of the target graph vertex and the corresponding neighbor graph node in each set of vertex pairs to a continuous memory area.

[0055] It can be understood that the embodiments of the present application can construct vertex pairs based on the target access graph vertex and the neighbor nodes of the target graph vertex, and map the neighbor list of the target access graph vertex and the neighbor list of the corresponding neighbor graph node in each set of vertex pairs to a continuous memory area.

[0056] For example, there is a graph containing vertices A, B, C, and D, and the neighbor graph node of vertex A is [B, C, D]. Each neighbor in the neighbor graph node of vertex A is traversed in parallel, and the neighbor list of each pair of vertices is mapped to a continuous memory area.

[0057] For example, if the target graph vertex is A, the neighbor graph nodes of vertex A include B, C, and D, that is, the neighbor list N of vertex A A = [B, C, D], forming vertex pairs (A, B), (A, C) and (A, D), traversing all neighbor graph nodes in parallel, such as neighbor graph node B, obtaining B's neighbor list N B , for a neighbor graph node C, get C's neighbor list N C , for a neighbor graph node D, get D's neighbor list N D , the neighbor lists of each pair of vertices are mapped to a continuous memory area. For example, for the vertex pair (A, B), the neighbor list N of vertex A is mapped to a continuous memory area. A and the neighbor list N of vertex B B Mapped into a contiguous memory area.

[0058] In step S104 , triangle counting is implemented based on the index array and the continuous memory area.

[0059] It can be understood that the embodiments of the present application can implement triangle counting based on the index array and the continuous memory area, and the specific steps are as follows.

[0060] In an embodiment of the present application, triangle counting is implemented based on an index array and a continuous memory area, including: determining a hash tree for each group of vertex pairs based on the index array; searching the neighbor list of each group of vertex pairs based on the hash tree to see whether there are identical neighbors; if there are identical neighbors, taking the target graph vertices and neighbor graph nodes corresponding to the identical neighbors and vertex pairs as triplets, and implementing triangle counting based on the triplets.

[0061] It can be understood that the embodiments of the present application can determine the hash tree of each group of vertex pairs based on the index array, and retrieve the neighbor list of each group of vertex pairs based on the hash tree to see whether there are the same neighbors. The target graph vertices and neighbor graph nodes corresponding to the same neighbors and vertex pairs are taken as triplets, and triangle counting is then implemented based on the triplets, that is, the neighbor lists of two vertices are retrieved based on the hash tree to see whether there are the same neighbors, and the same neighbors and the two vertices currently traversed are put into the answer set as triplets, thereby implementing triangle counting, wherein a triple is a triangle, and the neighbor list is retrieved based on the hash tree to see whether there are the same neighbors, thereby improving the retrieval efficiency.

[0062] In an embodiment of the present application, a hash tree is used to retrieve the neighbor list of each group of vertex pairs to see whether the same neighbors exist, including: obtaining the neighbor list of the corresponding neighbor graph node in each group of vertex pairs; loading the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array; determining the length of the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node; constructing a hash tree based on the neighbor list of short length, and determining the neighbor list of long length as the search space; enumerating each element in the search space, and retrieving whether the same element exists based on the hash tree, wherein the same element is the same neighbor.

[0063] It can be understood that the embodiments of the present application can load the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array, use the shorter neighbor list to build a hash tree, and the longer neighbor list is regarded as a search space, enumerate each element in the search space, and search based on the hash tree to see whether the same element exists.

[0064] For example, get the neighbor list N of vertex A A and the neighbor list N of vertex B A , N A and N B Load into a temporary array, which can be a one-dimensional array or a buffer, to store the neighbor lists, map the two neighbor lists into a continuous memory area to improve memory access efficiency, use the shorter neighbor list to build the hash tree, and the longer neighbor list is considered as the search space. For example, if N A If shorter, use N A Build a hash tree and enumerate the longer neighbor list N BFor each element in, check whether there is an identical element based on the hash tree.

[0065] If N A =[B,C],N B = [A, C, E], using the shorter neighbor list N A =[B, C] builds a hash tree.

[0066] Enumeration N B For each element b in , for b=A, calculate the hash value and check whether A exists in the hash tree. For b=C, calculate the hash value and check whether C exists in the hash tree. For b=E, calculate the hash value and check whether E exists in the hash tree.

[0067] For b=C, calculate the hash value and check whether C exists in the hash tree. If C is found, it indicates that there is a common neighbor C, so A, B, and C form a triangle.

[0068] The following is a specific example of the triangle counting method of the present application. The process is as follows: Figure 2 As shown, the following steps are included:

[0069] Step S10: construct a hash tree based on the neighbor lists of all vertices in the graph in a lock-free manner, and organize the indexes of the hash trees corresponding to all vertices into an index array.

[0070] Specifically, the embodiment of the present application will traverse all vertices, take out their neighbor lists, and build a hash tree in a lock-free manner. The hash tree is stored in a linked list, and each hash tree is a bucket that can store H vertices. In order to improve GPU memory throughput, Skiff in the embodiment of the present application will use a 32-way hash tree (i.e., H=32) to organize neighbor vertices.

[0071] Furthermore, the step of constructing the hash tree also includes:

[0072] An optimistic strategy is used to handle conflicts that occur when building a hash trie without locking operations. Figure 3 As shown, when a hash collision occurs, the conflicting item is placed in the next position of the original item without the need for a lock operation (such as Figure 3 If there are too many conflicts until the trie node is full, and the conflicting items are further placed in the next node under the protection of the CAS operation (as shown in the black curve in Figure 3 As shown by the gray curve in ). Once the current bucket is full and there are more conflicts, a new bucket is allocated and the two buckets are linked using a pointer from the last item in the current bucket to the first item in the new bucket. By using this strategy, most of the lock operations can be reduced.

[0073] Furthermore, the indexes of all vertices corresponding to the hash tree are organized into an index array, including:

[0074] Specifically, the present embodiment provides an example of H=4. Figure 4 As shown. First, a level array is used as an index into the hash tree to ensure that the algorithm can quickly locate active nodes. Each item in the array holds a pointer to a node at a certain level of the hash tree. The level array is a compact structure that takes up limited space. By using a level array to index the hash tree, only the tree can be quickly loaded into memory instead of the entire hash tree, and there are no empty buckets in the hash tree (virtual buckets are used to represent buckets with no elements), which can reduce the pressure on the GPU memory allocator.

[0075] Step S20: When accessing a certain graph vertex, all its neighboring graph nodes are traversed in parallel, and the neighbor list of each pair of points is mapped to a continuous memory area.

[0076] It adopts CTA thread organization technology and provides three strategies: Block Degree, Block Index and WarpIndex to adapt to different graphics.

[0077] In Block Degree (block-based thread organization with degree-based workload partitioning), a vertex v with degree d(v) is assigned blocks.

[0078] In Block Index (block-based thread organization with index-based workload partitioning), the vertex v associated with the target index of the index array is assigned blocks.

[0079] In Warp Index (warp-based thread organization with index-based workload partitioning), the vertex v associated with the target index of the horizontal array is assigned warps.

[0080] Step S30: Based on the hash tree, search the neighbor lists of the two vertices to see if there are any common neighbors, and put the common elements and the two vertices currently traversed as a triple into the answer set.

[0081] Specifically, the neighbor lists of the source and destination vertices of the active edge are loaded into an array, and then the hash tree is built using the shorter neighbor list, while the longer neighbor list is regarded as the search space. Each element in the search space is enumerated, and the hash tree is used to find out whether there is an identical element.

[0082] The part of the Skiff algorithm used to traverse the search space is as follows:

[0083] Input: neighbor list B, hash tree bucket;

[0084] Output: triangle triplets.

[0085] Step 1: Calculate the hash value based on B in parallel according to the width of B and the hash function;

[0086] Step 2: Find the location of the hash value of the current element b in B in the temporary storage bucket;

[0087] Step 3: If the hash value of b in the temporary storage bucket is greater than the position i of the current thread and is an odd number, store b in the hash position corresponding to the hash+H-1-i position and return the triangle (u, v, b).

[0088] The embodiment of the present application will explain the counting principle of triangles in combination with the above Skiff algorithm. Hash is the hash value of element b. By traversing elements with the same hash value, triangles can be found within the time complexity of O(1).

[0089] In summary, the embodiments of the present application fully consider the size of the memory space on the GPU and the highly parallel characteristics, organize graph data through a hash tree, eliminate branch divergence in triangle counting, and the lock-free operation when constructing the hash tree reduces hash conflicts and alleviates branch divergence during execution. In addition, the compact storage format improves GPU cache utilization while reducing the number of memory accesses, effectively improving the problem of poor memory access efficiency caused by irregular memory access.

[0090] According to the triangle counting implementation method of the graphics processor proposed in the embodiment of the present application, the graphics data in the graphics processor can be obtained, and the neighbor lists of all vertices can be identified, and a hash tree can be constructed according to the neighbor lists of all vertices in a lock-free manner, thereby avoiding performance bottlenecks caused by lock contention in a multi-threaded or multi-GPU environment, alleviating branch divergence during execution, and fully considering the size of the memory space on the GPU and the highly parallel characteristics. By establishing an index array of the hash tree corresponding to all vertices, the neighbor list of each vertex can be quickly accessed, thereby improving the efficiency of subsequent operations. When accessing the target graph vertex, all neighbor vertices of the target vertex are traversed in parallel, and the neighbor list is mapped to a continuous memory area, which improves memory access efficiency and reduces memory access latency. Triangle counting is implemented based on index arrays and continuous memory areas, effectively improving the computing power, computing efficiency and memory access efficiency of the GPU when applied to triangle counting.

[0091] Next, a triangle counting implementation device for a graphics processor according to an embodiment of the present application will be described with reference to the accompanying drawings.

[0092] Figure 5 4 is a block diagram of a device for implementing triangle counting of a graphics processor according to an embodiment of the present application.

[0093] like Figure 5 As shown, the triangle counting implementation device 10 of the graphics processor includes: an acquisition module 100 , a creation module 200 , a mapping module 300 and an implementation module 400 .

[0094] Among them, the acquisition module 100 is used to obtain the graphics data of the graphics processor; the establishment module 200 is used to identify the neighbor lists of all vertices in the graphics data, build a hash tree in a lock-free manner based on the neighbor lists of all vertices, and establish an index array of the hash tree corresponding to all vertices; the mapping module 300 is used to traverse all neighbor graph nodes of the target graph vertex in parallel when accessing the target graph vertex, and map the neighbor lists of all neighbor graph nodes to a continuous memory area; the implementation module 400 is used to implement triangle counting based on the index array and the continuous memory area.

[0095] In an embodiment of the present application, the mapping module 300 is further used to: construct at least one set of vertex pairs based on the target graph vertex and all neighbor graph nodes, and map the neighbor list of the target graph vertex and the corresponding neighbor graph node in each set of vertex pairs to a continuous memory area.

[0096] In an embodiment of the present application, the implementation module 400 is further used to: determine the hash tree of each group of vertex pairs based on the index array; retrieve the neighbor list of each group of vertex pairs based on the hash tree to see whether there are the same neighbors; if there are the same neighbors, take the target graph vertices and neighbor graph nodes corresponding to the same neighbors and vertex pairs as triplets, and implement triangle counting based on the triplets.

[0097] In an embodiment of the present application, the establishment module 200 is further used to: obtain the target number of paths of the node of the hash tree; calculate the hash value of the vertex and the hash value of the neighbor graph node in the neighbor list of the vertex, and insert the vertex and the neighbor graph node into the storage bucket of the corresponding hash tree node; if there are multiple neighbor graph nodes with the same hash value in the neighbor graph node of the vertex, then the multiple neighbor graph nodes are placed in sequence at the next position of the node of the hash tree until the number of nodes stored in the current hash tree reaches the target number of paths; if the number of nodes stored in the current hash tree reaches the target number of paths, then the multiple neighbor graph nodes with the same hash value are placed in a new storage bucket of the node of the current hash tree.

[0098] In an embodiment of the present application, the establishment module 200 is further used to: obtain the arrangement order of all vertices and the addresses of the target level nodes of the hash tree corresponding to all vertices; construct an index array based on the arrangement order and the addresses of the target level nodes of the hash tree corresponding to all vertices, wherein each element in the index array is a pointer to the node of the target level of the hash tree.

[0099] In an embodiment of the present application, the mapping module 300 is further used to: obtain a neighbor list of a neighbor graph node corresponding to each group of vertex pairs; load the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array; determine the length of the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node; construct a hash tree based on the neighbor list of short length, and determine the neighbor list of long length as the search space; enumerate each element in the search space, and retrieve whether there are identical elements based on the hash tree, wherein identical elements are identical neighbors.

[0100] It should be noted that the above explanation of the embodiment of the method for implementing triangle counting in a graphics processor is also applicable to the device for implementing triangle counting in a graphics processor of this embodiment, and will not be described in detail here.

[0101] According to the embodiment of the present application, a triangle counting implementation device for a graphics processor is proposed. By acquiring graphics data in the graphics processor and identifying neighbor lists of all vertices, a hash tree is constructed according to the neighbor lists of all vertices in a lock-free manner, thereby avoiding performance bottlenecks caused by lock contention in a multi-threaded or multi-GPU environment, alleviating branch divergence during execution, and fully considering the size of the memory space on the GPU and the highly parallel characteristics. By establishing an index array of hash trees corresponding to all vertices, the neighbor list of each vertex can be quickly accessed, thereby improving the efficiency of subsequent operations. When accessing a target graph vertex, all neighbor vertices of the target vertex are traversed in parallel, and the neighbor list is mapped to a continuous memory area, thereby improving memory access efficiency and reducing memory access latency. Triangle counting is implemented based on index arrays and continuous memory areas, effectively improving the computing power, computing efficiency, and memory access efficiency of the GPU when applied to triangle counting.

[0102] Figure 6 A schematic diagram of the structure of a graphics processor provided in an embodiment of the present application. The graphics processor may include:

[0103] A memory 601 , a processor 602 , and a computer program stored in the memory 601 and executable on the processor 602 .

[0104] When the processor 602 executes the program, the triangle counting implementation method of the graphics processor provided in the above embodiment is implemented.

[0105] Furthermore, the graphics processor also includes:

[0106] The communication interface 603 is used for communication between the memory 601 and the processor 602 .

[0107] The memory 601 is used to store computer programs that can be executed on the processor 602 .

[0108] The memory 601 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0109] If the memory 601, the processor 602 and the communication interface 603 are implemented independently, the communication interface 603, the memory 601 and the processor 602 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0110] Optionally, in a specific implementation, if the memory 601, the processor 602 and the communication interface 603 are integrated on a chip, the memory 601, the processor 602 and the communication interface 603 can communicate with each other through an internal interface.

[0111] The processor 602 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0112] The embodiment of the present application further provides a computer-readable storage medium having a computer program or instruction stored thereon. When the computer program or instruction is executed by a processor, the triangle counting implementation method of the graphics processor as described above is implemented.

[0113] The embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed, implements the above-mentioned triangle counting implementation method of the graphics processor.

[0114] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0115] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0116] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0117] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0118] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

Claims

1. A method for implementing triangle counting of a graphics processor, characterized in that: The following steps are involved: Get graphics data from the graphics processor; Identify neighbor lists of all vertices in the graph data, construct hash trees in a lock-free manner based on the neighbor lists of all vertices, and establish index arrays of the hash trees corresponding to all vertices; When accessing a target graph vertex, traverse all neighbor graph nodes of the target graph vertex in parallel, and map neighbor lists of all neighbor graph nodes to a continuous memory area; Triangle counting is implemented based on the index array and the continuous memory area.

2. The method for implementing triangle counting of a graphics processor according to claim 1, characterized in that: Before mapping the neighbor lists of all neighbor graph nodes to the continuous memory area, the method further includes: At least one set of vertex pairs is constructed based on the target graph vertex and all the neighbor graph nodes, and a neighbor list of the target graph vertex and the corresponding neighbor graph node in each set of vertex pairs is mapped to a continuous memory area.

3. The method for implementing triangle counting of a graphics processor according to claim 2, wherein: Implementing triangle counting based on the index array and the continuous memory area includes: Determine a hash tree for each set of vertex pairs based on the index array; Based on the hash tree, searching the neighbor list of each set of vertex pairs to see whether there are the same neighbors; If the same neighbor exists, the target graph vertex and the neighbor graph node corresponding to the same neighbor and the vertex pair are taken as a triplet, and triangle counting is implemented based on the triplet.

4. The method for implementing triangle counting of a graphics processor according to claim 1, characterized in that: The step of constructing a hash tree in a lock-free manner according to the neighbor lists of all vertices includes: Obtaining a target number of paths of nodes of the hash tree; Calculate the hash value of the vertex and the hash value of the neighbor graph node in the neighbor list of the vertex, and insert the vertex and the neighbor graph node into the storage bucket of the node of the corresponding hash tree; If there are multiple neighbor graph nodes with the same hash value in the neighbor graph nodes of the vertex, the multiple neighbor graph nodes are sequentially placed in the next position of the node of the hash tree until the number of nodes currently stored in the hash tree reaches the target number of paths; If the number of nodes currently stored in the hash tree reaches the target number of paths, multiple neighbor graph nodes with the same hash value are placed in a new storage bucket of the nodes of the current hash tree.

5. The method for implementing triangle counting of a graphics processor according to claim 1, characterized in that: The step of establishing the index array of the hash tree corresponding to all vertices includes: Obtaining the arrangement order of all the vertices and the addresses of the nodes of the target level of the hash tree corresponding to all the vertices; The index array is constructed based on the arrangement order and the addresses of the nodes of the target level of the hash tree corresponding to all the vertices, wherein each element in the index array is a pointer to the node of the target level of the hash tree.

6. The method for implementing triangle counting of a graphics processor according to claim 3, characterized in that: The step of searching the neighbor list of each group of vertex pairs based on the hash tree to see whether there are identical neighbors includes: Obtain a neighbor list of the neighbor graph nodes corresponding to each set of vertex pairs; Loading the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node into an array; Determine the length of the neighbor list of the target graph vertex and the neighbor list of the corresponding neighbor graph node; Building a hash tree based on the short neighbor list, and determining the long neighbor list as a search space; Enumerate each element in the search space, and search whether there is an identical element based on the hash tree, wherein the identical element is the identical neighbor.

7. A device for implementing triangle counting of a graphics processor, characterized in that: include: An acquisition module, used for acquiring graphics data of a graphics processor; Establishing a module for identifying neighbor lists of all vertices in the graph data, constructing a hash tree in a lock-free manner according to the neighbor lists of all vertices, and establishing an index array of the hash tree corresponding to all vertices; A mapping module, used for traversing all neighbor graph nodes of the target graph vertex in parallel when accessing the target graph vertex, and mapping the neighbor lists of all neighbor graph nodes to a continuous memory area; An implementation module is used to implement triangle counting based on the index array and the continuous memory area.

8. A graphics processor, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the triangle counting implementation method of the graphics processor according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: The computer program or instruction is executed by a processor to implement the triangle counting implementation method of a graphics processor according to any one of claims 1 to 6.

10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed, the triangle counting implementation method of the graphics processor according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • A triangle computing method for large-scale graph

    CN109254844A

  • Method and system for counting triangles in large-scale graph with low space overhead

    CN112131444A

  • Numa-perceived community discovery method based on k-trus decomposition

    CN114265691A

  • B-tree-based overlapping community discovery method, apparatus and device, and storage medium

    CN115809243A

  • Dynamic graph storage method and device based on nonvolatile memory

    CN118259830A

Cited By

  • Triangle counting implementation method and apparatus for graphics processing unit

    WO2026067562A1