A heterogeneous acceleration method, device, electronic device and storage medium

By converting the source code of the atmospheric power core mode algorithm into a heterogeneous parallel algorithm and performing calculations on a heterogeneous accelerator, the problem of long calculation time of the weather prediction system is solved and the efficiency of weather forecasting is improved.

CN118113342BActive Publication Date: 2025-03-18ZHONGKE TIANJI METEOROLOGICAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211510734.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2025-03-18
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

The weather forecasting system based on the core mode algorithm of atmospheric power has a long calculation time and the weather forecasting operation efficiency is low.

Method used

By obtaining the first heterogeneous parallel algorithm of the atmospheric power core mode algorithm, the source code is written based on the preset heterogeneous parallel programming model. If it is determined that acceleration calculation is required on the heterogeneous accelerator, the first heterogeneous parallel algorithm is converted to obtain the second heterogeneous parallel algorithm, and transplanted to the heterogeneous accelerator for heterogeneous acceleration calculation.

Benefits of technology

The calculation time of the weather prediction system of the atmospheric power core mode algorithm is shortened and the weather forecast operation efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118113342B_ABST
    Figure CN118113342B_ABST
Patent Text Reader

Abstract

The present invention discloses a heterogeneous acceleration method, device, electronic device and storage medium. The method comprises: obtaining a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, the first heterogeneous parallel algorithm is obtained by compiling the source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model; if the atmospheric sample data obtained by respectively calculating based on the first heterogeneous parallel algorithm and the source code is determined to need to be accelerated on a heterogeneous accelerator, the first heterogeneous parallel algorithm is converted into a programming language to obtain a second heterogeneous parallel algorithm; the second heterogeneous parallel algorithm is transplanted to the heterogeneous accelerator, and the atmospheric data to be calculated is heterogeneously accelerated on the heterogeneous accelerator, thereby shortening the calculation time of the weather forecasting system of the atmospheric dynamics core mode algorithm and improving the efficiency of weather forecasting operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a heterogeneous acceleration method, device, electronic device and storage medium. Background Art

[0002] In the era of big data, by executing specific programs to calculate massive amounts of data to achieve specific functions, a lot of value is created for mankind. For example, for the popular next-generation global forecasting system project's atmospheric dynamic core model algorithm FV3 (also known as the dynamic core of the finite volume cubic sphere), its Global Forecasting System (GFS) achieves weather forecasts through the simulation and calculation of atmospheric data, with high simulation accuracy and high computational scalability.

[0003] With the demand for increasingly high-precision weather forecasts, the computing requirements for weather forecasts have increased dramatically. However, the current atmospheric dynamics core model algorithm is generally only suitable for running on the CPU, resulting in long calculation time for weather forecast systems based on the atmospheric dynamics core model algorithm and low weather forecast operation efficiency. Summary of the invention

[0004] The present invention provides a heterogeneous acceleration method, device, electronic device and storage medium to solve the problems of long calculation time and low weather forecasting efficiency of the weather forecasting system based on the atmospheric dynamic core model algorithm, shorten the calculation time of the weather forecasting system based on the atmospheric dynamic core model algorithm, and improve the weather forecasting efficiency.

[0005] According to one aspect of the present invention, a heterogeneous acceleration method is provided, comprising:

[0006] Acquire a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by programming source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model;

[0007] If it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated by the first heterogeneous parallel algorithm and the source code, the first heterogeneous parallel algorithm is converted into a second heterogeneous parallel algorithm by programming language conversion;

[0008] The second heterogeneous parallel algorithm is transplanted to the heterogeneous accelerator, and heterogeneous accelerated computing is performed on the heterogeneous accelerator on the atmospheric data to be computed.

[0009] In an embodiment of the present invention, when verifying that a first heterogeneous parallel algorithm corresponding to the source code of an atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator, the first heterogeneous parallel algorithm is converted into a second heterogeneous parallel algorithm and transplanted to the heterogeneous accelerator for calculation, thereby realizing the heterogeneous computing operation of the atmospheric dynamics core mode algorithm, shortening the calculation time of the weather forecast system of the atmospheric dynamics core mode algorithm, and improving the efficiency of weather forecast operations.

[0010] Further, the determining that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated and acquired by the first heterogeneous parallel algorithm and the source code includes:

[0011] Obtain atmospheric sample data;

[0012] Inputting the atmospheric sample data into a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet a preset accuracy requirement;

[0013] Inputting the atmospheric sample data into the source code of the atmospheric dynamics core model algorithm to obtain a second calculation result and a second calculation completion time that meet a preset accuracy requirement;

[0014] If the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold, it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator.

[0015] The embodiment of the present invention provides a method for determining whether an atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator, by comparing the source code of the atmospheric dynamics core mode algorithm and a first heterogeneous parallel algorithm obtained based on the source code encoding of the atmospheric dynamics core mode algorithm, and calculating the same atmospheric sample data and the calculation time required under the condition that the calculation results meet the accuracy requirements, to determine whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator. Determining that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator provides a basis for the program of the atmospheric dynamics core mode algorithm to run on a heterogeneous accelerator, ensuring that the program of the atmospheric dynamics core mode algorithm can be accelerated.

