Dynamic load balancing method based on GPU parallel processing

By dynamically adjusting the mapping relationship between GPU thread blocks and the computing grid, load balancing is achieved under the uneven distribution of particles in plasma discharge simulation, improving the parallel efficiency and overall computing performance of the GPU, solving the problem of low computing efficiency under traditional methods.

CN119806813AActive Publication Date: 2025-04-11UNIV OF ELECTRONICS SCI & TECH OF CHINA

Patent Information

Application Number
CN202411848567.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-11
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

During plasma discharge, the particle distribution is highly uneven, resulting in the impact of the parallel efficiency and overall computing performance of the GPU under the traditional fixed thread allocation scheme.

Method used

The dynamic load balancing method based on GPU parallel processing is adopted. By dynamically adjusting the mapping relationship between thread blocks and calculation grids, we ensure that the number of particles processed by each thread block tends to be balanced, thereby improving the resource utilization of the GPU.

Benefits of technology

It significantly improves the parallel efficiency of GPU and the overall computing performance, can effectively deal with the inhomogeneity and dynamic changes of particle distribution, and improves the computing efficiency of MCC simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806813A_ABST
    Figure CN119806813A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of high-power microwave protection, and particularly relates to a dynamic load balancing method based on GPU parallel processing. By adjusting the mapping relation between the GPU thread block and the computational grid in real time, a dynamic load balancing algorithm is provided, and the problem of uneven particle distribution height in MCC simulation is effectively solved. According to the method, computing resources are dynamically allocated by evaluating the number of particles responsible for each thread block, it is ensured that the number of particles processed by each thread block is balanced as much as possible, and waste of the computing resources caused by overload of the thread blocks or idling of the thread blocks is avoided. Aiming at the continuous change of the number and distribution of particles in the ionization collision process, a thread block distribution strategy is dynamically adjusted at intervals of Ttime, and the balanced distribution of the calculation load can be always kept, so that the parallel efficiency and the overall performance of the GPU are remarkably improved. The problem that the existing MCC simulation ionization collision calculation efficiency is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of high-power microwave protection, and specifically relates to a dynamic load balancing method based on GPU parallel processing, which is particularly suitable for plasma discharge Monte Carlo collision simulation. Background Art

[0002] In the field of high-power microwave protection, the interaction between microwaves and gases often triggers plasma discharge, which significantly affects the microwave propagation characteristics and the performance of the protection system. Specifically, high-power microwaves may cause the breakdown of gas media and form high-density plasma through electron-atom ionization collisions, which in turn affects the absorption, reflection or scattering of microwave energy, leading to signal attenuation and failure of component systems. Therefore, studying the dynamic evolution characteristics of plasma during the discharge process is crucial to optimizing the design and performance of the protection system. The Monte Carlo Collision (MCC) method is a commonly used numerical technique in the numerical simulation of plasma discharge. This method obtains the macroscopic characteristics and microscopic dynamics information of the plasma by randomly sampling the collision process between particles and counting the movement and collision behavior of a large number of particles. In each time step, the MCC method traverses the particle list, calculates the collision probability of each particle, and compares it with the random number to determine whether a collision occurs; if a collision occurs, the particle's position, velocity, energy and other information are updated according to the collision type. When an ionization collision occurs, high-energy electrons collide with the background gas to produce new electrons and ions. This process will lead to a significant increase in the number of macro particles, which will bring a huge computational burden and affect the computational efficiency.

[0003] With the rapid development of computer science and high-performance computing technology, NVIDIA's CUDA platform provides powerful parallel computing capabilities for scientific computing. Graphics processing units (GPUs) have thousands of cores and can perform a large number of computing tasks simultaneously. In Monte Carlo collision simulation problems, GPU-based parallel computing can achieve more than an order of magnitude acceleration compared to traditional central processing units (CPUs). Using the CUDA programming model, particle collision calculation tasks can be assigned to multiple GPU cores for simultaneous execution, significantly increasing the calculation speed. Since the collision behaviors of particles within a single time step are independent of each other, this allows particle collision calculations to be highly parallelized, which is very suitable for accelerated calculations using the parallel architecture of the GPU.

