A multi-phase field model parallel computing system and method based on GPU

By using a GPU-based parallel computing system for multiphase field models and optimizing the algorithm structure with the CUDA architecture, the problem of low computational efficiency of multiphase field models is solved, enabling efficient simulation of the grain growth process of large-scale polycrystalline systems while reducing computation time and energy consumption.

CN116051358BActive Publication Date: 2026-04-21INST OF MODERN PHYSICS CHINESE ACADEMY OF SCI +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INST OF MODERN PHYSICS CHINESE ACADEMY OF SCI
Filing Date
2023-02-23
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Traditional serial methods for solving multiphase field models are computationally inefficient and time-consuming, while CPU-based parallel programming methods have high computational resource requirements and are difficult to efficiently handle complex interface simulations of polycrystalline systems.

Method used

A GPU-based parallel computing system for multiphase field models is adopted. The system allocates thread grids through a thread scheduling module, utilizes the GPU core modules to perform phase field and solute field calculations in parallel, and combines the CUDA architecture to optimize the algorithm structure, thereby achieving efficient parallel computing.

Benefits of technology

It improves the computational efficiency of multiphase field models, enabling the simulation of large-scale polycrystalline systems, explanation of grain growth processes, reduction of computation time and energy consumption, and guarantee of computational accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116051358B_ABST
    Figure CN116051358B_ABST
Patent Text Reader

Abstract

This invention relates to a GPU-based parallel computing system and method for multiphase field models, comprising a CPU and a GPU. The GPU includes: a thread scheduling module for calculating the thread grid size of each core module and allocating threads for each core module; several core modules for sequentially and in parallel executing phase-field and solute-field calculation tasks of the corresponding threads in the multiphase field model; a judgment module for determining whether the calculation results of each core module meet the output conditions; local memory for storing local variables used by the corresponding core module; and global memory for storing variables used in GPU calculations. The CPU includes: a memory allocation module for allocating memory on the GPU for storing data during the calculation process; a parameter setting module for setting kernel parameters and the maximum number of calculation steps; a control module for controlling the startup of each core module; and main memory for storing the calculation results of each core module. This invention can be widely applied in the field of multiphase field model simulation technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of multiphase field model simulation technology, and in particular to a parallel computing system and method for multiphase field models based on GPU (Graphics Processing Unit). Background Technology

[0002] With the development of computer science, numerical simulation of the microstructure formed during the solidification process of materials has become an important method in materials research. Unlike theoretical analysis and experimental research, numerical simulation can digitize theoretical models. By further analyzing the concrete results of the theoretical models, the causes of certain experimental results can be revealed, and phenomena not yet observed in experiments can be predicted. Among the many methods for simulating the microstructure of materials, the phase-field method is a powerful tool that has emerged in recent years for studying the evolution of microstructures. The phase-field variables are continuously differentiable throughout the computational domain, so the solutions to the phase-field equations can describe the evolution of the solid-liquid interface during the growth of microstructures. Furthermore, by coupling other physical fields such as temperature, gravity, flow, and electromagnetic fields with the phase field to establish a multi-physics coupled phase-field model, the simulation of the microstructure evolution process under real-world conditions can be completed more realistically and intuitively, which is also a current hot topic in the study of microstructure simulation.

[0003] With deeper research, single-phase field models for single-crystal systems have proven insufficient to address certain specific problems. For instance, in numerical simulations of polycrystalline systems with different growth orientations, single-phase field models cannot adequately describe these orientation differences. The emergence of multiphase field models effectively solves this problem. While multiphase field models can simulate polycrystalline systems with complex interfaces, their computational complexity and scale are significantly greater than those of single-phase field models. Using traditional serial methods to solve multiphase field models leads to low computational efficiency and long processing times. Therefore, exploring parallel programming methods for solving multiphase field models is the most effective way to address these issues.

[0004] High-performance computing can significantly improve computational efficiency and scale, thereby increasing the number of experiments within a limited time. With the maturation of computer hardware such as CPUs (Central Processing Units) and computer storage systems, numerous parallel programming methods have emerged. While coarse-grained parallelism based on MPI (Multi-Point Interface) and OpemMP can achieve parallelization of computational models, it requires substantial computational resources, causing significant inconvenience for research. Furthermore, computational efficiency remains limited. Summary of the Invention