[0016] Furthermore, before transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator, the method further includes:

[0017] Optimizing the thread scheduling method in the second heterogeneous parallel algorithm;

[0018] And / or; optimizing the parameter definition in the second heterogeneous parallel algorithm.

[0019] The embodiments of the present invention further optimize the thread scheduling method and / or parameter definition of the second heterogeneous parallel algorithm that needs to be transplanted to the heterogeneous accelerator for running, give full play to the underlying hardware functions and high-level instruction characteristics of the heterogeneous accelerator, and further improve the calculation speed of the atmospheric dynamics core model algorithm and the operating efficiency of weather forecasting.

[0020] Furthermore, the optimizing the thread scheduling method in the second heterogeneous parallel algorithm includes:

[0021] Setting a built-in function in the second heterogeneous parallel algorithm, wherein the built-in function is used to implement data access between adjacent threads based on the underlying hardware channel of the heterogeneous accelerator;

[0022] Obtaining a variable to be accessed in the second heterogeneous parallel algorithm;

[0023] The variable to be accessed is used as an input parameter of the built-in function and input into the built-in function.

[0024] The embodiment of the present invention further optimizes the thread scheduling method of the second heterogeneous parallel algorithm that needs to be transplanted to a heterogeneous accelerator for running, so that when the second heterogeneous parallel algorithm runs on the heterogeneous accelerator, unnecessary calculations caused by cross-thread access can be reduced, thereby reducing the amount of calculation for cross-thread access of the heterogeneous accelerator.

[0025] Furthermore, the optimizing the thread scheduling method in the second heterogeneous parallel algorithm includes:

[0026] In the second heterogeneous parallel algorithm, a mapping relationship between a three-dimensional array and threads is determined.

[0027] The embodiment of the present invention further optimizes the second heterogeneous parallel algorithm that needs to be transplanted to a heterogeneous accelerator for running, simplifies the thread scheduling process of the heterogeneous accelerator, reduces the impact on the compiler, and avoids thread idle waste or thread scheduling overhead.

[0028] Further, optimizing the parameter definition in the second heterogeneous parallel algorithm includes:

[0029] In the second heterogeneous parallel algorithm, macro definitions are performed on constants defined in the first heterogeneous parallel algorithm of the atmospheric dynamics core model algorithm;

[0030] In the second heterogeneous parallel algorithm, for an array containing a subscript, a calculation method of defining the subscript of the array is adopted by using a definition keyword.

[0031] The embodiment of the present invention further optimizes the parameter definition of the second heterogeneous parallel algorithm that needs to be transplanted to the heterogeneous accelerator for running, and uses macro definitions to define constants in the first heterogeneous parallel algorithm, so that when the second heterogeneous parallel algorithm runs on the heterogeneous accelerator, the constant can be directly replaced with a numerical value without occupying precious storage resources on the heterogeneous accelerator; when using an array, a definition keyword is used to define the array subscript calculation method in advance, so that the calculation expression of the array in the second heterogeneous parallel algorithm is more readable and easy to maintain the code.

[0032] Furthermore, before transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator, the method further includes:

[0033] Furthermore, the first heterogeneous parallel algorithm is a CUDA Fortran heterogeneous parallel algorithm; and the second heterogeneous operation algorithm is a HIP C heterogeneous parallel algorithm.

[0034] The embodiment of the present invention converts the CUDA Fortran heterogeneous parallel algorithm corresponding to the source code of the atmospheric dynamics core mode algorithm into a HIP C heterogeneous parallel algorithm for the Fortran language commonly used in the atmospheric dynamics core mode algorithm, thereby providing a basis for accelerating the calculation of the atmospheric dynamics core mode algorithm on a heterogeneous accelerator.

[0035] According to another aspect of the present invention, there is provided a heterogeneous acceleration device, comprising:

[0036] An acquisition module is used to acquire a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by programming the source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model;

[0037] A language conversion module, configured to convert the programming language of the first heterogeneous parallel algorithm into a second heterogeneous parallel algorithm if it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated and acquired by the first heterogeneous parallel algorithm and the source code;

[0038] The accelerated computing module is used to transplant the second heterogeneous parallel algorithm to the heterogeneous accelerator, and perform heterogeneous accelerated computing on the atmospheric data to be calculated on the heterogeneous accelerator.

[0039] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0040] at least one processor; and

[0041] a memory communicatively connected to the at least one processor; wherein,

[0042] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the heterogeneous acceleration method described in any embodiment of the present invention.

[0043] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the heterogeneous acceleration method described in any embodiment of the present invention when executed.

