Ocean model parallel computing method and system

By initializing the ocean model data on the CPU and transmitting it to the GPU, and combining OpenACC technology for loop reconstruction and parallel computing, the memory allocation and CUDA-C programming problems in parallel computing of ocean models are solved, and efficient parallel computing and simplified Program maintenance.

CN119201478AInactive Publication Date: 2024-12-27SHANDONG UNIV OF SCI & TECH

Patent Information

Application Number
CN202411718269.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing parallel computing methods of marine models have memory allocation problems, which makes it impossible to run on one or two processors, and it is difficult to program CUDA-C code, which makes it difficult to transplant and maintain, affecting computing efficiency.

Method used

The ocean model data is initialized by the CPU and transmitted to the GPU, and parallel computing is used for GPU, and circular reconstruction and data dependency analysis are used for OpenACC technology, parallel computing strategies are optimized, communication frequency between CPU and GPU, and high parallel processing capabilities are used for GPU Perform parallel calculations.

Benefits of technology

It significantly improves the computing speed of marine models and the ability to process large-scale data sets, reduces the data transmission burden, simplifies program maintenance, and improves the acceleration effect of parallel computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201478A_ABST
    Figure CN119201478A_ABST
Patent Text Reader

Abstract

The invention provides an ocean model parallel computing method and system, and relates to the technical field of ocean scientific computing. The ocean model parallel computing method comprises the steps that input data of an ocean model are initialized through a CPU, initial ocean parameters are obtained, and the initial ocean parameters are transmitted to a GPU from the CPU; processing the circulation region of the ocean model according to the initial ocean parameters through the GPU to obtain a processed circulation region; and carrying out parallel calculation on the processed circulation area in the internal and external modes of the ocean model according to the initial ocean parameters to obtain a calculation result of the initial ocean parameters, and transmitting the calculation result to the CPU from the GPU. The high parallel processing capacity of the GPU is utilized, the calculation speed and the large-scale data set processing capacity of the model are remarkably improved, acceleration of ocean model parallel calculation is achieved, and the acceleration effect of ocean model parallel calculation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of ocean science computing technology, and in particular to an ocean model parallel computing method and system. Background Art

[0002] At present, with the development of marine economy, accurate prediction of marine environment is becoming increasingly important. Therefore, it is usually necessary to rewrite POM through Princeton Ocean Model (POM) based on message passing interface or through CUDA-C code to achieve parallel computing of POM.

[0003] In the prior art, the method of performing parallel computing through the message passing interface cannot be run on one or two processors due to memory allocation reasons, resulting in certain limitations in POM parallel computing; at the same time, since the programming of CUDA-C code is relatively difficult, rewriting POM through CUDA-C code will make the porting of POM parallel computing difficult and difficult to maintain. Summary of the invention

[0004] The problem solved by the present invention is how to improve the acceleration effect of parallel computing of ocean models.

[0005] In order to solve the above problems, the present invention provides an ocean model parallel computing method and system.

[0006] In a first aspect, the present invention provides an ocean model parallel computing method, comprising: Initializing input data of the ocean model through the CPU to obtain initial ocean parameters, and transmitting the initial ocean parameters from the CPU to the GPU; Processing the circulation area of ​​the ocean model according to the initial ocean parameters by the GPU to obtain a processed circulation area; The processed circulation area is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model to obtain calculation results of the initial ocean parameters, and the calculation results are transmitted from the GPU to the CPU.

[0007] Optionally, the initializing the input data of the ocean model by the CPU to obtain initial ocean parameters, and transmitting the initial ocean parameters from the CPU to the GPU includes: The CPU performs formatting and unit conversion processing on the input data to obtain input data in the same format as the input of the ocean model as the initial ocean parameters; The initial ocean parameters are transmitted from the CPU to the GPU according to the data memory allocation space of the GPU.

[0008] Optionally, the ocean model parallel computing method further includes: Determine whether there is uninitialized data memory allocation space in the memory space of the GPU; If the memory space of the GPU contains the uninitialized data memory allocation space, the input data is initialized on the GPU by controlling the create instruction of OpenACC to obtain initial ocean parameters, and the initialized initial ocean parameters are allocated to the data memory allocation space of the GPU; If the memory space of the GPU does not have the uninitialized data memory allocation space, the input data of the ocean model is initialized by the CPU to obtain initial ocean parameters, and the initial ocean parameters are transmitted from the CPU to the GPU.

[0009] Optionally, the transmitting the initial ocean parameters from the CPU to the GPU comprises: If the memory space of the GPU does not have the uninitialized data memory allocation space, the initialized initial ocean parameters are stored from the memory space of the CPU to the video memory space of the GPU through the copy instruction of OpenACC.

[0010] Optionally, the processing the circulation area of ​​the ocean model according to the initial ocean parameters to obtain the processed circulation area includes: Analyze each of the circulation areas through the code of the initial ocean parameters to obtain data dependency between each of the circulation areas; The loop region is reconstructed according to the data dependency to obtain the processed loop region.

