Function file adjustment method, device, computer equipment and storage medium
By migrating and adjusting cyclic variables in the meteorological numerical mode, increasing the cyclic level, and using multiple parallel threads to execute, the problem that GPUs are difficult to run the meteorological numerical mode with high performance in traditional methods is solved, and efficient meteorological data processing and results are achieved. consistency.
Patent Information
- Application Number
- CN202010765978.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-03
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2040-08-03
AI Technical Summary
Traditional methods are difficult to ensure that the GPU runs weather numerical modes with high performance and cannot effectively utilize the computing performance of the GPU.
By obtaining the identification of the target loop variable, migrating to the main function file of the subfunction file, increasing the loop level, and executing the target main function file through multiple parallel threads, ensuring that the GPU processes weather data with high performance.
The GPU is able to efficiently process meteorological data, improve the calculation performance of meteorological numerical mode, and ensure the accuracy and consistency of processing results.
Smart Images

Figure CN111949336B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of high performance computing technology, and in particular to a method, device, computer equipment and storage medium for adjusting a function file. Background Art
[0002] At present, a simple multi-core CPU (Central Processing Unit) can no longer meet the requirements of high-performance computing for processor computing performance. Therefore, the world's leading supercomputers are equipped with a large number of GPU (Graphics Processing Unit) accelerators or multi-core processors for parallel acceleration to meet the requirements of high-performance computing for processor computing performance. The meteorological numerical model is a code written based on the CPU parallel architecture. In order to improve the meteorological numerical model's ability to predict weather and adapt it to the high computing performance of the GPU, the meteorological numerical model needs to be transplanted from the CPU to the GPU.
[0003] In traditional technology, meteorological numerical models are mainly transplanted from CPU to GPU through OpenACC (Open Accelerators). OpenACC adds some simple compiler directive statements in the code to enable the compiler to identify codes that can be calculated in parallel and run these codes in parallel on the GPU.
[0004] However, the traditional meteorological numerical model transplantation method cannot ensure the high performance of the GPU to run the meteorological numerical model. Summary of the invention
[0005] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for adjusting the function files of the meteorological numerical model to ensure high performance of the GPU in response to the above technical problems.
[0006] A method for adjusting a function file, the method comprising:
[0007] Obtaining an adjustment instruction; wherein the adjustment instruction includes an identifier of a target loop variable;
[0008] According to the identifier, the target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0009] The target main function file is executed through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data.
[0010] In one embodiment, after migrating the target loop variable to the main function file corresponding to the sub-function file, the method further includes:
[0011] The transfer variables of the target main function file are adjusted according to the variables in the target main function file and the number of the variables; the transfer variables are the variables transferred to the target sub-function file when the target main function file calls the target sub-function file.
[0012] In one embodiment, adjusting the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables includes:
[0013] According to the variables included in the target main function file and the number of the variables, the variable dimension transferred from the target main function file to the target sub-function file is adjusted to obtain the target variable dimension;
[0014] According to the target variable dimension, the variable name of the transfer variable is adjusted to obtain the target variable name.
[0015] In one embodiment, the method further comprises:
[0016] Perform consistency verification on the original function file and the target function file; the original function file includes the main function file and the sub-function file, the target function file includes the target main function file and the target sub-function file, and the target sub-function file is a file obtained after migrating the target loop variable in the sub-function file;
[0017] If the verification passes, it is determined that the objective function file is valid.
[0018] In one of the embodiments, if the verification fails, the step of adjusting the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables is re-executed.
[0019] In one embodiment, the consistency verification of the original function file and the target function file includes:
[0020] Running the objective function file to obtain a first running result;
[0021] Run the original function file to obtain a second running result;
[0022] If the first operation result and the second operation result are the same, the consistency check passes.
[0023] In one of the embodiments, the original function file is a WSM6 function file in the Weather Research Forecast Model WRF numerical model.
[0024] A device for adjusting a function file, the device comprising:
[0025] An acquisition module, used for acquiring an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable;
[0026] A first adjustment module is used to determine the target loop variable in the sub-function file according to the identifier, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0027] The execution module is used to execute the target main function file through multiple parallel threads to process the meteorological data and obtain the processing result of the main function file on the meteorological data.
[0028] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0029] Obtaining an adjustment instruction; wherein the adjustment instruction includes an identifier of a target loop variable;
[0030] According to the identifier, the target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0031] The target main function file is executed through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data.
[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0033] Obtaining an adjustment instruction; wherein the adjustment instruction includes an identifier of a target loop variable;
[0034] According to the identifier, the target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0035] The target main function file is executed through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data.
[0036] The above-mentioned function file adjustment method, device, computer equipment and storage medium obtain an adjustment instruction including the identification of the target loop variable. According to the identification of the target loop variable, the target loop variable can be determined in the sub-function file, and the target loop variable can be migrated to the main function file corresponding to the sub-function file to obtain the target main function file. In this way, the loop level of the main function file can be increased, and the target main function file can be executed by multiple parallel threads, ensuring that the GPU can process the meteorological data with high performance, thereby efficiently obtaining the processing results of the meteorological data. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of the internal structure of a computer device provided by an embodiment;
[0038] Figure 2 A schematic diagram of a flow chart of a method for adjusting a function file in an embodiment;
[0039] Figure 3 A schematic flow chart of a method for adjusting a function file in another embodiment;
[0040] Figure 4 A schematic diagram of a flow chart of a method for adjusting a function file in an embodiment;
[0041] Figure 5 The figure is a structural block diagram of a device for adjusting a function file in an embodiment. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0043] The function file adjustment method provided in the embodiment of the present application can be applied to Figure 1The computer device shown. The computer device includes a processor and a memory connected by a system bus, and a computer program is stored in the memory. When the processor executes the computer program, the steps of the following method embodiment can be executed. Optionally, the computer device may also include a network interface, a display screen and an input device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory, and the non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. Optionally, the computer device can be a server, a personal computer, a personal digital assistant, or other terminal devices, such as a tablet computer, a mobile phone, etc., or a cloud or remote server. The embodiment of the present application does not limit the specific form of the computer device.
[0044] In one embodiment, Figure 2 As shown, a method for adjusting a function file is provided, which is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:
[0045] S201, obtaining an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable.
[0046] Specifically, the computer device obtains an adjustment instruction, wherein the adjustment instruction includes an identifier of the target loop variable. Optionally, the adjustment instruction may be an instruction input by a user through the computer device. Optionally, the adjustment instruction may be a preset code file.
[0047] S202, according to the identifier, determine the target loop variable in the sub-function file, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed.
[0048] Specifically, the computer device determines the target loop variable in the sub-function file according to the identifier of the target loop variable included in the adjustment instruction, and migrates the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file; wherein, the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed. It can be understood that after the target loop variable determined in the sub-function file is migrated to the main function file corresponding to the sub-function file, the sub-function file after the migration of the target loop variable will be called when the main function file is executed. Exemplarily, taking the sub-function file including three loop variables and the main function file including one loop variable as an example, the computer device determines the target loop variable in the sub-function file, and migrates the target loop variable to the main function file corresponding to the sub-function file, the sub-function file will include two loop variables, and the main function file will include two loop variables. Exemplarily, the target main function file and the target sub-function file are taken as WSM6 function files in the WRF numerical mode. In order to be applicable to GPU fine-grained parallelism, the loop in the wsm6() function file needs to be modified after adding the above compiler directive statement. The main loop structure example in the modified wsm6() function file is as follows:
[0049]
[0050]
[0051] Modify the loop structure in the wsm61D() function file to:
[0052]
[0053] The wsm61D() function file is a modified function of the wsm62D() function file. If an OpenACC compiler directive statement similar to the following is added to the wsm6() function, the (jte-jts+1)×(ite-its+1) loops will be assigned to several threads for simultaneous calculation, improving the efficiency of parallelism, that is, satisfying the fine-grained parallelism of the GPU. Further, an example of an OpenACC compiler directive statement is as follows:
[0054]
[0055] S203, executing the target main function file through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data.
[0056] Specifically, the computer device executes the target main function file obtained above through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data. It can be understood that when the computer device executes the target main function file through multiple parallel threads, the multiple parallel threads will call the adjusted sub-function file to process the meteorological data and obtain the processing result of the meteorological data.
[0057] In the above-mentioned function file adjustment method, the computer device obtains an adjustment instruction including the identification of the target loop variable, and according to the identification of the target loop variable, can determine the target loop variable in the sub-function file, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file. In this way, the loop level of the main function file can be increased, and then the target main function file can be executed through multiple parallel threads, ensuring that the GPU can process the meteorological data with high performance, thereby efficiently obtaining the processing results of the meteorological data.
[0058] In the above scenario of migrating the target loop variable to the main function file corresponding to the sub-function file, it is necessary to adjust the transfer variable of the target main function file. In one embodiment, after migrating the target loop variable to the main function file corresponding to the sub-function file, the above method further includes: adjusting the transfer variable of the target main function file according to the variables in the target main function file and the number of variables; the transfer variable is the variable passed to the target sub-function file when the target main function file calls the target sub-function file.
[0059] Specifically, the computer device adjusts the transfer variables of the target main function file according to the variables in the target main function file obtained above and the number of the variables, wherein the transfer variables of the target main function file are the variables transferred to the target sub-function file when the target main function file calls the target sub-function file. Optionally, the computer device can adjust the variable dimension transferred from the target main function file to the target sub-function file according to the variables included in the target main function file and the number of the variables to obtain the target variable dimension; according to the target variable dimension, adjust the variable name of the transfer variable of the target main function file to obtain the target variable name. Exemplarily, we continue to use the WSM6 function file in the WRF numerical mode as an example to explain that in the wsm6() function file, the loop is changed from a single layer to a double layer of nesting, and the loop in the called sub-function file is changed from a double layer of nesting to a single layer. Therefore, the variables passed to the sub-function file and the interface of the sub-function file and the sub-function file need to be modified accordingly: Since it is necessary to keep a certain variable calculated by each thread independent of each other during parallel computing, that is, the variable is private to the thread, the two-dimensional variable passed to the sub-function file wsm62D() in the loop of the wsm6() function file needs to be redefined as a three-dimensional variable, that is, REAL,DIMENSION(its:ite,kts:kte)::t is redefined as: REAL,DIMENSION(its:ite,kts:kte,jts:jte)::t, and the other three-dimensional variables When passing it to the sub-function file wsm62D(), instead of keeping only j unchanged, i and j are kept unchanged, such as q(its:ite,kts:kte,j) is changed to q(i,kts:kte,j); the sub-function file name is changed from wsm62D() to wsm61D() (the wsm61D name here is customized, and the 1D in the file name means that only one dimension is looped, in order to distinguish it from wsm62D). The number of parameters and parameter names of the function file are the same as those of the wsm62D() function. Similarly, in the wsm61D() function file, the original two-dimensional variables need to be redefined as one-dimensional variables, that is, REAL,DIMENSION(its:ite,kts:kte)::t is redefined as REAL,DIMENSION(kts:kte)::t, and then in the wsm61D() function file, all the original loops for i and k are changed to loops only for k.
[0060] In this embodiment, the computer device migrates the target loop variable to the main function file corresponding to the sub-function file, and can accurately adjust the transfer variables of the target main function file according to the variables and the number of variables in the target main function file, thereby enabling the computer device to accurately run the target main function file and the sub-function file.
[0061] In the scenario where the computer device migrates the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file, the computer device will perform consistency verification on the obtained target main function file. Based on the above embodiment, Figure 3 As shown, the above method also includes:
[0062] S301, verify the consistency of the original function file and the target function file; the original function file includes a main function file and a sub-function file, and the target function file includes a target main function file and a target sub-function file. The target sub-function file is a file obtained after migrating the target loop variable in the sub-function file.
[0063] Specifically, the computer device performs consistency verification on the obtained target function file and the original function file corresponding to the target function file. The original function file includes the above-mentioned main function file and the above-mentioned sub-function file, and the target function file includes the target main function file and the target sub-function file. The target sub-function file is a file obtained after migrating the target loop variable in the above-mentioned sub-function file. Optionally, the computer device can run the above-mentioned target function file by calling a preset main program to obtain a first running result, and call the preset main program to run the above-mentioned original function file to obtain a second running result. If the first running result and the second running result are the same, the consistency check of the target function file and the original function file corresponding to the target function file is passed.
[0064] S302: If the verification is successful, it is determined that the target function file is valid.
[0065] Specifically, if the computer device passes the consistency check of the target function file and the original function file corresponding to the target function file, the computer device determines that the target function file obtained above is valid. Optionally, if the computer device fails the consistency check of the target function file and the original function file corresponding to the target function file, the computer device re-executes the above step of adjusting the transfer variables of the target main function file according to the variables and the number of variables in the target main function file.
[0066] In this embodiment, the computer device performs consistency verification on the target function file obtained above and the original function file corresponding to the target function file. If the consistency verification passes, it can ensure that the running result of the target function file is consistent with the running result of the original function file, thereby ensuring the accuracy of the target function file. If the consistency verification fails, the step of adjusting the transfer variables of the target main function file according to the variables and the number of variables in the target main function file is re-executed to further ensure the accuracy of the target function file.
[0067] In the above scenario of verifying the consistency of the original function file and the target function file, based on the above embodiment, as an optional implementation method, the original function file is a WSM6 function file in the numerical mode of the Weather Research Forecast Model WRF.
[0068] Specifically, the original function file is the WSM6 function file in the WRF numerical model. It should be noted that the WRF numerical model is mainly written in Fortran language, and the physical processes exist in the form of sub-functions in the Fortran language. As one of the physical processes of WRF, the WSM6 function file is stored in the module_mp_wsm6.F file under the WRF code subdirectory phys, corresponding to the wsm6() function file therein, and the spatial distribution of meteorological variables generally exists in a three-dimensional form, including the longitude (i.e., the east-west direction), latitude (i.e., the north-south direction) in the horizontal direction, and the height in the vertical direction. The WRF numerical model divides the calculated spatial area into a three-dimensional grid. For the meteorological variables at a certain grid point, its representation is similar to q(i,k,j), where i represents the index in the east-west direction, j represents the index in the north-south direction, and k represents the index of the altitude layer. q(i,k,j) represents the humidity at the location of a certain grid point, and the wsm6() function file will perform a loop calculation on all grid points. Currently, there is only a single-layer loop based on j in the wsm6() function file. Another sub-function wsm62D() function file is called in the loop. The wsm62D() function file then loops on i and k to complete the calculation of three dimensions. The main loop structure example in the wsm6() function file is as follows:
[0069]
[0070] Where jts and jte are the lower and upper bounds of the north-south index.
[0071] The loop structure in the wsm62D() function file is as follows:
[0072]
[0073] Among them, kts and kte are the lower and upper limits of the vertical index, and its and ite are the lower and upper limits of the east-west index. Usually, the range of the vertical index is much smaller than the range of the east-west and north-south indexes. In other words, the number of loops for k is much smaller than the number of loops for i or j.
[0074] It should be noted that, usually, to move the loop for j to GPU parallelism in the wsm6() function file, you need to add an OpenACC compiler directive statement similar to the following that starts with !$acc:
[0075]
[0076]
[0077] In this way, the wsm6() function file will assign the jte-jts+1 loop to several threads for simultaneous calculation.
[0078] In this embodiment, the original function file is the WSM6 function file in the numerical mode of the weather research forecast model WRF. The loop hierarchy in the WSM6 function file can be reorganized to transform the main calculation process from a single-layer loop to a two-layer nested loop, which is convenient for using OpenACC for fine-grained parallelism and ensures high-performance computing of the WSM6 function file.
[0079] In order to facilitate the understanding of those skilled in the art, the following is a detailed introduction to the adjustment method of the function file provided by the present application. Figure 4 As shown, the method may include:
[0080] S401, obtaining an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable.
[0081] S402, according to the identifier, determine the target loop variable in the sub-function file, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed.
[0082] S403, adjusting the variable dimension transferred from the target main function file to the target sub-function file according to the variables and the number of variables included in the target main function file to obtain the target variable dimension.
[0083] S404: Adjust the variable name of the transferred variable according to the target variable dimension to obtain the target variable name.
[0084] S405, run the target function file to obtain a first running result; run the original function file to obtain a second running result; if the first running result and the second running result are the same, then the original function file and the target function file are verified for consistency to determine that the target function file is valid; the original function file includes a main function file and a sub-function file, and the target function file includes a target main function file and a target sub-function file, and the target sub-function file is a file obtained after migrating the target loop variable in the sub-function file.
[0085] S406: If the verification fails, re-execute the step of adjusting the transfer variables of the target main function file according to the variables and the number of variables in the target main function file.
[0086] S407, executing the target main function file through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data.
[0087] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-3 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0088] In one embodiment, Figure 5 As shown, a function file adjustment device is provided, comprising: an acquisition module, a first adjustment module and an execution module, wherein:
[0089] An acquisition module is used to acquire an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable;
[0090] The first adjustment module is used to determine the target loop variable in the sub-function file according to the identifier, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain the target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process the meteorological data, and the sub-function file is called when the main function file is executed;
[0091] The execution module is used to execute the target main function file through multiple parallel threads to process the meteorological data and obtain the processing result of the main function file on the meteorological data.
[0092] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0093] Based on the above embodiment, optionally, the above device further includes: a second adjustment module, wherein:
[0094] The second adjustment module is used to adjust the transfer variables of the target main function file according to the variables and the number of variables in the target main function file; the transfer variables are variables transferred to the target sub-function file when the target main function file calls the target sub-function file.
[0095] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0096] Based on the above embodiment, optionally, the above second adjustment module includes: a first adjustment unit and a second adjustment unit, wherein:
[0097] The first adjustment unit is used to adjust the variable dimension transferred from the target main function file to the target sub-function file according to the variables and the number of variables included in the target main function file to obtain the target variable dimension.
[0098] The second adjustment unit is used to adjust the variable name of the transferred variable according to the target variable dimension to obtain the target variable name.
[0099] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0100] Based on the above embodiment, optionally, the above device further includes a verification module and a determination module, wherein:
[0101] The verification module is used to verify the consistency of the original function file and the target function file; the original function file includes a main function file and a sub-function file, and the target function file includes a target main function file and a target sub-function file. The target sub-function file is the file obtained after migrating the target loop variable in the sub-function file.
[0102] The determination module is used to determine whether the target function file is valid if the verification passes.
[0103] Optionally, the original function file is a WSM6 function file in the Weather Research Forecast Model WRF numerical model.
[0104] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0105] Based on the above embodiment, optionally, the above device further includes a third adjustment module, wherein:
[0106] The third adjustment module is used for re-executing the step of adjusting the transfer variables of the target main function file according to the variables and the number of variables in the target main function file if the verification fails.
[0107] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0108] Based on the above embodiment, optionally, the verification module includes: a first operation unit, a second operation unit and a verification unit, wherein:
[0109] The first running unit is used to run the target function file to obtain a first running result.
[0110] The second running unit is used to run the original function file to obtain a second running result.
[0111] The verification unit is used to verify that the consistency check passes if the first operation result and the second operation result are the same.
[0112] The function file adjustment device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0113] For the specific definition of the function file adjustment device, please refer to the definition of the function file adjustment method above, which will not be repeated here. Each module in the above function file adjustment device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0114] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0115] Obtaining an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable;
[0116] According to the identifier, a target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0117] The target main function file is executed through multiple parallel threads to process the meteorological data and obtain the processing results of the meteorological data.
[0118] The implementation principle and technical effect of the computer device provided in the above embodiment are similar to those of the above method embodiment, and will not be repeated here.
[0119] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0120] Obtaining an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable;
[0121] According to the identifier, a target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed;
[0122] The target main function file is executed through multiple parallel threads to process the meteorological data and obtain the processing results of the meteorological data.
[0123] The computer-readable storage medium provided in the above embodiment has similar implementation principles and technical effects as those of the above method embodiment, and will not be described in detail here.
[0124] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0125] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0126] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for adjusting a function file, characterized in that: The method comprises: Obtaining an adjustment instruction; wherein the adjustment instruction includes an identifier of a target loop variable; According to the identifier, the target loop variable is determined in the sub-function file, and the target loop variable is migrated to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed; Executing the target main function file through multiple parallel threads to process the meteorological data and obtain the processing result of the meteorological data; After migrating the target loop variable to the main function file corresponding to the sub-function file, the method further includes: According to the variables in the target main function file and the number of the variables, the transfer variables of the target main function file are adjusted; the transfer variables are variables passed to the target sub-function file when the target main function file calls the target sub-function file; the target sub-function file is a file obtained after the target loop variables in the sub-function file are migrated; The step of adjusting the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables comprises: According to the variables included in the target main function file and the number of the variables, the variable dimension transferred from the target main function file to the target sub-function file is adjusted to obtain the target variable dimension; According to the target variable dimension, the variable name of the transferred variable is adjusted to obtain the target variable name.
2. The method according to claim 1, characterized in that The method further comprises: Performing consistency verification on the original function file and the target function file; the original function file includes the main function file and the sub-function file, and the target function file includes the target main function file and the target sub-function file; If the verification passes, it is determined that the objective function file is valid.
3. The method according to claim 2, characterized in that If the verification fails, the step of adjusting the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables is re-executed.
4. The method according to claim 2 or 3, characterized in that: The consistency verification of the original function file and the target function file includes: Running the objective function file to obtain a first running result; Run the original function file to obtain a second running result; If the first operation result and the second operation result are the same, the consistency verification passes.
5. The method according to claim 4, characterized in that The original function file is the WSM6 function file in the Weather Research Forecast Model WRF numerical model.
6. A function file adjustment device, characterized in that: The device comprises: An acquisition module, used for acquiring an adjustment instruction; the adjustment instruction includes an identifier of a target loop variable; A first adjustment module is used to determine the target loop variable in the sub-function file according to the identifier, and migrate the target loop variable to the main function file corresponding to the sub-function file to obtain a target main function file; wherein the sub-function file includes at least two loop variables; the main function file and the sub-function file are both used to process meteorological data, and the sub-function file is called when the main function file is executed; An execution module, used for executing the target main function file through multiple parallel threads, processing the meteorological data, and obtaining a processing result of the main function file on the meteorological data; A second adjustment module is used to adjust the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables; the transfer variables are variables transferred to the target sub-function file when the target main function file calls the target sub-function file; the target sub-function file is a file obtained after the target loop variables in the sub-function file are migrated; Wherein, the second adjustment module includes: A first adjustment unit, configured to adjust the variable dimension transferred from the target main function file to the target sub-function file according to the variables included in the target main function file and the number of the variables, so as to obtain a target variable dimension; The second adjustment unit is used to adjust the variable name of the transferred variable according to the target variable dimension to obtain the target variable name.
7. The device according to claim 6, characterized in that The device also includes: A verification module, used for performing consistency verification on an original function file and a target function file; the original function file includes the main function file and the sub-function file, and the target function file includes the target main function file and the target sub-function file; A determination module is used to determine that the target function file is valid if the verification passes.
8. The device according to claim 7, characterized in that The device also includes: The third adjustment module is used for re-executing the step of adjusting the transfer variables of the target main function file according to the variables in the target main function file and the number of the variables if the verification fails.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