[0044] The present invention provides a heterogeneous acceleration method, device, electronic device and storage medium, the method comprising: obtaining a first heterogeneous parallel algorithm of an atmospheric dynamic core mode algorithm, the first heterogeneous parallel algorithm is obtained by compiling the source code of the atmospheric dynamic core mode algorithm based on a preset heterogeneous parallel programming model; if the atmospheric sample data obtained is calculated based on the first heterogeneous parallel algorithm and the source code, it is determined that the atmospheric dynamic core mode algorithm needs to be accelerated on a heterogeneous accelerator, then the first heterogeneous parallel algorithm is converted into a programming language to obtain a second heterogeneous parallel algorithm; the second heterogeneous parallel algorithm is transplanted to the heterogeneous accelerator, and the atmospheric data to be calculated is heterogeneously accelerated on the heterogeneous accelerator. By determining that the atmospheric dynamic core mode algorithm needs to be accelerated on a heterogeneous accelerator, the atmospheric dynamic core mode algorithm is transplanted to the heterogeneous accelerator for calculation, the problem of long calculation time and low efficiency of weather forecasting operation of the algorithm-based weather forecasting system is solved, and the beneficial effect of shortening the calculation time of the weather forecasting system of the atmospheric dynamic core mode algorithm and improving the efficiency of weather forecasting operation is achieved.

[0045] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 is a flow chart of a heterogeneous acceleration method provided according to Embodiment 1 of the present invention;

[0048] Figure 2A is a flow chart of a heterogeneous acceleration method provided according to Embodiment 2 of the present invention;

[0049] Figure 2B It is a schematic diagram of a cross-thread access process provided by Embodiment 2 of the present invention.

[0050] Figure 3 is a schematic diagram of the structure of a heterogeneous acceleration device provided according to Embodiment 3 of the present invention;

[0051] Figure 4 It is a schematic diagram of the structure of an electronic device for implementing the heterogeneous acceleration method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0053] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0054] Embodiment 1

[0055] Figure 1 A flowchart of a heterogeneous acceleration method is provided for the first embodiment of the present invention. This embodiment is applicable to the case of performing heterogeneous acceleration operations on the atmospheric dynamics core mode algorithm. The method can be executed by a heterogeneous acceleration device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device. Figure 1 As shown, the method includes:

[0056] S110, obtaining a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by writing source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model.

[0057] Among them, the first heterogeneous parallel algorithm is an algorithm suitable for heterogeneous acceleration obtained by writing the source code of the atmospheric dynamics core mode algorithm based on the preset heterogeneous parallel programming model. The preset heterogeneous parallel programming model is a programming model for heterogeneous parallel algorithms, and its main function is to provide a unified writing specification for source code writing for heterogeneous parallel algorithms. In the embodiment of the present invention, the preset heterogeneous parallel programming model can be specifically determined according to the programming language used by the programming model of the atmospheric dynamics core mode algorithm, and there is no limitation on this.

[0058] The atmospheric dynamic core model algorithm is an algorithm for weather forecasting based on atmospheric data. Due to its high precision of simulation calculation and high computational scalability, it has become the core algorithm of the global prediction system. The atmospheric dynamic core model algorithm has undergone more than ten years of development and optimization. From the perspective of atmospheric science and engineering calculation, it is already very good. However, since the atmospheric dynamic core model algorithm has always used the original programming model, the original atmospheric dynamic core model algorithm focuses on the accuracy of simulation calculations and has low requirements for forecast resolution, which can meet the computing requirements on the CPU. However, with the high-precision and high-resolution requirements for the atmospheric dynamic core model algorithm, the amount of calculation of the atmospheric dynamic core model algorithm has increased rapidly, and the computing efficiency of the CPU can no longer meet the real-time requirements of weather forecasting.

[0059] Specifically, in order to solve the above problems, it is necessary to operate the atmospheric dynamics core mode algorithm on a heterogeneous accelerator. Heterogeneous accelerators are usually composed of a general-purpose processor and many domain-specific processors: the general-purpose processor CPU is used as a control device (also called a host) for complex control and scheduling; the domain-specific processor is used as a sub-device (also called MLU) for large-scale parallel computing of computing tasks in a specific domain; the computing tasks are completed through the cooperation of the host and MLU. Among them, for heterogeneous accelerators, the homogeneous parallel programming model of the source code is no longer applicable. Therefore, it is necessary to write the source code of the atmospheric dynamics core mode algorithm as the first heterogeneous parallel algorithm based on the preset heterogeneous parallel programming model to provide a basis for the operation of the atmospheric dynamics core mode algorithm on heterogeneous accelerators.

[0060] S120: If it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated and acquired by the first heterogeneous parallel algorithm and the source code, the first heterogeneous parallel algorithm is converted into a programming language to obtain a second heterogeneous parallel algorithm.

[0061] Among them, the atmospheric sample data is sample data randomly sampled from the atmospheric data used for weather forecasting based on the atmospheric dynamic core mode algorithm. The atmospheric sample data is used to determine whether the atmospheric dynamic core mode algorithm needs to be accelerated on a heterogeneous accelerator. The second heterogeneous parallel algorithm can be understood as a heterogeneous parallel algorithm written based on a heterogeneous parallel programming model adapted to a heterogeneous accelerator, and the programming language used by the second heterogeneous parallel algorithm is determined by the programming language applicable to the interface of the heterogeneous accelerator. It is understandable that different heterogeneous accelerators may be applicable to different programming languages, for example, C, C++ or Java, etc.