[0004] However, during plasma discharge, particle distribution is usually highly non-uniform. If the traditional fixed thread allocation scheme is used, the thread blocks in the high-density area are overloaded, while the thread blocks in the low-density area are idle, which significantly reduces the parallel efficiency and overall computing performance of the GPU. In addition, as the ionization collision proceeds, the number and distribution of particles continue to change in time and space. The fixed thread allocation method cannot adapt to this dynamic change in real time, further exacerbating the load imbalance. Therefore, it is necessary to develop an efficient GPU parallel method to cope with the non-uniformity and dynamic changes of particle distribution, thereby improving simulation performance. Summary of the invention

[0005] In view of the above-mentioned problems or shortcomings, in order to solve the problem of low calculation efficiency of existing MCC simulation of ionization collision, the present invention provides a dynamic load balancing method based on GPU parallel processing, which ensures that the number of particles processed by each thread block tends to be balanced by dynamically adjusting the mapping relationship between thread blocks and computing grids, thereby improving the resource utilization of GPU and better applying Monte Carlo collision MCC to the numerical simulation research of plasma discharge.

[0006] A dynamic load balancing method based on GPU parallel processing includes the following steps:

[0007] Step 1: Simulate area division;

[0008] The simulation area is divided into N sub-areas. Each sub-area consists of several continuous grids. The set of grids is defined as the thread block grid set, denoted by G. i , where i is the index of the thread block (i = 0, 1, 2, ..., N-1). The value of N is determined by the architectural characteristics of the GPU and the problem size, and is consistent with the total number of thread blocks.

[0009] Assume that the total number of grids in the simulation area is M = N x ×N y ×N z , N x 、N y and N z They correspond to the number of grids in the x, y and z directions respectively, and the average number of grids allocated to each sub-area is expressed as M / N.

[0010] The particle count array S (i.e., the number of particles S) contained in each grid is determined by the initial conditions of the simulation and the particle distribution function. The number of particles will change dynamically during the simulation. A thread block is assigned to each sub-region, and each thread block is responsible for the collision tasks of all grids and their particles in its assigned sub-region. This allocation method ensures that the calculation tasks of each thread block are independent of each other, which facilitates parallel processing. A global particle array is defined to store the information of all current particles.

[0011] Step 2: Initial mapping of thread blocks to grids;

[0012] Traverse all particles, determine the index of the grid to which the particle belongs according to its position in three-dimensional space, count the number of particles in each grid, and obtain the particle count array S.

[0013] Based on the particle count array S, the starting offset O of the particles in each grid in the global particle array is calculated. This process is achieved by accumulating the starting offset of the previous grid and the number of particles in the grid. It is specifically expressed as:

[0014]

[0015] Where j is the grid index, and its value range is j=0,1,2,…,M-1. j represents the number of particles in the jth grid, O j Indicates the starting offset of the jth grid in the global particle array. The starting offset can be used to quickly locate the storage location of particles in each grid, thereby optimizing the memory access efficiency in the subsequent particle processing process.

[0016] Step 3: Dynamic load balancing adjustment;

[0017] Count the total number of particles T that all thread blocks need to process, and calculate the target number of particles P for each thread block based on the total number of thread blocks N. exp , specifically expressed as:

[0018]

[0019] The target number of particles represents the expected number of particles that each thread block should process under ideal load balancing conditions.

[0020] Traverse each thread block and accumulate the number of particles C in all grids it is responsible for:

[0021] C i =∑S j (3)

[0022] Among them, C i The total number of particles responsible for the i-th thread block. i and the target particle number P exp For comparison:

[0023] When C i >P exp , it means that there are too many particles in the current thread block, and the number of grids it is responsible for needs to be gradually reduced until C is satisfied. i ≤P exp Stop when.

[0024] When Ci <P exp , it means that the number of particles in the current thread block is too small, and the number of grids it is responsible for needs to be gradually increased until C is satisfied. i ≥P exp Stop when.

[0025] Update each thread block C i , ensuring that the number of particles processed by each thread block in subsequent calculations is C i As close as possible to the target particle number P exp , thereby achieving balanced load distribution and optimizing computing efficiency.

[0026] Step 4: Collision detection and execution;