[0011] Optionally, the analyzing each of the circulation areas by the code of the initial ocean parameters to obtain the data dependency between each of the circulation areas comprises: By coding the initial ocean parameters, determining whether each of the circulation areas has the same parameters as other circulation areas; If yes, determining that the loop region has the data dependency with the other loop regions; If not, it is determined that the loop region and the other loop regions do not have the data dependency.

[0012] Optionally, reconstructing the loop region according to the data dependency to obtain the processed loop region includes: Moving the outermost vertical circulation of the circulation area to the innermost layer of the circulation area; Determine the number of nested loop levels of the loop region through the collapse sub-statement; The loop sequence of the loop region is adjusted according to the number of nested loop layers to obtain the processed loop region.

[0013] Optionally, the circulation area after the processing is calculated in parallel according to the initial ocean parameters in the internal and external modes of the ocean model to obtain the calculation results of the initial ocean parameters, including: Adding parallel instructions in the loop region corresponding to the internal and external modes in the ocean model, wherein the internal mode and the external mode of the ocean model correspond to one loop region respectively; The parallel instructions are used to control all the circulation areas of the internal and external modes to perform calculations simultaneously, so as to obtain the calculation results of the initial ocean parameters.

[0014] Optionally, the calculation result is transmitted from the GPU to the CPU; Screening the calculation results to obtain output data required by the CPU; The output data is copied from the memory space of the GPU to the memory space of the CPU through an output instruction.

[0015] In a second aspect, the present invention provides an ocean model parallel computing system, comprising: A data processing unit, configured to initialize input data of an ocean model through a CPU to obtain initial ocean parameters, and transmit the initial ocean parameters from the CPU to a GPU; A circulation conversion unit, configured to process the circulation region of the ocean model according to the initial ocean parameters through the GPU to obtain a processed circulation region; A parallel processing unit is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model through the processed circulation area to obtain calculation results of the initial ocean parameters, and transmit the calculation results from the GPU to the CPU.

[0016] The ocean model parallel computing method and system of the present invention reduces the communication frequency between the CPU and the GPU by initializing the input data of the ocean model on the CPU and directly transmitting it to the GPU, thereby accelerating the startup and operation of the model. Then, the parallel computing capability is used on the GPU to process the loop area of ​​the ocean model according to the initial parameters, for example, loop reconstruction and data dependency analysis are used to ensure that the loop area can be efficiently executed in parallel while maintaining the consistency and accuracy of the data. Finally, the processed loop area is used to perform parallel calculations in the internal and external modes of the ocean model according to the initial ocean parameters, and the calculation process is accelerated through a sophisticated parallel strategy and an optimized data access mode, and the calculation results are synchronized to the CPU for subsequent analysis or storage. The present invention is responsible for initializing data and the final output data through the CPU, and the GPU is responsible for loop reconstruction and parallel computing strategies, and the entire program is transplanted to the GPU. All parallel loops are parallelized through the GPU, and the high parallel processing capability of the GPU is used to significantly improve the calculation speed of the model and the ability to process large-scale data sets, thereby realizing the acceleration of the parallel computing of the ocean model and improving the acceleration effect of the parallel computing of the ocean model. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flow chart of a method for parallel computing of an ocean model according to an embodiment of the present invention; Figure 2 A flow chart of the operation of the ocean model according to an embodiment of the present invention; Figure 3 A comparison diagram of the parallel acceleration effect of the ocean model of an embodiment of the present invention at different simulation running times; Figure 4 A comparison diagram of the parallel acceleration effect of the ocean model of an embodiment of the present invention at different horizontal resolutions; Figure 5 4 is a structural block diagram of an ocean model parallel computing system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0019] It should be noted that in the prior art, OpenACC technology (OpenACC: Open Accelerators) is an API for simplifying parallel programming, allowing developers to use simple instructions to guide the compiler to automatically parallelize the code for execution in heterogeneous computing environments (such as CPUs and GPUs). OpenACC is a high-level parallel programming model designed for heterogeneous systems, used to add parallelism to Fortran, C, and C++ programming languages. OpenACC is portable across platforms and different types of GPUs. In addition, OpenACC can work with a variety of compilers and requires less programming work, which makes it possible to add parallelism to existing code with less code, thereby reducing the workload of programmers and increasing their productivity, and it is also easier to maintain.

[0020] The programming model of OpenACC is based on programmers embedding hints on how to parallelize the code in their serial programs. In this way, the compiler can handle most of the complex details of translation without adding burden to application scientists or programmers. This allows scientists to focus on the knowledge of their field rather than the complex details of the target architecture. The way OpenACC parallelizes is not to rewrite the entire program like CUDA, but to add compilation tags to the serial C / C++ or Frotran code. Compilers that support OpenACC can understand these tags and compile the specified code area into a parallel program according to the instructions of the tags. The CPU and GPU have their own memory space. The main function of OpenACC is to unload arrays from the CPU to the GPU, so that large-scale scientific calculations can be performed on the GPU. These large-scale scientific calculations are usually loops, so as to achieve the purpose of acceleration; OpenACC instructions are divided into instructions in the computing area and data area. The former is used to execute code on the GPU, which is mostly a computing-intensive area, and the latter is responsible for data transmission between the CPU and the GPU.

