Intelligent optimization method based on multiphase flow LBM parallel algorithm

Through the intelligent search algorithm and CUDA kernel fusion method, a set of kernel fusion optimization strategies were designed to solve the problem of low parallel computing efficiency of multi-phase stream LBM algorithm on GPU, and achieved significant execution efficiency and parallel performance improvement.

CN119917388AActive Publication Date: 2025-05-02GUANGXI NORMAL UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411979128.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

The lack of efficient kernel fusion optimization strategy for multiphase stream LBM algorithms in the prior art, resulting in low efficiency when performing parallel computing of multiphase stream LBM on the GPU.

Method used

An intelligent search algorithm combined with CUDA kernel fusion method is used to design a set of kernel fusion optimization strategies. By building a data dependency relationship model and a memory fetch performance analysis model, combined with a grouping genetic algorithm, the optimal kernel fusion strategy is automatically determined, thereby optimizing the execution efficiency and parallel performance of the multi-phase flow LBM algorithm.

Benefits of technology

It significantly improves the execution efficiency and parallel performance of the multi-phase flow LBM algorithm, and provides new ideas to efficient parallel optimization of the LBM algorithm, bringing substantial performance improvements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917388A_ABST
    Figure CN119917388A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent optimization method based on a multiphase flow LBM parallel algorithm. The intelligent optimization method comprises the following steps: 1) constructing a data dependency model of the multiphase flow LBM parallel algorithm; 2) constructing a multiphase flow LBM parallel algorithm memory access performance analysis model; 3) proposing a kernel fusion rule and a performance change estimation method after fusion for the multiphase flow LBM algorithm according to the data dependency relationship model, the GPU memory access characteristics and the data read-write relationship; 4) combining the fusion rule and a performance change estimation method into a grouping genetic algorithm, and searching an optimal fusion scheme; and 5) performing optimization according to the optimal fusion scheme, and comparing the performance before and after optimization. According to the method, CUDA kernel data transmission and memory access characteristics are comprehensively considered, performance gains under various CUDA kernel fusion strategies are explored through an intelligent search algorithm, finally, the optimal CUDA kernel fusion strategy is obtained, and the acceleration effect is remarkably improved compared with a traditional multiphase flow LBM parallel method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the fields of GPU parallel computing and fluid mechanics, and in particular to an intelligent optimization method based on a multiphase flow LBM parallel algorithm. Background Art

[0002] In the field of computational fluid dynamics, the Lattice Boltzmann Method (LBM) is an important simulation technology that has been widely used in the study of multiphase flow, complex fluid flow and nonlinear fluid problems. 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] Among the existing technologies, the GPU-based LBM parallel algorithm has become a hot topic of research. The CUDA programming model launched by NVIDIA provides strong support for the parallelization of the LBM algorithm. Researchers have successfully migrated the LBM algorithm to the GPU by optimizing memory access patterns, utilizing shared memory, reducing synchronization between threads, and adjusting data layout, and have achieved significant acceleration effects. For example, Huang Bin et al. designed a parallel algorithm for LBM based on the CUDA programming model and applied it to the computational model of electroconvection; DBZhakebayev et al. proposed a LES-LBM solver for a GPU workstation that supports CUDA.

[0004] In addition, researchers have also conducted in-depth explorations in kernel fusion technology. The kernel fusion method can reduce memory access costs, reduce data transmission overhead, and further improve parallel computing efficiency by merging multiple kernel functions into a larger kernel function. 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 that aims to increase thread-level parallelism to hide instruction latency; J. Fukuhara et al. proposed a kernel fusion method based on control flow.