[0005] To address the aforementioned problems, the purpose of this invention is to provide a GPU-based parallel computing system and method for multiphase field models with high computational efficiency.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: On the other hand, it provides a GPU-based parallel computing system for multiphase field models, including a CPU and a GPU;

[0007] The GPU is equipped with:

[0008] The thread scheduling module is used to calculate the thread grid size of each core module based on the size of the thread block and the computational domain of the multiphase field model, and then allocate threads to each core module.

[0009] Several of the aforementioned core modules are used to execute corresponding kernel functions based on the control of the CPU, the allocated threads, and the set kernel parameters, and to execute the phase field calculation and solute field calculation tasks of the multiphase field model of the corresponding thread in parallel in sequence.

[0010] The judgment module is used to determine whether the calculation results of each core module meet the preset output conditions based on the maximum number of calculation steps. If they do, the current calculation result is sent to the CPU.

[0011] Local memory is used to store local variables used by the corresponding core module;

[0012] Global memory is used to store the variables used by the GPU for computation.

[0013] The CPU is equipped with:

[0014] A memory allocation module is used to allocate memory on the GPU for storing data during computation.

[0015] The parameter setting module is used to set kernel parameters and the maximum number of computation steps;

[0016] The control module is used to initialize the multiphase field and solute field of the multiphase field model, control the startup of each core module, and control data transmission.

[0017] The main memory is used to store the calculation results of each of the core modules.

[0018] Furthermore, each core module is provided with several thread grids, each thread grid is provided with several thread blocks, each thread block is provided with several threads, and the threads in each thread block are all launched to the same core module by the thread scheduling module.

[0019] Furthermore, each of the aforementioned core modules executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel in sequence, including:

[0020] Calculate the values, anisotropy, master equation, computation time, anti-solute trapping flow and solute field equations for each thread mesh of the multiphase field model, and update the boundary data, phase field data and solute field data for each phase.

[0021] On the other hand, a GPU-based parallel computation method for multiphase field models is provided, including:

[0022] The CPU initializes the multiphase field and solute field of the multiphase field model and sets the initial values ​​of the computational domain.

[0023] The CPU creates memory objects, allocates memory space, and allocates memory space on the GPU for storing data during the computation process;

[0024] The CPU sets the kernel parameters and the maximum number of computation steps, and copies the initialization data in the memory space to the GPU's memory space;

[0025] The CPU controls the startup of each core module of the GPU, each core module of the GPU executes the corresponding kernel function, and according to the initial value of the computational domain, executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel in sequence.

[0026] After the GPU completes a calculation, it determines whether the calculation results of each core module meet the preset output conditions and reach the maximum number of calculation steps. If not, each core module continues to perform the next round of iterative calculation; if so, it sends the current calculation result to the CPU.

[0027] The CPU releases memory space for both the CPU and GPU.

[0028] Furthermore, the CPU initializes the multiphase field and solute field of the multiphase field model and sets the initial values ​​of the computational domain, including:

[0029] The CPU sets the size of the computational domain for the multiphase field model simulation;

[0030] The CPU sets the variable parameters used;

[0031] The CPU defines the initial growth position and initial growth shape of multiple grains in the computation domain;

[0032] The CPU sets a flux-free boundary condition on the boundary of the multi-grain computing region and selects the diffusion interface thickness.

[0033] Furthermore, the CPU creates memory objects, allocates memory space, and allocates memory space on the GPU for storing data during computation, including:

[0034] CPU creates memory objects;

[0035] The memory space needed for outputting data is allocated on the CPU using the malloc() function;

[0036] The CPU uses the cudaMalloc() function to allocate memory space on the GPU for storing data during computation.

[0037] Furthermore, the CPU sets kernel parameters and the maximum number of computation steps, and copies the initialization data from the memory space to the GPU's memory space, including:

[0038] CPU settings include kernel parameters such as the number of threads and the number of blocks;

[0039] CPU maximum calculation steps;

[0040] The CPU uses the cudaMemcpy() function to transfer the stored initialization data to the GPU's memory space.

[0041] Furthermore, the CPU controls the startup of each core module of the GPU, and each core module executes its corresponding kernel function, performing phase field calculations and solute field calculations of the corresponding thread's multiphase field model in parallel in sequence, including:

[0042] The CPU sequentially starts several core modules of the GPU, and each core module executes its corresponding core function in order.

[0043] When the CPU starts each core module, the cudaDeviceSynchronize() synchronization function is used under each startup statement;

[0044] Each core module of the GPU executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the initial value of the computation domain.

[0045] Furthermore, each core module of the GPU executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the initial value of the computational domain, including:

[0046] The Lapalacian nine-point difference equation is used to calculate the values ​​of each thread mesh, anisotropy, and master equation in each phase of the multiphase field model.

[0047] The computation time for differentiating and calculating each phase of a multiphase field model;

[0048] Calculate the anti-solute trapping flow of each phase in a multiphase field model;

[0049] The solute field equation of the multiphase field model was calculated using the 5-point Stencil method.

[0050] Update the boundary data, phase field data, and solute field data of each phase in the multiphase field model.

[0051] Furthermore, this also includes creating threads on the CPU to keep the GPU constantly in a computational state. The specific process is as follows:

[0052] CPU creates threads;

[0053] The CPU defines a thread parameter structure, which contains arrays of variables used by the CPU and arrays of variables used by the GPU.

[0054] Create an output function containing statements that transfer data from the GPU to the CPU.

[0055] The CPU allocates memory space for the structure;

[0056] The CPU executes the relevant thread functions and waits for the threads to complete.

[0057] The present invention has the following advantages due to the adoption of the above technical solutions:

[0058] 1. This invention can fully utilize the computing performance of GPUs to effectively simulate larger-scale polycrystalline systems, obtain real-time information on the morphology and solute distribution of grains during growth and evolution, and explain the mechanism of competitive growth of polycrystalline grains at the microscopic scale.

[0059] 2. This invention leverages the powerful floating-point computing capabilities, high bandwidth, and lightweight computing cores of GPUs, employing the CUDA parallel architecture to implement the algorithm. Furthermore, in the algorithm structure design, an algorithm structure conforming to the GPU parallel model is designed based on the GPU's hardware architecture, employing a series of optimization strategies such as register and instruction optimization, and thread processing to improve operating efficiency.

[0060] 3. This invention solves the multiphase field model while ensuring computational accuracy, and explains the organizational evolution law of dendrite growth process in polycrystalline systems from a microscopic perspective, which greatly improves computational efficiency, saves computational time costs and reduces the energy consumption of computing equipment.

[0061] 4. This invention can not only simulate large-scale polycrystalline systems with complex interfaces, but also handle the massive amount of computation during the simulation process. It can ensure computational accuracy while improving computational efficiency. This invention coordinates the overall computational process from the host side, submits complex iterative computational tasks to the device side for execution, and handles time-consuming data transfer issues by opening threads, thus managing complex concurrent programs efficiently with low overhead.

[0062] In summary, this invention can be widely applied in the field of multiphase field model simulation technology. Attached Figure Description

[0063] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. In the drawings:

[0064] Figure 1 This is a schematic diagram of the system structure provided in an embodiment of the present invention;

[0065] Figure 2 This is a schematic diagram of parallel computing of a system provided in an embodiment of the present invention;

[0066] Figure 3 This is a schematic diagram of a method flow provided in an embodiment of the present invention;

[0067] Figure 4 This is a schematic diagram provided in an embodiment of the present invention;

[0068] Figure 5 This is a schematic diagram provided in an embodiment of the present invention. Detailed Implementation

[0069] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the invention and to fully convey the scope of the invention to those skilled in the art.

[0070] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0071] Although terms such as first, second, third, etc., may be used in this document to describe multiple elements, components, regions, layers, and / or segments, these elements, components, regions, layers, and / or segments should not be limited by these terms. These terms may be used only to distinguish one element, component, region, layer, or segment from another. Unless the context clearly indicates otherwise, terms such as "first," "second," and other numerical terms used herein do not imply order or sequence. Therefore, the first element, component, region, layer, or segment discussed below may be referred to as the second element, component, region, layer, or segment without departing from the teachings of the exemplary embodiments.

