Disclosure of Invention
In view of the above, the present invention provides a load distribution method, apparatus, device and medium, which can improve the acceleration effect of processing a load task. The specific scheme is as follows:
in a first aspect, the present application discloses a load distribution method, including:
carrying out grid fusion processing on initial grid units in an initial grid constructed based on a load task to obtain a target grid;
determining the partition weight of each fused grid unit in the target grid;
dividing the fused grid unit to a corresponding target partition based on the partition weight;
and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing.
Optionally, the determining the partition weight of each fused grid unit in the target grid includes:
determining the initial cell number of the initial grid cell corresponding to each fused grid cell in the target grid, and determining the partition weight of each fused grid cell based on the initial cell number.
Optionally, the determining the partition weight of each fused grid cell in the target grid includes:
and determining the partition weight of each fused grid unit in the target grid by using a recursive algorithm.
Optionally, before dividing the fused grid unit into corresponding target partitions based on the partition weight, the method further includes:
and calling a METIS library to determine a first mapping relation between each fused grid unit and the corresponding target partition based on the partition weight and the preset load requirement so as to divide the fused grid units into the corresponding target partitions based on the first mapping relation and the partition weight.
Optionally, the invoking a METIS library to determine a first mapping relationship between each fused grid unit and the corresponding target partition based on the partition weight and the preset load requirement includes:
determining the number of target units of the fused grid units and the number of the fused grid units adjacent to each fused grid unit;
and calling a METIS library to determine a first mapping relation between each fused grid unit and the corresponding target partition based on the partition weight, the preset load requirement, the number of the target units and the number of the fused grid units adjacent to each fused grid unit.
Optionally, the performing region segmentation on the initial mesh based on the target partition includes:
calculating a second mapping relation between the fused grid unit and the initial grid unit;
and performing region segmentation on the initial grid based on the first mapping relation, the second mapping relation and the target partition.
Optionally, the grid fusion processing on the initial grid unit in the initial grid constructed based on the load task to obtain the target grid includes:
and carrying out grid fusion processing on the initial grid unit in the initial grid constructed based on the load task by utilizing a preset grid fusion algorithm and a preset non-overlapping fusion condition to obtain the target grid.
In a second aspect, the present application discloses a load distribution apparatus comprising:
the fusion processing module is used for carrying out grid fusion processing on initial grid units in the initial grid constructed based on the load task to obtain a target grid;
a weight determination module, configured to determine a partition weight of each fused grid cell in the target grid;
the partition module is used for dividing the fused grid unit into corresponding target partitions based on the partition weight;
a segmentation module, configured to perform region segmentation on the initial mesh based on the target partitions to obtain segmented regions corresponding to the target partitions;
and the sending module is used for respectively sending the load tasks corresponding to the initial grid units in each divided region to corresponding computing nodes for processing.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the load distribution method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program realizes the steps of the load distribution method disclosed in the foregoing when being executed by a processor.
Therefore, the method and the device perform grid fusion processing on the initial grid unit in the initial grid constructed based on the load task to obtain the target grid; determining the partition weight of each fused grid unit in the target grid; dividing the fused grid unit to a corresponding target partition based on the partition weight; and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing. Therefore, the grid fusion processing is firstly carried out, the partition weight of each fused grid unit is determined, the fused grid units are divided into corresponding target partitions based on the partition weights, and then the initial grids are subjected to region division based on the target partitions, so that the obtained number of the initial grid units contained in each divided region is balanced, balanced load tasks are respectively sent to corresponding computing nodes to be processed, and the acceleration effect of the computing nodes for processing the load tasks is further improved.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, fluid mechanics calculation is widely applied to a plurality of industrial fields, but calculation usually needs a huge number of grids, and calculation is time-consuming. Parallel partitioning and multiple mesh fusion are two major acceleration techniques. The parallel partition is to divide the grid corresponding to the load task into a plurality of areas, and to respectively deliver the grids in different areas to different computing nodes for computing so as to reduce the computing time on the wall. The multi-grid fusion technology is to fuse the fine grids to obtain coarse grids, and the coarse grids can quickly eliminate low-frequency errors, so that the effect of accelerating convergence is achieved through alternate calculation of the coarse grids and the fine grids. However, the parallel partition and the multiple grids are simultaneously applied, so that the problem of using the sequence is solved, namely, the multiple grids are fused firstly or the parallel partition is carried out firstly, if a parallel partition priority strategy is adopted, the grid number of the fine grids in each area can be basically the same, namely, the load is balanced, but the implementation of some non-structural grid multiple fusion methods can be interfered, and further, the acceleration effect and the calculation robustness of the multiple grids are reduced; if multiple grids are considered preferentially, because the grid fusion rates of all areas of the unstructured grids are greatly different, the calculation load on the fine grids is seriously unbalanced by directly developing parallel partitions based on the coarse grids, and therefore the overall acceleration effect is seriously reduced.
Therefore, the load distribution scheme is correspondingly provided, and the acceleration effect of processing the load task is improved.
Referring to fig. 1, an embodiment of the present application discloses a load distribution method, including:
step S11: and carrying out grid fusion processing on the initial grid unit in the initial grid constructed based on the load task to obtain the target grid.
In this embodiment, it can be understood that the initial grid is the finest grid, and the finest initial grid is fused based on the preset grid fusion requirement, so as to obtain the coarsest target grid meeting the preset grid fusion requirement. It should be noted that NNW-FlowStar software may be adopted to fuse a plurality of initial grid cells in the initial grid into one grid cell in the next-layer grid, for example, based on a preset grid fusion requirement, two times of fusion need to be performed, as shown in a specific load distribution schematic diagram shown in fig. 2, where the initial grid is grid 0, the next-layer grid is grid 1, the target grid is grid 2, grid 0 includes 4011 initial grid cells, and fusion processing is performed on the 4011 initial grid cells to obtain a new grid cell including the target grid cell and the target grid cell including 4011 initial grid cellsMesh 1 of 592 mesh units, fusing, and then performing mesh fusion processing on the 592 mesh units to obtain a target mesh including 71 fused mesh units, wherein when initial mesh units are fused, for example, a specific mesh fusion diagram shown in fig. 3, 8 initial mesh units, that is, m, in the initial mesh may be fused 1 0 、m 2 0 、m 3 0 、m 4 0 、m 5 0 、m 6 0 、m 7 0 、m 8 0 And performing fusion to obtain a certain grid unit in the grid 1.
Step S12: and determining the partition weight of each fused grid unit in the target grid.
In this embodiment, the determining the partition weight of each fused grid cell in the target grid includes: and determining the partition weight of each fused grid unit in the target grid by using a recursive algorithm.
Step S13: and dividing the fused grid unit into corresponding target partitions based on the partition weight.
In this embodiment, before dividing the fused grid unit into corresponding target partitions based on the partition weights, the method further includes: and calling a METIS library to determine a first mapping relation between each fused grid unit and the corresponding target partition based on the partition weight and the preset load requirement so as to divide the fused grid units into the corresponding target partitions based on the first mapping relation and the partition weight. For example, in fig. 2, 71 fused grid cells in the grid 2 are divided into 4 target partitions, and the 4 target partitions respectively include 12 fused grid cells, 14 fused grid cells, 30 fused grid cells, and 15 fused grid cells.
In this embodiment, the determining, by using the METIS library, a first mapping relationship between each fused grid cell and the corresponding target partition based on the partition weight and the preset load requirement includes: determining the number of target cells of the fused grid cells and each fused grid cellThe grid cells after the fusion of the adjacent elements are numbered; and calling a METIS library to determine a first mapping relation between each fused grid unit and the corresponding target partition based on the partition weight, the preset load requirement, the number of the target units and the number of the fused grid units adjacent to each fused grid unit. It is understood that, for example, if the target grid is the L-th grid, the partition weight w of each fused grid cell is determined i L Number of target cells N of L-th layer mesh L And inputting the number of the fused grid unit adjacent to each fused grid unit into a METIS library as shown in the following formula:
in the formula, m i L Denotes the ith grid cell, w, of the L-th grid j L And the partition weight of the jth grid unit of the L-th grid is represented.
In this embodiment, the partition weight w of each fused grid cell is used i L Number of target cells N of L-th layer mesh L After the number of the fused grid unit adjacent to each fused grid unit is input into the METIS library, the METIS library outputs a first mapping relation between each fused grid unit and the corresponding target partition, as shown in the following formula:
in the formula, Z k Represents the kth target partition, Zn, of the L-th grid k L The kth target partition of the L-th grid contains the number of L-th grid cells, m p L Denotes the p grid cell, m, in the L grid q L Representing the q-th grid cell in the L-th grid.
Step S14: and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing.
In this embodiment, the performing the region segmentation on the initial mesh based on the target partition includes: calculating a second mapping relation between the fused grid unit and the initial grid unit; and performing region segmentation on the initial grid based on the first mapping relation, the second mapping relation and the target partition. For example, as shown in fig. 2, grid 0 is divided into 4 divided regions based on 4 target partitions, the first mapping relationship, and the second mapping relationship, where the 4 divided regions respectively include 1010 initial grid cells, 1000 initial grid cells, and 991 initial grid cells, that is, the initial grid cells are divided into 4 relatively balanced divided regions, and thus, load tasks corresponding to the divided regions are distributed in a balanced manner.
Therefore, the method and the device perform grid fusion processing on the initial grid unit in the initial grid constructed based on the load task to obtain the target grid; determining the partition weight of each fused grid unit in the target grid; dividing the fused grid unit to a corresponding target partition based on the partition weight; and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing. Therefore, the grid fusion processing is firstly carried out, the partition weight of each fused grid unit is determined, the fused grid units are divided into corresponding target partitions based on the partition weights, and then the initial grids are subjected to region division based on the target partitions, so that the obtained number of the initial grid units contained in each divided region is balanced, balanced load tasks are respectively sent to corresponding computing nodes to be processed, and the acceleration effect of the computing nodes for processing the load tasks is further improved.
Referring to fig. 4, an embodiment of the present application discloses a specific load distribution method, including:
step S21: and carrying out grid fusion processing on the initial grid unit in the initial grid constructed based on the load task by utilizing a preset grid fusion algorithm and a preset non-overlapping fusion condition to obtain the target grid.
In this embodiment, for example, the initial grid is a layer 0 grid, and the grid cell set M thereof 0 Comprises the following steps:
in the formula, N 0 Represents a total of N of the 0 th layer grids 0 A grid cell, m i 0 Represents the ith grid cell of the layer 0 grid.
In this embodiment, any one of the preset mesh fusion algorithms is used to perform mesh fusion processing on the layer 0 mesh, for example, the preset mesh fusion algorithm is a full-coverage direct imaging multiple mesh fusion algorithm, the layer 0 mesh is subjected to mesh fusion processing to obtain a layer 1 mesh, and a mesh unit set M of the layer 1 mesh is obtained 1 Comprises the following steps:
in the formula, N 1 Representing a total of N of the layer 1 mesh 1 A grid cell, m i 1 Denotes the ith grid cell of the layer 1 grid, where it is understood that m i 1 From n in the 0 th layer mesh i 0 The grid cells are fused, namely:
in the formula, m p 0 Denotes the p grid cell, m, in the 0 th grid q 0 Representing the q-th grid cell in the layer 0 grid.
In this embodiment, when the mesh is fused, each mesh unit is required to satisfy a preset non-overlapping fusion condition, where the preset non-overlapping fusion condition is:
in this embodiment, it can be understood that the L-th grid is fused from the L-1-th grid, and the L-th grid has N total L A unit cell, wherein the ith grid cell is m i L ,m i L From n to i L-1 The L-1 layer grid cells are fused, and the formula is shown as follows:
in the formula, m p L-1 Denotes the p-th grid cell, m, in the L-1-th grid q L-1 Representing the q-th grid cell in the L-1 th grid.
In this embodiment, in the process of merging the L-1 th layer mesh into the L-th layer mesh, the preset non-overlapping merging condition is also satisfied, which is shown as the following formula:
step S22: determining the initial cell number of the initial grid cell corresponding to each fused grid cell in the target grid, and determining the partition weight of each fused grid cell based on the initial cell number.
In this embodiment, the initial cell number of the initial grid cell corresponding to each fused grid cell in the target grid is determined, for example, the target grid is the coarsest L-th grid, m i L Is the ith grid cell of the L-th grid and consists of n i L-1 Fusing the L-1 layer grid cells, and determining m based on a recursive method i L The number of cells of the corresponding layer 0 mesh, and then m is determined based on the number of cells of the layer 0 mesh i L Partition weight value w i L The recursive algorithm and the partition weight calculation formula are as follows:
in the formula, w i L Represents the partition weight, w, of the ith grid cell in the L-th grid j L-1 Represents the partition weight, w, of the jth trellis cell in the L-1 th trellis i 0 Representing the partition weight of the ith grid cell in the 0 th grid.
Step S23: and dividing the fused grid unit into corresponding target partitions based on the partition weight.
In this embodiment, a first mapping relationship between the fused grid unit and the corresponding target partition is determined by using the METIS library based on the partition weight, and then the fused grid unit is divided into the corresponding target partition by using the first mapping relationship.
Step S24: and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing.
In this embodiment, for example, the target grid is an L-th grid, the initial grid is a 0-th grid, before the region of the initial grid is divided based on the target partition, the fusion processing and the first mapping relationship between the L-th grids obtained based on the 0-th grid are required to be used to calculate the second mapping relationship between each grid cell in the L-th grid and the initial grid, and further to calculate the mapping relationship between the target region and the initial grid, the mapping relationship between each target partition in the L-th grid and each grid cell in the L-1-th grid may be calculated first, then the mapping relationship between each grid cell in the L-1-th grid and each grid cell in the L-2-th grid is calculated, …, and so on, the mapping relationship between each grid cell in the 1-th grid and each grid cell in the 0-th grid is calculated, and then determining the mapping relation between each target partition in the L-th layer grid and each grid unit in the 0-th layer grid so as to perform region segmentation on the initial grid by using the mapping relation between each target partition in the L-th layer grid and each grid unit in the 0-th layer grid.
Therefore, according to the method and the device, the finest initial grid can be fused according to the preset grid fusion requirement to obtain the coarsest target grid, then the partition weight of each fused grid unit in the target grid is calculated based on the number of the initial units corresponding to each fused grid unit, and the target grid is partitioned based on the partition weight, so that the number of the initial grid units contained in a plurality of partitioned areas obtained by subsequently partitioning the initial grid into areas is approximately the same, further the load tasks distributed to the computing nodes are more balanced, and the speed of processing the load tasks by the computing nodes is increased.
Referring to fig. 5, an embodiment of the present application discloses a load distribution apparatus, including:
the fusion processing module 11 is configured to perform mesh fusion processing on initial mesh cells in an initial mesh constructed based on a load task to obtain a target mesh;
a weight determination module 12, configured to determine a partition weight of each fused grid cell in the target grid;
a partition module 13, configured to partition the fused grid cells into corresponding target partitions based on the partition weights;
a segmentation module 14, configured to perform region segmentation on the initial mesh based on the target partitions to obtain segmented regions corresponding to the target partitions;
a sending module 15, configured to send the load task corresponding to the initial grid unit in each of the divided regions to a corresponding computing node for processing.
Therefore, the method and the device perform grid fusion processing on the initial grid unit in the initial grid constructed based on the load task to obtain the target grid; determining the partition weight of each fused grid unit in the target grid; dividing the fused grid unit to a corresponding target partition based on the partition weight; and performing region segmentation on the initial grid based on the target partitions to obtain segmented regions corresponding to the target partitions, and then respectively sending the load tasks corresponding to the initial grid units in each segmented region to corresponding computing nodes for processing. Therefore, the grid fusion processing is firstly carried out, the partition weight of each fused grid unit is determined, the fused grid units are divided into corresponding target partitions based on the partition weights, and then the initial grids are subjected to area division based on the target partitions, so that the number of the initial grid units contained in each divided area is balanced, balanced load tasks are respectively sent to corresponding computing nodes to be processed, and the acceleration effect of the computing nodes for processing the load tasks is further improved.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The method specifically comprises the following steps: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the load distribution method executed by the electronic device disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
In addition, the storage 22 is used as a carrier for storing resources, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., the resources stored thereon include an operating system 221, a computer program 222, data 223, etc., and the storage may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling hardware devices and computer programs 222 on the electronic device, so as to implement operations and processing of the mass data 223 in the memory 22 by the processor 21, and may be Windows, Unix, Linux, or the like. The computer programs 222 may further include computer programs that can be used to perform other specific tasks in addition to the computer programs that can be used to perform the load distribution method performed by the electronic device disclosed in any of the foregoing embodiments. The data 223 may include data received by the electronic device and transmitted from an external device, or may include data collected by the input/output interface 25 itself.
Further, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored, and when the computer program is loaded and executed by a processor, the method steps executed in the load distribution process disclosed in any of the foregoing embodiments are implemented.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The load distribution method, device, apparatus and medium provided by the present invention are described in detail above, and the principle and the implementation of the present invention are explained in this document by applying specific examples, and the description of the above examples is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.