[0021] Among the existing technical solutions for parallel acceleration of POM, one is a parallel version of POM based on the message passing interface (MPI). Due to memory allocation reasons, the problem size of the test case is too large to run on one or two processors. The simulation is run between 4 and 2048 processors, which increases the limitations of using POM. The second is a parallel version of POM programmed in CUDA-C. The POM ocean model written in Fortran is rewritten in CUDA-C. Although it can have a good acceleration ratio, CUDA-C code programming is relatively difficult. For programmers who are accustomed to using Fortran and want to do the transplantation as soon as possible, it is not easy to maintain and it is also difficult to transplant. Therefore, how to improve the acceleration effect of parallel computing of ocean models has become a technical problem that needs to be solved in this field.

[0022] Based on this, combined Figure 1 As shown, the present invention provides an ocean model parallel computing method, comprising: The input data of the ocean model is initialized by the CPU to obtain initial ocean parameters, and the initial ocean parameters are transmitted from the CPU to the GPU.

[0023] Specifically, the CPU is used to initialize the model’s input data to obtain initial ocean parameters, which includes data preparation and preprocessing stages, such as setting initial parameters such as ocean temperature, salinity, and flow rate. These initial parameters are transferred from the CPU to the GPU through memory copy operations, achieving efficient data migration and ensuring that parallel computing can obtain the required input data in a timely manner.

[0024] The circulation area of ​​the ocean model is processed according to the initial ocean parameters by the GPU to obtain a processed circulation area.

[0025] Specifically, the initial ocean parameters transmitted to the GPU are used to perform loop reconstruction processing on the loop area of ​​the ocean model, and the GPU will perform parallel calculations and iteratively process each loop area. In a preferred embodiment of the present invention, by using parallel programming models such as OpenACC, these calculations can be parallelized on the GPU, thereby significantly improving the computing efficiency. In addition, for loops with data dependencies, such as vertical layer data dependencies, it is necessary to reconstruct the loop to ensure the order of data dependencies, for example, by moving the outermost vertical layer loop to the innermost layer and using the collapse(2) instruction for parallel processing.

[0026] The processed circulation area is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model to obtain calculation results of the initial ocean parameters, and the calculation results are transmitted from the GPU to the CPU.

[0027] Specifically, after obtaining the processed circulation areas, these areas are used to perform parallel calculations on the internal and external modes in the ocean model according to the initial ocean parameters; this step is the core of the entire parallel computing method, and parallel computing is performed on the GPU to increase the computing speed; in general, the external mode usually involves large-scale flows, while the internal mode focuses on small-scale processes; at the same time, parallel computing requires careful management to ensure that the calculation of the internal and external modes can be completed efficiently and accurately. By performing these calculations in parallel on the GPU, the time required for simulation can be greatly reduced while maintaining the accuracy of the results; after the calculation is completed, the !$acc update host instruction is used to transfer the results from the GPU back to the CPU for further analysis or storage. This step ensures that the calculation results can be fed back to the CPU in a timely manner, completing the entire parallel computing process; further reducing the burden of data transmission, which helps to improve the overall computing performance.

[0028] It should be noted that, under normal circumstances, the GPU cannot directly access the CPU memory. The CPU data is stored in the main memory, while the GPU data is stored in the video memory. Therefore, there are two data transmission processes between the CPU and the GPU, one from the CPU initialization data to the start of GPU acceleration and the other from the end of GPU acceleration to the CPU output data.

[0029] The ocean model parallel computing method of the present invention reduces the communication frequency between the CPU and the GPU by initializing the input data of the ocean model on the CPU and directly transmitting it to the GPU, thereby accelerating the startup and operation of the model. Then, the parallel computing capability is used on the GPU to process the loop area of ​​the ocean model according to the initial parameters, for example, by loop reconstruction and data dependency analysis, it is ensured that the loop area can be efficiently executed in parallel while maintaining the consistency and accuracy of the data. Finally, the processed loop area is used to perform parallel computing in the internal and external modes of the ocean model according to the initial ocean parameters, and the computing process is accelerated by a sophisticated parallel strategy and an optimized data access mode, and the computing results are synchronized to the CPU for subsequent analysis or storage. The present invention is responsible for initializing data and the final output data through the CPU, and the GPU is responsible for loop reconstruction and parallel computing strategies, and the entire program is transplanted to the GPU. All parallelizable loops are parallelized through the GPU, and the high parallel processing capability of the GPU is used to significantly improve the computing speed of the model and the ability to process large-scale data sets, thereby realizing the acceleration of the parallel computing of the ocean model and improving the acceleration effect of the parallel computing of the ocean model.

[0030] Optionally, the initializing the input data of the ocean model by the CPU to obtain initial ocean parameters, and transmitting the initial ocean parameters from the CPU to the GPU includes: The CPU performs formatting and unit conversion processing on the input data to obtain input data in the same format as the input of the ocean model as the initial ocean parameters; The initial ocean parameters are transmitted from the CPU to the GPU according to the data memory allocation space of the GPU.

