GPU-based model parallel computing method and system

Through the GPU-based model parallel computing method, parallel tasks are divided and calculation paths are optimized, and the calculation paths are solved, and the calculation efficiency of two-dimensional flood evolution model in typical flood control protection areas on a large basin scale is achieved, and more efficient flood simulation calculation is achieved.

CN119201438APending Publication Date: 2024-12-27CHINA INST OF WATER RESOURCES & HYDROPOWER RES +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411233687.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The data calculation efficiency of the two-dimensional flood evolution model in typical flood control protection areas at large basin scale is low, resulting in the inability to accurately calculate flooded areas such as dam collapse and dam flooding, which seriously restricts the practical application value of the model.

Method used

Using the GPU-based model parallel computing method, we use GPU-based model to determine the overall tasks of multiple two-dimensional flood evolution models, divide the parallel tasks, and use GPU resources to perform parallel computing, optimize the calculation order and path, and improve the computing efficiency.

Benefits of technology

The data calculation efficiency of the two-dimensional flood evolution model is significantly improved, ensuring that multiple parallel tasks can be completed as soon as possible, and improving the overall performance and accuracy of the calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201438A_ABST
    Figure CN119201438A_ABST
Patent Text Reader

Abstract

The invention discloses a GPU-based model parallel computing method and system, and relates to the technical field of flood routing simulation. The method comprises the following steps: determining an overall task of a plurality of two-dimensional flood routing models; dividing the whole task to obtain a plurality of parallel tasks; each parallel task comprises a parallel task node, and one parallel task node corresponds to one two-dimensional flood routing model; obtaining flood routing related data corresponding to each parallel task node, and loading the flood routing related data into a GPU memory; determining a shortest path corresponding to each parallel task based on each parallel task node; and respectively allocating each parallel task to the GPU resources in an idle state, and calculating the flood routing related data through the allocated GPU resources based on the shortest path and a preset GPU kernel function. By implementing the technical scheme provided by the invention, the data calculation efficiency of the two-dimensional flood routing model corresponding to the large-watershed-scale typical flood control protection area can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of flood evolution simulation, and in particular to a GPU-based model parallel computing method and system. Background Art

[0002] At present, in the real-time calculation of flood evolution in typical flood protection areas at the scale of large watersheds, one-dimensional hydrodynamic models are mostly used. However, this method cannot give the evolution process of floods in two-dimensional areas. The basin flood evolution model based on the one-dimensional hydrodynamic model is difficult to accurately calculate the flooded areas in the event of dam breach and overtopping, which seriously restricts the practical application value of the model. Therefore, the two-dimensional flood evolution model came into being.

[0003] However, in the actual application of the two-dimensional flood evolution model, due to the large number of corresponding two-dimensional flood evolution models in the typical flood protection area at the large watershed scale, in the actual data calculation process, the two-dimensional flood evolution model at the back needs to receive the data output by the previous two-dimensional flood evolution model before it can be calculated. Therefore, the two-dimensional flood evolution model corresponding to the typical flood protection area at the large watershed scale has the problem of low data calculation efficiency.

[0004] Therefore, there is an urgent need for a GPU-based model parallel computing method and system to solve the problems existing in the above-mentioned background technology. Summary of the invention

[0005] The present application provides a GPU-based model parallel computing method and system, which can effectively improve the data computing efficiency of a two-dimensional flood evolution model corresponding to a typical flood protection area at a large watershed scale.

[0006] In the first aspect, the present application provides a GPU-based model parallel computing method, the method comprising: determining the overall task of multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale; dividing the overall task to obtain multiple parallel tasks; each of the parallel tasks includes a parallel task node, and one parallel task node corresponds to one of the two-dimensional flood evolution models; obtaining flood evolution-related data corresponding to each of the parallel task nodes, and loading the flood evolution-related data into the GPU memory; determining the shortest path corresponding to each of the parallel tasks based on each of the parallel task nodes; and respectively allocating each of the parallel tasks to idle GPU resources, and calculating the flood evolution-related data through the allocated GPU resources and based on the shortest path and a preset GPU kernel function.

[0007] By adopting the above technical solution, the overall task of multiple two-dimensional flood evolution models is determined to determine the scope, target, and specific scenarios that need to be simulated of the computing task. The entire task is decomposed into multiple parallel tasks so that multiple two-dimensional flood evolution models can be processed at the same time, thereby effectively improving the computing efficiency when processing large-scale flood simulations; and each parallel task corresponds to a two-dimensional flood evolution model, so that the parallel tasks are executed on independent computing nodes, thereby ensuring isolation between tasks and avoiding direct mutual interference between computing tasks. And based on the parallel task nodes, the shortest path is determined to optimize the efficiency of the calculation to ensure that the calculation of multiple parallel tasks can be completed as soon as possible. Finally, each parallel task is assigned to the idle GPU resources for calculation, further improving the overall performance and efficiency of the calculation.