[0005] Kernel fusion technology also has potential application value in multiphase flow parallel optimization. By fusing multiple related kernel functions, it can reduce data transmission overhead and kernel startup overhead and improve computing efficiency. The kernel fusion problem can essentially be regarded as a combinatorial optimization problem. Its solution relies on efficient search algorithms to explore the optimal fusion strategy, while the CUDA kernel performance prediction model can give performance evaluations of each combination and provide guidance for the selection of the optimal solution in the combinatorial optimization process. Researchers have also made significant progress in combinatorial optimization problem algorithms and CUDA kernel performance prediction models. Wang Xiuqing, U. Khairuddin and others solved the packing problem through genetic algorithms, providing a foundation for combinatorial optimization problems. Sun Ren, Y. Jiang and others 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 models, Jiang Lin, Junjie Lai, Gargi Alavani, Sunpyo Hong and others have established performance prediction models from the aspects of instruction execution, intermediate code analysis, memory access, and computational cost. However, the multiphase flow LBM algorithm is a memory-intensive algorithm, and in view of this feature, a performance model that only considers the memory access cost is needed to provide a powerful tool for performance evaluation before and after kernel fusion.

[0007] Although kernel fusion technology has been widely used in many fields, its application in multiphase flow LBM algorithm is relatively rare. In addition, multiphase flow LBM algorithm is different from single-phase LBM algorithm. Due to the interaction between materials in different phases in multiphase flow, multiphase flow LBM algorithm often requires complex high-order gradient calculation and frequent large-scale data reading and writing. At present, there is a lack of kernel fusion optimization strategy for the characteristics of multiphase flow LBM algorithm. Therefore, how to comprehensively consider factors such as algorithm characteristics, memory access, data dependency and computational cost to achieve efficient parallel optimization of multiphase flow LBM algorithm has become a problem that needs to be solved urgently. Summary of the invention

[0008] The purpose of the present invention is to combine the intelligent search algorithm and the CUDA kernel fusion method to solve the problem of optimizing the multiphase flow LBM parallel algorithm, and propose an intelligent optimization method based on the multiphase flow LBM parallel algorithm. This method designs a set of kernel fusion optimization strategies, which not only deeply understands the unique properties of the LBM algorithm, but also comprehensively analyzes key factors such as memory access mode and data dependency. This method also incorporates the intelligent search technology of group genetic algorithm, 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 new ideas for the efficient parallel optimization of the LBM algorithm, but also brings substantial performance improvements to the scientific research and industrial application of multiphase flow LBM.

[0009] The technical solution for achieving the purpose of the present invention is:

[0010] An intelligent optimization method based on a multiphase flow LBM parallel algorithm comprises 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 reading and writing relationship, a core fusion rule and a method for estimating the performance change after fusion are proposed for the multiphase flow LBM algorithm;

[0014] 4) Using graph structure to represent data dependency, the fusion rules and performance change estimation method are combined into the group genetic algorithm to search for the optimal fusion solution 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] In the step 1), a data dependency model of the multiphase flow LBM parallel algorithm is constructed, including constructing a data dependency graph and an execution sequence graph. First, a data dependency graph of 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 deeply analyzing each kernel function in the CUDA program, each kernel function is represented as a node in the data dependency graph, and the data transmitted between each node is connected as the weight of the edge. Such a data dependency graph can clearly show the data dependency relationship between kernel functions, so that the structure and behavior of the entire CUDA program are clear at a glance, which is easy to understand and optimize.

[0017] An execution sequence graph is constructed according to the execution order of each processing step of the original multiphase flow LBM algorithm. The execution sequence graph is a directed acyclic graph, in which the nodes in the execution sequence graph represent kernel functions. When constructing this execution sequence graph, the nodes are merged in a logical order without violating the execution priority between kernels. The execution sequence graph is used to accurately determine which original kernels can be merged into the new kernel, thereby optimizing the performance of the CUDA program without violating the logical order of the CUDA program.