[0072] While MPI parallel programming is one of the better cluster parallelization methods currently available, it can divide functions suitable for parallelization across different nodes in the cluster for computation, thereby parallelizing the computational model and improving computational efficiency. However, MPI parallelization based on the CPU platform still involves serial computation within each node after partitioning, limiting its computational efficiency. GPUs, on the other hand, possess a large number of computing units, exhibiting a fine-grained parallelism mode. They are characterized by high parallelism, low power consumption, and low cost, excelling in single-instruction multiple-data (SMI) computation and well-suited for large-scale simulations. Their design goal is to maximize computational power within a limited area. CUDA (Compute Unified Device Architecture) is a shared-memory parallel computing architecture based on GPUs. This programming model fully utilizes the structural characteristics of GPUs, allowing multiple computing units on the GPU to perform computations simultaneously, significantly improving computational efficiency. Using GPUs to solve multiphase field models can efficiently simulate the multigrain growth process during the directional solidification of alloys, and explain the evolution law of grain growth during the directional solidification of alloys at the microscale. The GPU-based multiphase field model parallel computing system and method provided in this invention places the computation points on a GPU with many threads for parallel processing, which can greatly improve the computational efficiency.

[0073] Example 1

[0074] Since it is a multiphase field model, multiple phases can be simulated within a specified computational domain. This embodiment uses two phases as examples, defined as phase A and phase B, but the present invention is not limited to the simulation of two phases.

[0075] like Figure 1As shown, this embodiment provides a GPU-based parallel computing system for multi-phase field models, including a CPU and a GPU. The GPU contains several kernel modules, several local memories, a thread scheduling module, a decision-making module, and a global memory. The CPU contains a memory allocation module, a parameter setting module, a control module, and a host memory. This embodiment uses 12 kernel modules and local memories as an example for illustration.

[0076] The thread scheduling module is used to calculate the size of the thread grid of each core module based on the size of the thread block and the computational domain of the multiphase field model, and then allocate threads to each core module. In order to match the GPU threads with the computing nodes, the number of threads provided should be greater than or equal to the number of thread grids.

[0077] Each kernel module is used to control the CPU, allocate threads, and set kernel parameters to execute the corresponding kernel functions, and execute the phase field calculation and solute field calculation tasks of the multiphase field model of the corresponding thread in parallel in sequence.

[0078] The judgment module is used to determine whether the calculation results of each core module meet the preset output conditions based on the maximum number of calculation steps. If they do not meet the conditions, each core module continues to perform the next round of iterative calculation; if they do meet the conditions, the current calculation result is sent to the main memory.

[0079] Local memory is used to store local variables used by the corresponding core module.

[0080] Global memory is used to store variables used by the device, i.e., GPU computing.

[0081] The memory allocation module is used to create memory objects, allocate or release memory space, and allocate memory on the GPU for storing data during computation.

[0082] The parameter setting module is used to set kernel parameters and the maximum number of computation steps.

[0083] The control module is used to initialize the multiphase field and solute field of the multiphase field model, control the startup of each core module, and control the data transfer between the host side (CPU) and the device side.

[0084] The main memory is used to store the results calculated by each core module.

[0085] In a preferred embodiment, such as Figure 2As shown, each core module contains several thread grids, each thread grid contains several thread blocks, and each thread block contains several threads. The threads in each thread block are all dispatched to the same core module by the thread scheduling module.

[0086] Specifically, GPU hardware scheduling typically uses 32 threads as a warp, so the dimensions of each thread block and the array space of the global memory are defined as integer multiples of 32.

[0087] In a preferred embodiment, on the device side, thread grids, thread blocks, and threads are all logically considered two-dimensional. After the CPU starts the kernel function, the corresponding kernel module on the device side executes the computation task. A large number of logically two-dimensional, physically one-dimensional threads are created on the device side, and each thread can execute independently and concurrently. For example... Figure 2 Figure (b) shows the computational domain of the multiphase field model. The multiphase field model divides the entire computational domain into uniformly sized grids using the finite difference method. There is a one-to-one correspondence between grid nodes and threads; one thread is responsible for computing one grid node. During parallel computation on the device side, the core module calls the thread grid, and all threads in the thread grid can cover the grids in the computational domain. For example... Figure 2 As shown in Figure (c), the entire computational domain is divided into a series of non-overlapping subdomains, each corresponding to a thread block on the device side. The stencil computation method is key to scientific computing. By fixing the values ​​of adjacent grid points on the geometry, each point in the structured grid is calculated and updated according to the corresponding expression. Iterative updates over a large number of time steps drive the evolution of the entire computational domain system. Figure 2 Figure (b) shows the computation modes of the multiphase field equation and the solute field equation, respectively. The multiphase field equation is constructed using the 9-point template (Stencil) method, and the solute field equation is constructed using the 5-point template (Stencil) method. There is no data dependency between adjacent grid points on the fixed geometry in the computation domain, which is suitable for parallel computing.