[0008] Optionally, the parallel task also includes n non-parallel task nodes, wherein one non-parallel task node corresponds to one of the two-dimensional flood evolution models, and n is a natural number; determining the shortest path corresponding to each of the parallel tasks based on each of the parallel task nodes specifically includes: judging whether n is 0; when n is not 0, determining the initial node and the target node in the shortest path corresponding to each of the parallel tasks based on the parallel task nodes and the non-parallel task nodes in each of the parallel tasks; selecting an intermediate node from the n non-parallel task nodes in turn until the intermediate node is the target node; determining the parent node corresponding to the target node; tracing back from the target node to the initial node based on tracing back the parent node, and reconstructing the path to obtain the shortest path corresponding to each of the parallel tasks.

[0009] By adopting the above technical solution, the shortest path of each task is found for multiple parallel tasks, and the starting point and end point of each parallel task are determined, and the intermediate nodes in the shortest path are found; then by calculating the parent node, the entire shortest path is finally reconstructed, thereby effectively optimizing the calculation order of parallel tasks, thereby improving efficiency and accuracy.

[0010] Optionally, selecting an intermediate node from the n non-parallel task nodes in sequence until the intermediate node is the target node specifically includes: adding the n non-parallel task nodes to an open list; taking the initial node as the currently selected node; based on the initial node and the target node, selecting the intermediate node from at least one adjacent node of the currently selected node; the adjacent node is included in the n non-parallel task nodes; judging whether the intermediate node is the target node; if so, taking the intermediate node as the target node; if not, removing the non-parallel task node corresponding to the intermediate node from the open list, taking the intermediate node as the currently selected node, and repeating the step of selecting the intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node until it is determined that the selected intermediate node is the target node.

[0011] Optionally, the intermediate node is selected from at least one adjacent node of the currently selected node based on the initial node and the target node, specifically including: initializing the actual cost function value and the heuristic evaluation function value of the initial node; based on the initial node, calculating the actual cost function values ​​corresponding to n non-parallel task nodes; based on the target node, calculating the heuristic evaluation function values ​​corresponding to n non-parallel task nodes; based on the actual cost function value and the heuristic evaluation function value, obtaining the total cost values ​​corresponding to the n non-parallel task nodes; judging whether each of the adjacent nodes is in the open list, and filtering out the first adjacent node from all the adjacent nodes, the first adjacent node is the adjacent node in the open list; selecting the second adjacent node from the first adjacent node, the second adjacent node is the adjacent node with the smallest total cost value among the total cost values ​​corresponding to all the first adjacent nodes; and using the second adjacent node as the intermediate node.

[0012] By adopting the above technical solution, the shortest path from the initial node to the target node is constructed by continuously searching for the next intermediate node during the search process. By combining the actual cost function value and the heuristic evaluation function value, and screening the adjacent nodes and selecting the adjacent node with the minimum total cost value as the intermediate node from the adjacent nodes, the optimal path for the parallel task can be found effectively and more quickly.

[0013] Optionally, the step of calculating the heuristic evaluation function values ​​corresponding to the n non-parallel task nodes based on the target node specifically includes: obtaining the non-parallel task node coordinates corresponding to the i-th non-parallel task node , where i is a positive integer and i∈[1,n]; obtain the target node coordinates corresponding to the target node ; The heuristic evaluation function value corresponding to the i-th non-parallel task node is calculated by the following formula: {d}_{i}=\sqrt[{2}] {{({x}_{goal}-{x}_{i})}^{2}+{({y}_{goal}-{y}_{i})}^{2}}{}^{} ;in, is the heuristic evaluation function value corresponding to the i-th non-parallel task node.

[0014] Optionally, based on the parallel task nodes and the non-parallel task nodes in each of the parallel tasks, determining the initial node and the target node in the shortest path corresponding to each of the parallel tasks specifically includes: taking the parallel task node as the initial node; determining the arrangement order of the non-parallel task nodes, and taking the non-parallel task node with the last arrangement order as the target node.

[0015] Optionally, after determining whether n is 0, the method further includes: when n is 0, using the parallel task node itself as the shortest path corresponding to the parallel task.

[0016] In a second aspect of the present application, a GPU-based model parallel computing system is provided, the system comprising: In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any method described in the first aspect of the present application.

[0017] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed, a computer program executes the method as described in any one of the first aspect of the present application.

[0018] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. Determine the scope, objectives, and specific scenarios of the computing tasks by determining the overall tasks of multiple two-dimensional flood evolution models. Decompose the entire task into multiple parallel tasks so that multiple two-dimensional flood evolution models can be processed simultaneously, thereby effectively improving the computing efficiency when processing large-scale flood simulations; and each parallel task corresponds to a two-dimensional flood evolution model, so that the parallel tasks are executed on independent computing nodes, thereby ensuring isolation between tasks and avoiding direct mutual interference between computing tasks. And based on the parallel task nodes, determine the shortest path to optimize the efficiency of the calculation to ensure that the calculation of multiple parallel tasks can be completed as soon as possible. Finally, each parallel task is assigned to the idle GPU resources for calculation, further improving the overall performance and efficiency of the calculation.

[0019] 2. By finding the shortest path for each task for multiple parallel tasks, determining the starting point and end point of each parallel task, and finding the intermediate nodes in the shortest path; then by calculating the parent node, the entire shortest path is finally reconstructed, thereby effectively optimizing the calculation order of parallel tasks, thereby improving efficiency and accuracy.