[0062] Specifically, the atmospheric sample data is input into the source code of the atmospheric dynamics core mode algorithm to obtain the calculation result parameter information corresponding to the source code, and the atmospheric sample data is input into the first heterogeneous parallel algorithm written based on the preset heterogeneous parallel programming model to obtain the calculation result parameter information corresponding to the first heterogeneous parallel algorithm; according to the calculation result parameter information of the two, it is determined whether the atmospheric dynamics core mode algorithm needs to be accelerated on the heterogeneous accelerator. If it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on the heterogeneous accelerator, the first heterogeneous parallel algorithm corresponding to the source code of the atmospheric dynamics core mode algorithm is converted into a programming language to obtain a second heterogeneous parallel algorithm.

[0063] Exemplarily, the calculation result parameter information includes the time to complete the calculation, and may also include the accuracy of the calculation result and the time taken for the calculation process, etc. The method for determining whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator may be: comparing the calculation parameter information of the first heterogeneous parallel algorithm with the calculation parameter information of the source code, and determining whether each calculation parameter information of the first heterogeneous parallel algorithm is better than the calculation parameter information corresponding to the source code. If so, it is determined whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator; otherwise, it is determined that the atmospheric dynamics core mode algorithm does not need to be accelerated on a heterogeneous accelerator.

[0064] Exemplarily, a method for determining whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator may also be: comparing the calculation parameter information of the first heterogeneous parallel algorithm with the calculation parameter information of the source code, and determining whether the time it takes for the first heterogeneous parallel algorithm to complete the calculation is less than the time it takes for the source code to complete the calculation when other calculation result parameter information of the first heterogeneous parallel algorithm and the source code meets the conditions, or whether the ratio of the time it takes for the first heterogeneous parallel algorithm to complete the calculation meets the preset threshold; if so, determining whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator; otherwise, determining that the atmospheric dynamics core mode algorithm does not need to be accelerated on a heterogeneous accelerator.

[0065] For example, if the programming language used by the first heterogeneous parallel algorithm is Fortran and the programming language applicable to the heterogeneous accelerator is Java, the first heterogeneous parallel algorithm written in Fortran is converted into a second heterogeneous parallel algorithm written in Java. The embodiment of the present invention does not elaborate on the specific process of converting Fortran to Java, and the conversion algorithm can be written by referring to the existing conversion program or based on the specification requirements of the two languages.

[0066] S130: transplant the second heterogeneous parallel algorithm to the heterogeneous accelerator, and perform heterogeneous accelerated computing on the atmospheric data to be computed on the heterogeneous accelerator.

[0067] The atmospheric data to be calculated are the atmospheric data that need to be calculated. The weather forecast result can be obtained by calculating the atmospheric data to be calculated through the atmospheric dynamic core model algorithm.

[0068] Specifically, after obtaining a second heterogeneous parallel algorithm suitable for heterogeneous accelerated computing, the second heterogeneous parallel algorithm is transplanted to the heterogeneous accelerator; the atmospheric data to be calculated is obtained, and the atmospheric data to be calculated is input into the second heterogeneous parallel algorithm on the heterogeneous accelerator for heterogeneous acceleration, thereby realizing the calculation of the atmospheric data to be calculated based on the atmospheric dynamics core model algorithm, and then obtaining the weather forecast result.

[0069] Optionally, the first heterogeneous parallel algorithm is a CUDA Fortran heterogeneous parallel algorithm; and the second heterogeneous operation algorithm is a HIP C heterogeneous parallel algorithm.

[0070] Among them, the CUDA Fortran heterogeneous parallel algorithm is a heterogeneous parallel algorithm written in CUDA and Fortran; CUDA is a heterogeneous parallel programming model that can use NVIDIA GPU for general computing. The HIP C heterogeneous parallel algorithm is a heterogeneous parallel algorithm written in HIP and C; HIP is a heterogeneous programming model that can run on heterogeneous accelerators such as CUDA.

[0071] The source code of FV3, the power core of the finite volume cubic sphere used in the currently popular global forecast system, is mostly written in Fortran language, while the underlying layers of commonly used heterogeneous accelerators are mostly implemented in C language. Therefore, we can transplant the heterogeneous algorithms corresponding to the source code of FV3 to most heterogeneous accelerators to achieve accelerated computing, which has a wide range of applications.

[0072] The technical solution of the embodiment of the present invention calculates the atmospheric sample data respectively through the first heterogeneous parallel algorithm and source code based on the atmospheric dynamics core mode algorithm, determines that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator, then converts the first heterogeneous parallel algorithm into a second heterogeneous parallel algorithm and transplants it to the heterogeneous accelerator, thereby realizing heterogeneous accelerated calculation of the atmospheric data to be calculated, solving the problems of long calculation time and low weather forecast operation efficiency of the weather forecast system based on the atmospheric dynamics core mode algorithm, and achieving the beneficial effects of shortening the calculation time of the weather forecast system based on the atmospheric dynamics core mode algorithm and improving the weather forecast operation efficiency.

[0073] Embodiment 2