[0031] Specifically, the preparation of initial ocean parameters is to format and convert the input data on the CPU to ensure that the data is consistent with the input format of the ocean model, which may include reading the original ocean observation data or the data output by the previous model, and then performing necessary preprocessing, such as interpolation, time averaging or spatial averaging, and converting the data to the units required by the model, such as converting the temperature from Celsius to Kelvin, to ensure that the model can receive input data in the correct format and unit, so that the initial state of the ocean can be accurately simulated. After the initialization processing is completed, the formatted and unit-converted initial ocean parameters are transferred from the CPU to the GPU memory through OpenACC instructions, such as "!$acc data copyin(var-list)", to prepare for subsequent parallel computing.

[0032] In this optional embodiment, by formatting and converting the data on the CPU, the consistency and accuracy of the data can be ensured, which is crucial to the reliability of the model and the accuracy of the prediction. Secondly, by transferring the data to the GPU, the high parallel processing capability of the GPU can be utilized to significantly improve the calculation speed of the model and the ability to process large-scale data sets. In addition, it also helps to reduce the time and bandwidth requirements for data transmission between the CPU and GPU, thereby improving the overall computing efficiency.

[0033] Optionally, the ocean model parallel computing method further includes: Determine whether there is uninitialized data memory allocation space in the memory space of the GPU; If the memory space of the GPU contains the uninitialized data memory allocation space, the input data is initialized on the GPU by controlling the create instruction of OpenACC to obtain initial ocean parameters, and the initialized initial ocean parameters are allocated to the data memory allocation space of the GPU; If the memory space of the GPU does not have the uninitialized data memory allocation space, the input data of the ocean model is initialized by the CPU to obtain initial ocean parameters, and the initial ocean parameters are transmitted from the CPU to the GPU.

[0034] Specifically, in the prior art, the CPU and GPU have their own memory space. When the compiler encounters a parallel directive, it will copy the array required in the parallel area from the CPU to the GPU. When leaving the area, the array will be copied from the GPU to the CPU. Such data transfer in each cycle will greatly increase the running time; most of these data transfers are repeated and useless, and reducing data transfer is the key to improving the running speed. In addition to initializing data on the GPU, it is also necessary to transfer the ocean parameters that have been initialized on the CPU to the GPU, which involves checking whether the GPU memory space already has corresponding data memory allocation space. If there is no uninitialized data space in the GPU memory, then the initial ocean parameters are directly transferred from the CPU to the GPU. Among them, if there is no uninitialized data memory allocation space in the GPU memory space, it means that all necessary data structures have been pre-allocated and initialized in the GPU memory. In this case, improving the acceleration effect of parallel computing of the ocean model can be achieved through the following steps: First, initialize the input data of the ocean model on the CPU to obtain the initial ocean parameters; then, use the copyin instruction of OpenACC to transfer these initialized initial ocean parameters directly from the CPU memory to the GPU memory; this ensures the availability of data on the GPU and avoids additional initialization steps on the GPU, thereby reducing the time overhead of the data preparation stage. In this way, the computing tasks can be quickly transferred from the CPU to the GPU, so that parallel computing can start as early as possible, thereby improving the overall computing efficiency and acceleration effect.

[0035] Therefore, in this embodiment, it is necessary to determine whether space has been allocated for the input data in the GPU memory space. If space has not been allocated for these data in the GPU memory, the create instruction of OpenACC will be used to initialize and allocate space for these data on the GPU to ensure that there is enough memory space on the GPU to store the initial ocean parameters required by the model, such as temperature, salinity, and flow rate.

[0036] In a preferred embodiment of the present invention, the OpenACC instruction !$acc create can be used to allocate space for a three-dimensional array and initialize each element in the array, for example, to initialize the array to a specific temperature value, and then the data is used for subsequent parallel computing; this process not only ensures the availability of data on the GPU, but also allows further data operations to be performed directly on the GPU, such as calculating and updating the ocean state, thereby preparing for parallel processing. If there is no uninitialized data memory allocation space in the GPU's memory space, the need for repeated data initialization on the GPU is avoided by transferring the initial ocean parameters from the CPU to the GPU, thereby saving computing resources and time, allowing flexible processing of data preprocessed on the CPU, and minimizing the dependency between data transmission and parallel computing.

[0037] In a preferred embodiment of the present invention, memory space is allocated on the GPU for arrays that have not yet been initialized and will be initialized in a modal loop, and a default (present) sub-statement is added after the parallel directive, which assumes that the arrays required by the parallel region already exist in the memory of the current GPU and does not require additional data transfer.

[0038] In this optional embodiment, by using the create instruction on the GPU to initialize data, the number of data transmissions between the CPU and the GPU can be reduced. Since the initialization and storage of data are completed on the GPU, not only the delay in data transmission is reduced, but also the burden on the CPU is reduced, allowing memory space to be dynamically allocated and released on the GPU as needed, thereby better adapting to simulation needs of different scales.

[0039] Optionally, the transmitting the initial ocean parameters from the CPU to the GPU comprises: If the memory space of the GPU does not have the uninitialized data memory allocation space, the initialized initial ocean parameters are stored from the memory space of the CPU to the video memory space of the GPU through the copy instruction of OpenACC.