[0027] Based on the adjusted mapping relationship between thread blocks and grids, each thread block processes all particles in the grid range it is responsible for in parallel. Each particle is assigned an independent thread, which calculates the corresponding collision cross section based on its energy and determines its collision probability, which is then compared with the random number to determine whether an ionization collision occurs.

[0028] If an ionization collision occurs, a new electron and a new ion are generated. To optimize performance, shared memory is used to cache newly generated particles. When all threads in a thread block have finished processing, the newly generated particle data in the shared memory is written to the global particle array in parallel.

[0029] Step 5: Loop through steps 2 to 4 until steady state is reached; then copy the particle data from the GPU back to the host, and release the allocated memory to complete the entire simulation solution process.

[0030] Furthermore, in each cycle of step 5, step 2 and step 3 are not executed at every time step, but at a predetermined time interval T. time Execution, T time The design needs to balance the dynamic changes of particle distribution and the computational overhead to choose a design that can adapt to the dynamic non-uniform changes of particle distribution and reduce the additional computational overhead.

[0031] Furthermore, the T time Choose a smaller time interval (such as T time =10) to cope with the rapidly changing particle distribution.

[0032] Furthermore, the T time Choose a larger time interval (such as T time =100) to cope with slowly changing particle distribution.

[0033] Furthermore, the above-mentioned dynamic load balancing method based on GPU parallel processing is applied to the field of high-power microwave protection. By simulating the dynamic evolution of plasma discharge caused by the interaction between microwaves and gases, the design of high-power microwave devices or systems is realized.

[0034] In summary, the present invention proposes a dynamic load balancing algorithm by adjusting the mapping relationship between GPU thread blocks and computing grids in real time, which effectively addresses the problem of highly uneven particle distribution in MCC simulation. The method evaluates the number of particles each thread block is responsible for and dynamically allocates computing resources to ensure that the number of particles processed by each thread block is as balanced as possible, avoiding the waste of computing resources caused by thread block overload or thread block idleness. In view of the continuous changes in the number and distribution of particles during the ionization collision process, the present invention adjusts the number of particles processed by each thread block every time T time Dynamically adjusting the thread block allocation strategy can always maintain a balanced distribution of computing load, thereby significantly improving GPU parallel efficiency and overall performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A schematic diagram of dynamic load balancing adjustment and collision parallel solution of the present invention;

[0036] Figure 2 The non-uniform distribution diagram of electrons in the simulation area at the initial moment;

[0037] Figure 3 This is the particle distribution diagram after ionization collision. DETAILED DESCRIPTION

[0038] The present invention is further described in detail below through examples and drawings.

[0039] A dynamic load balancing method based on GPU parallel processing, such as Figure 1 As shown, this embodiment simulates the ionization collision process of electrons in an argon background gas, and the specific implementation steps are as follows:

[0040] Step 1: Simulate area division;

[0041] Assume that the total number of grids in the simulation area is 2560 = 16 × 16 × 10, and define that every 10 grids form a sub-area, so there are 256 sub-areas in total. Assign an independent GPU thread block to each sub-area, for a total of 256 thread blocks. Each thread block is responsible for the particle ionization collision process of all 10 grids in its assigned sub-area. The number of grids managed by each thread block can be adjusted according to specific needs.

[0042] The simulation area is filled with argon gas with uniform density as background gas, and its density is 1×10 21 m -3The electrons are initially distributed in the simulation area in a non-uniform manner. The initial number of electrons is 1 million, and their distribution follows a Gaussian distribution, that is, the electron density in the middle area is high and gradually decreases toward the boundary. Figure 2 The distribution of electrons in the XY plane at the initial moment is shown. In order to optimize memory access on the GPU, electrons are stored in a structure array, and each electron contains six attributes (x, y, z, vx, vy, vz).

[0043] Step 2: Initial mapping of thread blocks to grids;

[0044] Traverse all particles and determine the grid index according to their three-dimensional spatial position. Count the total number of particles in each grid and get the particle count array S = {S0, S1, ... S 2559}, where S j Represents the number of particles in the jth grid.