[0020] 3. By continuously searching for the next intermediate node during the search process, the shortest path from the initial node to the target node is constructed. By combining the actual cost function value and the heuristic evaluation function value, and screening the adjacent nodes and selecting the adjacent nodes with the minimum total cost value as the intermediate nodes, the optimal path for parallel tasks can be found effectively and more quickly. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is one of the flow charts of a GPU-based model parallel computing method provided in an embodiment of the present application; Figure 2 This is the second flow chart of a GPU-based model parallel computing method disclosed in an embodiment of the present application; Figure 3 This is the third structural diagram of a GPU-based model parallel computing system disclosed in an embodiment of the present application; Figure 4 It is a structural diagram of a GPU-based model parallel computing system disclosed in an embodiment of the present application; Figure 5 It is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application.

[0022] Explanation of the accompanying drawings: 1. Task determination module; 2. Parallel task division module; 3. Acquisition module; 4. Shortest path determination module; 5. Processing module; 500, electronic device; 501, processor; 502, communication bus; 503, user interface; 504, network interface; 505, memory. DETAILED DESCRIPTION

[0023] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0024] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.

[0025] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0026] The 2D flood evolution model is a hydrodynamic model used to simulate and analyze the propagation and evolution of floods. It considers the flow of floods on a horizontal plane and is calculated through the following elements: Topographic data: The 2D flood evolution model needs to describe the changes in the height of the surface based on a digital elevation model (DEM) or terrain data in order to calculate the path and speed of the water flow. Hydrodynamic equations: The 2D flood evolution model uses hydrodynamic equations to describe the changes in water flow, including continuity equations and momentum equations, which consider the relationship between the velocity, flow rate, water level and terrain of the water flow. Initial conditions: The 2D flood evolution model requires initial conditions, usually including the starting water level and flow rate of the flood, in order to start the simulation process. Boundary conditions: Boundary conditions specify the simulation boundaries of the 2D flood evolution model, usually the outlet of a river or lake, which affects the propagation of the flood in the water area. Time step: The model uses discrete time steps to simulate the evolution of floods, and usually requires multiple time steps to simulate the entire flood event.

[0027] However, since the calculation process of the above elements is very complicated and the amount of calculation is large, the traditional serial calculation method can no longer meet the requirements. Therefore, converting the hydrodynamic model from serial calculation to parallel calculation and introducing it into the GPU for parallel calculation can greatly improve the calculation speed. Therefore, this application provides a GPU-based model parallel calculation method, referring to Figure 1 , Figure 1 This is one of the flow charts of a GPU-based model parallel computing method disclosed in an embodiment of the present application. The GPU-based model parallel computing method includes steps S1 to S5, which are as follows: Step S1: Based on multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale, determine the overall tasks of multiple two-dimensional flood evolution models.

[0028] In the above steps, the server determines the overall tasks of multiple two-dimensional flood evolution models based on multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale.

[0029] Specifically, in this technical solution, the server is deployed at the flood evolution terminal of a typical flood protection zone at a large watershed scale.

[0030] Typical flood protection areas at the large watershed scale are selected areas within a large river basin (usually a river or a river tributary). These protection areas are usually located within a large watershed and cover important cities, farmlands, industrial areas, water resources and ecosystems. Their geographical scope is usually upstream and downstream of a river or a tributary. These areas are usually threatened by floods and may face periodic or occasional flooding events. These floods may be caused by extreme weather events, heavy rains, snowmelt or river flooding.

[0031] According to the topographic, geological, hydrological and meteorological characteristics of typical flood protection areas at large watershed scales, and by determining the initial conditions and boundary conditions of each model, multiple two-dimensional flood evolution models are obtained. The overall task of multiple two-dimensional flood evolution models is obtained by the user configuring multiple two-dimensional flood evolution models and global parameters on the user side.

[0032] Step S2: Divide the overall task to obtain multiple parallel tasks; each parallel task includes a parallel task node, and a parallel task node corresponds to a two-dimensional flood evolution model.

[0033] In the above steps, the server divides the overall task into multiple parallel tasks; each parallel task includes a parallel task node, and a parallel task node corresponds to a two-dimensional flood evolution model.

[0034] Specifically, in this technical solution, the server divides the overall task according to the business requirements selected by the user to obtain multiple parallel tasks. Assuming that the user only needs to study the flood evolution in the area corresponding to the two-dimensional flood evolution model A, the task corresponding to the two-dimensional flood evolution model A is used as a parallel task, and the two-dimensional flood evolution model A is used as the parallel task node of the parallel task.

[0035] Step S3: Obtain the flood evolution related data corresponding to each parallel task node, and load the flood evolution related data into the GPU memory.

[0036] In the above steps, the server obtains the flood evolution related data corresponding to each parallel task node, and loads the flood evolution related data into the GPU memory.

[0037] Specifically, in this technical solution, before obtaining the flood evolution related data corresponding to each parallel task node and loading the flood evolution related data into the GPU memory, it is necessary to first select a suitable GPU to meet the computing requirements, so as to maximize the computing performance; and in order to use the GPU for parallel computing, it is necessary to install the GPU driver and CUDA; and then select a programming language or framework suitable for GPU parallel computing. Common choices include CUDA C / C++, OpenCL, and libraries and frameworks that use GPU acceleration. In this solution, CUDA C / C++ is preferably used.

