A dynamic load balancing method based on GPU parallel processing

By dynamically adjusting the mapping relationship between thread blocks and grids, the problem of unbalanced computational load caused by uneven particle distribution in plasma discharge simulation is solved, the parallel computing efficiency and memory access efficiency of the GPU are improved, and efficient Monte Carlo collision simulation is achieved.

CN119806813BActive Publication Date: 2025-09-23UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the numerical simulation of plasma discharge, the traditional fixed thread allocation scheme causes thread blocks in high-density areas to be overloaded, while thread blocks in low-density areas are idle, resulting in low GPU parallel efficiency and inability to adapt to dynamic changes in particle distribution, affecting computational efficiency.

Method used

By dynamically adjusting the mapping relationship between thread blocks and computing grids, we ensure that the number of particles processed by each thread block is balanced. By adopting a dynamic load balancing method, we adjust the thread block allocation strategy in real time to adapt to changes in particle distribution and improve resource utilization.

Benefits of technology

It significantly improves the parallel computing efficiency and overall performance of the GPU, reduces thread block overload or idleness, optimizes memory access efficiency, and increases the calculation speed of Monte Carlo collision simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806813B_ABST
    Figure CN119806813B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of high-power microwave protection, and specifically relates to a dynamic load balancing method based on GPU parallel processing. 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 simulations. The method dynamically allocates computing resources by evaluating the number of particles each thread block is responsible for, ensuring that the number of particles processed by each thread block is as balanced as possible, and 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 load balancing algorithm every time T time Dynamically adjusting the thread block allocation strategy can always maintain a balanced distribution of computational load, significantly improving GPU parallel efficiency and overall performance. This solves the problem of low computational efficiency in existing MCC simulations of ionization collisions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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, microwave-gas interactions often trigger plasma discharges, significantly impacting microwave propagation characteristics and the performance of protection systems. Specifically, high-power microwaves, through electron-atom ionization collisions, can cause breakdown of the gaseous medium and the formation of high-density plasma. This, in turn, can affect the absorption, reflection, or scattering of microwave energy, leading to signal attenuation and component failure. Therefore, studying the dynamic evolution of plasmas during discharges is crucial for optimizing the design and performance of protection systems. The Monte Carlo Collision (MCC) method is a commonly used numerical technique in the numerical simulation of plasma discharges. This method randomly samples collisions between particles and statistically analyzes the motion and collision behavior of a large number of particles to obtain information about the macroscopic and microscopic dynamics of the plasma. At each time step, the MCC method iterates through a list of particles, calculates the collision probability of each particle, and compares it with a random number to determine whether a collision has occurred. If a collision occurs, the particle's position, velocity, and energy are updated based on the collision type. When an ionization collision occurs, high-energy electrons collide with the background gas, generating new electrons and ions. This process significantly increases the number of macroparticles, imposing a significant computational burden and impacting 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 acceleration of more than an order of magnitude 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 improving calculation speed. Because the collision behavior of particles within a single time step is independent of each other, particle collision calculations can be highly parallelized, making them ideal for accelerating calculations using the parallel architecture of GPUs.

[0004] However, during plasma discharge, particle distribution is often highly non-uniform. If a traditional fixed thread allocation scheme is used, thread blocks in high-density areas will be overloaded, while thread blocks in low-density areas will be idle, significantly reducing the parallel efficiency and overall computing performance of the GPU. In addition, as ionization collisions proceed, the number and distribution of particles continuously change in time and space. Fixed thread allocation cannot adapt to these dynamic changes 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 response to the above-mentioned problems or shortcomings, and to solve the problem of low computational efficiency of existing MCC simulation of ionization collisions, the present invention provides a dynamic load balancing method based on GPU parallel processing. By dynamically adjusting the mapping relationship between thread blocks and computational grids, it ensures that the number of particles processed by each thread block tends to be balanced, thereby improving the resource utilization of the GPU and better applying the 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 as 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 These 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 simulation conditions and the particle distribution function. The number of particles changes dynamically as the simulation progresses. Each subregion is assigned a thread block, which is responsible for the collision task of all grids and their particles within its assigned subregion. This allocation ensures that the computational tasks of each thread block are independent of each other, facilitating parallel processing. A global particle array is defined to store information about 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 they belong based on their 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 Represents 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 within each grid, thereby optimizing memory access efficiency during subsequent particle processing.