[0088] In a preferred embodiment, taking a multiphase field model including phase A and phase B as an example, but the multiphase field model is not limited to only phase A and phase B, it can also include more phases (e.g., phase C and phase D, etc.). Each core module executes the phase field calculation and solute field calculation tasks of the corresponding thread of the multiphase field model in parallel in sequence, including:

[0089] Calculate the values, anisotropy, master equation, computation time, anti-solute trapping flow and solute field equations for each thread mesh of the multiphase field model, and update the boundary data, phase field data and solute field data for each phase.

[0090] Example 2

[0091] like Figure 3 As shown, this embodiment provides a GPU-based parallel computing method for multiphase field models, including the following steps:

[0092] 1) The CPU (Host) initializes the multiphase field and solute field of the multiphase field model, and sets the initial values ​​of the computational domain, specifically:

[0093] 1.1) The CPU sets the size of the computational domain for the multiphase field model simulation, including the x and y directions, such as... Figure 2 As shown in (b).

[0094] 1.2) The CPU sets the initial values ​​of the computation domain:

[0095] 1.2.1) CPU settings include the variable parameters used, such as solute partition coefficient, diffusivity, spatial step size, time step size, maximum number of iterations, dimensionless diffusivity, temperature gradient, pulling speed, anisotropy coefficient, anisotropy intensity, maximum temperature value, and capillary length.

[0096] 1.2.2) The CPU defines the initial growth position and initial growth shape of multiple grains in the computation domain.

[0097] Specifically, the initial growth location of polycrystalline grains is generally set at the numerical domain wall. The bottom boundary is evenly divided according to the number of grains to ensure that each grain has sufficient growth space. The initial growth shape of polycrystalline grains is generally a spherical seed at the numerical domain wall, and the number of spherical seeds is determined according to the number of grains.

[0098] 1.2.3) Apply a flux-free (reflection) boundary condition to the boundary of the multi-grain computation region in the CPU and select a sufficiently small diffusion interface thickness to obtain more accurate results.

[0099] 2) The CPU creates memory objects, allocates memory space, and allocates memory space on the GPU for storing data during computation. Specifically:

[0100] 2.1) The CPU creates memory objects.

[0101] 2.2) Allocate memory space for the data to be output on the CPU using the malloc() function.

[0102] For example, the memory allocation for the phase field data array (pA) of phase A is as follows:

[0103] pA=(double*)malloc(max_x*max_y*sizeof(double))

[0104] The memory allocation for the phase field data array (pB) of phase B is as follows:

[0105] pB=(double*)malloc(max_x*max_y*sizeof(double))

[0106] The memory allocation for the solute field data array (U) is as follows:

[0107] U=(double*)malloc(max_x*max_y*sizeof(double)) etc.

[0108] 2.3) The CPU uses the cudaMalloc() function to allocate memory space on the GPU for storing data during the computation process.

[0109] For example, the memory allocation for the phase field data array (d_pA) of phase A is as follows:

[0110] cudaMalloc((void**)&d_pA,sizeof(double)*max_x*max_y)

[0111] The memory allocation for the anisotropic data array (d_anisA) of phase A is as follows:

[0112] cudaMalloc((void**)&d_anisA,sizeof(double)*max_x*max_y)

[0113] The memory allocation for the anti-solute cutoff array (d_scrA) of phase A is as follows:

[0114] cudaMalloc((void**)&d_scrA,sizeof(double)*max_x*max_y)

[0115] The memory allocation for the phase field data array (d_pB) of phase B is as follows:

[0116] cudaMalloc((void**)&d_pB,sizeof(double)*max_x*max_y)

[0117] The memory allocation for the anisotropic data array (d_anisB) of phase B is as follows:

[0118] cudaMalloc((void**)&d_anisB,sizeof(double)*max_x*max_y)

[0119] The memory allocation for the anti-solute cutoff array (d_scrB) in phase B is as follows:

[0120] cudaMalloc((void**)&d_scrB,sizeof(double)*max_x*max_y) etc.

[0121] 3) Configure CPU kernel parameters, including the number of threads (threaddim) and the number of blocks (blockdim).

[0122] Specifically, the CPU sets the number of threads within a block based on hardware conditions; and sets the number of blocks based on the size of the computation domain. All array variables in this embodiment are in one-dimensional vector form.

[0123] 4) Set the maximum number of computation steps for the CPU and copy the initialization data from the memory space to the GPU's memory space, specifically:

[0124] 4.1) Set the maximum number of computation steps for the CPU: int maximod.

[0125] 4.2) The CPU uses the cudaMemcpy() function to transfer the stored initialization data to the GPU's memory space.

[0126] For example: the initial phase field data array (pA) of phase A is transmitted to the data array (d_pA) of phase A field of GPU, the initial phase field data array (pB) of phase B is transmitted to the data array (d_pB) of phase B field of GPU, the initial solute field data array (U) of solute field is transmitted to the data array (d_U) of solute field of GPU, etc.

[0127] 5) The CPU controls the startup of each core module of the GPU. Each core module of the GPU executes its corresponding kernel function and, based on the initial values ​​of the computational domain, executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the order. Specifically:

[0128] 5.1) The CPU sequentially starts the 12 core modules of the GPU. The 12 core modules of the GPU execute their corresponding kernel functions in sequence, as follows:

[0129] sumnnAKernel<<<blockdim,threaddim> >>(),

[0130] anisAKernel<<<blockdim,threaddim> >>(),

[0131] gainAKernel<<<blockdim,threaddim> >>(),

[0132] sumnnBKernel<<<blockdim,threaddim> >>(),

[0133] anisBKernel<<<blockdim,threaddim> >>(),

[0134] gainBKernel<<<blockdim,threaddim> >>(),

[0135] gainABKernel<<<blockdim,threaddim> >>(),

[0136] srcAKernel<<<blockdim,threaddim> >>(),

[0137] srcBKernel<<<blockdim,threaddim> >>(),

[0138] sumnnUKernel<<<blockdim,threaddim> >>(),

[0139] updataKernel<<<blockdim,threaddim> >>(),

[0140] boundKernel<<<blockdim,threaddim> >>().

[0141] 5.2) When the CPU starts each core module, the cudaDeviceSynchronize() synchronization function is used under each startup statement to ensure that the kernel function of the previous core module is executed before the kernel function of the next core module is executed in sequence.

[0142] 5.3) Based on the initial values ​​of the computational domain, each core module of the GPU (device side) executes the phase-field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the order:

[0143] 5.3.1) The values ​​of each thread grid in phase A of the multiphase field model are calculated using the nine-point difference formula of the Laplacian operator.

[0144] 5.3.2) Calculate the anisotropy in phase A of the multiphase field model.

[0145] 5.3.3) Calculate the master equation of phase A of the multiphase field model.

[0146] 5.3.4) The Laplacian nine-point difference formula is used to calculate the values ​​of each thread grid in phase B of the multiphase field model.

[0147] 5.3.5) Calculate the anisotropy in phase B of the multiphase field model.

[0148] 5.3.6) Calculate the master equation of phase B of the multiphase field model.

[0149] 5.3.7) Calculate the calculation time of phase A and phase B of the multiphase field model by taking the derivative, which are dA / dt and dB / dt, respectively.

[0150] 5.3.8) Calculate the anti-solute trapping flow of phase A in the multiphase field model.

[0151] 5.3.9) Calculate the anti-solute trapping flow of phase B in the multiphase field model.

[0152] 5.3.10) The solute field equation of the multiphase field model is calculated using the 5-point template (Stencil) calculation method.

[0153] 5.3.11) Update the phase field data and solute field data of phase A and phase B in the multiphase field model.

[0154] 5.3.12) Update the boundary data of phase A and phase B of the multiphase field model.

[0155] 6) After the GPU completes a calculation, it determines whether the calculation results of each core module meet the preset output conditions. If not, it proceeds to step 5), and each core module continues to perform the next round of iterative calculations. If the conditions are met, the current calculation result is sent to the CPU.