[0040] Specifically, when there is no uninitialized data memory allocation space in the memory space of the GPU, the initialized initial ocean parameters are stored from the memory space of the CPU to the video memory space of the GPU through the copy instruction of OpenACC. For example, if these parameters have been given specific initial values on the CPU, then the data is transferred to the GPU through the instruction "!$acc datacopyin(temperature(:), salinity(:), velocity(:))" to prepare for parallel computing, ensuring that the GPU has all the data required to execute the calculation and can start processing immediately, thus eliminating the need to initialize the data again on the GPU.

[0041] In this optional embodiment, the efficiency of memory management is improved through the copy instruction of OpenACC because the data initialized on the CPU can be directly used without the need to reallocate and initialize memory on the GPU.

[0042] Optionally, processing the loop regions of the ocean model according to the initial ocean parameters to obtain the processed loop regions includes: Analyzing each of the loop regions through the code of the initial ocean parameters to obtain the data dependencies between each of the loop regions; Reconstructing the loop regions according to the data dependencies to obtain the processed loop regions.

[0043] Specifically, analyzing each loop region through the code of the initial ocean parameters aims to identify and understand the data dependencies between these loop regions. These data dependencies usually involve physical processes in the ocean model, such as hydrodynamic equations and thermodynamic exchanges. Data dependency means that there is a data dependency relationship between two operations. For example, to calculate the values of array elements a[0] to a[N], if the value of a[j] (j < i) is required when calculating a[i], then it is said that there is a data dependency between a[i] and a[j]. Data independence means that there is no data dependency between two operations. For example, a loop may calculate the sea surface temperature at the next time step, and this calculation depends on the temperature and flow velocity at the current time step. Once the data dependencies are identified, the next task is to reconstruct the loop regions according to these dependencies to ensure that they can be executed in parallel on the GPU safely and efficiently. This involves changing the order of the loops, or merging or splitting certain loop iterations, and introducing new variables to temporarily store intermediate results.

[0044] Therefore, in a preferred embodiment of the present invention, two nested loops can be parallelized by using the collapse clause of OpenACC, while keeping the third loop (which may involve data dependencies at the vertical level) serial to maintain the order of data dependencies. This reconstruction ensures that in parallel computing, each computing step can obtain the necessary input data before it is needed, thereby avoiding data competition and errors.

[0045] In the preferred embodiment of the present invention, the loop region parallelization in the ocean model needs to add the "!$acc parallel loop / !$acc end parallel" lead in the loop region. Some loops in the ocean model mode have data dependencies. At this time, the loop region with data dependencies needs to be analyzed and appropriate sub-statements are added after the lead to avoid forced parallelism and outputting erroneous results. Figure 2 As shown, the initialization parameters are performed on the CPU to set the initial parameters required for the ocean model. The internal mode calculation part specifically includes: "do 9000" is the beginning of the internal mode calculation, which represents the cyclic process. The advection and horizontal diffusion of U, V: calculate the horizontal flow and advection diffusion process in the ocean; the baroclinic terms of U, V: deal with the terms related to pressure, update U, V: update the values ​​of the velocity field U and V; the boundary operation of the seawater continuity equation: calculate the boundary conditions related to the continuity of seawater; the boundary operation of the turbulence equation: deal with the boundary conditions of the turbulence equation; the boundary operation of the tracer transport equation (T, S): calculate the boundary conditions of the tracer (such as temperature T and salinity S). The external modal calculation part specifically includes: "do 8000" is the beginning of the external modal calculation, sea surface height: calculate the fluctuation or height change of the sea surface; vertical integral equation: perform integral calculation in the vertical direction; UT, VT are used for internal modal boundary operation: the calculation results of the external mode are used to update the boundary conditions of the internal mode; "8000": indicates the end of the external modal calculation; output results: after completing the calculation of the internal and external modes, the results are transferred from the GPU back to the CPU for output. Among them, "9000" and "8000" have no specific meaning, but are just labels used for loops in the Fortran77 language. The numbers used in the source code are "9000" and "8000". The entire flowchart is a parallel calculation process, in which the CPU is responsible for initialization and result output, while the GPU is responsible for performing computationally intensive internal and external modal calculations. In this way, the parallel processing capabilities of the GPU are used to accelerate the calculation process of the ocean model.

[0046] In this optional embodiment, by carefully analyzing and reconstructing the loop regions, the parallelism of the ocean model on the GPU can be maximized, thereby significantly reducing the total time required for simulation. Secondly, this embodiment ensures the accuracy of parallel computing because by maintaining the order of data dependencies, erroneous results due to data competition or inconsistency are avoided.

[0047] Optionally, the analyzing each of the circulation areas by the code of the initial ocean parameters to obtain the data dependency between each of the circulation areas comprises: By coding the initial ocean parameters, determining whether each of the circulation areas has the same parameters as other circulation areas; If yes, determining that the loop region has the data dependency with the other loop regions; If not, it is determined that the loop region and the other loop regions do not have the data dependency.