[0074] Figure 2A This is a flow chart of a heterogeneous acceleration method provided in the second embodiment of the present invention. This embodiment further refines step S120 of the above embodiment. Figure 2A As shown, the method includes:

[0075] S210. Obtain a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by writing source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model.

[0076] S220: Acquire atmospheric sample data.

[0077] Specifically, the method for obtaining the atmospheric sample data may be to randomly extract a preset number of data from the atmospheric data obtained in the historical time as the atmospheric sample data.

[0078] S230, inputting the atmospheric sample data into a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet preset accuracy requirements.

[0079] The first calculation result is a calculation result output by the first heterogeneous parallel algorithm of the atmospheric dynamics core model algorithm, and the first calculation result needs to meet a preset accuracy requirement. The preset accuracy requirement can be set according to actual needs, and the embodiment of the present invention does not set a restriction on this. The first calculation completion time is the time required to execute the first heterogeneous parallel algorithm to obtain the first calculation result.

[0080] Specifically, the atmospheric sample data obtained by random sampling is input into the first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm, the first heterogeneous parallel algorithm is run to obtain a first calculation result that meets the preset accuracy requirements, and the first calculation completion time corresponding to the first calculation result is recorded.

[0081] S240: Input the atmospheric sample data into the source code of the atmospheric dynamics core model algorithm to obtain a second calculation result and a second calculation completion time that meet preset accuracy requirements.

[0082] Among them, the second calculation result is the calculation result of the source code output of the atmospheric dynamics core model algorithm, and the second calculation result needs to meet the preset accuracy requirements; the second calculation completion time is the time required to execute the source code to obtain the second calculation result.

[0083] Specifically, the atmospheric sample data obtained by random sampling is input into the source code of the atmospheric dynamics core model algorithm, the source code is run to obtain a second calculation result that meets the preset accuracy requirement, and the second calculation completion time corresponding to the second calculation result is recorded.

[0084] S250: If the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold, it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator.

[0085] The preset threshold refers to the minimum expected value of the acceleration calculation degree, and the preset threshold can be determined according to actual needs or based on experience, and the embodiment of the present invention does not limit this. It should also be noted that the second calculation result and the first calculation result meet the same preset accuracy requirements.

[0086] In the embodiment of the present invention, under the condition that the accuracy of the calculation results is the same, by comparing the completion calculation time of the source code of the atmospheric dynamics core mode algorithm and the first heterogeneous parallel algorithm, it is determined whether the first heterogeneous parallel algorithm has achieved accelerated calculation relative to the source code, or more precisely, whether the degree of accelerated calculation has reached expectations. If the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold, it means that the degree of accelerated calculation of the first heterogeneous parallel algorithm has reached expectations; if the ratio is less than the preset threshold, it means that the degree of accelerated calculation of the first heterogeneous parallel algorithm has not reached expectations.

[0087] Furthermore, if the degree of accelerated computing of the first heterogeneous parallel algorithm does not meet expectations, it means that the accelerated computing of the aerodynamic core mode algorithm on a heterogeneous accelerator cannot significantly improve the computing efficiency, and it is not necessary to calculate on a heterogeneous accelerator. If the degree of accelerated computing of the first heterogeneous parallel algorithm meets expectations, it means that the accelerated computing of the aerodynamic core mode algorithm on a heterogeneous accelerator can significantly improve the computing efficiency, and it is necessary to calculate on a heterogeneous accelerator. However, since the programming language of the first heterogeneous parallel algorithm is inconsistent with that of the heterogeneous accelerator, the first heterogeneous parallel algorithm cannot be directly transplanted to the heterogeneous accelerator at this time, and the programming language of the first heterogeneous parallel algorithm needs to be converted.

[0088] S260: Convert the first heterogeneous parallel algorithm into a programming language to obtain a second heterogeneous parallel algorithm.

[0089] S270: Optimize the thread scheduling method in the second heterogeneous parallel algorithm.

[0090] Specifically, in order to achieve higher computing efficiency of the atmospheric dynamics core mode algorithm on heterogeneous accelerators, the thread scheduling method of the atmospheric dynamics core mode algorithm can be further optimized, so that when the atmospheric dynamics core mode algorithm is run on heterogeneous accelerators, the computational complexity can be reduced and less computing resources can be occupied.

[0091] In an optional embodiment, step S270 includes:

[0092] Setting a built-in function in the second heterogeneous parallel algorithm, wherein the built-in function is used to implement data access between adjacent threads based on the underlying hardware channel of the heterogeneous accelerator;

[0093] Obtaining a variable to be accessed in the second heterogeneous parallel algorithm;

[0094] The variable to be accessed is used as an input parameter of the built-in function and input into the built-in function.

[0095] Heterogeneous accelerators are generally equipped with vector general purpose registers (VGPRs), which have the hardware advantage of extremely low access latency. Hot data in the algorithm is usually stored in vector registers in order to take advantage of the hardware advantages of vector registers, increase the speed of variable access, and thus increase the calculation speed. However, the capacity of vector registers is generally very small, and the variables accessed by each thread are independent and private, which makes it impossible for compiler tools to communicate data across threads. In the second heterogeneous parallel algorithm corresponding to the atmospheric dynamics core mode algorithm, there is often a need to access the data of adjacent threads. Therefore, in the vector register, each thread needs to calculate the data of adjacent threads again to complete the correct calculation. This undoubtedly increases the number of VGPR accesses and also increases the amount of calculation.