[0038] The flood evolution related data corresponding to each parallel task node include but are not limited to upstream hydrological data, hydrodynamic data, hydrodynamic parameter configuration data, time series data and boundary condition data. After obtaining the flood evolution related data corresponding to each parallel task node, the flood evolution related data is transferred from the host memory to the GPU memory, which can be achieved in the following ways: first, the GPU memory is allocated through the cudaMalloc function, that is, the memory block of the specified size is allocated on the GPU through the cudaMalloc function for the GPU core to perform computing tasks; then the data is copied to the GPU memory through the cudaMemcpy function; then the GPU memory is transferred back through the cudaMemcpy function; and finally the GPU memory is released.

[0039] Step S4: Based on each parallel task node, determine the shortest path corresponding to each parallel task.

[0040] In the above steps, the server determines the shortest path corresponding to each parallel task based on each parallel task node.

[0041] Specifically, in this technical solution, based on each parallel task node, the shortest path corresponding to each parallel task is determined to ensure that each parallel task can be completed in the shortest time, thereby effectively improving the computing efficiency of each parallel task and effectively utilizing GPU resources.

[0042] Specifically based on each parallel task node, the method steps for determining the shortest path corresponding to each parallel task will be described in detail in subsequent embodiments, so no further details will be given here.

[0043] Step S5: Allocate each parallel task to the GPU resources in an idle state respectively, and calculate the flood evolution related data through the allocated GPU resources based on the shortest path and the preset GPU kernel function.

[0044] In the above steps, the server allocates each parallel task to the idle GPU resources respectively, and calculates the flood evolution related data through the allocated GPU resources based on the shortest path and the preset GPU kernel function.

[0045] Specifically, in this technical solution, before each parallel task is assigned to an idle GPU resource, and the flood evolution related data is calculated by the allocated GPU resources based on the shortest path and the preset GPU kernel function, it is also necessary to use a suitable programming language or framework to write the GPU kernel function to ensure that the written kernel function is parallelized to maximize the computing performance. The specific method of writing the GPU kernel function is not overly limited in this application.

[0046] The server calls the GPU kernel function instruction and assigns the tasks in the computing queue to the idle GPU resources. Through the allocated GPU resources and based on the shortest path and the preset GPU kernel function, it performs multi-task parallel calculations on the flood evolution related data and records the GPU occupancy status.

[0047] It should be noted that before the GPU calculates parallel tasks, it is necessary to use GPU performance analysis tools to identify performance bottlenecks and optimize the code, so as to optimize and debug the GPU to ensure the efficiency and correctness of GPU parallel computing. After the GPU completes the calculation of all parallel tasks, it is necessary to ensure that the GPU memory and other resources are released to avoid memory leaks or resource waste. Furthermore, the server can also consider expanding to multiple GPUs or clusters based on factors such as the two-dimensional flood evolution model and the scale of the data to cope with larger-scale computing needs.

[0048] In one possible implementation, refer to Figure 2 , Figure 2This is the second flow chart of a GPU-based model parallel computing method disclosed in the embodiment of the present application. The parallel task also includes n non-parallel task nodes, wherein one non-parallel task node corresponds to a two-dimensional flood evolution model, n is a natural number, and step S4 specifically includes steps S41-S45: Step S41: Determine whether n is 0.

[0049] Specifically, in this technical solution, the server will determine whether the number of non-parallel task nodes is 0. There may be multiple two-dimensional flood evolution models in a parallel task. The first two-dimensional flood evolution model outputs the operation result after calculating the data, and then inputs the operation result into the second two-dimensional flood evolution model for calculation, and so on, until the last two-dimensional flood evolution model is calculated and the final operation result is obtained. Among them, the first two-dimensional flood evolution model is the parallel task node, and the remaining two-dimensional flood evolution models are non-parallel task nodes.

[0050] For example, assuming that there are two-dimensional flood evolution model B, two-dimensional flood evolution model C and two-dimensional flood evolution model D in a parallel task, the server first inputs data into two-dimensional flood evolution model B for calculation to obtain a first calculation result, then inputs the first calculation result into two-dimensional flood evolution model C for calculation to obtain a second calculation result, then inputs the second calculation result into two-dimensional flood evolution model D for calculation to obtain a final calculation result. Therefore, two-dimensional flood evolution model B is the parallel task node in the parallel task, and two-dimensional flood evolution model C and two-dimensional flood evolution model D are the non-parallel task nodes in the parallel task.

[0051] Step S42: when n is not 0, based on the parallel task nodes and non-parallel task nodes in each parallel task, determine the initial node and the target node in the shortest path corresponding to each parallel task.

[0052] Specifically, in this technical solution, when the server determines that the number of non-parallel task nodes is not 0, it determines the initial node and target node in the shortest path corresponding to each parallel task based on the parallel task nodes and non-parallel task nodes in each parallel task.

[0053] In a possible implementation, step S42 specifically includes the following steps: The parallel task node is used as the initial node; the arrangement order of the non-parallel task nodes is determined, and the non-parallel task node with the last arrangement order is used as the target node.