[0156] 7) The GPU determines whether the maximum number of computation steps has been reached. If it has, the GPU computation task ends; otherwise, proceed to step 5), and each core module continues to perform the next round of iterative computation.

[0157] 8) The CPU releases the memory space of the CPU and GPU respectively.

[0158] For example: CPU frees the phase field data array of phase A in the CPU's memory space using free(pA), frees the phase field data array of phase B in the CPU's memory space using free(pB), and GPU frees the phase field data array of phase A in the GPU's memory space using cudaFree(d_pA), and GPU frees the phase field data array of phase B in the GPU's memory space using cudaFree(d_pB).

[0159] like Figure 4 The diagram shown is a timing diagram of the state without using threads to handle data transfer between the GPU and CPU. Figure 5The diagram shown illustrates the timing sequence of data transfer between the GPU and CPU using threads. Performance testing of the GPU program for solving multiphase field models revealed that a significant factor affecting computational efficiency is the data transfer between the GPU and CPU. Specifically, after the program meets the output conditions, the GPU copies the calculated results to the CPU for output. During this process, the GPU is in a waiting state, inevitably leading to a decrease in computational efficiency. The timing diagram for this state is shown below. Figure 4 As shown, this execution process is mainly reflected in step 6 above. To address this, for each loop's data copying and output, the CPU creates a separate thread to handle the related operations. This keeps the GPU in a continuous computing state. The timing diagram of this computing state is shown below. Figure 5 As shown. Because the program passes many parameters, which does not conform to the syntax rules for passing parameters in threads, a structure is used to solve the problem of multiple parameters. The specific implementation process is as follows:

[0160] ①The CPU creates a thread pthread_t t1.

[0161] ② The CPU defines a thread parameter structure struct threadarg{}, which contains arrays of variables used by the CPU and arrays of variables used by the GPU.

[0162] ③ Create an output function void*output(void*arg){}, which contains statements that transmit data from the GPU to the CPU.

[0163] For example:

[0164] cudaMemcpy(pA,d_pA,sizeof(double)*max_x*max_y,cudaMemcpyDeviceToHost),

[0165] cudaMemcpy(pB,d_pB,sizeof(double)*max_x*max_y,cudaMemcpyDeviceToHost),

[0166] cudaMemcpy(U,d_U,sizeof(double)*max_x*max_y,cudaMemcpyDeviceToHost).

[0167] ④ The CPU allocates memory space for the structure:

[0168] threadarg*arg=(threadarg*)malloc(sizeof(threadarg))

[0169] ⑤ The CPU runs the relevant thread function pthread_create(&t1 NULL,output,(void*)arg).

[0170] ⑥ The CPU waits for thread t1 to finish executing pthread_join(t1,0).

[0171] The above embodiments are only used to illustrate the present invention. The structure, connection method and manufacturing process of each component can be varied. All equivalent transformations and improvements made on the basis of the technical solution of the present invention should not be excluded from the protection scope of the present invention.

Claims

1. A GPU-based parallel computation method for multiphase field models, characterized in that, include: The CPU initializes the multiphase field and solute field of the multiphase field model and sets the initial values ​​of the computational domain. The CPU creates memory objects, allocates memory space, and allocates memory space on the GPU for storing data during the computation process; The CPU sets the kernel parameters and the maximum number of computation steps, and copies the initialization data in the memory space to the GPU's memory space; The CPU controls the startup of each core module of the GPU, each core module of the GPU executes the corresponding kernel function, and according to the initial value of the computational domain, executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel in sequence. After the GPU completes a calculation, it determines whether the calculation results of each core module meet the preset output conditions and reach the maximum number of calculation steps. If not, each core module continues to perform the next round of iterative calculation; if so, it sends the current calculation result to the CPU. The CPU releases memory space for both the CPU and GPU separately; The CPU initializes the multiphase field and solute field of the multiphase field model and sets the initial values ​​of the computational domain, including: The CPU sets the size of the computational domain for the multiphase field model simulation; The CPU sets the variable parameters used; The CPU defines the initial growth position and initial growth shape of multiple grains in the computation domain; The CPU sets a flux-free boundary condition on the boundary of the multi-grain computing region and selects the diffusion interface thickness. The CPU controls the startup of each core module of the GPU, and each core module of the GPU executes its corresponding kernel function, performing phase field calculations and solute field calculations of the corresponding thread's multiphase field model in parallel in sequence, including: The CPU sequentially starts several core modules of the GPU, and each core module of the GPU executes its corresponding core function in sequence. When the CPU starts each core module, the cudaDeviceSynchronize() synchronization function is used under each startup statement; Each core module of the GPU executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the initial value of the computation domain. Each core module of the GPU executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel according to the initial value of the computational domain, including: The Lapalacian nine-point difference equation is used to calculate the values ​​of each thread mesh, anisotropy, and master equation in each phase of the multiphase field model. The computation time for differentiating and calculating each phase of a multiphase field model; Calculate the anti-solute trapping flow of each phase in a multiphase field model; The solute field equation of the multiphase field model was calculated using the 5-point Stencil method. Update the boundary data, phase field data, and solute field data of each phase in the multiphase field model.