[0045] Based on the particle count array, the starting offset of the particles in each grid in the global particle array is calculated according to formula (2) to obtain the starting offset array O. For example, the starting offset of the second grid is O1=S0, the starting offset of the third grid is O2=S0+S1, and so on. The offset array is used to quickly locate the storage location of the particles in each grid and optimize the memory access efficiency in the subsequent particle processing process.

[0046] Step 3: Dynamic load balancing adjustment;

[0047] Count the total number of particles T that need to be processed by all thread blocks (256), in this example T is 1 million. Calculate the target number of particles P for each thread block exp About 3906.

[0048] Traverse each thread block and accumulate the number of particles C in the grid it is responsible for i , and the target particle number P exp For comparison:

[0049] When C i >P exp , it means that there are too many particles in the current thread block, and the number of grids it is responsible for needs to be gradually reduced, that is, the tail index of the grid corresponding to the current block is reduced by 1 until C is satisfied. i ≤P exp Stop when.

[0050] When C i <P exp , it means that the number of particles in the current thread block is too small, and the number of grids it is responsible for needs to be gradually increased, that is, the tail index of the grid corresponding to the current block is increased by 1 until C is satisfied. i ≥P exp Stop when.

[0051] Update the grid index interval that each thread block is responsible for to ensure that the number of particles C processed by each thread block in subsequent calculations i As close as possible to the target particle number P exp , thereby achieving balanced load distribution and optimizing computing efficiency.

[0052] Step 4: Collision detection and execution

[0053] Based on the adjusted thread block and grid mapping relationship, each thread block processes all particles within the grid range it is responsible for in parallel. Assign an independent thread to each particle, calculate its energy, and calculate the collision probability P in combination with the background gas density and time step. Compare P with the random number R generated by the cuRAND library. If P < R, no collision occurs; otherwise, an ionization collision occurs. If an ionization collision occurs, a new electron and a new ion are generated. In order to optimize performance, shared memory is used to cache newly generated particles. When all threads in the thread block are processed, the newly generated particle data in the shared memory is written in parallel to the global particle list.

[0054] Step 5: Execute steps 2 to 4 in a loop. Steps 2 and 3 are repeated every T time The step size is executed once. Weighing the dynamic change of particle distribution and the computational overhead, this embodiment T time = 10. After all loops are completed, the particle data is copied from the GPU back to the host, and the allocated memory is released, completing the entire simulation solution process.

[0055] This example compares the computation time of the ionization collision process under GPU parallel and CPU serial conditions. Figure 3 shows the particle distribution in the XY plane after ionization, where Figure 3 (a) represents the initial electron, 3(b) represents the newly ionized electron, and 3(c) represents the newly ionized ion. It can be seen that more collisions occur in the initial electron gathering area, the number of particles is large, and the number of particles in other areas is small, and the distribution pattern is in line with expectations. When the initial distribution is 1 million electrons and the graphics card is GeForce RTX 4060, the serial running time of the CPU is 672.3ms, while the parallel running time of the GPU is 15.98ms. The final acceleration ratio is about 42, and the computing efficiency is significantly improved.

[0056] It can be seen from the above embodiments that the present invention proposes a dynamic load balancing algorithm by adjusting the mapping relationship between GPU thread blocks and computing grids in real time, which effectively addresses the problem of highly uneven particle distribution in MCC simulation. The method evaluates the number of particles each thread block is responsible for and dynamically allocates computing resources to ensure that the number of particles processed by each thread block is as balanced as possible, avoiding the waste of computing resources caused by thread block overload or thread block idleness. In view of the continuous changes in the number and distribution of particles during the ionization collision process, the present invention adjusts the number of particles processed by each thread block to the same level every time T. time Dynamically adjusting the thread block allocation strategy can always maintain a balanced distribution of computing load, thereby significantly improving the GPU parallel efficiency and overall performance. The present invention solves the problem of low computational efficiency of existing MCC simulation of ionization collisions and provides a basis for the design of protection for high-power microwave devices and systems.

Claims