[0054] Specifically, in this technical solution, the server takes the parallel task node in a parallel task as the initial node; and according to the arrangement order of the non-parallel task nodes, takes the non-parallel task node with the last arrangement order as the target node, thereby obtaining the initial node and target node in the shortest path corresponding to the parallel task, to ensure that each parallel task knows where to start and where to end, so as to correctly calculate the shortest path.

[0055] It should be noted that the server may also determine the initial node and the target node in the shortest path corresponding to the parallel task through user selection.

[0056] Step S43: Select an intermediate node from the n non-parallel task nodes in sequence until the intermediate node becomes the target node.

[0057] Specifically, in this technical solution, the server selects an intermediate node from n non-parallel task nodes in sequence until the intermediate node is the target node. The intermediate node is the node on the shortest path except the initial node, and the last intermediate node is the target node.

[0058] In one possible implementation, refer to Figure 3 , Figure 3 This is the third flow chart of a GPU-based model parallel computing method disclosed in the embodiment of the present application. Step S43 specifically includes steps S431-S436: Step S431: Add n non-parallel task nodes to the open list.

[0059] Specifically, in this technical solution, the server adds n non-parallel task nodes to the open list, and also needs to add parallel task nodes to the open list. The open list is a data structure, and adding n non-parallel task nodes to the open list indicates that the parallel task nodes and n non-parallel task nodes stored in the open list have not been selected in the process of constructing the shortest path.

[0060] Step S432: Use the initial node as the currently selected node.

[0061] Specifically, in this technical solution, the server uses the initial node as the current selected node.

[0062] It should be noted that after the initial node is used as the current selected node, the parallel task node corresponding to the initial node needs to be removed from the open list and added to the closed list. The closed list is also a data structure, which indicates that the parallel task nodes and non-parallel task nodes stored in the closed list have been selected in the process of constructing the shortest path.

[0063] Step S433: Based on the initial node and the target node, an intermediate node is selected from at least one adjacent node of the currently selected node; the adjacent node is included in the n non-parallel task nodes.

[0064] Specifically, in this technical solution, the server selects an intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node; the adjacent node is included in n non-parallel task nodes. The adjacent node is a node that is directly connected to the currently selected node or can be reached by one-step movement. It can determine a grid data by querying the boundary condition data (here refers to each node) specified by the model, and then search for at least one adjacent node adjacent to the currently selected node in the grid data.

[0065] After obtaining at least one adjacent node, an intermediate node is selected from the at least one adjacent node. The following embodiment will describe in detail the method for selecting an intermediate node from at least one adjacent node.

[0066] In a possible implementation, step S433 specifically includes the following steps: Initialize the actual cost function value and heuristic evaluation function value of the initial node.

[0067] Specifically, in this technical solution, the server initializes the actual cost function value and the heuristic evaluation function value of the initial node.

[0068] The actual cost function value is used to represent the actual cost from one position to another. For example, the actual cost function value of node A-node A is 0, the actual cost function value of node A-node B is 1, the actual cost function value of node A-node B-node C is 2, the actual cost function value of node A-node B-node C-node D is 3, and so on, which is similar to the step size.

[0069] The heuristic evaluation function value is used to estimate the shortest path cost from the currently selected node to the target node.

[0070] Therefore, the actual cost function value of the initial node after initialization is 0, that is, the heuristic evaluation function value of the initial node after initialization is the shortest path cost from the initial node to the target node.

[0071] Based on the initial node, calculate the actual cost function values ​​corresponding to n non-parallel task nodes.

[0072] Specifically, in this technical solution, the server calculates the actual cost function values ​​corresponding to n non-parallel task nodes based on the initial node. Calculating the actual cost function values ​​corresponding to n non-parallel task nodes means calculating the actual cost function values ​​of each non-parallel task node and the initial node.

[0073] Based on the target node, calculate the heuristic evaluation function values ​​corresponding to n non-parallel task nodes.

[0074] Specifically, in this technical solution, the server calculates the heuristic evaluation function values ​​corresponding to n non-parallel task nodes based on the target node. Calculating the heuristic evaluation function values ​​corresponding to n non-parallel task nodes means calculating the heuristic evaluation function values ​​of each non-parallel task node and the target node.

[0075] The following embodiment will explain in detail the method for calculating the heuristic evaluation function values ​​corresponding to n non-parallel task nodes based on the target node.

[0076] In a possible implementation, the heuristic evaluation function values ​​corresponding to the n non-parallel task nodes are calculated in the following manner: Get the non-parallel task node coordinates corresponding to the i-th non-parallel task node , where i is a positive integer and i∈[1,n].

[0077] Specifically, in this technical solution, the server obtains the non-parallel task node coordinates corresponding to the i-th non-parallel task node .

[0078] Get the target node coordinates corresponding to the target node .

[0079] Specifically, in this technical solution, the server obtains the target node coordinates corresponding to the target node .

[0080] The heuristic evaluation function value corresponding to the i-th non-parallel task node is calculated by the following formula: {d}_{i}=\sqrt[{2}] {{({x}_{goal}-{x}_{i})}^{2}+{({y}_{goal}-{y}_{i})}^{2}}{}^{} ; in, is the heuristic evaluation function value corresponding to the i-th non-parallel task node.