[0096] In order to solve the above problem, an embodiment of the present invention implements cross-thread data access in the second heterogeneous parallel algorithm corresponding to the atmospheric dynamics core mode algorithm.

[0097] In a heterogeneous accelerator, there is a hardware channel on the vector arithmetic logic unit (VALU) for assuming the actual computing function, which can read the data of the VGPR corresponding to the adjacent VALU. However, the compiler of the heterogeneous accelerator cannot automatically enable the cross-thread access function through the compiler front end and programming specifications. Therefore, in an embodiment of the present invention, the hardware channel and the built-in function supported by the compiler are used to implement data access between adjacent threads. The specific method is: a built-in function is set in the second heterogeneous parallel algorithm, and the built-in function can encapsulate the data access function between adjacent threads in the function based on the hardware channel at the bottom of the heterogeneous accelerator, for example, a thread is set to read data from the next adjacent thread, or read data from the previous adjacent thread. Then, the variable to be accessed in the second heterogeneous parallel algorithm is obtained; the variable to be accessed can be understood as a variable that needs to be accessed across threads. The variable to be accessed is input into the built-in function as an input parameter of the built-in function. Therefore, when the atmospheric power core mode algorithm is calculated on the heterogeneous accelerator, the data stored in the vector register corresponding to the adjacent thread can be accessed across threads by calling the built-in function. Therefore, when the second heterogeneous parallel algorithm runs on a heterogeneous accelerator, it can directly access the fast thread, reduce unnecessary calculations caused by cross-thread access, and reduce the amount of calculation for cross-thread access of the heterogeneous accelerator.

[0098] For example, Figure 2B FIG. 1 is a schematic diagram of a cross-thread access process provided by Embodiment 2 of the present invention. Figure 2B As shown, each thread can access the data stored in the vector register corresponding to the adjacent thread, and perform corresponding logical calculations on the data read from the adjacent thread and the data read by its own thread.

[0099] In another optional embodiment, step S270 includes:

[0100] In the second heterogeneous parallel algorithm, a mapping function between a multidimensional array and threads is set.

[0101] When reading or calculating the multidimensional array in the second heterogeneous parallel algorithm, a corresponding number of threads are required, but each thread is essentially independent, so when the compiler compiles, it is necessary to perform thread scheduling based on a preset thread scheduling strategy, which will inevitably have a certain impact on the compilation speed of the compiler. Therefore, the embodiment of the present invention advances the work of thread scheduling from the compiler to the second heterogeneous parallel algorithm, reduces the impact on the compiler, and avoids idle thread waste or thread scheduling overhead. The specific method is to set a mapping function between the multidimensional array and the thread in the second heterogeneous parallel algorithm, and encapsulate the mapping relationship between each dimension in the multidimensional array and the thread in the function. When the second heterogeneous parallel algorithm runs on a heterogeneous accelerator, it can directly access the mapping function call corresponding to the thread, without the need for the compiler to perform scheduling allocation, reducing the impact on the compiler.

[0102] For example, after testing, the optimized thread scheduling method provided by this solution has a maximum speed-up of 26% and an average speed-up of 16.15% for the calculation of kernel functions of three-dimensional arrays compared to the traditional compiler-based thread scheduling method, with a significant performance improvement effect.

[0103] S280: transplant the second heterogeneous parallel algorithm to the heterogeneous accelerator, and perform heterogeneous accelerated computing on the atmospheric data to be computed on the heterogeneous accelerator.

[0104] The technical solution of the embodiment of the present invention determines that the atmospheric dynamics core mode algorithm needs to be accelerated on an accelerator by comparing the source code of the atmospheric dynamics core mode algorithm and the calculation completion time of the first heterogeneous parallel algorithm for calculating atmospheric sample data at the same precision, and converts the first heterogeneous parallel algorithm into a second heterogeneous parallel algorithm and then transplants it to the accelerator, thereby realizing heterogeneous accelerated calculation of the atmospheric dynamics core mode algorithm and optimizing the thread scheduling method in the second heterogeneous parallel algorithm, further shortening the calculation time of the weather forecast system of the atmospheric dynamics core mode algorithm and improving the efficiency of weather forecast operations.

[0105] Optionally, step S270 may be replaced by step S271, or step S271 may be performed after step S270 to optimize the parameter definition in the second heterogeneous parallel algorithm. Step S271 specifically includes:

[0106] In the second heterogeneous parallel algorithm, macro definitions are performed on constants defined in the first heterogeneous parallel algorithm of the atmospheric dynamics core model algorithm;

[0107] In the second heterogeneous parallel algorithm, for an array containing a subscript, a calculation method of defining the subscript of the array is adopted by using a definition keyword.