[0018] Through such a design, this 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 the step 2), a memory access performance analysis model of the multiphase flow LBM parallel algorithm is constructed, and the memory access performance of the multiphase flow LBM in the CUDA program is deeply analyzed and optimized. In view of the fact that the changes in the calculation operations of the LBM CUDA program before and after the kernel fusion are relatively small, the analysis focuses on the changes in the memory access cost before and after the fusion, rather than the increase or decrease in the calculation cost; during the execution of the CUDA program, the memory access of the kernel function covers the access to the global memory, shared memory and registers. In order to achieve effective optimization of the memory access performance, it is required to conduct a detailed analysis of the kernel function, accurately calculate the number of accesses to various types of memory in the kernel function, and fully consider the number of cycles required for the GPU device to access different memories;

[0020] The number of memory access cycles of 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 Respectively represent the number of cycles for GPU to access global memory, shared memory, and registers. G 、N S 、N R Respectively represent the number of times the kernel function accesses global memory, shared memory, and registers, C represents the sum of the memory access cycles of all kernels in the CUDA program, and C(k) represents the memory access cycle number of kernel function k;

[0024] In the step 3), kernel fusion rules and a method for estimating performance changes after fusion are proposed for the multiphase flow LBM algorithm according to the data dependency model, the characteristics of GPU memory access, and the data read-write relationship. Specifically, kernel fusion is manifested in the data dependency graph as the fusion of multiple kernel functions to form a large kernel function. Different fusion strategies will directly affect the data read-write strategy. The rules for judging whether multiple kernel functions can be fused and how to fuse them are divided into the following two cases:

[0025] (3.1) Rule 1: If there is a kernel function that writes an array, followed by another kernel function that reads the array, then the two kernel functions can be fused, and after fusion, the array can be stored in a register to reduce memory access cycles; A represents the number of times the original kernel accesses the array before fusion; in this case, the memory access cycle reduction Δ 1 The calculation is as follows:

[0026] Δ 1 =A·(C G -C R ), (3)

[0027] (3.2) Rule 2: If there are multiple kernel functions that 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 accesses the array before fusion; at this time, the memory access cycle reduction Δ 2 The calculation is as follows:

[0028] Δ 2 =(A-1)·C G -A.C S , (4)

[0029] The calculation method of the number of access cycles ΔC(K) that is finally reduced by the fused single kernel K is as follows:

[0030] ΔC(K)=Δ 1 +Δ 2 , (5)

[0031]

[0032] Finally, the memory access cycle improvement efficiency E before and after fusion is calculated by formula (6), so as to quantitatively evaluate the improvement degree of kernel fusion on memory access performance.

[0033] In step 4), a graph structure is used to record data dependencies, and the fusion rules and performance prediction and estimation methods are combined into a group genetic algorithm to search for the optimal fusion solution of the multiphase flow LBM parallel algorithm. Specifically, the CUDA kernel fusion problem can be regarded as a combinatorial optimization problem, which can be solved by using a group genetic algorithm in a heuristic search algorithm. In the group genetic algorithm, the fitness function should be based on the formula (6) obtained by analyzing the performance changes before and after the fusion. The specific steps are as follows:

[0034] (4.1) First, the kernel functions in the CUDA program and the arrays they access are numbered one by one, and the data dependency graph and execution sequence graph of the CUDA program are stored using the graph structure data structure; then, the kernel functions are topologically sorted according to the execution sequence graph, and the kernel functions are randomly divided into several groups according to the results of the topological sorting. Each group is assigned a unique number, and the kernel function numbers contained in each group are counted to 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-write relationship between the kernel functions in the group, and determine which fusion rule is met; then, use formula (3) or formula (4) to calculate the change in memory access cycle of each group; this step will be applied to all groups to calculate their respective memory access cycle changes; then, according to the improvement efficiency E defined in formula (6), calculate the fitness value of each individual and save the result;

[0036] (4.3) Select several individuals from the population as parents through the roulette wheel method, perform crossover and mutation operations to generate new offspring individuals, and determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence graph. If the conditions are not met, the parent individuals are retained and steps (4.2) and (4.3) are repeated;