[0081] Specifically, in this technical solution, the server obtains the heuristic evaluation function value of the ith non-parallel task node and the target node by calculating the Euclidean distance between the ith non-parallel task node and the target node.

[0082] Based on the actual cost function value and the heuristic evaluation function value, the total cost value corresponding to n non-parallel task nodes is obtained.

[0083] Specifically, in this technical solution, the server obtains the total cost value corresponding to n non-parallel task nodes based on the actual cost function value and the heuristic evaluation function value. Total cost value = actual cost function value + heuristic evaluation function value.

[0084] It should be noted that after calculating the actual cost function values ​​corresponding to the n non-parallel task nodes, the server stores the actual cost function values ​​corresponding to the n non-parallel task nodes in the memory so as to quickly search for them in subsequent use.

[0085] It is determined whether each adjacent node is in the open list, and the first adjacent node is obtained from all adjacent nodes. The first adjacent node is the adjacent node in the open list.

[0086] Specifically, in this technical solution, the server determines whether each adjacent node is in the open list, and screens all adjacent nodes to obtain the first adjacent node, which is the adjacent node in the open list. If the non-parallel task node corresponding to the adjacent node is not in the open list, it is not considered; if the non-parallel task corresponding to the adjacent node is in the open list, the first adjacent node is obtained.

[0087] A second adjacent node is selected from the first adjacent nodes, where the second adjacent node is an adjacent node having the smallest total cost value among the total cost values ​​corresponding to all the first adjacent nodes.

[0088] Specifically, in this technical solution, the server selects the second adjacent node from the first adjacent node, and the second adjacent node is the adjacent node with the smallest total cost value among the total cost values ​​corresponding to all the first adjacent nodes. It should be noted that if there is only one first adjacent node, the first adjacent node is used as the intermediate node.

[0089] The second adjacent node is regarded as the middle node.

[0090] Specifically, in this technical solution, the server uses the second adjacent node as the intermediate node. After using the second adjacent node as the intermediate node, the server uses the intermediate node as the current selected node and continues to search for the shortest path toward the target node.

[0091] Step S434: Determine whether the intermediate node is the target node.

[0092] Specifically, in this technical solution, the server determines whether the intermediate node is the target node. Determining whether the intermediate node is the target node means determining whether the shortest path has been found.

[0093] Step S435: If yes, the intermediate node is used as the target node.

[0094] Specifically, in this technical solution, when the server determines that the intermediate node is the target node, the intermediate node is used as the target node. If the intermediate node is the target node, it means that the shortest path has been found, the intermediate node is set as the target node, and the shortest path algorithm ends.

[0095] Step S436: If not, the non-parallel task node corresponding to the intermediate node is removed from the open list, and the intermediate node is used as the current selected node, and the step of selecting the intermediate node from at least one adjacent node of the current selected node based on the initial node and the target node is repeated until the selected intermediate node is determined to be the target node.

[0096] Specifically, in the present technical solution, when the server determines that the intermediate node is not the target node, the non-parallel task node corresponding to the intermediate node is removed from the open list and added to the closed list, and then the current intermediate node is used as the current selected node, and steps S433 and S434 are repeated until the intermediate node obtained is the target node.

[0097] It should be noted that if the open list is empty and the target node is still not found, it means that there is no feasible shortest path for the task, and the initial node and target node need to be redesigned and the shortest path needs to be found again.

[0098] Step S44: Determine the parent node corresponding to the target node.

[0099] Specifically, in this technical solution, the server determines the parent node corresponding to the target node.

[0100] Step S45: trace back from the target node to the initial node based on the method of backtracking the parent node, and reconstruct the path to obtain the shortest path corresponding to each parallel task.

[0101] Specifically, in this technical solution, the server traces back from the target node to the initial node based on the way of backtracking the parent node, and reconstructs the path to obtain the shortest path corresponding to each parallel task. Starting from the target node, the path is gradually backtracked using the information of the parent node until it returns to the initial node. Each node will have a parent node, which is the node that caused the current node to be selected during the search process. While backtracking the path, the server will also store the passed nodes in a path list in the order of backtracking. From the initial node to the target node, this path list will contain all the intermediate nodes on the shortest path.

[0102] In one possible implementation, refer to Figure 2 , after step S41, the method further comprises step S46: Step S46: When n is 0, the parallel task node itself is used as the shortest path corresponding to the parallel task.

[0103] Specifically, in this technical solution, when the server determines that the number of non-parallel task nodes is 0, the parallel task node itself is used as the shortest path corresponding to the parallel task. If there is only one node, that is, only one parallel task node, then the parallel task node itself is the starting point and end point of the shortest path.