[0108] Specifically, the computing resources of vector registers are very valuable. Once the computing resources of vector registers are full, the data stored in the vector registers will be forced to overflow to the global memory, which will not give full play to the hardware advantage of the extremely low latency of vector register access. And for each additional variable used in the kernel function, the actual computing resources occupied by the on-chip storage are the product of the variable size and the number of all computing units currently involved in the calculation. Therefore, for the constants defined in the first heterogeneous parallel algorithm, macro definitions are used to replace them, so that the numerical values ​​can be directly replaced during program pre-compilation without occupying on-chip storage resources.

[0109] In addition, since it is generally more complicated to express multidimensional arrays in the programming language corresponding to heterogeneous accelerators, it is also possible to use definition keywords to define the calculation method of the subscripts of arrays containing subscripts, so that the calculation method of the array in the program remains unchanged, but the readability is enhanced, and the calculation efficiency will not be reduced.

[0110] For example, for pf(i,j,k)=ptop!

[0111] pf[(i-isd)+(j-jsd)*(ied-isd+1)+(1-1)*\(ied-isd+1)*(jed-jsd+1)]=ptop; / / 3D array before definition

[0112] #define pf(i,j,k)(*(pf+(i-isd)+(j-jsd)*(ied-isd+1)+(k-1)*(ied-isd+1)))pf(i,j,k)=ptop; / / Three-dimensional array after definition

[0113] #undef pf

[0114] In a specific embodiment, a heterogeneous acceleration method for an atmospheric dynamics core mode algorithm specifically includes: (1) obtaining a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by writing the source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model; wherein the first heterogeneous parallel algorithm is a CUDA Fortran heterogeneous parallel algorithm. (2) obtaining atmospheric sample data; inputting the atmospheric sample data into the first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet the preset accuracy requirements; inputting the atmospheric sample data into the source code of the atmospheric dynamics core mode algorithm to obtain a second calculation result and a second calculation completion time that meet the preset accuracy requirements; if the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold, it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator. (3) converting the first heterogeneous parallel algorithm into a programming language to obtain a second heterogeneous parallel algorithm, wherein the second heterogeneous operation algorithm is a HIP C heterogeneous parallel algorithm. (4) In the second heterogeneous parallel algorithm, a built-in function is set, and the built-in function is used to implement data access between adjacent threads based on the hardware channel at the bottom layer of the heterogeneous accelerator; obtain the variable to be accessed in the second heterogeneous parallel algorithm; and input the variable to be accessed as an input parameter of the built-in function. (5) In the second heterogeneous parallel algorithm, a mapping function between a multidimensional array and a thread is set. (6) In the second heterogeneous parallel algorithm, a macro definition is performed for the constants defined in the first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm. (7) In the second heterogeneous parallel algorithm, for an array containing a subscript, a calculation method of defining the subscript of the array is defined by using a definition keyword.

[0115] Embodiment 3

[0116] Figure 3 This is a schematic diagram of the structure of a heterogeneous acceleration device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device comprises:

[0117] An acquisition module 310 is used to acquire a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, where the first heterogeneous parallel algorithm is obtained by programming the source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model;

[0118] A language conversion module 320 is used for, if it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated and acquired by the first heterogeneous parallel algorithm and the source code, then performing programming language conversion on the first heterogeneous parallel algorithm to obtain a second heterogeneous parallel algorithm;

[0119] The accelerated computing module 330 is used to transplant the second heterogeneous parallel algorithm to the heterogeneous accelerator, and perform heterogeneous accelerated computing on the atmospheric data to be calculated on the heterogeneous accelerator.

[0120] Optionally, the language conversion module 320 includes:

[0121] A data acquisition unit, used for acquiring atmospheric sample data;

[0122] A first calculation unit, used for inputting the atmospheric sample data into a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet a preset accuracy requirement;

[0123] A second calculation unit, used for inputting the atmospheric sample data into the source code of the atmospheric dynamics core model algorithm to obtain a second calculation result and a second calculation completion time that meet a preset accuracy requirement;

[0124] A determination unit is used to determine that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator if the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold.

[0125] Optionally, also include:

[0126] A thread scheduling optimization module, used for optimizing the thread scheduling mode in the second heterogeneous parallel algorithm before transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator;

[0127] and / or,

[0128] A parameter definition optimization module is used to optimize the parameter definition in the second heterogeneous parallel algorithm.

[0129] Optionally, the thread scheduling optimization module is specifically used to:

[0130] Setting a built-in function in the second heterogeneous parallel algorithm, wherein the built-in function is used to implement data access between adjacent threads based on the underlying hardware channel of the heterogeneous accelerator;

[0131] Obtaining a variable to be accessed in the second heterogeneous parallel algorithm;

[0132] The variable to be accessed is used as an input parameter of the built-in function and input into the built-in function.

[0133] Optionally, the thread scheduling optimization module is specifically used to:

[0134] In the second heterogeneous parallel algorithm, a mapping function between a multidimensional array and threads is set.

[0135] Optionally, the parameter definition optimization module is specifically used for:

[0136] In the second heterogeneous parallel algorithm, macro definitions are performed on constants defined in the first heterogeneous parallel algorithm of the atmospheric dynamics core model algorithm;