[0037] (4.4) After each evolution, the individual with the highest fitness value in the population is regarded as the optimal individual of that generation. After 50 generations of evolution, the fitness values ​​of the optimal individuals of each generation are compared, and the grouping of the individuals with the highest fitness value is output, and the optimal kernel fusion strategy is obtained.

[0038] In the step 5), the original multiphase flow LBM parallel algorithm is optimized according to the optimal fusion solution, and the performance before and after the optimization is compared. The read-only array is stored in the shared memory, and the read-write array is stored in the register to obtain the optimized CUDA program. The running time of the program before and after the improvement is statistically compared to calculate the efficiency of the performance improvement.

[0039] Compared with the existing technology, the significant feature of this technical solution method is that it has designed a set of kernel fusion optimization strategies specifically for the multiphase flow LBM parallel algorithm. This strategy not only has a deep insight into the unique properties of the LBM algorithm, but also comprehensively analyzes key factors such as memory access patterns and data dependencies. This technical solution cleverly incorporates the group 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 new ideas for 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 Data dependency diagram for chemical potential multiphase flow LBM parallel program;

[0041] Figure 2 This is the execution sequence diagram of the chemical potential multiphase flow LBM parallel program;

[0042] Figure 3 Flowchart of the group genetic algorithm for searching the optimal nuclear fusion solution;

[0043] Figure 4 Comparison of global memory access before and after fusion;

[0044] Figure 5 The amount of shared memory access after fusion;

[0045] Figure 6 Before and after the fusion in A100 and V100, the program updates millions of fluid grid points per second. DETAILED DESCRIPTION

[0046] The present invention is further described below with reference to the accompanying drawings and embodiments, but the present invention is not limited thereto.

[0047] Example:

[0048] The intelligent optimization method of the chemical potential multiphase flow LBM parallel algorithm includes the following steps:

[0049] 1) If Figure 1 As shown in the figure, we first need 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 dependence of each kernel function in data processing, so as to construct 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, and the hexagonal nodes represent the arrays read and written by these kernel functions. Figure 1 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 sequence graph is further established. In this execution sequence graph, the numbers of CUDA kernel functions are used as graph nodes, and the connections between nodes reflect the logical execution order of the kernel functions. When constructing this execution sequence graph, the principle of execution priority between kernels must not be violated, that is, according to the data dependency relationship and the characteristics of parallel computing, the nodes are logically sorted and connected reasonably. The final execution sequence graph is as follows: Figure 2 As shown, the 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 chemical potential multiphase flow LBM. During the execution of CUDA program, the memory access of kernel function covers the access of global memory, shared memory and register. Since the number of cycles of GPU accessing global memory is much larger than that of shared memory and register, in order to effectively optimize the memory access performance, it is necessary to reduce the access of global memory and use shared memory and register to read and write data as much as possible. This requires a detailed analysis of kernel function, accurate calculation of the number of accesses to various types of memory in kernel function, and full consideration of the number of cycles required for GPU device to access different memories.

[0052] The number of memory access cycles of the kernel function k before fusion 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 Respectively represent the number of cycles for GPU to access global memory, shared memory, and registers. G 、N S 、N R Respectively represent the number of times the kernel function accesses global memory, shared memory, and registers, C represents the sum of the memory access cycles of all kernels in the CUDA program, and C(k) represents the memory access cycle number of kernel function k;

[0056] 3) Based on the data dependency model, the characteristics of GPU memory access and the data read-write relationship, kernel fusion rules and a method for estimating the performance change after fusion are proposed for the multiphase flow LBM algorithm; kernel fusion is manifested in the data dependency graph as multiple kernel functions fused into a large kernel function. Different fusion strategies will directly affect the data read-write strategy. The rules for judging whether multiple kernel functions can be fused and how to fuse them are divided into the following two cases:

[0057] (3.1) Figure 1 As shown in the red dashed box, the kernel function K_1 in the combination The array is written, and then the kernel function K_2 reads it. After fusion, the array can be stored in the register to reduce the memory access cycle. At this time, the memory access cycle is reduced by Δ 1 The calculation is as follows:

