An intelligent optimization method based on multiphase flow LBM parallel algorithm
By constructing a data dependency model and a memory access performance analysis model, and combining a grouped genetic algorithm to optimize the memory access and data dependency of the multiphase flow LBM algorithm, the kernel fusion optimization problem of the multiphase flow LBM algorithm is solved, and a significant improvement in computational efficiency is achieved.
Patent Information
- Application Number
- CN202411979128.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Existing technologies lack kernel fusion optimization strategies for multiphase flow LBM algorithms, which cannot effectively solve the problems of complex high-order gradient calculations and frequent large-scale data read and write in multiphase flow LBM algorithms, resulting in low parallel computing efficiency.
Combining intelligent search algorithms and CUDA kernel fusion methods, a kernel fusion optimization strategy was designed. By constructing a data dependency model and a memory access performance analysis model, a grouped genetic algorithm was used to search for the optimal fusion scheme, optimize memory access and data dependencies of the multiphase flow LBM algorithm, and utilize shared memory and registers for data storage to reduce memory access cycles.
It significantly improves the execution efficiency and parallel performance of the multiphase flow LBM algorithm, and enhances computational efficiency, especially on high-performance GPU platforms, where the number of millions of fluid lattice points updated per second is significantly improved.
Smart Images

Figure CN119917388B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the field of GPU parallel computing and fluid mechanics, and particularly relates to an intelligent optimization method based on a multiphase flow LBM parallel algorithm. BACKGROUND
[0002] In the field of computational fluid dynamics, the lattice Boltzmann method (LBM) has been widely used in the study of multiphase flow, complex fluid flow and nonlinear fluid problems as an important simulation technology. With the rapid development of computer technology, researchers are constantly exploring how to use parallel computing technology to improve the simulation efficiency of LBM.
[0003] In the prior art, the LBM parallel algorithm based on GPU has become a research hotspot. The CUDA programming model launched by NVIDIA provides strong support for the parallelization of LBM algorithm. Researchers successfully migrated the LBM algorithm to GPU by optimizing memory access mode, using shared memory, reducing thread synchronization and adjusting data layout, and achieved significant speedup. For example, Huang Bin et al. designed a parallel algorithm of LBM based on the CUDA programming model and applied it to the calculation model of electroconvection; D.B.Zhakebayev et al. proposed a LES-LBM solver supporting CUDA GPU workstation.
[0004] In addition, researchers have also conducted in-depth exploration in the aspect of kernel fusion technology. The kernel fusion method can reduce memory access cost and data transmission overhead by merging multiple kernel functions into a larger kernel function, further improving the efficiency of parallel computing. Fousek et al. demonstrated how to improve the performance of BLAS-1 and BLAS-2 routines through fusion; A.Li et al. proposed an automatic horizontal fusion technology aimed at increasing thread-level parallelism to hide instruction latency; J.Fukuhara et al. proposed a control-flow-based kernel fusion method.
[0005] The kernel fusion technology also has potential application value in the parallel optimization of multiphase flow. By fusing multiple related kernel functions, the data transmission overhead and kernel startup overhead can be reduced, and the computing efficiency can be improved. The kernel fusion problem can be essentially regarded as a combination optimization problem, and its solution depends on an efficient search algorithm to explore the optimal fusion strategy. The CUDA kernel performance prediction model can provide performance evaluation of each combination and guide the selection of the optimal solution in the combination optimization process. Researchers have made significant progress in the algorithm of combination optimization problem and the CUDA kernel performance prediction model. Wang Xiujing and U. Khairuddin et al. solved the packing problem by using genetic algorithm, which provided a basis for the combination optimization problem. Sun Ren and Y. Jiang et al. designed and implemented a three-dimensional packing algorithm based on reinforcement learning for the three-dimensional packing problem.
[0006] In terms of CUDA kernel performance prediction model, Jiang Lin, Junjie Lai, Gargi Alavani and Sunpyo Hong et al. established performance prediction models from the aspects of instruction execution, intermediate code analysis, memory access, computing cost and the like. However, the multiphase flow LBM algorithm is a memory-intensive algorithm, and a performance model considering only memory cost is needed to provide a powerful tool for performance evaluation before and after kernel fusion.
[0007] Although the kernel fusion technology has been widely used in many fields, its application in the multiphase flow LBM algorithm is relatively less. The multiphase flow LBM algorithm is different from the single-phase LBM algorithm. Due to the interaction between different phases of matter in the multiphase flow, the multiphase flow LBM algorithm often needs complex high-order gradient calculation and frequent and large data reading and writing. At present, there is a lack of kernel fusion optimization strategy for the characteristics of the multiphase flow LBM algorithm. Therefore, how to comprehensively consider the algorithm characteristics, memory access, data dependency and computing cost and other factors to realize the efficient parallel optimization of the multiphase flow LBM algorithm has become a problem to be solved. SUMMARY
[0008] The purpose of the present application is to combine intelligent search algorithm and CUDA kernel fusion method, solve the problem of optimizing multiphase flow LBM parallel algorithm, and propose an intelligent optimization method based on multiphase flow LBM parallel algorithm. This method designs a set of kernel fusion optimization strategy. This strategy not only deeply understands the unique properties of LBM algorithm, but also analyzes the memory access mode, data dependency and other key factors. This method also integrates the grouping genetic algorithm, an intelligent search technology, which can automatically determine the optimal kernel fusion strategy, thereby significantly improving the execution efficiency and parallel performance of the multiphase flow LBM algorithm. This innovation not only provides a new idea for the efficient parallel optimization of LBM algorithm, but also brings substantial performance improvement for the scientific research and industrial application of multiphase flow LBM.
[0009] The technical solution to achieve the objective of this invention is:
[0010] A smart optimization method based on the multiphase flow LBM parallel algorithm includes the following steps:
[0011] 1) Construct a data dependency model for the multiphase flow LBM parallel algorithm;
[0012] 2) Construct a memory access performance analysis model for the multiphase flow LBM parallel algorithm.
[0013] 3) Based on the data dependency model, the characteristics of GPU memory access, and the data read / write relationship, a kernel fusion rule and a method for estimating the performance change after fusion are proposed for the multiphase flow LBM algorithm;
[0014] 4) A graph structure is used to represent data dependencies, and the fusion rules and performance change estimation methods are combined into the grouped genetic algorithm to search for the optimal fusion scheme of the multiphase flow LBM parallel algorithm;
[0015] 5) Optimize the original multiphase flow LBM parallel algorithm according to the optimal fusion scheme, and compare the performance before and after optimization.
[0016] Step 1) involves constructing a data dependency model for the multiphase flow LBM parallel algorithm, including building a data dependency graph and an execution order graph. First, a data dependency graph for the multiphase flow LBM is constructed. In this data dependency graph, there are three key types of arrays: read-only arrays, read-write arrays, and write-only arrays. By conducting in-depth analysis of each kernel function in the CUDA program, each kernel function is represented as a node in the data dependency graph, and the data passed between each node is used as the weight of the edge to connect them. This data dependency graph can clearly show the data dependencies between kernel functions, making the structure and behavior of the entire CUDA program clear at a glance, which is convenient for understanding and optimization.
[0017] An execution sequence graph is constructed following the execution order of each processing step in the original multiphase flow LBM algorithm. The execution sequence graph is a directed acyclic graph, where the nodes represent kernel functions. When constructing this execution sequence graph, the nodes are merged in logical order without violating the execution priority between kernels. Using the execution sequence graph, it is possible to accurately determine which original kernels can be merged into the new kernel, thereby optimizing the performance of CUDA programs without violating the logical order of CUDA programs.
[0018] Through this design, the technical solution not only provides an intuitive display of data dependencies, but also ensures the logical correctness and executability of the kernel fusion process.
[0019] In step 2), a memory access performance analysis model for the multiphase flow LBM parallel algorithm is constructed to conduct in-depth analysis and optimization of the memory access performance of multiphase flow LBM in CUDA programs. Given that the changes in CUDA program computation operations before and after kernel fusion are relatively small, the analysis focuses on the changes in memory access costs before and after fusion, rather than the increase or decrease in computation costs. During the execution of CUDA programs, the memory access of kernel functions covers global memory, shared memory, and register access. To achieve effective optimization of memory access performance, a detailed analysis of kernel functions is required, accurately calculating the number of accesses to various types of memory in the kernel functions, and fully considering the number of cycles required by the GPU device when accessing different types of memory.
[0020] The number of memory access cycles for kernel function k is calculated as follows:
[0021] C(k)=N G ·C G +N R ·C R +N S ·C S (1)
[0022]
[0023] In formulas (1) and (2), C G C S C R N represents the number of cycles required for the GPU to access global memory, shared memory, and registers, respectively. G N S N R These represent the number of times the kernel function accesses global memory, shared memory, and registers, respectively. C represents the sum of memory access cycles of all kernels in the CUDA program, and C(k) represents the number of memory access cycles of kernel function k.
[0024] In step 3), based on the data dependency model, GPU memory access characteristics, and data read / write relationships, a kernel fusion rule and a method for estimating performance changes after fusion are proposed for the multiphase flow LBM algorithm. Specifically, kernel fusion in the data dependency graph is represented by the fusion of multiple kernel functions into a large kernel function. Different fusion strategies directly affect the data read / write strategy. The rules for determining whether and how multiple kernel functions can be fused are divided into the following two cases:
[0025] (3.1) Rule 1: If one kernel function performs a write operation on an array, and then another kernel function performs a read operation on the same array, these two kernel functions can be merged. After merging, the array can be stored in a register to reduce memory access cycles. A represents the number of times the original kernel accessed the array before merging. In this case, the reduction in memory access cycles Δ1 is calculated as follows:
[0026] Δ1=A·(C G -C R (3)
[0027] (3.2) Rule 2: If multiple kernel functions perform read-only operations on the same array, these multiple kernel functions can be merged into one kernel function, and the array can be stored in shared memory to avoid multiple reads of global memory, thereby reducing memory access cycles; A represents the number of times the original kernel accessed the array before merging; at this time, the reduction in memory access cycles Δ2 is calculated as follows:
[0028] Δ2=(A-1)·C G -A·C S (4)
[0029] The final reduction in access cycles ΔC(K) of a single kernel K after fusion is calculated as follows:
[0030] ΔC(K)=Δ1+Δ2,(5)
[0031]
[0032] Finally, the memory access cycle improvement efficiency E before and after fusion is calculated using formula (6), thereby quantifying the degree of improvement in memory access performance brought about by kernel fusion.
[0033] In step 4), a graph structure is used to record data dependencies. The fusion rules and performance prediction estimation methods are combined into the grouped genetic algorithm to search for the optimal fusion scheme of the multiphase flow LBM parallel algorithm. Specifically, for the CUDA kernel fusion problem, it can be regarded as a combinatorial optimization problem, which can be solved by the grouped genetic algorithm in the heuristic search algorithm. In the grouped genetic algorithm, the fitness function should be based on the formula (6) obtained from the performance change analysis before and after fusion. The specific steps are as follows:
[0034] (4.1) First, number each kernel function and the arrays it accesses in the CUDA program, and use a graph structure to store the data dependency graph and execution order graph of the CUDA program; then, perform topological sorting on the kernel functions according to the execution order graph, and randomly divide the kernel functions into several groups according to the topological sorting result, and assign a unique number to each group, count the kernel function numbers contained in each group, and thus form an individual; in this way, 50 individuals are randomly generated to form an initial population;
[0035] (4.2) By analyzing the data dependency graph, determine the read and write relationships of the arrays between kernel functions in the group, and determine which fusion rule is met accordingly; then, use formula (3) or formula (4) to calculate the memory access cycle change of each group; this step will be applied to all groups to calculate their respective memory access cycle change; then, according to the improvement efficiency E defined in formula (6), calculate the fitness value of each individual and save the results;
[0036] (4.3) Select a number of individuals from the population as parents by roulette wheel selection, perform crossover and mutation operations to generate new offspring individuals, determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence diagram, if they do not meet the requirements, retain the parent individuals, and repeat the operations of steps (4.2) and (4.3).
[0037] (4.4) After each evolution, the individual with the highest fitness value in the population is regarded as the best individual of that generation. After 50 generations of evolution, the fitness values of the best individuals in each generation are compared, and the grouping of the individuals with the highest fitness values is output to obtain the optimal kernel fusion strategy.
[0038] In step 5), the original multiphase flow LBM parallel algorithm is optimized according to the optimal fusion scheme, and the performance before and after optimization is compared. The read-only array is stored in shared memory, and the read-write array is stored in registers to obtain the optimized CUDA program. The running time of the program before and after the improvement is statistically analyzed, and the efficiency of the performance improvement is calculated.
[0039] Compared to existing technologies, the significant feature of this technical solution lies in its specially designed kernel fusion optimization strategy for the multiphase flow LBM parallel algorithm. This strategy not only deeply understands the unique properties of the LBM algorithm but also comprehensively analyzes key factors such as memory access patterns and data dependencies. This solution cleverly incorporates a grouped genetic algorithm, an intelligent search technique, which can automatically determine the optimal kernel fusion strategy, thereby significantly improving the execution efficiency and parallel performance of the multiphase flow LBM algorithm. This innovation not only provides a new approach to the efficient parallel optimization of the LBM algorithm but also brings substantial performance improvements to the scientific research and industrial applications of multiphase flow LBM. Attached Figure Description
[0040] Figure 1 Data dependency graph for the LBM parallel program of chemical potential multiphase flow;
[0041] Figure 2 This is a diagram showing the execution sequence of the LBM parallel program for multiphase flow with chemical potential.
[0042] Figure 3 Flowchart of the grouped genetic algorithm for searching the optimal kernel fusion scheme;
[0043] Figure 4 Comparison of global memory access volume before and after merging;
[0044] Figure 5 Shared memory access volume after merging;
[0045] Figure 6 The program updates millions of fluid grid points per second before and after merging in A100 and V100. Detailed Implementation
[0046] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this is not intended to limit the scope of the invention.
[0047] Example:
[0048] The intelligent optimization method of the LBM parallel algorithm for chemical potential multiphase flow includes the following steps:
[0049] 1) such as Figure 1 As shown, the first step is to conduct an in-depth analysis of the data dependencies between kernel functions in the chemical potential multiphase flow LBM parallel program. This step aims to clarify the mutual dependencies of each kernel function in data processing, thereby constructing a data dependency graph of the chemical potential model. In this data dependency graph, each circular node represents the number of the CUDA kernel function, while the hexagonal nodes represent the arrays read and written by these kernel functions. Figure 1 In the diagram, red hexagons represent read-only arrays, yellow hexagons represent read-write arrays, and green hexagons represent write-only arrays.
[0050] Next, based on the constructed data dependency graph, an execution order graph is further established. In this execution order graph, the CUDA kernel function numbers serve as graph nodes, and the connections between nodes reflect the logical execution order of the kernel functions. When constructing this execution order graph, the principle of kernel execution priority must not be violated; that is, the nodes must be logically ordered and connected according to data dependencies and the characteristics of parallel computing. The final execution order graph is as follows: Figure 2 As shown, this execution sequence diagram ensures that the subsequent fusion process strictly follows the logical order of the program and does not produce any logical conflicts;
[0051] 2) Analyze the memory access performance of the chemical potential multiphase flow LBM. During the execution of the CUDA program, the memory access of the kernel function covers global memory, shared memory, and register access. Since the number of cycles for GPU to access global memory is much greater than that for shared memory and registers, in order to effectively optimize memory access performance, it is necessary to reduce global memory access and use shared memory and registers to read and write data as much as possible. This requires a detailed analysis of the kernel function, accurate calculation of the number of accesses of various types of memory in the kernel function, and full consideration of the number of cycles required by the GPU device when accessing different types of memory.
[0052] The number of memory access cycles for the kernel function k before merging is calculated as follows:
[0053] C(k)=N G ·C G +N R ·C R +N S ·C S (1)
[0054]
[0055] In formulas (1) and (2), C G C S C R N represents the number of cycles required for the GPU to access global memory, shared memory, and registers, respectively. G N S N R These represent the number of times the kernel function accesses global memory, shared memory, and registers, respectively. C represents the sum of memory access cycles of all kernels in the CUDA program, and C(k) represents the number of memory access cycles of kernel function k.
[0056] 3) Based on the data dependency model, GPU memory access characteristics, and data read / write relationships, a kernel fusion rule and a method for estimating performance changes after fusion are proposed for the multiphase flow LBM algorithm. Kernel fusion in the data dependency graph is represented by the fusion of multiple kernel functions into a large kernel function. Different fusion strategies directly affect the data read / write strategies. The rules for determining whether and how multiple kernel functions can be fused are divided into the following two cases:
[0057] (3.1) such as Figure 1 As shown in the red dashed box, the kernel function K_1 pair in the combination The array is written to, then read from by the kernel function K_2. After merging, the array can be stored in a register to reduce memory access cycles. The reduction in memory access cycles Δ1 is calculated as follows:
[0058] Δ1=A·(C G -C R (3)
[0059] (3.2) such as Figure 1 As shown in the blue dashed box, multiple functions in the combination perform read-only operations on the ρ array. After merging, this array can be stored in shared memory to achieve the same goal of reducing memory access cycles. The reduction in memory access cycles Δ2 is calculated as follows:
[0060] Δ2=(A-1)·C G -A·C S (4)
[0061] In formulas (3) and (4), A represents the number of times the original kernel accessed the array before fusion. In this example, A = 2 in formula (3) and A = 3 in formula (4).
[0062] The final reduction in access cycles ΔC(K) of the merged kernel K is calculated as follows:
[0063] ΔC(K)=Δ1+Δ2,(5)
[0064] Taking the fusion of K-1 and K-2 as an example, ΔC(K 1,2 ) is 2(C G -C R )+[(2-1)C G -2C S ],
[0065]
[0066] Finally, the memory access cycle improvement efficiency E before and after fusion is calculated using formula (6), thereby quantitatively evaluating the degree of improvement in memory access performance brought about by kernel fusion.
[0067] 4) such as Figure 3 As shown, a graph structure is used to record data dependencies. The fusion rules and performance prediction estimation methods are combined into the grouped genetic algorithm. The specific process for searching the optimal kernel fusion scheme of the multiphase flow LBM parallel algorithm is as follows:
[0068] (4.1) First, number each kernel function and the arrays it accesses in the CUDA program, and use a graph structure to store the data dependency graph and execution order graph of the CUDA program; then, perform topological sorting on the kernel functions according to the execution order graph, and randomly divide the kernel functions into several groups according to the topological sorting result, and assign a unique number to each group, count the kernel function numbers contained in each group, and thus form an individual; in this way, 50 individuals are randomly generated to form an initial population;
[0069] (4.2) By analyzing the data dependency graph, determine the read and write relationships of the arrays between kernel functions in the group, and determine which fusion rule is met accordingly; then, use formula (3) or formula (4) to calculate the memory access cycle change of each group; this step will be applied to all groups to calculate their respective memory access cycle change; then, according to the improvement efficiency E defined in formula (6), calculate the fitness value of each individual and save the results;
[0070] (4.3) Select a number of individuals from the population as parents by roulette wheel selection, perform crossover and mutation operations to generate new offspring individuals, determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence diagram, if they do not meet the requirements, retain the parent individuals, and repeat the operations of steps (4.2) and (4.3).
[0071] The crossover and mutation process of the grouped genetic algorithm for searching the optimal kernel fusion scheme is as follows:
[0072] First, two parent individuals are selected from the population. In each parent's chromosome, a set of consecutive genes (fusion nuclei) is randomly selected as the crossover gene. The crossover gene from one parent's chromosome is inserted into the other parent's chromosome, positioned before the crossover gene from the other parent. After insertion, there may be duplicate original nuclei in the old and new genes. All original nuclei of the old gene are marked, and all genes in the marked original nuclei are deleted. This step aims to remove duplicate or redundant gene information to ensure chromosome stability and gene uniqueness. The missing original nuclei are then used to form new genes, which are inserted at the end of the individual's chromosome. Due to the deletion operation, some original nuclei may be missing. These missing original nuclei are then reassembled into new genes, and these... The insertion of a new gene at the end of an individual chromosome aims to restore chromosome integrity and ensure that all necessary genetic information is preserved. Next, mutation adjustments are performed on each individual in the population with a low probability to explore new regions in the search space and help escape potential local optima as the algorithm gradually approaches convergence. Two operations, splitting and merging, are employed. When the number of genes on a chromosome exceeds half the number of original nuclei, two adjacent genes are randomly selected for merging. Conversely, if the number of genes is less than half the number of original nuclei, at most one gene with the number of original nuclei is selected for splitting, splitting the gene with the number of original nuclei into two new genes, thereby increasing gene diversity and broadening the search range.
[0073] (4.4) After each evolution, the individual with the highest fitness value in the population is regarded as the best individual of that generation. After 50 generations of evolution, the fitness values of the best individuals in each generation are compared, and the grouping of the individuals with the highest fitness values is output to obtain the optimal kernel fusion strategy.
[0074] 5) The optimal fusion strategy was determined based on the intelligent search algorithm, and the original chemical potential multiphase flow LBM parallel algorithm was optimized. Based on the original kernel grouping, the read-only array was stored in shared memory, and the read-write array was stored in registers, resulting in the optimized CUDA program. To verify the actual effect of this improvement, the memory access behavior of the program before and after fusion was statistically analyzed. Figure 4 , Figure 5As can be clearly seen, the merged program exhibits a significant reduction in global memory read and write speeds compared to the original program. This is attributed to the merged program's clever use of shared memory and registers for data read and write operations, thereby drastically reducing global memory read and write operations and effectively shortening memory access cycles. To concretely demonstrate the performance improvement, experiments were conducted on different GPU platforms, such as... Figure 6 As shown, the optimization strategy in this example works best on the high-performance A100 GPU. During the experiment, various flow field sizes were used for testing. The results show that when the flow field size is set to 128... 3 The performance improvement was most significant when the flow field size was 448. After fusion, the number of millions of fluid lattice points updated per second increased by 24.7% compared to before fusion. Conversely, when the flow field size was 448... 3 At that time, the performance improvement was relatively poor, with the number of millions of fluid grid points updated per second after fusion only increasing by 17.2% compared to before fusion.
Claims
1. A smart optimization method based on the multiphase flow LBM parallel algorithm, characterized in that, Includes the following steps: 1) Construct a data dependency model for the multiphase flow LBM parallel algorithm; this model includes constructing a data dependency graph and an execution order graph; firstly, construct the data dependency graph of the multiphase flow LBM, in which the arrays involved in each process are divided into three types: read-only array, read-write array, and write-only array; each kernel function is represented as a node in the data dependency graph, and the data passed between each node is used as the weight of the edge to connect them; An execution sequence graph is constructed following the execution order of each processing step in the original multiphase flow LBM algorithm. The execution sequence graph is a directed acyclic graph, where the nodes represent kernel functions. When constructing this execution sequence graph, the nodes are merged in logical order without violating the execution priority between kernels. By using the execution sequence graph, it is guaranteed that the merged CUDA algorithm does not violate the logical order of the original LBM algorithm. 2) Construct a memory access performance analysis model for the multiphase flow LBM parallel algorithm, and conduct in-depth analysis and optimization of the memory access performance of multiphase flow LBM in CUDA programs. Given that the changes in CUDA program computation operations are relatively small before and after kernel fusion, and considering that the memory access of kernel functions during the execution of CUDA programs covers global memory, shared memory, and register access, determine the number of accesses of various types of memory in kernel functions, and consider the number of cycles required by the GPU device when accessing different types of memory. The number of memory access cycles for kernel function k is calculated using the following formula: (1), (2), In formulas (1) and (2) , , These represent the number of cycles required for the GPU to access global memory, shared memory, and registers, respectively. , , These represent the number of times the kernel function accesses global memory, shared memory, and registers, respectively. This represents the sum of memory access cycles for all kernels in a CUDA program. This represents the number of memory access cycles for kernel function k; 3) Based on the data dependency model, the characteristics of GPU memory access, and the data read / write relationship, a kernel fusion rule and a method for estimating the performance change after fusion are proposed for the multiphase flow LBM algorithm; 4) Integrate the fusion rules and performance change estimation methods into the grouped genetic algorithm to search for the optimal fusion scheme of the multiphase flow LBM parallel algorithm; 5) Optimize the original multiphase flow LBM parallel algorithm according to the optimal fusion scheme, and compare the performance before and after optimization.
2. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 1, characterized in that: In step 3), based on the data dependency model, GPU memory access characteristics, and data read / write relationships, a kernel fusion rule and a method for estimating performance changes after fusion are proposed for the multiphase flow LBM algorithm. Specifically, kernel fusion in the data dependency graph is represented by merging multiple kernel functions into a large kernel function. Different fusion strategies directly affect the data read / write strategy. The rules for determining whether and how multiple kernel functions can be merged are divided into the following two cases: (3.1) Rule 1: If a kernel function performs a write operation on an array, and then another kernel function performs a read operation on the same array, these two kernel functions can be merged. After merging, the array is stored in a register. In this way, the read operation of the array by the latter kernel function changes from reading off-chip global memory to reading on-chip registers, reducing memory access cycles. At this time, the reduction in memory access cycles is... The calculation method is as follows: (3), (3.2) Rule 2: If multiple kernel functions perform read-only operations on the same array, these multiple kernel functions can be merged into one kernel function, and the array can be stored in shared memory to avoid multiple reads of global memory, thereby reducing memory access cycles; in this case, the reduction in memory access cycles is... The calculation method is as follows: (4), In formulas (3) and (4), A represents the number of times the original kernel accessed the array before fusion; The number of access cycles ultimately reduced by the merged single kernel K The calculation method is as follows: (5), (6), Finally, the memory access cycle improvement efficiency E before and after fusion is calculated using formula (6), thereby quantifying the degree of improvement in memory access performance brought about by kernel fusion.
3. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 2, characterized in that: In step 4), a graph structure is used to represent data dependencies. The fusion rules and performance prediction estimation methods are combined into the grouped genetic algorithm to search for the optimal fusion scheme of the multiphase flow LBM parallel algorithm. Specifically, for the CUDA kernel fusion problem, it is regarded as a combinatorial optimization problem and is solved by the grouped genetic algorithm in the heuristic search algorithm. In the grouped genetic algorithm, the fitness function should be based on the formula (6) obtained from the performance change analysis before and after fusion. The specific steps are as follows: (4.1) First, number each kernel function and the arrays accessed by the CUDA program, and use a graph structure to store the data dependency graph and execution order graph of the CUDA program; then, perform topological sorting of the kernel functions according to the execution order graph, and according to the result of the topological sorting, randomly combine all kernel functions into several groups, and assign a unique number to each group. Count the kernel function numbers contained in each group to form an individual; in this way, 50 individuals are randomly generated to form an initial population. (4.2) By analyzing the data dependency graph, determine the read and write relationships of the arrays between kernel functions in the group, and determine which fusion rule it conforms to; then, use formula (3) or formula (4) to calculate the memory access cycle change of each group; This step will be applied to all groups to calculate their respective memory access cycle changes; Subsequently, the fitness value of each individual is calculated according to the improvement efficiency E defined in formula (6), and the results are saved. (4.3) Select a number of individuals from the population as parents by roulette wheel selection, perform crossover and mutation operations to generate new offspring individuals, determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence diagram, if they do not meet the requirements, retain the parent individuals, and repeat the operations of steps (4.2) and (4.3). (4.4) After each evolution, the individual with the highest fitness value in the population is regarded as the best individual of the offspring. After 50 generations of evolution, the fitness values of the best individuals in each generation are compared, and the grouping of the individuals with the highest fitness values is output to obtain the optimal kernel fusion strategy.
4. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 1, characterized in that: In step 5), the original multiphase flow LBM parallel algorithm is optimized according to the optimal fusion scheme, and the performance before and after optimization is compared; that is, the read-only array is stored in shared memory, and the read-write array is stored in registers to obtain the optimized CUDA program. The running time of the program before and after the improvement is statistically analyzed, and the efficiency of the performance improvement is calculated.
Citation Information
Patent Citations
Method for accelerating lattice-Boltzmann by utilizing graphic processing units (GPUs)
CN102681972A
Graphics processing unit (GPU) program optimization method based on compute unified device architecture (CUDA) parallel environment
CN102981807A