[0137] In the second heterogeneous parallel algorithm, for an array containing a subscript, a calculation method of defining the subscript of the array is adopted by using a definition keyword.

[0138] Optionally, the first heterogeneous parallel algorithm is a CUDA Fortran heterogeneous parallel algorithm; and the second heterogeneous operation algorithm is a HIP C heterogeneous parallel algorithm.

[0139] The heterogeneous acceleration device provided in the embodiment of the present invention can execute the heterogeneous acceleration method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0140] Embodiment 4

[0141] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other required computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0142] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0143] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0144] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 performs the various methods and processes described above, such as heterogeneous acceleration methods. The heterogeneous acceleration method provided by the present invention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18 of the electronic device 10. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the heterogeneous acceleration method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the heterogeneous acceleration method in any other appropriate manner (e.g., by means of firmware).

[0145] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0146] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0147] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0148] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0149] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0150] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0151] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0152] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A heterogeneous acceleration method, characterized in that: include: Acquire a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by programming source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model; If it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated by the first heterogeneous parallel algorithm and the source code, the first heterogeneous parallel algorithm is converted into a second heterogeneous parallel algorithm by programming language conversion; transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator, and performing heterogeneous accelerated computing on the atmospheric data to be computed on the heterogeneous accelerator; The determining that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the atmospheric sample data respectively calculated and acquired by the first heterogeneous parallel algorithm and the source code comprises: Obtain atmospheric sample data; Inputting the atmospheric sample data into a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet a preset accuracy requirement; Inputting the atmospheric sample data into the source code of the atmospheric dynamics core model algorithm to obtain a second calculation result and a second calculation completion time that meet a preset accuracy requirement; If the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold, it is determined that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator.

2. The method according to claim 1, characterized in that Before transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator, the method further includes: Optimizing the thread scheduling method in the second heterogeneous parallel algorithm; And / or; optimizing the parameter definition in the second heterogeneous parallel algorithm.

3. The method according to claim 2, characterized in that The optimizing the thread scheduling method in the second heterogeneous parallel algorithm includes: Setting a built-in function in the second heterogeneous parallel algorithm, wherein the built-in function is used to implement data access between adjacent threads based on the underlying hardware channel of the heterogeneous accelerator; Obtaining a variable to be accessed in the second heterogeneous parallel algorithm; The variable to be accessed is used as an input parameter of the built-in function and input into the built-in function.

4. The method according to claim 2, characterized in that: The optimizing the thread scheduling method in the second heterogeneous parallel algorithm includes: In the second heterogeneous parallel algorithm, a mapping function between a multidimensional array and threads is set.

5. The method according to claim 2, characterized in that: Optimizing the parameter definition in the second heterogeneous parallel algorithm includes: In the second heterogeneous parallel algorithm, macro definitions are performed on constants defined in the first heterogeneous parallel algorithm of the atmospheric dynamics core model algorithm; In the second heterogeneous parallel algorithm, for an array containing a subscript, a calculation method of defining the subscript of the array is adopted by using a definition keyword.

6. The method according to claim 1, characterized in that The first heterogeneous parallel algorithm is a CUDA Fortran heterogeneous parallel algorithm; and the second heterogeneous operation algorithm is a HIP C heterogeneous parallel algorithm.

7. A heterogeneous acceleration device, characterized in that: include: An acquisition module is used to acquire a first heterogeneous parallel algorithm of an atmospheric dynamics core mode algorithm, wherein the first heterogeneous parallel algorithm is obtained by programming the source code of the atmospheric dynamics core mode algorithm based on a preset heterogeneous parallel programming model; A determination module, configured to determine whether the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator based on the first heterogeneous parallel algorithm and the source code to calculate the atmospheric sample data; a language conversion module, configured to, if yes, convert the first heterogeneous parallel algorithm into a programming language to obtain a second heterogeneous parallel algorithm; An accelerated computing module, used for transplanting the second heterogeneous parallel algorithm to the heterogeneous accelerator, and performing heterogeneous accelerated computing on the atmospheric data to be calculated on the heterogeneous accelerator; The language conversion module comprises: A data acquisition unit, used for acquiring atmospheric sample data; A first calculation unit, used for inputting the atmospheric sample data into a first heterogeneous parallel algorithm of the atmospheric dynamics core mode algorithm to obtain a first calculation result and a first calculation completion time that meet a preset accuracy requirement; A second calculation unit, used for inputting the atmospheric sample data into the source code of the atmospheric dynamics core model algorithm to obtain a second calculation result and a second calculation completion time that meet a preset accuracy requirement; A determination unit is used to determine that the atmospheric dynamics core mode algorithm needs to be accelerated on a heterogeneous accelerator if the ratio of the first calculation completion time to the second calculation completion time is greater than or equal to a preset threshold.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the heterogeneous acceleration method described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the heterogeneous acceleration method described in any one of claims 1 to 6 when executed.

Citation Information

Patent Citations

  • Method for quickly developing heterogeneous parallel program

    CN104035781A

  • PM2.5 prediction model based on multi-source heterogeneous data fusion

    CN111598156A