[0058] Δ 1 =A·(C G -C R ), (3)

[0059] (3.2) Figure 1 As shown in the blue dotted box, multiple functions in the combination perform read-only operations on the ρ array. After fusion, the modified array can be stored in the shared memory to achieve the purpose of reducing the memory access cycle. At this time, the memory access cycle is reduced by Δ 2 The calculation is as follows:

[0060] Δ 2 =(A-1)·CG -A.C S , (4)

[0061] A in formulas (3) and (4) represents the number of times the original kernel accesses the array before fusion. In this example, A=2 in formula (3) and A=3 in formula (4).

[0062] The calculation method of the number of access cycles ΔC(K) that is finally reduced by the fused kernel K is 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 by formula (6), so as to quantitatively evaluate the improvement degree of kernel fusion on memory access performance.

[0067] 4) If Figure 3 As shown in the figure, a graph structure is used to record data dependencies, and the fusion rules and performance prediction and estimation methods are combined into the group genetic algorithm. The specific process of searching for the optimal core fusion solution of the multiphase flow LBM parallel algorithm is as follows:

[0068] (4.1) First, the kernel functions in the CUDA program and the arrays they access are numbered one by one, and the data dependency graph and execution sequence graph of the CUDA program are stored using the graph structure data structure; then, the kernel functions are topologically sorted according to the execution sequence graph, and the kernel functions are randomly divided into several groups according to the results of the topological sorting. Each group is assigned a unique number, and the kernel function numbers contained in each group are counted to 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-write relationship between the kernel functions in the group, and determine which fusion rule is met; 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; then, according to the improvement efficiency E defined in formula (6), calculate the fitness value of each individual and save the result;

[0070] (4.3) Select several individuals from the population as parents through the roulette wheel method, perform crossover and mutation operations to generate new offspring individuals, and determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence graph. If the conditions are not met, the parent individuals are retained and steps (4.2) and (4.3) are repeated;

[0071] The crossover and mutation process of the grouping genetic algorithm for searching the optimal kernel fusion solution is as follows:

[0072] First, two parent individuals are selected from the population, and a group of continuous genes (fusion nuclei) are randomly selected from the chromosomes of each parent individual as crossover genes. The crossover genes of one parent chromosome are inserted into the chromosome of the other parent, and the insertion position is located in front of the crossover genes of the other parent itself. After the insertion, the original nuclei in the old gene and the new gene may be repeated, and all the original nuclei of the old gene are marked, and all the genes of the marked original nuclei are deleted. This step is to remove repeated or redundant gene information to ensure the stability of the chromosome and the uniqueness of the gene. The missing original nuclei are composed of new genes and inserted into the end of the individual chromosome. Due to the deletion operation, some original nuclei may be missing, and these missing original nuclei are reorganized into new genes, and these The new gene is inserted into the end of the individual chromosome. This step aims to restore the integrity of the chromosome and ensure that all necessary genetic information is retained. Next, mutation adjustment is performed on each individual in the population with a low probability, aiming to explore new areas in the search space and help get rid of the potential local optimal dilemma when the algorithm gradually approaches the convergence state. Two operations, splitting and merging, are used. When the number of genes in a chromosome exceeds half of the original number of nuclei, two adjacent genes are randomly selected for merging. On the contrary, if the number of genes is less than half of the original number of nuclei, at most one gene with the original number of nuclei is selected for splitting, and the gene with the original number of nuclei is split into two new genes, thereby increasing the diversity of genes and broadening the search range.

[0073] (4.4) The individual with the highest fitness value in the population after each evolution is regarded as the optimal individual of that generation. After 50 generations of evolution, the fitness values ​​of the optimal individuals of each generation are compared, and the grouping of the individuals with the highest fitness value is output, and the optimal kernel fusion strategy is obtained;