[0104] This application also provides a model parallel computing system based on GPU, referring to Figure 4 , which shows a structural schematic diagram of a GPU-based model parallel computing system provided by an embodiment of the present application. The system includes: a task determination module 1, a parallel task division module 2, an acquisition module 3 and a processing module 5; the task determination module 1 is used to determine the overall task of multiple two-dimensional flood evolution models based on multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale; the parallel task division module 2 is used to divide the overall task to obtain multiple parallel tasks; each parallel task includes a parallel task node, and a parallel task node corresponds to a two-dimensional flood evolution model; the acquisition module 3 is used to obtain the flood evolution related data corresponding to each parallel task node, and load the flood evolution related data into the GPU memory; the shortest path determination module 4 is used to determine the shortest path corresponding to each parallel task based on each parallel task node; the processing module 5 is used to respectively assign each parallel task to the GPU resources in an idle state, and calculate the flood evolution related data through the allocated GPU resources and based on the shortest path and the preset GPU kernel function.

[0105] In a possible implementation, the shortest path determination module 4 is also used to determine whether n is 0; the shortest path determination module 4 is also used to determine the initial node and the target node in the shortest path corresponding to each parallel task based on the parallel task nodes and non-parallel task nodes in each parallel task when n is not 0; the shortest path determination module 4 is also used to select an intermediate node from n non-parallel task nodes in turn until the intermediate node is the target node; the shortest path determination module 4 is also used to determine the parent node corresponding to the target node; the shortest path determination module 4 is also used to trace back from the target node to the initial node based on backtracing the parent node, and reconstruct the path to obtain the shortest path corresponding to each parallel task.

[0106] In a possible implementation, the shortest path determination module 4 is also used to add n non-parallel task nodes to an open list; the shortest path determination module 4 is also used to use the initial node as the currently selected node; the shortest path determination module 4 is also used to select an intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node; the adjacent node is included in the n non-parallel task nodes; the shortest path determination module 4 is also used to determine whether the intermediate node is a target node; the shortest path determination module 4 is also used to use the intermediate node as the target node if so; the shortest path determination module 4 is also used to remove the non-parallel task node corresponding to the intermediate node from the open list if not, and use the intermediate node as the currently selected node, and repeat the step of selecting an intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node until the selected intermediate node is determined to be the target node.

[0107] In a possible implementation, the shortest path determination module 4 is also used to initialize the actual cost function value and the heuristic evaluation function value of the initial node; the shortest path determination module 4 is also used to calculate the actual cost function values ​​corresponding to n non-parallel task nodes based on the initial node; the shortest path determination module 4 is also used to calculate the heuristic evaluation function values ​​corresponding to n non-parallel task nodes based on the target node; the shortest path determination module 4 is also used to obtain the total cost value corresponding to the n non-parallel task nodes based on the actual cost function value and the heuristic evaluation function value; the shortest path determination module 4 is also used to determine whether each adjacent node is in an open list, and to filter out the first adjacent node from all adjacent nodes, the first adjacent node being the adjacent node in the open list; the shortest path determination module 4 is also used to select the second adjacent node from the first adjacent node, the second adjacent node being the adjacent node with the smallest total cost value among the total cost values ​​corresponding to all first adjacent nodes; the shortest path determination module 4 is also used to use the second adjacent node as an intermediate node.

[0108] In a possible implementation, the acquisition module 3 is further used to acquire the non-parallel task node coordinates corresponding to the i-th non-parallel task node. , where i is a positive integer and i∈[1,n]; the acquisition module 3 is also used to obtain the target node coordinates corresponding to the target node ; The shortest path determination module 4 is also used to calculate the heuristic evaluation function value corresponding to the i-th non-parallel task node through the following formula: {d}_{i}=\sqrt[{2}] {{({x}_{goal}-{x}_{i})}^{2}+{({y}_{goal}-{y}_{i})}^{2}}{}^{} ;in, is the heuristic evaluation function value corresponding to the i-th non-parallel task node.

[0109] In a possible implementation, the shortest path determination module 4 is further used to use the parallel task node as the initial node; the shortest path determination module 4 is further used to determine the arrangement order of the non-parallel task nodes, and use the non-parallel task node with the last arrangement order as the target node.

[0110] In a possible implementation manner, the shortest path determination module 4 is further configured to, when n is 0, use the parallel task node itself as the shortest path corresponding to the parallel task.

[0111] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0112] The present application also discloses an electronic device. Figure 5 , Figure 5 The electronic device 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , and at least one communication bus 502 .

[0113] The communication bus 502 is used to realize the connection and communication between these components.

[0114] The user interface 503 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 503 may also include a standard wired interface and a wireless interface.

[0115] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0116] Among them, the processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 505, and calling data stored in the memory 505. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and it can be implemented separately through a chip.

[0117] Among them, the memory 505 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 505 may also be optionally at least one storage device located away from the aforementioned processor 501. Refer to Figure 5 , the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program.

[0118] exist Figure 5In the electronic device 500 shown, the user interface 503 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 501 can be used to call an application stored in the memory 505, and when executed by one or more processors 501, the electronic device 500 executes one or more methods in the above-mentioned embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.

[0119] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0120] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0121] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.

[0124] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, those skilled in the art will easily think of other embodiments of the present disclosure.