2. The GPU-based parallel computation method for multiphase field models as described in claim 1, characterized in that, The CPU creates memory objects, allocates memory space, and allocates memory space on the GPU for storing data during computation, including: CPU creates memory objects; The memory space needed for outputting data is allocated on the CPU using the malloc() function; The CPU uses the cudaMalloc() function to allocate memory space on the GPU for storing data during computation.

3. The GPU-based parallel computation method for multiphase field models as described in claim 1, characterized in that, The CPU sets kernel parameters and the maximum number of computation steps, and copies the initialization data from the memory space to the GPU's memory space, including: CPU settings include kernel parameters such as the number of threads and the number of blocks; CPU maximum calculation steps; The CPU uses the cudaMemcpy() function to transfer the stored initialization data to the GPU's memory space.

4. The GPU-based parallel computation method for multiphase field models as described in claim 1, characterized in that, This also includes creating threads on the CPU to keep the GPU constantly in a computing state. The specific process is as follows: CPU creates threads; The CPU defines a thread parameter structure, which contains arrays of variables used by the CPU and arrays of variables used by the GPU. Create an output function containing statements that transfer data from the GPU to the CPU. The CPU allocates memory space for the structure; The CPU executes the relevant thread functions and waits for the threads to complete.

5. A GPU-based multiphase field model parallel computing system based on the GPU-based multiphase field model parallel computing method according to any one of claims 1 to 4, characterized in that, Including CPU and GPU; The GPU is equipped with: The thread scheduling module is used to calculate the thread grid size of each core module based on the size of the thread block and the computational domain of the multiphase field model, and then allocate threads to each core module. Several of the aforementioned core modules are used to execute corresponding kernel functions based on the control of the CPU, the allocated threads, and the set kernel parameters, and to execute the phase field calculation and solute field calculation tasks of the multiphase field model of the corresponding thread in parallel in sequence. The judgment module is used to determine whether the calculation results of each core module meet the preset output conditions based on the maximum number of calculation steps. If they do, the current calculation result is sent to the CPU. Local memory is used to store local variables used by the corresponding core module; Global memory is used to store the variables used by the GPU for computation. The CPU is equipped with: A memory allocation module is used to allocate memory on the GPU for storing data during computation. The parameter setting module is used to set kernel parameters and the maximum number of computation steps; The control module is used to initialize the multiphase field and solute field of the multiphase field model, control the startup of each core module, and control data transmission. The main memory is used to store the calculation results of each of the core modules.

6. The GPU-based parallel computing system for multiphase field models as described in claim 5, characterized in that, Each core module is provided with several thread grids, each thread grid is provided with several thread blocks, each thread block is provided with several threads, and the threads in each thread block are all launched to the same core module by the thread scheduling module.

7. The GPU-based parallel computing system for multiphase field models as described in claim 5, characterized in that, Each of the aforementioned core modules executes the phase field calculation and solute field calculation tasks of the corresponding thread's multiphase field model in parallel in sequence, including: Calculate the values, anisotropy, master equation, computation time, anti-solute trapping flow and solute field equations for each thread mesh of the multiphase field model, and update the boundary data, phase field data and solute field data for each phase.

Citation Information

Patent Citations

  • Prediction method for dendritic crystal growth in molten steel based on GPU parallel computing

    CN111815067A

  • Prediction method for three-dimensional multi-dendrite growth under convection of molten steel based on GPU (Graphic Processing Unit) parallel calculation

    CN114819393A