1. A dynamic load balancing method based on GPU parallel processing, characterized in that: The following steps are involved: Step 1: Simulate area division; The simulation area is divided into N sub-areas. Each sub-area consists of several continuous grids. The set of grids is defined as the thread block grid set, denoted by G. i , where i is the index of the thread block, and N is the same as the total number of thread blocks; i = 0, 1, 2, ..., N-1; Assume that the total number of grids in the simulation area is M = N x ×N y ×N z , N x 、N y and N z They correspond to the number of grids in the x, y and z directions respectively; the average number of grids allocated to each sub-area is expressed as M / N; The particle count array S contained in each grid is determined by the simulation initial conditions and the particle distribution function. The number of particles will change dynamically during the simulation process. A thread block is assigned to each sub-region. Each thread block is responsible for the collision tasks of all grids and their particles in its assigned sub-region. A global particle array is defined to store the information of all current particles. Step 2: Initial mapping of thread blocks to grids; Traverse all particles, determine the index of the grid to which the particle belongs according to its position in three-dimensional space, count the number of particles in each grid, and obtain the particle count array S; Based on the particle count array S, the starting offset O of the particles in each grid in the global particle array is calculated. This process is achieved by accumulating the starting offset of the previous grid and the number of particles in the grid. It is specifically expressed as: Where j is the grid index, and its value range is j=0,1,2,…,M-1; S j represents the number of particles in the jth grid, O j Indicates the starting offset of the jth grid in the global particle array; Step 3: Dynamic load balancing adjustment; Count the total number of particles T that all thread blocks need to process, and calculate the target number of particles P for each thread block based on the total number of thread blocks N. exp , specifically expressed as: The target number of particles represents the expected number of particles that each thread block should process under ideal load balancing conditions; Traverse each thread block and accumulate the number of particles C in all grids it is responsible for: C i =∑S j (3) Among them, C i The total number of particles responsible for the i-th thread block; C i and the target particle number P exp For comparison: When C i >P exp When the number of grids it is responsible for is gradually reduced until C is satisfied i ≤P exp Stop when When C i <P exp When the number of grids it is responsible for is gradually increased until C is satisfied i ≥P exp Stop when Update each thread block C i ; Step 4: Collision detection and execution; Based on the adjusted mapping relationship between thread blocks and grids, each thread block processes all particles within the grid range it is responsible for in parallel; an independent thread is assigned to each particle, the corresponding collision cross section is calculated according to its energy, and its collision probability is determined, which is then compared with the random number to determine whether an ionization collision occurs; If an ionization collision occurs, a new electron and a new ion are generated, and the newly generated particles are cached using shared memory. When all threads in the thread block have finished processing, the newly generated particle data in the shared memory are written to the global particle array in parallel. Step 5: Loop through steps 2 to 4 until steady state is reached; then copy the particle data from the GPU back to the host, and release the allocated memory to complete the entire simulation solution process.

2. The dynamic load balancing method based on GPU parallel processing as claimed in claim 1, characterized in that: In each cycle of step 5, step 2 and step 3 are performed at a predetermined time interval T. time implement.

3. The dynamic load balancing method based on GPU parallel processing as claimed in claim 1, characterized in that: The T time Choose a smaller time interval T time =10 to cope with rapidly changing particle distribution.

4. The dynamic load balancing method based on GPU parallel processing as claimed in claim 1, characterized in that: The T time Choose a larger time interval T time = 100 to cope with slowly changing particle distribution.

5. The dynamic load balancing method based on GPU parallel processing as claimed in claim 1, characterized in that: Applied in the field of high-power microwave protection, it simulates the dynamic evolution of plasma discharge caused by the interaction between microwaves and gases, thereby realizing the design of high-power microwave devices or systems.

Citation Information

Patent Citations

  • Graphics processing unit based discrete simulation computation method of multicomponent system

    CN101727653A

  • Particle flow simulation system and method

    CN103324780A

  • Adaptive parallel algorithm for traversing neighbors in fixed radius under CPU-GPU (Central Processing Unit-Graphic Processing Unit) heterogeneous framework

    CN105468439A

  • Charge exchange collision MCC method used for ion thruster numerical simulation

    CN108549763A

  • Load balancing method in numerical simulation calculation

    CN113850032A

Cited By

  • SPH heterogeneous parallel solving method based on adaptive time sequence dynamic load balancing

    CN120950258A