[0048] Specifically, in the parallel processing of the ocean model, in order to ensure the correctness of parallel computing, it is necessary to analyze the loop area in the code to identify data dependencies, which first involves reviewing each loop area in the code to determine whether there are parameters shared with other loop areas. For example, an ocean model may contain multiple loops that handle different physical processes, and these loops may access and modify the same three-dimensional data array. When the calculation result of one loop area is used as input by another loop area, this indicates that there is data dependency between them; if it is found through analysis that the two loop areas do not share any parameters, then it can be determined that there is no data dependency between them, so they can be executed independently and in parallel on the GPU.

[0049] In this optional embodiment, by determining whether data dependency exists, it helps to optimize the performance of parallel computing, reduce unnecessary data synchronization and conflicts, and ensure the accuracy of the calculation results. In this way, the ocean model can more efficiently utilize the parallel processing capabilities of the GPU, accelerate the simulation process, and maintain the correct representation of the physical process.

[0050] Optionally, reconstructing the loop region according to the data dependency to obtain the processed loop region includes: Moving the outermost vertical circulation of the circulation area to the innermost layer of the circulation area; Determine the number of nested loop levels of the loop region through the collapse sub-statement; The loop sequence of the loop region is adjusted according to the number of nested loop layers to obtain the processed loop region.

[0051] Specifically, the data dependencies in the ocean model pattern all occur at the vertical level, so the outermost vertical loop of the loop region is moved to the innermost layer, thereby reducing the restrictions of data dependencies on parallel execution. For example, the loop region of the ocean model may include horizontal grid loops and vertical layer loops, where the vertical layer loop depends on the calculation results of the previous layer; by moving the vertical layer loop to the innermost layer, it can be ensured that all dependent lower layer data have been calculated before calculating the current layer; next, the collapse substatement in OpenACC is used to determine the number of nested loop layers in the loop region, and the compiler treats multiple nested loops as a single parallel loop, thereby further improving the degree of parallelism.

[0052] For example, the collapse(2) instruction can merge two layers of nested loops and execute the outer loop in parallel, while keeping the inner loop (now a vertical layer loop) executed serially to maintain the order of data dependencies. The reconstruction strategy of this embodiment not only optimizes the memory access pattern, but also reduces unnecessary data synchronization and transmission, making parallel computing more efficient.

[0053] In a preferred embodiment of the present invention, for loops with data dependence, the outermost vertical layer loop k is transplanted to the innermost layer and parallelized using the !$acc parallel loop collapse(2) statement. The collapse(N) sub-statement is used to specify the number of layers of tightly nested loops associated with the parallel directive. When N=2, only the first two loops in the triple loop are parallelized, and the vertical layer is still calculated serially to ensure the correctness of the output results.

[0054] In this optional embodiment, the data-dependent loop is moved to the inner layer for execution, ensuring the correctness and consistency of data in parallel computing and avoiding errors caused by data competition. Secondly, the outer loop is parallelized using the collapse clause, making full use of the large-scale parallel processing capabilities of the GPU and reducing computing time.

[0055] Optionally, the circulation area after the processing is calculated in parallel according to the initial ocean parameters in the internal and external modes of the ocean model to obtain the calculation results of the initial ocean parameters, including: Adding parallel instructions in the loop region corresponding to the internal and external modes in the ocean model, wherein the internal mode and the external mode of the ocean model correspond to one loop region respectively; The parallel instructions are used to control all the circulation areas of the internal and external modes to perform calculations simultaneously, so as to obtain the calculation results of the initial ocean parameters.

[0056] Specifically, loop regions related to the internal and external modes are identified in the code, and OpenACC parallel instructions are added before these regions, such as the "!$acc parallel loop" instruction, to instruct the compiler that these loops should be executed in parallel on the GPU. In this way, multiple GPU threads can be activated at the same time to process these loops in parallel, thereby significantly speeding up the calculation. At the same time, the internal mode and external mode of the ocean model each correspond to a loop region. By adding OpenACC parallel instructions in these loop regions, simultaneous parallel calculations of the loop regions of these two modes can be achieved; the parallelization strategy of this embodiment enables the calculation of the internal mode and the external mode to be executed in parallel instead of serial waiting, thereby significantly reducing the overall calculation time, so that the calculation results of the initial ocean data can be obtained faster, because all loop regions are processed simultaneously on the GPU, making full use of the multi-core characteristics of the GPU to accelerate the simulation and prediction of the ocean model.

[0057] In a preferred embodiment of the present invention, parallel instructions are added so that complex calculations involving temperature, salinity and flow rate are executed in parallel on the GPU, and each thread processes a subset of the data, thereby fully utilizing the parallel processing capability of the GPU.

[0058] In this optional embodiment, by adding parallel instructions in the loop regions corresponding to the internal and external modes, the model can utilize the massively parallel architecture of the GPU, thereby significantly reducing the time required to complete complex ocean simulations.

[0059] Optionally, the calculation result is transmitted from the GPU to the CPU; Screening the calculation results to obtain output data required by the CPU; The output data is copied from the memory space of the GPU to the memory space of the CPU through an output instruction.