[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 When , it means that the number of particles in the current thread block is too large, 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 When , 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 between thread blocks and grids, each thread block processes all particles within its grid in parallel. Each particle is assigned a separate thread, which calculates its collision cross section based on its energy and determines its collision probability. This probability is then compared with a random number to determine whether an ionizing collision has occurred.

[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 completed processing, the newly generated particle data in 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, steps 2 and 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 computational overhead to select a design that can adapt to the dynamic non-uniform changes of particle distribution and reduce 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 gas, the design of high-power microwave devices or systems can be 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 simulations. This method dynamically allocates computing resources by evaluating the number of particles each thread block is responsible for, ensuring 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 response to the continuous changes in the number and distribution of particles during the ionization collision process, the present invention adjusts the load balancing algorithm 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 This is 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 argon background gas, and the specific implementation steps are as follows:

[0040] Step 1: Simulate area division;

[0041] Assume that the total number of grid cells in the simulation domain is 2560 (16 × 16 × 10). Each subregion is defined as 10 grid cells, resulting in a total of 256 subregions. Each subregion is assigned a separate GPU thread block, for a total of 256 thread blocks. Each thread block is responsible for the particle ionization collision process for all 10 grid cells within its assigned subregion. The number of grid cells managed by each thread block can be adjusted based on specific needs.

[0042] The simulation area is filled with argon gas of uniform density as background gas, with a density of 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 towards the boundary. Figure 2 The figure shows the distribution of electrons in the XY plane at the initial moment. To optimize memory access on the GPU, electrons are stored in a structure array, where 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 each grid particle 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. This offset array is used to quickly locate the storage location of particles in each grid and optimize memory access efficiency in subsequent particle processing.

[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 3,906.

[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 When , 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 When , 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 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 to calculate its energy and calculate the collision probability P based on the background gas density and time step. P is compared 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. To optimize performance, shared memory is used to cache newly generated particles. When all threads in the thread block have finished processing, the newly generated particle data in the shared memory is written in parallel to the global particle list.

[0054] Step 5: Loop through steps 2 to 4. Steps 2 and 3 are repeated every T time The step size is executed once. Weighing the dynamic change of particle distribution and 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 electrons, (b) represents the newly ionized electrons, and (c) represents the newly ionized ions. It can be seen that the initial electron concentration region exhibits more collisions and a higher particle count, while other regions have fewer particles, demonstrating a distribution pattern consistent with expectations. When the initial distribution contains 1 million electrons and the graphics card is a GeForce RTX 4060, the CPU serial runtime is 672.3ms, while the GPU parallel runtime is 15.98ms, resulting in a speedup of approximately 42, significantly improving computational efficiency.

[0056] As can be seen from the above embodiments, 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 simulations. This method dynamically allocates computing resources by evaluating the number of particles each thread block is responsible for, ensuring 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 response to the continuous changes in the number and distribution of particles during the ionization collision process, the present invention adjusts the load balancing algorithm every time T time Dynamically adjusting the thread block allocation strategy can consistently maintain a balanced distribution of computational load, significantly improving GPU parallel efficiency and overall performance. This invention addresses the low computational efficiency of existing MCC simulations of ionizing collisions and provides a foundation 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 as 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 information about all current particles. Step 2: Initial mapping of thread blocks to grids; Traverse all particles, determine the index of the grid to which they belong based on their 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 j-th 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 C i ≥P exp Stop when Update each thread block C i ; Step 4: Collision detection and execution; Based on the adjusted mapping between thread blocks and grids, each thread block processes all particles within its grid in parallel. Each particle is assigned a separate thread, which calculates the corresponding collision cross section based on its energy and determines its collision probability, which is then compared with a random number to determine whether an ionizing collision has occurred. If an ionization collision occurs, a new electron and a new ion are generated, and the newly generated particles are cached in 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 according to 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 according to 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 according to claim 1, wherein: 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 according to claim 1, characterized in that: Applied to 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