[0125] This application is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not described in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A GPU-based model parallel computing method, characterized in that: The method comprises: Based on multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale, determine the overall tasks of the multiple two-dimensional flood evolution models; The overall task is divided to obtain a plurality of parallel tasks; each of the parallel tasks includes a parallel task node, and one parallel task node corresponds to one of the two-dimensional flood evolution models; Obtaining flood evolution related data corresponding to each of the parallel task nodes, and loading the flood evolution related data into the GPU memory; Based on each of the parallel task nodes, determining the shortest path corresponding to each of the parallel tasks; Each of the parallel tasks is respectively allocated to an idle GPU resource, and the flood evolution related data is calculated through the allocated GPU resources and based on the shortest path and a preset GPU kernel function.

2. The method according to claim 1, characterized in that The parallel task also includes n non-parallel task nodes, wherein one non-parallel task node corresponds to one of the two-dimensional flood evolution models, and n is a natural number; determining the shortest path corresponding to each of the parallel tasks based on each of the parallel task nodes specifically includes: Determine whether n is 0; When n is not 0, based on the parallel task nodes and the non-parallel task nodes in each of the parallel tasks, determining the initial node and the target node in the shortest path corresponding to each of the parallel tasks; Selecting one intermediate node from the n non-parallel task nodes in sequence until the intermediate node becomes the target node; Determine the parent node corresponding to the target node; Based on the method of backtracing the parent node, the target node is traced back to the initial node, and the path is reconstructed to obtain the shortest path corresponding to each of the parallel tasks.

3. The method according to claim 2, characterized in that The step of sequentially selecting an intermediate node from the n non-parallel task nodes until the intermediate node becomes the target node specifically includes: Adding n of the non-parallel task nodes to an open list; Taking the initial node as the currently selected node; Based on the initial node and the target node, the intermediate node is selected from at least one adjacent node of the currently selected node; the adjacent node is included in the n non-parallel task nodes; Determining whether the intermediate node is the target node; If yes, then taking the intermediate node as the target node; If not, the non-parallel task node corresponding to the intermediate node is removed from the open list, and the intermediate node is used as the current selected node, and the step of selecting the intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node is repeated until it is determined that the selected intermediate node is the target node.

4. The method according to claim 3, characterized in that The step of selecting the intermediate node from at least one adjacent node of the currently selected node based on the initial node and the target node specifically includes: Initializing the actual cost function value and the heuristic evaluation function value of the initial node; Based on the initial node, calculating actual cost function values ​​corresponding to the n non-parallel task nodes; Based on the target node, calculating the heuristic evaluation function values ​​corresponding to the n non-parallel task nodes; Based on the actual cost function value and the heuristic evaluation function value, obtaining a total cost value corresponding to the n non-parallel task nodes; Determine whether each of the adjacent nodes is in the open list, and select a first adjacent node from all the adjacent nodes, where the first adjacent node is an adjacent node in the open list; A second adjacent node is selected from the first adjacent nodes, where the second adjacent node is an adjacent node having the smallest total cost value among the total cost values ​​corresponding to all the first adjacent nodes; The second adjacent node is used as the intermediate node.

5. The method according to claim 4, characterized in that The calculating, based on the target node, the heuristic evaluation function values ​​corresponding to the n non-parallel task nodes specifically includes: Get the non-parallel task node coordinates corresponding to the i-th non-parallel task node , where i is a positive integer and i∈[1,n]; Get the target node coordinates corresponding to the target node ; The heuristic evaluation function value corresponding to the i-th non-parallel task node is calculated by the following formula: ; in, is the heuristic evaluation function value corresponding to the i-th non-parallel task node.

6. The method according to claim 2, characterized in that The determining, based on the parallel task nodes and the non-parallel task nodes in each of the parallel tasks, an initial node and a target node in the shortest path corresponding to each of the parallel tasks specifically includes: Using the parallel task node as the initial node; The arrangement order of the non-parallel task nodes is determined, and the non-parallel task node with the last arrangement order is used as the target node.

7. The method according to claim 2, characterized in that After determining whether n is 0, the method further includes: When n is 0, the parallel task node itself is used as the shortest path corresponding to the parallel task.

8. A GPU-based model parallel computing system, characterized in that: The system comprises: a task determination module, a parallel task division module, an acquisition module, a shortest path determination module and a processing module; The task determination module is used to determine the overall tasks of multiple two-dimensional flood evolution models based on multiple two-dimensional flood evolution models corresponding to typical flood protection areas at a large watershed scale; The parallel task division module is used to divide the overall task into multiple parallel tasks; each of the parallel tasks includes a parallel task node, and one parallel task node corresponds to one of the two-dimensional flood evolution models; The acquisition module is used to acquire the flood evolution related data corresponding to each of the parallel task nodes, and load the flood evolution related data into the GPU memory; The shortest path determination module is used to determine the shortest path corresponding to each of the parallel tasks based on each of the parallel task nodes; The processing module is used to respectively allocate each of the parallel tasks to the GPU resources in an idle state, and calculate the flood evolution related data through the allocated GPU resources and based on the shortest path and the preset GPU kernel function.

9. An electronic device, characterized in that: The electronic device (500) comprises a processor (501), a memory (505), a user interface (503) and a network interface (504), wherein the memory (505) is used to store instructions, the user interface (503) and the network interface (504) are used to communicate with other devices, and the processor (501) is used to execute the instructions stored in the memory (505) so that the electronic device (500) executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 7 is executed.