[0060] Specifically, after the calculation on the GPU is completed, the calculation results must be transferred back to the CPU for further processing or output. For example, a specific data transfer instruction, such as the "!$acc copyout" instruction of OpenACC, can be used to synchronize the calculation results of the GPU back to the CPU memory.

[0061] In a preferred embodiment of the present invention, after the parallel region is executed, the "!$acc end data" instruction is used to mark the end of the data transmission, and then the array data named resultArray is transferred from the GPU back to the CPU through "!$acc copyout", ensuring that the CPU can access the latest ocean model calculation results. After the data transmission, these results need to be screened to extract information that is useful for further analysis or decision support, such as identifying abnormal climate signals or environmental changes in specific areas.

[0062] In this optional embodiment, by transferring the calculation results from the GPU back to the CPU, the timely availability of the calculation results and the consistency of the data are ensured; the screening process further ensures that only relevant and meaningful data are retained and analyzed, thereby improving the efficiency and accuracy of data processing.

[0063] In an optional embodiment of the present invention, in combination with Figure 2 As shown in the figure, first, the initialization parameters are set on the CPU, and then these initial parameters are transferred from the CPU to the GPU through the MemcpyHostToDevice operation. On the GPU, the model performs multiple loops and calculation steps, including advection and horizontal diffusion of U and V components, calculation of baroclinic terms, update of sea surface height, processing of external and internal modes, and calculation of seawater continuity equation, vertical integral equation, turbulence equation, tracer transport equation and momentum equation. Finally, after the calculation is completed, the results are transferred from the GPU back to the CPU through the MemcpyDeviceToHost operation for final output and analysis.

[0064] For example, in Table 1, the simulation run time represents the duration of the ocean model simulation, and the table lists four different simulation durations: 10, 20, 30, and 60; where the unit is: day. The horizontal resolution represents the horizontal resolution of the ocean model. The speedup ratio represents the speed improvement of parallel operation relative to serial operation. As can be seen from Table 1, as the simulation run time increases, the speedup ratio also increases, which indicates that parallel computing can provide higher performance improvements when processing longer simulation times. This is because in longer simulation times, the parallel processing capabilities of the GPU are more fully utilized, thereby reducing the overall computing time. While keeping the resolution at 650×490, increasing the simulation time (i.e., simulation run time), the parallel acceleration effect of the ocean model at different simulation run times is compared. Figure 3 As shown in Table 1.

[0065] Table 1 Comparison of the parallel acceleration effects of the ocean model at different simulation run times

[0066] For example, when the simulation duration is kept at 0.025 days, the resolution is increased, and the comparison of the parallel acceleration effect of the ocean model at different horizontal resolutions is as follows: Figure 4 As shown in Table 2, the duration of ocean model simulation is 0.025 days. The table lists the horizontal resolutions of four different ocean models: 650×490, 1300×980, 1950×1470, and 2600×1960. As the resolution increases, the model can simulate the physical processes of the ocean more finely. The speedup ratio increases with the increase in resolution, which shows that the advantages of GPU parallel computing are more obvious at higher resolutions. As can be seen from Table 2, as the model resolution increases, the speedup ratio increases significantly, especially at the highest resolution of 2600×1960, the speedup ratio reaches 44.37. This shows that when processing higher resolution ocean models, the use of parallel computing can significantly improve computational efficiency.

[0067] Table 2 Comparison of parallel acceleration effects of ocean models at different horizontal resolutions

[0068] Combination Figure 5 As shown, the present invention also provides an ocean model parallel computing system, comprising: A data processing unit, configured to initialize input data of an ocean model through a CPU to obtain initial ocean parameters, and transmit the initial ocean parameters from the CPU to a GPU; A circulation conversion unit, configured to process the circulation region of the ocean model according to the initial ocean parameters through the GPU to obtain a processed circulation region; A parallel processing unit is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model through the processed circulation area to obtain calculation results of the initial ocean parameters, and transmit the calculation results from the GPU to the CPU.

[0069] The ocean model parallel computing system of the present invention reduces the communication frequency between the CPU and the GPU by initializing the input data of the ocean model on the CPU and directly transmitting it to the GPU, thereby accelerating the startup and operation of the model. Then, the parallel computing capability is used on the GPU to process the loop area of ​​the ocean model according to the initial parameters, for example, by loop reconstruction and data dependency analysis, it is ensured that the loop area can be efficiently executed in parallel while maintaining the consistency and accuracy of the data. Finally, the processed loop area is used to perform parallel calculations in the internal and external modes of the ocean model according to the initial ocean parameters, and the calculation process is accelerated through a sophisticated parallel strategy and an optimized data access mode, and the calculation results are synchronized to the CPU for subsequent analysis or storage. The present invention is responsible for initializing data and the final output data through the CPU, and the GPU is responsible for loop reconstruction and parallel computing strategies, and the entire program is transplanted to the GPU. All parallel loops are parallelized through the GPU, and the high parallel processing capability of the GPU is used to significantly improve the calculation speed of the model and the ability to process large-scale data sets, thereby realizing the acceleration of the parallel computing of the ocean model and improving the acceleration effect of the parallel computing of the ocean model.