[0074] 5) Determine the optimal fusion strategy based on the intelligent search algorithm and optimize the original chemical potential multiphase flow LBM parallel algorithm. Store the read-only array in the shared memory according to the grouping of the original kernel, and store the read-write array in the register to obtain the optimized CUDA program. In order to verify the actual effect of this improvement, the memory access of the program before and after the fusion is counted. Combined with Figure 4 , Figure 5, we can intuitively see that the fused program has significantly reduced the global memory read and write operations compared to the pre-fusion program. This is due to the fact that the fused program cleverly uses shared memory and registers for data read and write, which greatly reduces the global memory read and write operations, and thus effectively shortens the memory access cycle; In order to specifically demonstrate the effect of performance improvement, experiments are conducted on different GPU platforms, such as Figure 6 As shown in Figure 2, the optimization strategy of this example works best on the high-performance GPU A100. During the experiment, this example used a variety of flow field sizes for testing. The results show that when the flow field size is set to 128 3 The performance improvement is most significant when the flow field size is 448. After fusion, the number of million fluid grid points that can be updated per second increases by 24.7% compared to before fusion. 3 The performance improvement is relatively poor, and the number of million fluid grid points updated per second after fusion is only 17.2% higher than that before fusion.

Claims

1. An intelligent optimization method based on multiphase flow LBM parallel algorithm, characterized in that: The steps include: 1) Construct a data dependency model for the multiphase flow LBM parallel algorithm; 2) Construct a memory access performance analysis model for the multiphase flow LBM parallel algorithm. 3) Based on the data dependency model, the characteristics of GPU memory access and the data reading and writing relationship, a core fusion rule and a method for estimating the performance change after fusion are proposed for the multiphase flow LBM algorithm; 4) Combine the fusion rules and performance change estimation method into the group genetic algorithm to search for the optimal fusion solution 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 is characterized in that: In the step 1), a data dependency model of the multiphase flow LBM parallel algorithm is constructed, including constructing a data dependency graph and an execution sequence graph; firstly, a data dependency graph of the multiphase flow LBM is constructed, in which arrays involved in each process are divided into three types: read-only arrays, read-write arrays, and write-only arrays; each kernel function is represented as a node in the data dependency graph, and the data transmitted between each node is connected as the weight of the edge, such a data dependency graph can clearly show the data dependency relationship between kernel functions, so that the structure and behavior of the entire CUDA program are clear at a glance, which is easy to understand and optimize; An execution sequence graph is constructed according to the execution order of each processing step of the original multiphase flow LBM algorithm. The execution sequence graph is a directed acyclic graph, in which the nodes in the execution sequence graph represent kernel functions. When constructing this execution sequence graph, the nodes are fused in a logical order without violating the execution priority between kernels. The execution sequence graph is used to ensure that the fused CUDA algorithm does not violate the logical order of the original LBM algorithm.

3. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 2 is characterized in that: In the step 2), a memory access performance analysis model of the multiphase flow LBM parallel algorithm is constructed, and the memory access performance of the multiphase flow LBM in the CUDA program is deeply analyzed and optimized. In view of the relatively small changes in the computing operations of the LBM CUDA program before and after kernel fusion, the analysis focuses on the changes in memory access costs before and after fusion, rather than the increase or decrease in computing costs. During the execution of the CUDA program, the memory access of the kernel function covers access to global memory, shared memory, and registers. In order to achieve effective optimization of memory access performance, it is required to conduct a detailed analysis of the kernel function, determine the number of accesses to each type of memory in the kernel function, and consider the number of cycles required for the GPU device to access different memories. The number of memory access cycles of kernel function k is calculated using the following formula: C(k)=N G ·C G +N R ·C R +N S ·C S , (1) In formulas (1) and (2), C G , C S , C R Respectively represent the number of cycles for GPU to access global memory, shared memory, and registers. G 、N S 、N R They represent the number of times the kernel function accesses global memory, shared memory, and registers respectively. C represents the sum of the memory access cycles of all kernels in the CUDA program. C(k) represents the memory access cycles of kernel function k.

4. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 1 is characterized in that: In the step 3), kernel fusion rules and a method for estimating performance changes after fusion are proposed for the multiphase flow LBM algorithm according to the data dependency model, the characteristics of GPU memory access, and the data read-write relationship. Specifically, kernel fusion is manifested in the data dependency graph as the fusion of multiple kernel functions into a large kernel function. Different fusion strategies will directly affect the data read-write strategy. The rules for judging whether multiple kernel functions can be fused and how to fuse them are divided into the following two cases: (3.1) Rule 1: If there is a kernel function that writes an array, and then another kernel function reads the array, then the two kernel functions can be fused, and after fusion, the array can be stored in a register. In this way, the read operation of the latter kernel function on the array is changed from reading the off-chip global memory to reading the on-chip register, reducing the memory access cycle; at this time, the reduction in memory access cycle Δ1 is calculated as follows: Δ1=A·(C G -C R ), (3) (3.2) Rule 2: If there are multiple kernel functions that 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 reading the global memory multiple times, thereby reducing the memory access cycle; in this case, the reduction in memory access cycle Δ2 is calculated as follows: Δ2=(A-1)·C G -A·C S , (4) A in formulas (3) and (4) represents the number of times the original kernel accesses the array before fusion; The calculation method of the number of access cycles ΔC(K) that is finally reduced by the fused single kernel K is as follows: ΔC(K)=Δ1+Δ2, (5) Finally, the memory access cycle improvement efficiency E before and after fusion is calculated by formula (6), so as to quantitatively evaluate the improvement degree of kernel fusion on memory access performance.

5. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 4 is characterized in that: In step 4), a graph structure is used to represent data dependencies, and the fusion rule and the performance prediction and estimation method are combined into a group genetic algorithm to search for the optimal fusion solution of the multiphase flow LBM parallel algorithm. Specifically, the CUDA kernel fusion problem can be regarded as a combinatorial optimization problem, which can be solved by using a group genetic algorithm in a heuristic search algorithm. In the group genetic algorithm, the fitness function should be based on the formula (6) obtained by analyzing the performance changes before and after the fusion. The specific steps are as follows: (4.1) First, the kernel functions in the CUDA program and the arrays they access are numbered one by one, and the data dependency graph and execution sequence graph of the CUDA program are stored using the graph structure data structure; then, the kernel functions are topologically sorted according to the execution sequence graph, and all the kernel functions are randomly combined into several groups according to the results of the topological sorting. Each group is assigned a unique number, and the kernel function numbers contained in each group are counted 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-write relationship of the arrays between the 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 changes; Then, according to the improvement efficiency E defined in formula (6), the fitness value of each individual is calculated and the result is saved; (4.3) Select several individuals from the population as parents through the roulette wheel method, perform crossover and mutation operations to generate new offspring individuals, and determine whether these newly generated offspring individuals meet the topological sorting requirements of the execution sequence graph. If the conditions are not met, the parent individuals are retained and steps (4.2) and (4.3) are repeated; (4.4) After each evolution, the individual with the highest fitness value in the population is regarded as the optimal individual of that generation. After 50 generations of evolution, the fitness values ​​of the optimal individuals of each generation are compared, and the grouping of the individuals with the highest fitness value is output, and the optimal kernel fusion strategy is obtained.

6. The intelligent optimization method based on the multiphase flow LBM parallel algorithm according to claim 1 is characterized in that: In the step 5), the original multiphase flow LBM parallel algorithm is optimized according to the optimal fusion solution, and the performance before and after the optimization is compared; the read-only array is stored in the shared memory, and the read-write array is stored in the register to obtain the optimized CUDA program, and the running time of the program before and after the improvement is counted to calculate the efficiency of the performance improvement.

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

  • Particle swarm optimization method and system based on GPU operation of mobile terminal

    WO2017124809A1