A Contact Search Method Based on GPU Parallelism
Through the GPU parallel-based contact search method, using the CUDA architecture and Thrust library for contact block extended domain calculation and parallel sorting, the problem of low contact search efficiency on a single processor is solved, and efficient computing and memory savings of contact search are achieved.
Patent Information
- Application Number
- CN202311705183.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2043-12-13
AI Technical Summary
The contact collision detection algorithm implemented in the prior art on a single processor is difficult to meet the actual engineering requirements for computing efficiency, and contact search accounts for 40% to 50% of the simulation calculation time.
The contact search method based on GPU parallelism is adopted, and the contact block extension domain is calculated through a single CUDA thread under the CUDA architecture, forming a mixed table and sorting, and the parallel search of test pairs and contact pairs is used to perform fine-grained parallel calculations corresponding to threads and contact blocks to reduce the number of useless detections.
It realizes GPU acceleration for contact search, improves computing efficiency, reduces computing workload and saves memory space.
Smart Images

Figure CN117689530B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of high-performance numerical simulation analysis in engineering, and particularly relates to a contact search method based on GPU parallelism. Background Art
[0002] Contact phenomena are ubiquitous. In the process of actual engineering mechanics simulation, complex contact situations are often involved. For example, in the process of vehicle collision, there are a large number of contacts and slips of components. Contact occurs not only between the vehicle and the outside world, between various components of the vehicle, but also self-contact collisions may occur within a certain component of the vehicle. Contact search is the most time-consuming part in the simulation of contact-collision problems. Therefore, an efficient contact search algorithm is the key to improving the efficiency of numerical analysis.
[0003] Commonly used contact search algorithms include the master-slave surface method, the hierarchical domain method, the integrated method, and the octree global search method. Although these algorithms can search for contact objects more accurately, with the increase in the scale of the simulation scenario, the contact collision detection algorithm implemented on a single processor has been difficult to meet the requirements of actual engineering for computational efficiency. Contact search is the search for contact points, which is to find all the nodes that are close enough to the contacted block and should be treated as contacted points through calculation. It can be divided into two situations, one is the pre-contact search, and the other is the post-contact search. The pre-contact search is for the nodes that were not in the contact state in the previous calculation, and its purpose is to find possible new contact nodes. The post-contact search is for the nodes that were already in the contact state in the previous calculation, and its purpose is to find new contact positions on the contacted points and check whether there are any contacted points that have become disengaged. Therefore, as long as the coordinates of a node and the node coordinates of the contact block that may contact this node are given, the relative position between this node and those contact blocks can be calculated, so as to determine whether this node should be treated as a contacted point. In this process, not only every contacted point and the corresponding contact block need to be accurately found, but also the computational workload should be minimized as much as possible. Practice shows that in complex contact problems, contact search occupies 40% - 50% of the solution time. From the perspective of engineering applications, the amount of calculation is also a very important issue. The improvement of the calculation speed means that more work can be done in the same time, or the same problem can be solved with more elements to improve the calculation accuracy. Therefore, a very important issue in contact point search is how to reduce the computational workload and minimize the memory space occupied. Therefore, it is necessary to propose a contact search method based on GPU parallelism to solve the above problems. Summary of the Invention
[0004] The object of the present invention is to provide a contact search method based on GPU parallelism in view of the deficiencies of the prior art, so as to solve the problem that the contact collision detection algorithm implemented on a single processor in the prior art is difficult to meet the requirements of actual engineering for computing efficiency.
[0005] The present invention provides a contact search method based on GPU parallelism, including:
[0006] Calculating the extended domain of the contact block. Among them, under the CUDA architecture, the calculation method of using a single CUDA thread corresponding to a single contact block is adopted to calculate the extended domain of each contact block and store it in a one-dimensional array in the global video memory for storing the hybrid table;
[0007] Finding the contact points falling within the extended domain of the contact block to form test pairs;
[0008] Finding contact pairs from the test pairs.
[0009] Further, calculating the extended domain of the contact block includes:
[0010] Calculating the direction of the longest side of the entire contact system;
[0011] Storing the coordinates of the contact points and the lower limit points of the extended domain of the contact block in the direction of the longest side into the same array in the order of the first half of the extended domain of the contact block and the second half of the contact points to obtain a hybrid table;
[0012] Sorting the coordinates in the hybrid table in ascending order to obtain a sorted table.
[0013] Further, finding the contact points falling within the extended domain of the contact block to form test pairs includes:
[0014] Performing the first search for test pairs in the sorted table. Starting from the first element of the sorted table, each element is detected one by one. When an extended domain lower limit point is found, the span of the extended domain in the direction of the longest side is calculated, and the contact point numbers falling within this span are found in the sorted table; among them, the first search consists of two layers of loops, and the outer loop in the two layers of loops is extended to each CUDA thread;
[0015] After the search in the direction of the longest side is completed, an array including the extended domain of the contact block and the subordination relationship of the contact points is obtained. By directly comparing the coordinate values in the other two directions, it is detected whether the contact points are truly within the extended domain of the contact block; if the coordinate values of the contact points in the other two directions are also within the extended domain of the contact block, a test pair is formed.
[0016] Further, finding contact pairs from the test pairs includes:
[0017] Starting from the surface level, the test pairs that form the contact pairs at the surface level enter the edge level for detection. The test pairs that pass the edge level detection then enter the point level for contact detection, and finally form the true contact pair relationship.
[0018] Furthermore, in each level of contact detection among the surface level, edge level, and point level, the test pair needs to be used as the basic calculation unit to calculate the geometric relationship between the contact points in the test pair and the corresponding level, so as to determine whether the contact relationship is satisfied.
[0019] Furthermore, when using the test pair as the basic calculation unit to calculate the geometric relationship between the contact points in the test pair and the corresponding level, a parallel calculation is implemented in the GPU in a way that one thread corresponds to one test pair.
[0020] Furthermore, the update of the test pairs between levels among the surface level, edge level, and point level is all operated within the same array space.
[0021] Furthermore, starting from the surface level, the test pairs that form the contact pairs at the surface level enter the edge level for detection. The test pairs that pass the edge level detection then enter the point level for contact detection, and finally form the true contact pair relationship, including:
[0022] Performing contact judgment on multiple test pairs in parallel;
[0023] If the current test pair meets the contact condition, save the number of the test pair;
[0024] If the current test pair does not meet the contact condition, set the number of the test pair to a very large number to obtain a new test pair array; the very large number is greater than the total number of test pairs;
[0025] Use the Thrust function to sort the test pairs from small to large, so that the contact pairs that meet the contact condition are all arranged in the front part of the array. By finding the position where the first very large number appears, it is possible to obtain how many contact pairs are generated, and at the same time, the requirement of sequential storage is also met.
[0026] The present invention has the following beneficial effects: The contact search method based on GPU parallelism provided by the present invention, in response to the demand for an efficient contact search algorithm in the field of contact collision simulation, proposes a contact search strategy based on GPU parallelism. For the large number of test pairs and contact pairs formed by contact blocks and nodes that appear in the contact search process, it develops a mapping strategy between threads and contact blocks and GPU parallel sorting technology, and makes full use of the multi-core characteristics of the GPU to calculate such data-intensive independent tasks using GPU threads, realizing the GPU acceleration of the search for test pairs and contact pairs. Description of the Drawings
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0028] Figure 1 is the flowchart of the contact search method based on GPU parallel provided by the present invention;
[0029] Figure 2 is the schematic diagram of the composition of the hierarchical contact system;
[0030] Figure 3 is the schematic diagram of the contact block and its block domain, contact domain, and extension domain, where (a) is the contact block and its block domain, (b) is the contact block and its contact domain, and (c) is the block domain, contact domain, and extension domain of the contact block;
[0031] Figure 4 is the schematic diagram of the mixed sorting of contact points and the extension domain of the contact block, where (a) is the original state and (b) is the sorted state;
[0032] Figure 5 is the schematic diagram of the execution mode of the test pair search;
[0033] Figure 6 is the schematic diagram of the parallel execution mode of the contact pair search. Specific Embodiments
[0034] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The following will refer to the drawings and combine with the embodiments to detail the present invention. It should be pointed out that the following detailed description is illustrative and aims to provide further explanation for the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs.
[0035] For the existing contact search methods: the master-slave surface method, the hierarchical domain method, the integrated method, and the octree global search method, parallel strategies based on GPU (Graphics Processing Unit) can be constructed. For the convenience of description, the embodiments of the present invention introduce the contact search method based on GPU parallel of the present invention by taking the hierarchical domain method as an example.
[0036] A multi-body contact system is composed of more than two contacting objects, and a contacting object may have one or more contact surfaces. The hierarchical domain method systematically introduces the concepts of contact points, contact edges, contact blocks, contact surfaces, contact bodies, and contact systems, and collectively refers to them as contact elements. Obviously, these contact elements are at different levels. Among them, the contact system is at the highest level, followed by contact bodies, contact surfaces, contact blocks, contact edges, and contact points in sequence. That is to say, a contact system can be decomposed into contact bodies, a contact body can be decomposed into contact surfaces, a contact surface can be decomposed into contact blocks, a contact block can be decomposed into contact edges, and a contact edge can be decomposed into contact points, as Figure 2 shown, this is the concept of "hierarchy" in the hierarchical domain method.
[0037] To improve the contact search speed, it is often necessary to define the block domain of contact, as Figure 3 shown, which are the concepts of basic contact blocks and block domains, contact domains, and extended domains. A contact block represents the computational body where contact occurs, usually a finite element; a block domain represents the block body enclosed by the minimum and maximum coordinates in each direction of the contact block; a contact domain means that all contact points falling into this area will come into contact with this contact block; an extended domain is the space obtained by equally expanding the block domain in the directions of each coordinate axis to make up for the flaw that the contact points falling into the contact domain may not necessarily fall into the block domain; this is the concept of "domain" in the hierarchical domain method.
[0038] According to the basic characteristics of the hierarchical domain method, the GPU parallel strategy for contact search in the present invention is divided into the following three steps:
[0039] S101, calculate the extended domain of the contact block. Among them, under the CUDA (Compute Unified Device Architecture) architecture, the calculation method of using a single CUDA thread corresponding to a single contact block is adopted to calculate the extended domain of each contact block and store it in a one-dimensional array in the global video memory for storing the hybrid table.
[0040] S102, find the contact points falling into the extended domain of the contact block to form test pairs.
[0041] S103, find the contact pairs from the test pairs.
[0042] Among them, the calculation of the extended domain of the contact block has good independence. Under the CUDA architecture, the calculation method of using a single CUDA thread corresponding to a single contact block can achieve good calculation efficiency.
[0043] The parallel search based on GPU in the present invention is mainly divided into the parallel search of test pairs and contact pairs, and the specific steps are as follows:
[0044] Step 1: Parallel search of test pairs under the CUDA architecture:
[0045] During the test pair search process for three-dimensional collision problems, a strategy of sorting in the long side direction is usually adopted to exclude a large number of meaningless contact point and contact block comparisons, thereby improving the search efficiency. Its serial execution process is described as follows:
[0046] First, calculate the direction of the longest side of the entire contact system. Store the coordinates of the lower limit points of the contact points and the contact block expansion domains in the direction of the longest side into the same array in the order of the first half of the contact block expansion domains and the second half of the contact points to obtain a mixed table, as shown in Figure 4 (a). After mixing, sort in ascending order to obtain a sorted table, as shown in Figure 4 (b). In the figure, the black dots represent the lower limit points of the expansion domains of the expansion blocks, and the hollow dots represent the contact point coordinates.
[0047] Then, conduct the first search for test pairs in the sorted table. Start detecting one by one from the first element of the sorted table. When a lower limit point of the expansion domain is found, calculate the span of the expansion domain in the long side direction. And find the contact point numbers that fall within this span in the sorted table.
[0048] Finally, after the search in the long side direction is completed and an array including the contact block expansion domains and the subordination relationships of the contact points is obtained, the contact points can be detected whether they are truly within the expansion domain of the contact block by directly comparing the coordinate values in the other two directions. If the coordinate values of the contact points in the other two directions are also within the contact block expansion domain, a test pair is formed.
[0049] In summary, the parallel execution strategy based on CUDA is as follows:
[0050] The formation of the mixed table can be completed during the parallel expansion domain calculation of the contact blocks, which has good parallelism. During parallel calculation, each expansion domain is calculated in parallel in a way that one thread corresponds to one contact block and stored into a one-dimensional array in the global video memory used to store the mixed table. Here, the Thrust library provided by CUDA is used to implement quick sort. Thrust is a C++ template library that provides efficient algorithms and data structures for GPU computing. It aims to provide a simple and easy-to-use interface for developing high-performance GPU programs, providing a high-level programming paradigm for GPU programming, enabling developers to use algorithms and data structures similar to STL to accelerate applications.
[0051] In the serial algorithm, the first search for test pairs in the long side direction consists of two layers of loops. After testing, it occupies more than 90% of the search time. Considering the fine-grained execution mode of the GPU and the dependency relationship of the two layers of loops, the outer loop in the two layers of loops is extended to each CUDA thread to reduce the loop time complexity, as shown in Figure 5 shown.
[0052] The main difficulty in executing in CUDA threads lies in how to tightly store the searched test pairs in the global memory space. When performing the search for test pairs in a way that one CUDA thread corresponds to one contact expansion domain, there are four situations for a single thread: not being the lower limit point of the contact block, not finding a test pair, finding one test pair, and finding multiple test pairs. Threads that are not the lower limit point of the contact block and do not find a test pair do not need to record test pairs and thus do not involve operations of writing to the global memory. However, in the case where test pairs are generated, threads that find one test pair and find multiple test pairs need to perform operations similar to pushing onto a stack. Here, atomic operations in parallel computing are used to handle this to achieve the search for test pairs.
[0053] Step 2: Parallel search for contact pairs under the CUDA architecture:
[0054] In the hierarchical domain method, the search for contact pairs starts from the face level first. The test pairs that form contact pairs at the face level then enter the edge level for detection. Those that pass the edge level detection then enter the point level contact detection, and finally, the true contact pair relationship is formed. This hierarchical detection method can effectively reduce the number of useless detections and improve the detection efficiency. In each level of contact detection, it is necessary to calculate the geometric relationship between the contact points in the test pair and the corresponding level with the test pair as the basic computing unit to determine whether the contact relationship is satisfied. Similarly, the calculation of this geometric relationship within the same level has good fine-grained parallelism, and parallel computing can be implemented in the GPU in a way that one thread corresponds to one test pair.
[0055] To save memory space and reduce inefficient operations in the global memory space, the update of test pairs between levels is all performed within the same array space. To ensure that the array updated in the previous level can satisfy the sequential execution of threads in the next level without skipping, the present invention proposes a search strategy based on the idea of sorting after calculation. As Figure 6 shown, assume there are 10 test pairs "TP". First, perform the "e1" contact judgment in parallel. If the current test pair meets the contact condition, save the number of the test pair. If not, set the number of the test pair to a very large number "MX". In this way, a new test pair array is obtained. Then, use the Thrust function in Step 1 to sort from smallest to largest. In this way, the contact pairs that meet the contact condition are all arranged in the front part of the array. By finding the position where the first "MX" appears, it is possible to know how many contact pairs are generated, and at the same time, it also meets the requirement of sequential storage. The array and the total number of contact pairs information obtained in this way are beneficial for writing the contact pair program in the next level and improving the execution efficiency of the program. Among them, "MX" just needs to be greater than the total number of test pairs. Usually, the size of "MX" is set to the total number of tests plus 1.
[0056] As can be seen from the above embodiments, based on the characteristics of hierarchical and domain-based search of the level domain method, the present invention formulates a parallel mode of CUDA threads corresponding to contact blocks for test pairs and contact pairs, and performs parallel computing at the same level, greatly improving the computing efficiency. The present invention realizes fine-grained parallelism of test pairs by corresponding threads to contact blocks, uses the Thrust library for hybrid sorting of contact blocks and contact points, and uses atomic operations to avoid write competition errors during the storage of test pairs, ensuring the efficient and normal execution of the program. The present invention proposes to perform fine-grained parallel search of contact pairs by corresponding thread cores to test pairs at the same level, and uses the method of sorting after calculation to ensure seamless data transfer between levels and save video memory space.
[0057] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they specify the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0058] It should be noted that the terms "first", "second", etc. in the description, claims and drawings of the present application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0059] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A contact search method based on GPU parallelism, characterized in that, including: Calculating the contact block extension domain. Under the CUDA architecture, a single CUDA thread corresponds to a single contact block for calculation. Calculate each contact block extension domain and store it in a one-dimensional array in the global video memory for storing the mixing table; calculating the contact block extension domain includes: calculating the longest side direction of the entire contact system; storing the coordinates of the contact point and the lower limit point of the contact block extension domain in the longest side direction into the same array in the order of the first half of the contact block extension domain and the second half of the contact point to obtain the mixing table; sorting the coordinates in the mixing table in ascending order to obtain the sorted table; Finding the contact points falling within the contact block extension domain to form test pairs; Finding contact pairs from the test pairs.
2. The contact search method based on GPU parallelism according to claim 1, wherein Finding the contact points falling within the contact block extension domain to form test pairs, including: Performing the first search for test pairs in the sorted table. Starting from the first element of the sorted table, detect one by one. When an extension domain lower limit point is found, calculate the span of the extension domain in the longest side direction and find the contact point numbers falling within this span in the sorted table; the first search consists of two nested loops, and the outer loop in the two nested loops is extended to each CUDA thread; After the search in the longest side direction, obtain an array including the contact block extension domain and the contact point subordination relationship. By directly comparing the coordinate values in the other two directions, detect whether the contact point is truly within the extension domain of the contact block; if the coordinate values of the contact point in the other two directions are also within the contact block extension domain, then form a test pair.
3. The contact search method based on GPU parallelism according to claim 2, wherein Finding contact pairs from the test pairs, including: Starting from the face level, the test pairs that form contact pairs at the face level enter the edge level for detection, and the test pairs that pass the edge level detection enter the contact detection at the point level, and finally form the true contact pair relationship.
4. The contact search method based on GPU parallelism according to claim 3, wherein In each level of contact detection of the face level, edge level, and point level, the test pair needs to be used as the basic calculation unit to calculate the geometric relationship between the contact points in the test pair and the corresponding level, so as to judge whether the contact relationship is satisfied.
5. The contact search method based on GPU parallelism according to claim 4, wherein, When using the test pair as the basic calculation unit to calculate the geometric relationship between the contact points in the test pair and the corresponding level, a parallel calculation is implemented in the GPU in a way that one thread corresponds to one test pair.
6. The contact search method based on GPU parallelism according to claim 5, wherein, The update of the test pairs between the levels of the face level, edge level, and point level is all operated within the same array space.
7. The contact search method based on GPU parallelism according to claim 6, characterized in that Starting from the face level, the test pairs that form contact pairs at the face level enter the edge level for detection, and the test pairs that pass the edge level detection enter the contact detection at the point level, and finally form the true contact pair relationship, including: Performing contact judgment on several test pairs in parallel; If the current test pair meets the contact condition, save the number of the test pair; If the current test pair does not meet the contact condition, set the number of the test pair to a very large number to obtain a new test pair array; the very large number is greater than the total number of test pairs; Using the Thrust function to sort the test pairs from small to large, so that the contact pairs that meet the contact condition are all arranged in the front part of the array. By finding the position where the first very large number appears, obtain how many contact pairs are generated, and at the same time meet the requirement of sequential storage.
Citation Information
Patent Citations
Simulation and prediction method of large-scale particle system composed of slender flexible objects
CN115600449A