[0070] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the 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 by the present invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0071] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0072] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for parallel computing of ocean models, characterized in that: include: Initializing input data of the ocean model through the CPU to obtain initial ocean parameters, and transmitting the initial ocean parameters from the CPU to the GPU; Processing the circulation area of ​​the ocean model according to the initial ocean parameters by the GPU to obtain a processed circulation area; The processed circulation area is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model to obtain calculation results of the initial ocean parameters, and the calculation results are transmitted from the GPU to the CPU.

2. The ocean model parallel computing method according to claim 1, characterized in that: Initializing the input data of the ocean model by the CPU to obtain initial ocean parameters, and transmitting the initial ocean parameters from the CPU to the GPU, includes: The CPU performs formatting and unit conversion processing on the input data to obtain input data in the same format as the input of the ocean model as the initial ocean parameters; The initial ocean parameters are transmitted from the CPU to the GPU according to the data memory allocation space of the GPU.

3. The ocean model parallel computing method according to claim 2, characterized in that: Also includes: Determine whether there is uninitialized data memory allocation space in the memory space of the GPU; If the memory space of the GPU contains the uninitialized data memory allocation space, the input data is initialized on the GPU by controlling the create instruction of OpenACC to obtain initial ocean parameters, and the initialized initial ocean parameters are allocated to the data memory allocation space of the GPU; If the memory space of the GPU does not have the uninitialized data memory allocation space, the input data of the ocean model is initialized by the CPU to obtain initial ocean parameters, and the initial ocean parameters are transmitted from the CPU to the GPU.

4. The ocean model parallel computing method according to claim 3, characterized in that: The transmitting the initial ocean parameters from the CPU to the GPU comprises: If the memory space of the GPU does not have the uninitialized data memory allocation space, the initialized initial ocean parameters are stored from the memory space of the CPU to the video memory space of the GPU through the copy instruction of OpenACC.

5. The ocean model parallel computing method according to claim 1, characterized in that: The processing of the circulation area of ​​the ocean model according to the initial ocean parameters to obtain the processed circulation area includes: Analyze each of the circulation areas through the code of the initial ocean parameters to obtain data dependency between each of the circulation areas; The loop region is reconstructed according to the data dependency to obtain the processed loop region.

6. The ocean model parallel computing method according to claim 5, characterized in that: The code of the initial ocean parameters is used to analyze each of the circulation areas to obtain data dependencies between each of the circulation areas, including: By coding the initial ocean parameters, determining whether each of the circulation areas has the same parameters as other circulation areas; If yes, determining that the loop region has the data dependency with the other loop regions; If not, it is determined that the loop region and the other loop regions do not have the data dependency.

7. The ocean model parallel computing method according to claim 5, characterized in that: The reconstructing the loop region according to the data dependency to obtain the processed loop region includes: Moving the outermost vertical circulation of the circulation area to the innermost layer of the circulation area; Determine the number of nested loop levels of the loop region through the collapse sub-statement; The loop sequence of the loop region is adjusted according to the number of nested loop layers to obtain the processed loop region.

8. The ocean model parallel computing method according to claim 1, characterized in that: The processing-processed circulation area performs parallel calculations in the internal and external modes of the ocean model according to the initial ocean parameters to obtain calculation results of the initial ocean parameters, including: Adding parallel instructions in the loop region corresponding to the internal and external modes in the ocean model, wherein the internal mode and the external mode of the ocean model correspond to one loop region respectively; The parallel instructions are used to control all the circulation areas of the internal and external modes to perform calculations simultaneously, so as to obtain the calculation results of the initial ocean parameters.

9. The ocean model parallel computing method according to claim 1, characterized in that: said transmitting the calculation result from the GPU to the CPU; Screening the calculation results to obtain output data required by the CPU; The output data is copied from the memory space of the GPU to the memory space of the CPU through an output instruction.

10. An ocean model parallel computing system, characterized in that: include: A data processing unit, configured to initialize input data of an ocean model through a CPU to obtain initial ocean parameters, and transmit the initial ocean parameters from the CPU to a GPU; A circulation conversion unit, configured to process the circulation region of the ocean model according to the initial ocean parameters through the GPU to obtain a processed circulation region; A parallel processing unit is used to perform parallel calculations according to the initial ocean parameters in the internal and external modes of the ocean model through the processed circulation area to obtain calculation results of the initial ocean parameters, and transmit the calculation results from the GPU to the CPU.

Citation Information

Patent Citations

  • GPU parallel three-dimensional seismic wave field generating method and system

    CN106842320A

  • GPU parallel-based quick execution method for tsunami numerical calculation model

    CN108460195A

  • Function file adjustment method and device, computer equipment and storage medium

    CN111949336A

  • Ocean environment data generation method and system based on ROMS

    CN116776591A

Cited By

  • Estuary salt tide invasion numerical forecasting method and system based on standard language parallel acceleration

    CN121166382A

  • Numerical prediction method and system for estuary saltwater intrusion based on standard language parallel acceleration

    CN121166382B