Error compensation processing method and device for single-precision floating-point program execution process
Patent Information
- Application Number
- CN202611281421.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-09-29
AI Technical Summary
然而,单精度浮点格式的有效位数有限,在时间推进、局部累加、空间离散更新及多步迭代过程中容易产生舍入误差,并在大规模计算任务中逐渐累积和传播
本发明通过依次执行程序表示获取、运算结构分类、误差敏感等级判定以及补偿策略选择与执行,形成面向单精度浮点程序执行过程的误差补偿处理流程。在保持原有数值计算模型和程序执行逻辑基本不变的情况下,根据目标应用场景中不同浮点运算的结构特点和误差敏感程度进行差异化补偿,降低单精度浮点计算过程中舍入误差、累积误差及其传播对场景输出结果的影响。其中,在大气数值预测场景中,可降低物理状态变量长期演化过程中的偏移;在多智能体控制、自动驾驶协同控制、导航以及运动控制场景中,可降低状态更新和控制计算过程中的误差累积,提高预测结果、状态估计结果以及控制输出结果的稳定性和可靠性。同时,通过根据误差敏感等级控制补偿范围和补偿强度,避免对全部计算过程进行无差别补偿,在提升输出结果可靠性的同时降低额外计算和存储开销。
Smart Images

Figure CN122837779A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of computer data processing and program execution optimization, specifically to an error compensation processing method and apparatus for single-precision floating-point program execution. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] With the development of high-performance computing systems, numerical simulation and scientific computing programs are gradually evolving towards large-scale grids, high-resolution discretization, and multi-physics process coupling, and are widely used in atmospheric and ocean numerical simulations, fluid mechanics, plasma computing, and other fields. In atmospheric and ocean simulations, long-term time integration processes rely on solving for the continuous evolution of physical fields such as temperature, pressure, flow velocity, and concentration. Accumulated errors may lead to deviations in climate trend predictions and distortions in the characterization of extreme weather processes. In fluid mechanics calculations, boundary layer evolution, turbulence structure capture, and stability analysis of complex flow fields rely on high-precision discretization updates. Numerical errors may cause biases in flow state judgments, difficulties in simulation convergence, or loss of key flow characteristics. In plasma computing, particle motion, electromagnetic field evolution, and energy exchange processes have strong coupling characteristics, and error accumulation may affect plasma stability analysis and physical process prediction. Therefore, the operation of such programs requires the continuous execution of a large number of floating-point operations on processors or accelerators, placing high demands on computational efficiency, storage usage, cache utilization, memory bandwidth consumption, and parallel throughput.
[0004] To reduce data storage and memory access overhead, single-precision floating-point format is increasingly used in core computational processes. However, single-precision floating-point format has a limited number of effective bits, which easily leads to rounding errors during time progression, local accumulation, spatial discrete updates, and multi-step iterations. These errors gradually accumulate and propagate in large-scale computational tasks. Such errors reduce the stability of the numerical solution process, requiring some computational tasks to include additional processing such as error compensation, stability testing, correction iterations, or high-precision recalculation. This increases the processor's computational burden, memory access pressure, and overall execution overhead, limiting the running efficiency of scientific computing programs on large-scale parallel computing platforms. Summary of the Invention
[0005] To address the aforementioned problems, this invention proposes an error compensation processing method and apparatus for single-precision floating-point program execution. It establishes a precision enhancement processing mechanism for different operational structures within single-precision floating-point programs, thereby improving error control during program execution while maintaining the advantages of single-precision computing resources and enhancing prediction accuracy in various physical field application environments.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: The first aspect of this invention provides an error compensation processing method for the execution process of single-precision floating-point programs, comprising the following steps: For the execution process of a single-precision floating-point program in the target application scenario, obtain the program representation corresponding to the target numerical calculation process; Based on the operational expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, the operational structure of the target floating-point operation in the program representation is classified to obtain the operational structure type corresponding to the target floating-point operation. For each type of target floating-point operation, error characteristics are determined to obtain the error sensitivity level of each target floating-point operation; The appropriate compensation method is selected based on the type of the target floating-point operation structure, and the compensation intensity is determined based on its error sensitivity level, thereby generating a matching compensation strategy; the compensation calculation is performed according to the compensation strategy to obtain the result value of the target calculation process after compensation, and the output result of the target application scenario prediction or control process is updated based on the compensation result value.
[0007] Further technical solutions and target application scenarios include atmospheric numerical prediction, multi-agent cooperative control, cooperative positioning and path planning for autonomous vehicles, aircraft or satellite combined navigation, robotic arm trajectory control, and motor motion control scenarios.
[0008] A further technical solution, a method for obtaining the program representation corresponding to the target numerical calculation process, includes the following steps: Static scanning is performed on the target program for the target numerical calculation process to identify single-precision floating-point assignment statements in the target program. Each single-precision floating-point assignment statement is used as a statement-level analysis unit. For each statement-level analysis unit, update frequency characteristics are calculated based on variable update data; For each statement-level analysis unit, loop accumulation features are extracted based on loop execution relationships; For each statement-level analysis unit, state write-back features are extracted based on variable usage relationships; For the right-hand expression in a single-precision floating-point assignment statement, multi-source contribution convergence features are extracted based on the data source of the expression. Based on the extracted update frequency features, cyclic accumulation features, state write-back features, and multi-source contribution convergence features, the propagation association between each statement-level analysis unit is established according to the variable definition relationship and variable usage relationship. Each single-precision floating-point operation statement is connected according to the variable propagation relationship to form a structured program representation that includes calculation statements, variable dependencies, and execution propagation paths.
[0009] A further technical solution divides the target floating-point operation into state update operation and accumulation summation operation; State update operations are operations in which the new value of a variable is obtained by adding the increment to the old value. Target floating-point operations that satisfy the following characteristics are classified as state update operations: Target floating-point operations are single-precision floating-point operations that assign or update target variables or target storage locations; The new value of the target variable is the sum of the old value of the target variable or the equivalent stored value corresponding to the target variable and the increment term; The updated results of the target variable are reused in subsequent time steps, subsequent iterations, or subsequent sub-steps; The auxiliary judgment conditions for state update type operation are: the numerical magnitude of the increment term relative to the old value is less than a preset ratio threshold; the new value of the target variable is written back to the original variable or the corresponding state storage location; the target floating-point operation is located in the program structure corresponding to time advancement, stage step update, state quantity correction or iterative write-back.
[0010] A further technical solution would classify target floating-point operations that meet the following characteristics as cumulative summation operations: The target floating-point operation is a single-precision floating-point operation that updates the accumulated variable or the accumulated storage location; The current value of the cumulative variable or cumulative storage location is recalculated in the expression on the right and added to the newly added contribution item to obtain the updated cumulative value; The auxiliary judgment conditions for cumulative summation operations are: the number of newly added contribution items participating in the accumulation is greater than the preset number of items threshold; the update chain length of the cumulative variable is greater than the preset length threshold; the numerical relationship between the newly added contribution item and the current cumulative value is not fixed; the newly added contribution item has different data sources or calculation sources in different loop steps or iteration steps.
[0011] A further technical solution, a method for classifying the operational structures of target floating-point operations in program representation, includes the following steps: The structural features corresponding to the target floating-point operations in the program representation are extracted and encoded to obtain a structural feature vector, including target variable self-reference features, increment term features, loop triggering features, variable write-back features, multi-source input features, and contribution term convergence features; The self-reference feature, increment feature, loop triggering feature, and variable write-back feature are weighted and summed to obtain the state update structure score. The weighted summation of cyclic trigger features, multi-source input features, aggregated contribution features, and the number of newly added contribution items yields a cumulative summation-type structural score. ; Based on the obtained state-updated structure score Sum-of-the-products type scoring The size and difference determine the classification results of the operation structure type, including state update type operation, cumulative summation type operation and operation to be confirmed; For confirmation operations, the state update structure is scored based on the variable propagation relationship, loop execution relationship, and variable write-back relationship corresponding to the target floating-point operation. Sum-of-the-products type scoring The size is adjusted and judged to determine the type of operation structure.
[0012] A further technical solution involves determining the error characteristics of each target floating-point operation to obtain the error sensitivity level of each target floating-point operation. This process specifically includes the following steps: Based on the error sources of different types of target floating-point operations, error-related data are extracted to construct error-sensitive indicators; The error sensitivity scores are obtained by weighted summation of the corresponding error sensitivity indices for different computational structures. The error sensitivity level is determined by using a threshold judgment method based on the error sensitivity score.
[0013] A further technical solution involves determining a compensation strategy based on the target floating-point operation structure type and error sensitivity level, and then performing compensation during the operation execution process by rewriting the target statement or calling the corresponding compensation interface. The resulting value of the compensated target calculation process includes the following steps: Step 41: Select the corresponding compensation method according to the type of operation structure; When the target floating-point operation is identified as a state update operation, the first compensation method is selected: read the old state master value and the corresponding compensation value, update it in combination with the current increment item, obtain the new master value and the new compensation value, and write the new master value and the new compensation value back to the storage location; When the target floating-point operation is identified as an accumulation and summation operation, the second compensation method is selected; the cumulative amount and compensation item are initialized, each contribution item is read in a loop, the updated cumulative value is calculated and the compensation item is updated based on the current cumulative amount, newly added item and compensation item, until all contribution items are accumulated and the compensated cumulative result is obtained; Step 42: Determine the compensation intensity corresponding to the target floating-point operation based on the error sensitivity level; the compensation intensity includes the compensation enable flag, compensation execution frequency, compensation coverage, and compensation value retention period; Step 43: Based on the determined compensation type and compensation intensity, integrate the compensation calculation into the target program execution flow, execute the compensation calculation process, and obtain the compensated result value.
[0014] A further technical solution involves determining the compensation intensity corresponding to the target floating-point operation based on the error sensitivity level. Specifically: For floating-point operations on high-sensitivity targets, the compensation enable flag is set to enabled, the compensation execution frequency is set to each execution, the compensation coverage is set to the complete time progression process or the complete summation chain, and the corresponding compensation value is continuously saved. For floating-point operations of targets with medium sensitivity level, partial compensation is performed according to the preset compensation window, and the compensation value is updated or reset after the compensation window ends. For floating-point operations with low sensitivity levels, disable the compensation enable flag, or only collect error indicators and re-enable compensation after the sensitivity level increases.
[0015] A second aspect of the present invention provides an error compensation processing apparatus for single-precision floating-point program execution, comprising: The acquisition module is configured to acquire the program representation corresponding to the target numerical calculation process for the single-precision floating-point program execution process of the target application scenario. The operation structure identification module is configured to classify the operation structure of the target floating-point operation in the program representation based on the operation expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, and obtain the operation structure type corresponding to the target floating-point operation. The error feature identification module is configured to determine the error features of each type of target floating-point operation and obtain the error sensitivity level of each target floating-point operation. The compensation module is configured to select the appropriate compensation method based on the operational structure type of the target floating-point operation and determine the compensation intensity based on its error sensitivity level, thereby generating a matching compensation strategy; perform compensation calculation according to the compensation strategy to obtain the result value of the target calculation process after compensation; and update the output result of the target application scenario prediction or control process based on the compensation result value.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention forms an error compensation process for single-precision floating-point program execution by sequentially executing the following steps: program representation acquisition, operational structure classification, error sensitivity level determination, and compensation strategy selection and execution. While maintaining the original numerical calculation model and program execution logic largely unchanged, differentiated compensation is performed based on the structural characteristics and error sensitivity of different floating-point operations in the target application scenario. This reduces the impact of rounding errors, accumulated errors, and their propagation on the scenario output results during single-precision floating-point calculations. Specifically, in atmospheric numerical prediction scenarios, it can reduce the offset of physical state variables during long-term evolution; in multi-agent control, autonomous driving cooperative control, navigation, and motion control scenarios, it can reduce the accumulation of errors during state updates and control calculations, improving the stability and reliability of prediction results, state estimation results, and control output results. Simultaneously, by controlling the compensation range and intensity according to the error sensitivity level, indiscriminate compensation for the entire calculation process is avoided, improving the reliability of the output results while reducing additional computational and storage overhead.
[0017] The advantages of the present invention, as well as its additional advantages, will be described in detail in the following specific embodiments. Attached Figure Description
[0018] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute a limitation thereof.
[0019] Figure 1 This is a flowchart of the error compensation processing method of Embodiment 1 of the present invention; Figure 2(a) is a schematic diagram of the execution process of the first compensation method in an example of Embodiment 1 of the present invention; Figure 2(b) is a schematic diagram of the execution process of the second compensation method in an example of Embodiment 1 of the present invention; Figure 3 This is a structural block diagram of the error compensation processing device according to Embodiment 3 of the present invention. Detailed Implementation
[0020] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0021] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0022] It should be noted that the terminology used herein is for describing particular embodiments only and is not intended to limit the exemplary embodiments of the present invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof. It should be noted that, without conflict, the various embodiments and features within those embodiments can be combined with each other. The embodiments will now be described in detail with reference to the accompanying drawings.
[0023] Example 1 In one or more of the technical solutions disclosed in the embodiments, such as Figure 1 As shown, an error compensation method for single-precision floating-point program execution includes the following steps: Step 1: For the execution process of a single-precision floating-point program in the target application scenario, obtain the program representation corresponding to the target numerical calculation process; Step 2: Based on the operation expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, classify the operation structure of the target floating-point operation in the program representation to obtain the operation structure type corresponding to the target floating-point operation; Step 3: Determine the error characteristics of each type of target floating-point operation to obtain the error sensitivity level of each target floating-point operation; Step 4: Determine the compensation strategy based on the target floating-point operation structure type and error sensitivity level, and perform compensation during the operation execution process to obtain the result value of the target calculation process after compensation. Update the output result of the target application scenario prediction or control process based on the compensation result value.
[0024] The output results corresponding to the target application scenario have different data formats depending on the application scenario.
[0025] Specifically, in atmospheric numerical prediction scenarios, the output results include predictions of physical state variables such as temperature, pressure, wind speed, density, and humidity; in multi-agent control and autonomous vehicle cooperative control scenarios, the output results include the target object's position, velocity, attitude, and control outputs; in aircraft or satellite integrated navigation scenarios, the output results include navigation state information such as position, velocity, and attitude; and in robotic arm trajectory control and motor motion control scenarios, the output results include motion state information, control quantities, and control commands.
[0026] This embodiment forms an error compensation process for single-precision floating-point program execution by sequentially executing program representation acquisition, operational structure classification, error sensitivity level determination, and compensation strategy selection and execution. While maintaining the original numerical calculation model and program execution logic largely unchanged, differentiated compensation is performed based on the structural characteristics and error sensitivity of different floating-point operations in the target application scenario. This reduces the impact of rounding errors, accumulated errors, and their propagation on the scenario output results during single-precision floating-point calculations. Specifically, in atmospheric numerical prediction scenarios, it can reduce the offset of physical state variables during long-term evolution; in multi-agent control, autonomous driving cooperative control, navigation, and motion control scenarios, it can reduce the accumulation of errors during state updates and control calculations, improving the stability and reliability of prediction results, state estimation results, and control output results. Simultaneously, by controlling the compensation range and intensity according to the error sensitivity level, indiscriminate compensation for the entire calculation process is avoided, improving the reliability of the output results while reducing additional computational and storage overhead.
[0027] Through the above-described scheme of this embodiment, for state update type operations, the method of this embodiment can suppress the long-term loss of low-order information caused by single-precision rounding during repeated state updates of small increments; for cumulative summation type operations, it can reduce the propagation of rounding errors and the numerical distortion caused by positive and negative cancellation during continuous summation, thereby improving the accuracy of prediction or control in the target application scenario. The specific implementation methods of each step are described in detail below.
[0028] In step 1, the target application scenario refers to the specific physical application scenario in which a single-precision floating-point program is used to perform numerical calculation tasks, including scenarios such as atmospheric numerical prediction, multi-agent cooperative control, cooperative localization and path planning of autonomous vehicles, aircraft or satellite combined navigation, robotic arm trajectory control, and motor motion control. The target numerical computation process refers to one or more computational flows actually executed during the execution of a single-precision floating-point program to complete a specific numerical computation task. This computational flow is composed of statement sequences, loop structures, branch structures, function call relationships, variable read and write relationships, and floating-point arithmetic expressions in the program, and can reflect the specific implementation method of the numerical computation task during program execution.
[0029] Specifically, in the atmospheric and oceanic numerical prediction program, the target numerical calculation process can include the update calculation of physical state variables such as temperature field, pressure field, velocity field, humidity field, salinity field, density field and tracer quantity during the time step progression, as well as gradient calculation, flux calculation, diffusion calculation and source-sink term calculation based on spatial grid discretization.
[0030] In fluid dynamics calculation programs, the target numerical calculation process can include time integration calculation of velocity field, pressure field, density field, momentum field and energy field during the flow evolution process, pressure correction calculation, boundary condition update calculation, turbulence model calculation, and discrete equation solution process based on finite volume method, finite difference method or finite element method.
[0031] This embodiment addresses the target numerical calculation process in a single-precision floating-point environment. In a single-precision floating-point environment, the target numerical calculation process may include at least one of the following: time progression process, spatial discretization process, cyclic accumulation process, flux aggregation process, state variable update process, or local residual assembly process.
[0032] Among them, the time-progression process refers to the execution process in which the program updates the computational state step by step according to a preset time step; the spatial discretization process refers to the execution process in which the program performs discrete solutions on continuous physical quantities or mathematical models based on grids, nodes, cells, or discrete points; the iterative accumulation process refers to the execution process in which the program continuously sums, accumulates, or reduces multiple intermediate computational results in iterative loops; the flux aggregation process refers to the execution process in which the program merges, superimposes, or aggregates flux results generated in different directions, different boundaries, different cell interfaces, or different computational regions; the state quantity update process refers to the execution process in which the program assigns or corrects the next state quantity based on the current state quantity, intermediate variables, source terms, flux terms, or residual terms; and the local residual assembly process refers to the execution process in which the program generates and assembles residual terms in local grid cells, local node regions, or local computational subdomains.
[0033] The program representation can be the program statements, loop bodies, core calculation segments in functions, or calculation segments in modules that implement the above-mentioned target numerical calculation process. It can also be a set of target expressions obtained through source code parsing, abstract syntax tree analysis, compiler intermediate representation extraction, or manual annotation.
[0034] In one implementation, for the execution process of a single-precision floating-point program in a target application scenario, the program representation corresponding to the target numerical calculation process is obtained. The program representation can be obtained by directly specifying functions, subroutine segments, modules, or code segments as the program representation to be analyzed. For example, developers can specify time advancement subroutines, flux divergence calculation subroutines, tracer quantity delivery calculation subroutines, etc. as the program representation to be analyzed.
[0035] In a preferred embodiment of this example, the specific method of obtaining the program representation corresponding to the target numerical calculation process can be achieved by performing a scanning analysis of the target program based on statement-level static features to extract the program representation corresponding to the target numerical calculation process. Furthermore, the method for obtaining the program representation corresponding to the target numerical calculation process includes the following steps: Step 11: Perform static scanning on the target program for the target numerical calculation process, identify single-precision floating-point assignment statements in the target program, and treat each single-precision floating-point assignment statement as a statement-level analysis unit. Specifically, a static scan is performed on the target program's source code to identify assignment statements of single-precision floating-point type. Each single-precision floating-point assignment statement is treated as a minimum analysis unit, i.e., a statement-level analysis unit. For each minimum analysis unit, the program location of the assignment statement is analyzed, including the loop structure it belongs to, the sub-function or local execution module it belongs to, and the code location of the statement. At the same time, the target variable on the left-hand side, the calculation expression on the right-hand side, and the variable read / write relationships corresponding to the program statement are obtained.
[0036] Through the above processing, a set of basic analysis units containing statement position, variable information, and expression information is obtained, which serves as the processing object for subsequent execution feature extraction and variable propagation relationship analysis.
[0037] Step 12: For each statement-level analysis unit, calculate the update frequency characteristics based on the variable update data; Specifically, for each statement-level analysis unit, the number of times the variable on the left side of a single-precision floating-point assignment statement is repeatedly assigned within a unit time window or iteration window is counted, i.e., the variable update data, and the update frequency characteristics are calculated. This step yields the update frequency characteristics of each analysis unit, which are used to determine whether the target variable is a high-frequency update variable and serve as the basis for the analysis unit's intensity classification and error accumulation risk analysis.
[0038] Step 13: For each statement-level analysis unit, extract loop accumulation features based on loop execution relationships; Specifically, for each statement-level analysis unit, the loop index, iteration variable, and array subscript in the right-hand expression of the single-precision floating-point assignment statement are analyzed, and the loop accumulation feature is obtained by combining the number of times the single-precision floating-point assignment statement is triggered in the loop. Through the above processing, the cyclic cumulative features corresponding to each analysis unit are obtained, which serve as input information for subsequent judgment of error propagation path and calculation structure type.
[0039] Step 14: For each statement-level analysis unit, extract state write-back features based on variable usage relationships; Specifically, for each statement-level analysis unit, the left-hand variable of the single-precision floating-point assignment statement is traced along the subsequent execution path to see if it is used as input again in subsequent time steps, iteration steps, or sub-function calls, thus obtaining state write-back characteristics; when the calculation result of the target variable is continuously referenced in the subsequent calculation process, the propagation position, calling relationship, and number of times the variable is used are recorded as state write-back characteristics. Through the above processing, we obtain state write-back features that can characterize the continuous participation of calculation results in subsequent calculation processes, which can be used to establish variable propagation associations and identify the continuous propagation path of errors.
[0040] Step 15: For the right-hand expression in a single-precision floating-point assignment statement, extract multi-source contribution convergence features based on the data source of the expression. These features are used to characterize the number of data sources involved in the calculation during the target variable update process, the source type, and the data convergence relationship between different sources. Specifically, for the right-hand expression of the single-precision floating-point assignment statement in each statement-level analysis unit, the sub-computed items in the expression are parsed, and the data source corresponding to each sub-computed item is traced. When data from multiple different grid locations, boundary locations, spatial direction components, or different physical processes simultaneously participate in the update of the same target variable, it is determined that the target variable has a multi-source data convergence relationship. The corresponding number of data sources, source variable index, data access location relationship, and the computing module to which the source belongs are recorded, and the above information is used to form a multi-source contribution convergence feature.
[0041] For example, in a numerical computation program for fluid mechanics, there exists a single-precision floating-point assignment statement: ; Among them, the target variable The calculation also depends on the current density field variables. Time progression parameters Velocity field variables and the divergence term obtained based on spatial discretization. By parsing the right-hand expression of the assignment statement, it was determined that the update process of the target variable involved data input from multiple different sources.
[0042] Multi-source contribution convergence features characterize the combined effects of multiple data sources on the update of the same target variable during single-precision floating-point computation, and serve as the basis for subsequent analysis of inter-variable propagation correlations, identification of complex computational structures, and determination of numerical error propagation paths.
[0043] Step 16: Based on the extracted update frequency features, cyclic accumulation features, state write-back features, and multi-source contribution convergence features, establish the propagation association between each statement-level analysis unit according to the variable definition relationship and variable usage relationship, connect each single-precision floating-point operation statement according to the variable propagation relationship, and form a structured program representation that includes calculation statements, variable dependencies, and execution propagation paths; In one implementation, propagation relationships between statement-level analysis units are established based on variable definition and usage relationships. Specifically: when the output variable of one statement appears as input in another statement, a statement dependency relationship is established; when the same variable continues to appear across loop iterations or time steps, a cross-iteration propagation relationship is established. Thus, single-precision floating-point arithmetic statements are mapped to statement-level analysis units, and these units are connected by variable propagation relationships, forming a structured program representation that can characterize the floating-point arithmetic expression, loop execution relationships, result write-back locations, and error propagation paths.
[0044] It is feasible to store the obtained structured program representation using an adjacency table, variable index mapping table, or variable linked list, and output the analysis unit identifier, statement position, variable index, belonging loop or time step, and propagation association information as input for the operation structure classification in step 2.
[0045] It should be noted that for large-scale numerical programs, it is not necessary to analyze the entire program at once. Instead, priority should be given to processing the program representations corresponding to critical paths that are highly sensitive to errors, constitute a large proportion of the computation, and have a significant impact on the overall results. By obtaining the program representations, the computational expressions, variable relationships, loop structures, and result write-back locations in the target numerical calculation process can be preserved, providing a foundation for subsequent identification of state update operations, cumulative summation operations, and other error-sensitive operations. Therefore, this step improves the automation foundation and engineering adaptability of error compensation processing.
[0046] Step 2: Based on the operation expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, classify the operation structure of the target floating-point operation in the program representation to obtain the operation structure type corresponding to the target floating-point operation; Specifically, the target floating-point operation can include single-precision floating-point operation statements, assignment expressions, loop accumulation expressions, or intermediate representation nodes in the program representation; In this embodiment, based on the variable update method and the calculation contribution formation method during floating-point operations, the target floating-point operations are divided into state update type operations and cumulative summation type operations. State update type operations represent a calculation structure that updates the variable state based on existing state values and the current calculation increment; cumulative summation type operations represent a calculation structure that continuously receives multiple contribution items and forms a cumulative result during loops or iterations.
[0047] The following explains state update operations and cumulative summation operations: State update operations refer to operations where the new value of a variable is obtained by adding a preset increment to the old value. This can be expressed as: ; in, Indicates a state variable or intermediate variable. This represents a new value for a state variable or intermediate variable. This represents the old value of a state variable or intermediate variable. This represents the increment of the state in the current time step, substep, stage step, or iteration step. The increment is the single-step change used to correct the old state quantity, and is represented in the program as a right-hand expression term added to the old value.
[0048] State update operations can exist in atmospheric simulation, ocean simulation, fluid dynamics calculation, plasma calculation, heat conduction calculation, reaction and diffusion calculation, as well as discrete solution programs such as finite volume method, finite difference method, and finite element method.
[0049] Specifically, in atmospheric and ocean simulation programs, state update operations can include updates of wind speed, temperature, humidity, salinity, density, pressure, or tracer quantities as the time step progresses. In fluid dynamics calculation programs, state update operations can include updates of velocity, momentum, pressure, density, energy, or turbulence variables during time integration, pressure correction, flux correction, or boundary condition correction processes. In plasma computing programs, state update operations can include updates of electric field, magnetic field, charge density, particle velocity, or distribution function over time. In heat conduction or reaction diffusion calculation programs, state update operations can include updates of temperature, concentration, or reaction variables under the influence of diffusion, source, or reaction terms. In discrete solution programs for the finite volume method, finite difference method, or finite element method, state update operations can include the updating of element state variables, nodal state variables, residual correction variables, stage step variables, or iteration variables during time progression, stage step write-back, source term correction, diffusion correction, or iterative correction processes.
[0050] The summation operation refers to a cumulative quantity receiving multiple contributions during a loop or iteration. Its typical form can be expressed as: ; in, For cumulative amounts, For the first Each contribution term is a unique feature. This type of operation typically occurs during edge loops, cell loops, vertex loops, layer loops, or neighborhood summation processes. New contribution terms can be obtained from one or more of the following: neighborhood data, boundary data, mesh cell data, flux data on edges or faces, discrete equation terms, source terms, residual terms, interpolation terms, reconstruction terms, or contribution terms from different physical processes.
[0051] It should be noted that the cumulative quantity in the summation type operation... Typically initialized before the start of the local summation chain, and receiving contributions from different data locations or computation sources sequentially within the same loop or reduction process. After the cycle ends, the final cumulative amount is formed. In state update operations This indicates that the state value saved across time steps, stage steps, or iteration steps will be written back to the state storage location and continue to participate in subsequent state evolution.
[0052] Summation-type operations are widely present in the contribution convergence stage of the discrete solution process for partial differential equations. Specifically, in the finite volume method, it can be the summation of fluxes from multiple directions, boundary fluxes, or surface fluxes toward the same control volume residual term; in the finite difference method, it can be the convergence of difference terms from multiple directions or neighborhood discrete terms toward the same discrete operator; in the finite element method, it can be the summation of multiple nodal contribution terms, weight terms, or element integral terms toward the same assembly variable. Furthermore, in the processes of source-sink term superposition, interpolation calculations, and tracer transport calculations, there are also computational structures where multiple physical process contribution terms, spatial neighborhood contribution terms, or transport contribution terms converge toward the same target variable.
[0053] In some embodiments, state update operations are operations in which the new value of a variable is obtained by adding the increment to the old value. Target floating-point operations that satisfy the following characteristics are determined to be state update operations: (1) Target floating-point operation is a single-precision floating-point operation that assigns or updates the target variable or target storage location; (2) The new value of the target variable is the sum of the old value of the target variable or the equivalent stored value corresponding to the target variable and the increment term; (3) The update results of the target variable are reused in subsequent time steps, subsequent iterations or subsequent sub-steps; In addition to meeting the above conditions, confirmation can also be made by combining at least one of the following auxiliary conditions. The auxiliary judgment conditions for state update type operation are: the numerical magnitude of the increment relative to the old value is less than a preset ratio threshold; the new value of the target variable is written back to the original variable or the corresponding state storage location; the target floating-point operation is located in the program structure corresponding to time advancement, stage step update, state quantity correction or iterative write-back.
[0054] In some embodiments, target floating-point operations that satisfy the following characteristics are determined to be summation operations: (1) The target floating-point operation is a single-precision floating-point operation that updates the cumulative variable or the cumulative storage location; (2) The current value of the cumulative variable or the cumulative storage location is calculated again in the expression on the right and added to the newly added contribution item to obtain the updated cumulative value; In addition to meeting the above conditions, at least one of the following auxiliary conditions can be used for confirmation: the auxiliary judgment conditions for cumulative summation operations are: the number of new contribution items participating in the accumulation is greater than the preset number of items threshold; the update chain length of the cumulative variable is greater than the preset length threshold; the numerical relationship between the new contribution item and the current cumulative value is not fixed; the new contribution item has different data sources or calculation sources in different loop steps or iteration steps. To achieve automatic classification of operational structures, this embodiment provides an automatic classification method based on program structure features. This method uses the judgment conditions corresponding to state update operations and cumulative summation operations as a basis, transforming the structural judgment criteria used for manual identification into program-recognizable feature information; furthermore, the method for classifying the operational structures of target floating-point operations in the program representation includes the following steps: Step 21: Extract the structural features corresponding to the target floating-point operations in the program representation and encode them to obtain the structural feature vector; Specifically, each target floating-point operation statement in the program representation is parsed for syntax structure, loop position, and variable definition and usage relationship to obtain the corresponding structural features, including target variable self-reference features, increment features, loop triggering features, variable write-back features, multi-source input features, and contribution item aggregation features. The target variable self-reference characteristic is used to indicate whether the left-hand variable or its old value storage variable of the program statement appears in the right-hand expression. Specifically, it parses the variable reference relationship between the left-hand variable of the target floating-point operation statement and the variable reference relationship in the right-hand expression. When the left-hand target variable or its corresponding historical state variable or old value storage variable appears in the right-hand expression, the target variable self-reference characteristic is set to 1; otherwise, the target variable self-reference characteristic is set to 0.
[0055] For example, for Due to the left-hand variable It also appears in the right-hand expression, therefore the self-reference characteristic of the target variable is 1; The increment term feature indicates whether there is a new calculation result in the right-hand side expression of a program statement to correct the old state value. Specifically, after semantic parsing the right-hand side expression and removing the expression terms corresponding to the old state of the target variable, it is determined whether the remaining expression terms form a new change for updating the target variable. When there are one or more independent calculation terms used to correct the state of the target variable, the increment term feature is set to 1; otherwise, the increment term feature is set to 0.
[0056] Optionally, the incremental term in this embodiment is not limited to a specific physical name, but refers to one or more new calculation results in the right-hand side expression of the target floating-point operation, other than the old state value, used to change the old state value. The incremental term can be an intermediate variable, a function return value, an array access result, or a calculation result obtained by combining multiple sub-expressions in the program.
[0057] For example, in "new temperature = old temperature + time step × temperature change rate", the "time step × temperature change rate" and in "new velocity = old velocity + pressure gradient correction + external force correction" are all incremental terms.
[0058] The loop trigger feature indicates whether a statement is repeatedly executed within a loop, time-step progression, or iterative structure. Specifically, based on program control flow information, it determines whether the target floating-point operation statement is located inside a loop structure, time-step progression structure, or iterative solution structure. When the statement has a nested loop relationship, or is repeatedly called during program execution, the loop trigger feature is set to 1; otherwise, the loop trigger feature is set to 0.
[0059] The variable write-back characteristic is used to indicate whether the result is written back to the original variable or the equivalent storage location for continued use in subsequent time steps. Specifically, variable usage relationship analysis is performed along the program execution path after the target floating-point operation. When the target variable update result is written back to the original variable or state storage location, or used again as an input variable in subsequent time steps, iteration steps, or subroutine calls, the variable write-back characteristic is set to 1; otherwise, the variable write-back characteristic is set to 0.
[0060] The multi-source input feature is used to indicate whether the right-hand side expression contains inputs from different array subscripts, grid positions, boundary numbers, directional components, or physical processes. Specifically, the source analysis of the input variables in the right-hand side expression is performed. When multiple input variables are detected to originate from different array subscripts, different grid positions, different boundary numbers, different spatial directional components, or different physical calculation processes, the multi-source input feature is set to 1; otherwise, the multi-source input feature is set to 0.
[0061] The contribution term aggregation feature indicates whether multiple inputs converge to the same cumulative variable, flux variable, residual variable, or discrete equation term through floating-point addition, subtraction, or weighted combination. Specifically, the operator structure in the right-hand side expression is parsed. When multiple input terms converge to the same target variable, cumulative variable, flux variable, residual variable, or discrete equation term through addition, subtraction, or weighted combination, the contribution term aggregation feature is set to 1; otherwise, the contribution term aggregation feature is set to 0.
[0062] The obtained structural features are quantized and encoded to generate the first... The structural feature vector corresponding to each target floating-point arithmetic statement: ; in, to These represent the target variable self-reference feature, incremental term feature, loop triggering feature, variable write-back feature, multi-source input feature, and contribution term aggregation feature, respectively. Each feature can be represented by 0 or 1 to indicate whether the corresponding feature is present, or it can be normalized to a continuous feature value between 0 and 1 based on the number of loop executions, subsequent usages, propagation times across time steps, number of different source terms, or number of contribution paths.
[0063] Step 22: Perform a weighted summation of the structural feature vectors to calculate the state-updated structural score. Sum-of-the-products type scoring ; Specifically, the self-reference feature, incremental feature, loop triggering feature, and variable write-back feature are weighted and summed to obtain the state update structure score. The weighted summation of cyclic trigger features, multi-source input features, aggregated contribution features, and the number of newly added contribution items yields a cumulative summation-type structural score. The formula is as follows: ; ; in, and They represent the first Scoring of state-updating and summation-based structures for target floating-point operations; to , to These are the weighting coefficients; For the first The normalized result of the number of new contributions in the program statement corresponding to each target floating-point operation or in the loop segment where it is located.
[0064] The weighting coefficients can be determined and adjusted based on the target program type, historical identification results, manual review results, or statistical results of compensation effects. This is feasible. For state update operations, since these operations primarily involve state advancement based on existing state values and increment terms, the weights of the target variable's self-reference feature, increment term feature, and variable write-back feature can be increased. In one example, weights can be set... to The values are 0.35, 0.30, 0.15, and 0.20 respectively, which means: ; For summation operations, since these operations primarily involve multiple contributors converging towards the same cumulative variable, the weights of loop-triggered features, multi-source input features, and contributor convergence features can be increased. In one example, weights can be set... to The values are 0.15, 0.30, 0.40, and 0.15 respectively, which means: ; Step 23: Score the updated structure based on the obtained state. Sum-of-the-products type scoring The size and difference determine the classification results of the operation structure type, including state update type operation, cumulative summation type operation and operation to be confirmed; when When the difference between the two exceeds the classification confidence threshold, it is determined to be a state update operation; when When the difference between the two exceeds the classification confidence threshold, it is determined to be an accumulation summation operation; When the difference between the two does not exceed the classification confidence threshold, the target floating-point operation is marked as an operation to be confirmed, and step 24 is executed. Step 24: For the operation to be confirmed, score the state-updating structure based on the variable propagation relationship, loop execution relationship, and variable write-back relationship corresponding to the target floating-point operation. Sum-of-the-products type scoring The size is adjusted and judged to determine the type of operation structure; The state-update classification results are corrected based on variable propagation relationships. Specifically, the usage of the calculation result corresponding to the left-hand variable of the target floating-point operation in subsequent program execution is analyzed. When the target variable appears in the right-hand expression and has the characteristic of target variable self-referencing, but the new value calculated by this statement does not continue to participate in the calculation as a state variable in subsequent time steps, iteration steps, or subroutine calls, the state-update structure score corresponding to this target floating-point operation is reduced.
[0065] The classification results for cumulative summation types are revised based on the contribution source relationship. Specifically, the input sources in the loop structure containing the target floating-point operation and the right-hand expression are analyzed. When the target floating-point operation is located inside the loop structure, but each execution is based on a single source variable for updating, and there are no contributions from multiple different positions, directions, or calculation processes converging towards the same target variable, the score of the cumulative summation type structure corresponding to that target floating-point operation is reduced.
[0066] The final type is determined based on the program context. Specifically, after completing the corrections based on variable propagation relationships and contribution source relationships, the variable propagation chain, loop structure, and target variable write-back path between the target floating-point operation and adjacent statements are further analyzed. When the update result of the target variable continues to propagate along time steps, iteration steps, or stage steps and is continued to be used by subsequent calculation processes, the target floating-point operation is determined to be a state update type operation. When the target variable continuously receives contributions from multiple data sources during the loop or iteration process and forms cumulative results, throughput results, residual results, or discrete calculation items, the target floating-point operation is determined to be an accumulation summation type operation.
[0067] Through the above consistency correction process, the final operation structure type corresponding to the target floating-point operation to be confirmed is determined.
[0068] Based on the above steps, for floating-point arithmetic structures that require manual reading of loop structures, variable update logic, and calculation expressions in traditional methods, this embodiment can achieve program-level identification through structural feature quantification and automatic classification. Furthermore, by distinguishing between error propagation structures in the state progression process and error accumulation structures in the multi-contribution convergence process, it can automatically and accurately distinguish between state update operations and accumulation and summation operations, avoiding structural identification difficulties caused by differences in variable naming, program module differences, or implementation methods, and avoiding resource waste caused by using a unified processing strategy for all single-precision floating-point operations.
[0069] In step 3, based on the target floating-point operation structure type output in step 2, corresponding error feature analysis methods are established for state update type operations and accumulation summation type operations, respectively. By collecting data related to floating-point error accumulation, error sensitivity indicators are constructed, and the error sensitivity level of each target floating-point operation is determined based on the indicator calculation results. Error feature judgment is performed on each target floating-point operation to obtain the error sensitivity level of each target floating-point operation. The specific process includes the following: Step 31: Based on the error sources of different types of target floating-point operations, extract error-related data to construct error-sensitive indicators; Specifically, for state update operations, error-related data includes the old state value corresponding to the target floating-point operation, the increment value, the number of update executions, the number of variable write-backs, the number of times the data is saved across time steps, and the number of times it is used subsequently. Among these, the old state value is used to represent the historical state quantity on which the current calculation depends; the increment value is used to represent the amount of change in the state variable caused by the current time step, iteration step, or stage step. For cumulative summation operations, error-related data includes the number of contributing terms involved in the same cumulative result, the numerical range of each contributing term, the sign distribution of the contributing terms, the sum of the absolute values of the contributing terms, the algebraic sum of the contributing terms, the number of times the cumulative variable is updated, and the subsequent use of the cumulative result. This data can be obtained from program representation, variable usage-definition chains, loop information, runtime sampling data, or trial run results before compensation.
[0070] A further technical solution involves establishing corresponding error-sensitive indicators for different computational structures based on the acquired error-related data. Specifically: For state update operations, construct a magnitude difference index. Update frequency indicators Back-to-back dissemination metrics and subsequent dependency metrics , means as follows: ; For summation operations, construct a contribution item quantity index. Quantity of dispersion index Symbolic mixed indicators Partial offset index and cumulative results propagation indicators , means as follows: ; One specific method for constructing the magnitude difference index is to calculate it based on the order-of-magnitude relationship between the old state value and the incremental term. Specifically, the old state value and the incremental term corresponding to the target floating-point operation are obtained, the absolute value ratio of the two is logarithmically transformed, and the transformed result is normalized to obtain the magnitude difference index. The logarithmic transformation is expressed as follows: ; in, The old state value, For incremental terms, To prevent positive numbers with a denominator of zero.
[0071] The update frequency metric is obtained by normalizing the ratio of the number of times the target statement is executed to the number of times the reference statement is executed; The write-back propagation metric is obtained by normalizing the ratio of write-backs to executions. Subsequent dependency metrics are obtained by normalizing based on subsequent usage frequency or dissemination depth; A specific method for constructing an error-sensitive index for cumulative summation operations is explained below: The contribution quantity indicator, which measures the number of contribution items. Normalization yields the result; The magnitude dispersion index is obtained by log normalizing the ratio of the maximum to the minimum absolute value of the non-zero contribution item. The sign mixing index is used to represent the degree of mixing of positive and negative signs among the contributing terms involved in the summation operation. Specifically, it involves obtaining all contributing terms corresponding to the target cumulative variable, counting the number of positive and negative contributing terms separately, and determining the sign mixing index based on the proportional relationship between the number of positive and negative contributing terms. This index can be expressed as: ; in, and These represent the number of positive contributions and the number of negative contributions, respectively. This indicates a pre-defined positive number to prevent the denominator from being zero; Using the above method, when the number of positive and negative contributions in the cumulative calculation is close, it indicates a strong sign mixing relationship between contributions from different directions, and the sign mixing index is large; when the contribution items are mainly composed of data with the same sign, the sign mixing index is small. The sign mixing index is used to reflect the risk of significant digit loss due to the interaction of positive and negative contributions during the accumulation process.
[0072] The partial cancellation index is used to indicate the degree to which numerical cancellation occurs between multiple contributing items in a summation-type operation. Specifically, it involves obtaining the values of each contributing item participating in the same cumulative result calculation, calculating the sum of the absolute values of each contributing item and the algebraic sum of each contributing item, and determining the partial cancellation index based on the difference between the two. The calculation formula is as follows: ; in, Indicates the first One contribution item, Represents the algebraic sum of all contributions. This represents the sum of the absolute values of all contributions. This indicates a preset positive number to prevent the denominator from being zero.
[0073] Using the above method, when there is a clear positive and negative offsetting relationship between multiple contribution items, the sum of the absolute values of the contribution items is significantly greater than the absolute value of the final cumulative result, and the local offsetting index approaches 1; when the contribution items are in the same direction or there is no clear offsetting, the difference between the two is small, and the local offsetting index approaches 0. The local offsetting index is used to measure the degree of risk of a decrease in effective accuracy due to mutual offsetting of contribution items during the cumulative calculation process.
[0074] All of the above indicators are limited to between 0 and 1. The larger the indicator value, the more obvious the corresponding error risk factor.
[0075] Step 32: Weight the corresponding error sensitivity indices for different operational structures and sum them to obtain the error sensitivity score; Computational state update operations Error sensitivity score for summation operations The formula is as follows:
[0076] in, and These are the state update-type error sensitivity score and the cumulative summation-type error sensitivity score, respectively. to , to The weights are non-negative, and the sum of the weights in the same score is 1. The weights can be determined based on the target program type, historical error statistics, the importance of key propagation links, or the change in error before and after compensation.
[0077] Step 33: Determine the error sensitivity level based on the error sensitivity score; In one implementation, a first sensitivity threshold and a second sensitivity threshold are set, wherein the first sensitivity threshold is greater than the second sensitivity threshold. When the error sensitivity score is greater than or equal to the first sensitivity threshold, it is determined to be of a high sensitivity level; When the error sensitivity score is between the first sensitivity threshold and the second sensitivity threshold, it is determined to be of medium sensitivity level; When the error sensitivity score is lower than the second sensitivity threshold, it is determined to be of low sensitivity level.
[0078] Furthermore, to improve adaptability under different program environments, the level boundary can be adaptively adjusted based on the distribution of floating-point operation scores of all targets within the same target program, score percentiles, compensation resource budget, and the importance of variable propagation links.
[0079] When the compensation resource budget is low, only operations with scores in the top preset proportion and located on key propagation links are identified as high-sensitivity operations; when the resource budget increases, the coverage of high-sensitivity or medium-sensitivity operations is expanded. The sensitivity level of operations whose results enter multiple subsequent core computing links is increased, and the sensitivity level of operations that only form local temporary results and do not continue to propagate is decreased.
[0080] Furthermore, the operation identifier, operation structure type, error sensitivity index values, error sensitivity score, and error sensitivity level of each target floating-point operation are output and stored together with the statement position, variable index, and loop or time step information. The operation structure type is used in step 4 to determine the compensation method category, and the error sensitivity level and error sensitivity score are used to determine the compensation activation conditions, execution frequency, coverage, compensation value retention period, and compensation resource allocation method.
[0081] In step 4, the compensation strategy is determined based on the target floating-point operation structure type and error sensitivity level. Compensation is then performed during the operation execution process by rewriting the target statement or calling the corresponding compensation interface. The resulting value of the compensated target calculation process includes the following steps: Step 41: Select the corresponding compensation method according to the type of operation structure; Specifically, when the target floating-point operation is identified as a state update operation, the first compensation method is selected; the first compensation method is used to retain the low-order error information caused by single-precision floating-point rounding during the state update process, and to feed it back and utilize it in subsequent state update processes. When the target floating-point operation is identified as an accumulation summation operation, the second compensation method is selected; the second compensation method is used to maintain the error compensation term during the continuous summation process, record the rounding error generated by each accumulation, and correct it during the subsequent accumulation of contribution terms.
[0082] A further technical solution involves performing compensation calculations, as shown in Figure 2(a). When the first compensation method is used to perform one compensation, the old state master value and corresponding compensation value are read, and updated in combination with the current incremental item to obtain a new master value and a new compensation value. The new master value and the new compensation value are then written back to the storage location. When the second compensation method is used to perform one compensation, the cumulative amount and compensation item are initialized. Each contribution item is read in a loop, and the updated cumulative value is calculated based on the current cumulative amount, the newly added item, and the compensation item. The updated compensation item is then updated until all contribution items are accumulated, and the compensated cumulative result is obtained. In a preferred embodiment, the first compensation method employs a quasi-double precision (QDP) compensation approach: variables are represented as a combination of principal values and compensation values, where the principal value is the primary physical or numerical quantity, and the low-order errors generated during the update process are used as compensation values. When a state update operation performs the addition of the old value to the increment, the principal value is updated to the old value plus the increment plus the compensation value, and the compensation value is also updated simultaneously. In this way, information discarded during a single-step update does not disappear directly but is saved in the form of compensation and fed back in subsequent updates.
[0083] In practical implementation, the QDP algorithm compensation process is explained as follows; The specific form of state update operations is as follows: ; in, Number the time step, stage step, or iteration step. For the first The old state value of the step, This is the increment for this step. This indicates that the operations within the parentheses are performed in single-precision floating-point format and rounded to single-precision result.
[0084] To preserve the low-order bits that did not enter the single-precision principal value during the update process, the state value is represented as the principal value. Compensation value The combination, namely For a single state update, perform the following compensatory update: ; ; ; ; ; in, This is to incorporate the previous compensation value into the corrected increment obtained after this step. This is the single-precision principal value for this step. The result of single-precision reconstruction of the principal value change. This is the low-order rounding error reconstructed based on the addition relationship in this step. and These are the updated primary value and the compensation value, respectively. The updated state value is determined by... This indicates that subsequent state updates will continue to read both, allowing the low-order information that has not yet entered the main value to participate in the next calculation.
[0085] All the additions and subtractions described above are single-precision floating-point operations; when no overflow occurs and the usual nearest-rounding rules are used, the results are obtained through error reconstruction. Used to store the low-order part that is rounded during main value addition.
[0086] Alternatively, the first compensation method can also employ an error feedback update method. Let... For the first Step master state value, To compensate for the feedback amount defined by the low-order portion of the main value that was over- or under-counted in this instance, the following compensation process is performed: ; ; ; ; Continue using in the next update The new increment is then corrected. The error feedback update method organizes the calculation using the master state value and the feedback quantity; the aforementioned dual-component compensation method uses both the master value and the low-order compensation value as the state representation. Both methods utilize subsequent updates to compensate for low-order errors, but the sign convention of the compensation quantity and the state representation method differ.
[0087] When the target operation is identified as an accumulation summation operation, the second compensation method is selected. As shown in Figure 2(b), the basic idea of the second compensation method is: for the summation chain that continuously receives contribution terms for the cumulative amount, an error compensation term is maintained in each addition step to record the part lost due to rounding in this addition, and is corrected in subsequent summations.
[0088] The second compensation method is a compensation summation algorithm, which can be the Kahan compensation summation method, the Neumaier (Improved Kahan–Babuška algorithm, Neumaier) compensation summation method, or other equivalent summation methods with error tracking ideas.
[0089] Unlike the first compensation method, the second compensation method does not emphasize the long-term preservation of low-order information of the same state variable across time steps, but rather emphasizes controlling error propagation and offsetting distortion in a local summation chain.
[0090] In a preferred embodiment, the second compensation method employs the Kahan compensation summation method. Let... For the first One contribution item, To complete the first The cumulative principal value after each contribution item To complete the first Compensation items following each contribution item Initialize to the total number of contribution items. , ;right The following compensation process will be executed sequentially: ; ; ; ; ; in, This indicates single-precision floating-point rounding. To utilize the contribution item revised from the previous round of compensation items, This is the temporary cumulative amount for this round. Used to estimate the lower-order portion of the cumulative principal value that did not enter the current round of addition; according to the above notation conventions, the next round is passed... Error feedback is implemented. By maintaining a compensation term during continuous accumulation, the second compensation method can reduce errors caused by rounding and summation order sensitivity without changing the underlying single-precision data type.
[0091] Step 42: Determine the compensation intensity corresponding to the target floating-point operation based on the error sensitivity level; the compensation intensity includes the compensation enable flag, compensation execution frequency, compensation coverage, and compensation value retention period; The compensation enable flag is used to determine whether the corresponding compensation method is enabled for the target floating-point operation. When the error sensitivity level of the target floating-point operation reaches the preset enable condition, the compensation enable flag is set to enabled, and the corresponding compensation calculation is performed in subsequent execution; otherwise, the original single-precision floating-point calculation method is maintained. The compensation execution frequency is used to determine the time interval or execution frequency at which compensation calculations are triggered, and to control the frequency of the compensation process. For target floating-point operations with high error sensitivity, compensation is enabled every time the target operation is executed; for target floating-point operations with medium error sensitivity, compensation can be executed at preset time intervals, specified iteration steps, key time steps, or partial loop cycles; for target floating-point operations with low error sensitivity, the compensation execution frequency can be reduced or compensation can be disabled.
[0092] The compensation coverage is used to determine the computational scope in which the compensation method applies, including the target statement scope, loop scope, time progression scope, spatial region scope, or local summation chain scope. For state update operations, the compensation coverage can be the range of state variables that need to continuously maintain compensation values; for cumulative summation operations, the compensation coverage can be the range of the set of contribution items that need to be compensated and summed.
[0093] The compensation value retention period is used to determine how long the error compensation information is stored during program execution. For state update operations, the compensation value can be continuously stored across time steps, stage steps, or iteration steps to participate in subsequent state updates; for cumulative summation operations, the compensation value can be retained until the end of the current summation chain and output or reset after the cumulative calculation is completed.
[0094] In one implementation, for high-sensitivity floating-point operations, the compensation enable flag is set to the enabled state, the compensation execution frequency is set to each execution, the compensation coverage is set to the complete time progression process or the complete summation chain, and the corresponding compensation value is continuously saved; for medium-sensitivity floating-point operations, partial compensation is performed according to a preset compensation window, and the compensation value is updated or reset after the compensation window ends; for low-sensitivity floating-point operations, the compensation enable flag is turned off, or only error indicators are collected and compensation is re-enabled after the sensitivity level increases.
[0095] Step 43: Based on the determined compensation type and compensation intensity, integrate the compensation calculation into the target program execution flow, execute the compensation calculation process, and obtain the compensated result value; The compensation method in this embodiment does not perform post-processing correction on the final calculation result after the program execution is completed, but rather compensates for the intermediate calculation process during the execution of the target floating-point operation. Specifically, the compensation calculation process can be integrated by modifying the program representation corresponding to the target numerical calculation process, inserting compensation statements into the source code or intermediate representation, replacing the original single-precision floating-point operation with the compensation operation, or calling a preset compensation calculation function, runtime interface, or compensation operator.
[0096] After the above processing, when the target program performs the target floating-point operation, in addition to calculating the floating-point principal value result, it also synchronously generates, saves and feeds back error compensation information, so that the low-order error information generated by the rounding operation during the single-precision floating-point operation can continue to participate in the operation in the subsequent calculation process.
[0097] For state update operations, the first compensation method is executed; for summation operations, the second compensation method is executed. In a preferred embodiment, the compensation calculation can be performed by function calls, that is, by calling the compensation interface on the target statement. In another implementation, it can also be accomplished through preprocessing code expansion, template replacement, compiler rewriting, or inlining.
[0098] Preprocessing code expansion refers to expanding the original single-precision floating-point statements into code fragments containing main calculation variables, compensation variables, and error correction processes before the program is compiled, based on the target floating-point operation position and compensation strategy. This transforms the original one-time state update or cumulative summation process into a compensation calculation process that can record and backfill rounding errors.
[0099] Template replacement refers to pre-establishing state update type compensation templates and cumulative summation type compensation templates, and replacing ordinary floating-point statements with corresponding compensation templates according to the target operation type, variable type, error sensitivity level and compensation intensity parameters; Compiler rewriting refers to the process of converting a regular single-precision expression into a sequence of expressions that includes compensation variable maintenance, error updates, and result output, based on the target floating-point operation identifier information, at the compiler front-end, abstract syntax tree, or intermediate representation stage. Inline implementation refers to embedding the compensation logic directly into the target floating-point operation location through macro definitions, inline functions, or local code expansion, so that the compensation logic is executed continuously with the original floating-point statement, thereby reducing the additional overhead caused by independent function calls.
[0100] Furthermore, after the compensation calculation is completed, the compensated result value is output and continues to participate in subsequent numerical calculations. For state update operations, the output typically includes a new principal value and a new compensation value, where the principal value serves as the main input for subsequent calculations, and the compensation value is retained as a hidden or explicit error tracking quantity. For cumulative summation operations, the output is the cumulative sum after compensation, or the final compensation term can be retained for subsequent analysis.
[0101] In one alternative implementation, error analysis information can also be output, such as the difference before and after compensation, the size of the compensation term, and changes in error at key stages. This information can be used for subsequent performance tuning, threshold correction, or compensation range optimization.
[0102] To illustrate the implementation process and effect of the method in this embodiment, an experiment was conducted in a specific physical scenario. For the single-precision floating-point calculation process in the atmospheric numerical simulation program MPAS-Atmosphere, the hybrid compensation method proposed in this embodiment was used to compensate and modify two typical floating-point operations (state update type operation and accumulation summation type operation), and the results were compared with the uncompensated single-precision calculation results to verify the suppression effect of the method on the accumulation of floating-point errors in long-term numerical simulation. The specific explanation is as follows; The MPAS-Atmosphere atmospheric numerical simulation program was selected as the experimental object, and the typical floating-point calculation process in its dynamics module was compensated and modified.
[0103] First, based on the method of this embodiment, the floating-point operations in the dynamics module are structurally identified, and the calculation process is divided into state update type operations and accumulation summation type operations. Specifically, the calculation process in which multiple edge flux contribution terms are cyclically accumulated to form the divergence result during the calculation of horizontal divergence (h_divergence) is identified as an accumulation summation type operation. A compensation summation method is used to modify the accumulation process. By introducing a cumulative principal value and an error compensation term, the rounding error is recorded and fed back during each contribution term accumulation process.
[0104] For the calculation process of updating the density state variable rho_p based on the old state value and the current increment during time progression, it is identified as a state update type operation and modified by adopting a state update compensation method. By maintaining the principal value and compensation value, the low-order error information that has not entered the principal value during the single-precision update process is saved and fed back and utilized in subsequent time step updates.
[0105] The following experimental control group was set up: the original double-precision calculation method was used as the reference benchmark; the original single-precision calculation method was used as the uncompensated baseline; and the mixed compensation group was set up by using Neumaier compensation for cumulative summation operations and QDP algorithm compensation for state update operations, which is the compensation method of this embodiment.
[0106] Through the above experiments, the original single-precision MPAS-Atmosphere program, the individual summation compensation program, the individual state update compensation program, and the hybrid compensation program proposed in this embodiment were compared and tested. The double-precision calculation results were used as a reference benchmark. The accuracy improvement comparison analysis is shown in Table 1. Table 1 compares the MPAS-Atmosphere physical variable errors before and after using the hybrid compensation method in this embodiment;
[0107] Table 1 presents a comparison of the calculation errors of typical physical variables in the MPAS-Atmosphere program before and after applying the hybrid compensation method of this embodiment. RMSE (Root Mean Square Error) represents the root mean square error, used to measure the overall error level of the calculation result relative to the double-precision reference result; MAE (Mean Absolute Error) represents the mean absolute error, used to reflect the average deviation change of the calculation result. "Original Single Precision" refers to the single-precision calculation result without the compensation method of this embodiment, and "Hybrid Compensation" refers to the calculation result obtained after applying the method of this embodiment.
[0108] As shown in Table 1, compared with the original single-precision calculation results, the RMSE of all listed physical variables was reduced after adopting the hybrid compensation method of this embodiment. The RMSE reduction ranged from 7.18% to 52.77%, with an average reduction of 25.10%; the MAE reduction ranged from 7.25% to 11.16%, with an average reduction of 8.58%. The above results indicate that using matching compensation methods for different operational structures can effectively reduce the error accumulation in the single-precision floating-point calculation process.
[0109] Among them, the improvements in divergence, vertical velocity (w), and vorticity were the most significant. The RMSE of divergence decreased from 7.8576e-08 to 3.7113e-08, a reduction of 52.77%; the RMSE of vertical velocity decreased from 6.3811e-05 to 3.2531e-05, a reduction of 49.02%; and the RMSE of vorticity decreased from 2.9654e-07 to 1.9228e-07, a reduction of 35.16%. The RMSE reductions of these three variables all exceeded 30%, indicating that the hybrid compensation has a strong suppressive effect on the significant error deviations in the calculation of divergence, vertical velocity, and vorticity.
[0110] For variables such as kinetic energy (ke) and zonal velocity reconstruction (uReconstructZonal), the RMSE decreased by 25.38% and 24.67%, respectively; for zonal velocity (u), potential temperature (theta), density (rho), pressure, and meridional velocity reconstruction (uReconstructMeridional), the RMSE reduction ranged from 7.18% to 16.66%. The RMSE reductions for these three variables all exceeded 30%, indicating that the hybrid compensation has a strong suppressive effect on significant error deviations in the calculation of divergence, vertical velocity, and vorticity.
[0111] RMSE is more sensitive to larger error points, while MAE reflects the overall average deviation. In Table 1, the reduction percentages of RMSE and MAE for each variable are all positive, indicating that hybrid compensation reduces the overall average error while suppressing larger error deviations. Compared to the more concentrated reduction percentage of MAE, the reduction percentages of RMSE for different variables vary more significantly, indicating that the operational structure, numerical magnitude, degree of cancellation, and error propagation path of each variable are different, resulting in different levels of improvement from the compensation treatment.
[0112] Based on the above experimental results, after adopting the hybrid compensation method of this embodiment, the errors of all 10 physical variables listed in Table 1 were improved compared with the original single-precision calculation results, with an average reduction of RMSE of 25.10% and an average reduction of MAE of 8.58%. The experimental results show that, without changing the original mathematical model, physical equations, and overall calculation process, performing cumulative summation compensation and state update compensation according to the floating-point operation structure can simultaneously suppress local rounding errors and the propagation of errors in subsequent calculations, improve the consistency between single-precision scientific calculation results and double-precision reference results, and thus improve the simulation accuracy of the evolution process of key physical variables such as temperature, velocity, density, and pressure in atmospheric numerical simulation, and enhance the stability and reliability of physical state prediction during long-term time integration.
[0113] Example 2 Based on Embodiment 1, this embodiment provides an application of the error compensation processing method for single-precision floating-point program execution described in Embodiment 1. It is applied to scenarios involving a large number of iterative updates and floating-point calculation processes, such as atmospheric numerical prediction, multi-agent control, cooperative positioning and path planning of autonomous vehicles, aircraft or satellite combined navigation, robotic arm trajectory control, and motor motion control, to improve the stability and reliability of physical state prediction, position estimation, and control output. In atmospheric numerical prediction scenarios, state variables such as temperature, pressure, velocity, and density need to be updated through a large number of time steps. The rounding error generated by single-precision floating-point calculation is prone to accumulate continuously during state advancement and multi-physical process coupling, causing deviations in physical state evolution and affecting the stability and reliability of weather process simulation, climate trend analysis, and extreme weather prediction.
[0114] This embodiment uses wind speed prediction and temperature prediction in the atmospheric numerical prediction program as examples for illustration. However, for air pressure, humidity, density, pollutant concentration, ocean temperature, salinity, fluid velocity or control system state variables, as long as the program execution process includes single-precision floating-point state update operation or cumulative summation operation, the method of embodiment 1 can be used. For wind speed prediction scenarios, the first step is to acquire physically meaningful wind speed prediction input data, including the current horizontal wind speed components u and v, vertical velocity component w, pressure field, density field, temperature field, adjacency relationships between grid cells and grid edges, boundary conditions, time step, and edge flux, surface flux, or directional flux data. The acquired data is then used by existing atmospheric numerical prediction programs to calculate pressure gradient, momentum flux, flux divergence, dissipation correction, and external force correction, and to update the wind speed state for the next time step.
[0115] For grid cells The horizontal wind speed state update can be represented as: ; ; in, and The old wind speed component at the current moment, and To predict the wind speed component for the next time step, For time step, and The rate of change of wind speed is formed by pressure gradient, flux divergence, dissipation term, boundary correction term, or other physical processes. Flux divergence can be formed by summing multiple edge contributions, for example: ; in, To be compatible with grid cells Associated edges or faces, For direction symbols, This is the corresponding flux contribution item.
[0116] During the execution of the iterative wind speed prediction program, step 1 of Example 1 is executed, performing a static scan of the time progression process, momentum tendency calculation process, flux divergence calculation process, and edge contribution accumulation process in the wind speed prediction program. This scan retrieves single-precision floating-point assignment statements, loop structures, variable read / write relationships, and function call relationships, constructing the corresponding structured program representation. Step 2 is executed, which involves writing back the old wind speed value, incremental term, and result, and continuing into subsequent time steps. or Update statements are identified as state update operations; operations that aggregate multiple edge flux contributions to the same divergence variable through a loop are identified as cumulative summation operations. Step 3 is executed: for wind speed state update operations, old wind speed values, wind speed increments, update counts, variable write-back counts, cross-time step save counts, and subsequent usage counts are collected; magnitude difference, update frequency, write-back propagation, and subsequent dependency indicators are calculated. For flux divergence cumulative summation operations, the number of edge contributions, numerical range, positive and negative term distribution, absolute value sum, algebraic sum, and subsequent usage of the cumulative result are collected; the number of contribution items, magnitude dispersion, sign mixing, local cancellation, and cumulative result propagation indicators are calculated. The scoring distribution, propagation path, and compensation resource budget error sensitivity level are considered.
[0117] Step 4 involves selecting the first compensation method for state-updated wind speed calculations and the second compensation method for flux divergence accumulation calculations. High-sensitivity calculations undergo full compensation on each execution; medium-sensitivity calculations only perform compensation at critical time steps, critical cycle segments, or critical grid regions; and low-sensitivity calculations maintain the original single-precision calculation or only monitor indicators. The final output is the compensated wind speed prediction for the next time step. and This reduces the loss of effective numbers caused by small incremental updates, positive and negative offsetting of edge flux, and cumulative propagation over multiple time steps.
[0118] In temperature prediction scenarios, data such as current temperature field, wind speed field, air pressure field, humidity field, radiation input, surface heat flux, boundary temperature conditions, and grid adjacency relationships are acquired. For each grid cell... In the temperature prediction program, the temperature at the next time step can be expressed as: ; in, This is the old temperature value. This refers to the temperature change caused by convective transport. This is a correction factor generated by spatial difference, flux difference, or diffusion process. Source and sink corrections for radiation, surface heat flux, heating, cooling, or boundary conditions.
[0119] After obtaining the core single-precision floating-point statements in the processes of temperature time progression, temperature transport, diffusion term, source-sink term, and neighborhood flux accumulation, The statement type is identified as a state update operation, which combines the temperature difference, flux contribution, or physical process contribution of multiple adjacent grids through looping or weighted combination. , or The process is identified as an accumulation and summation operation.
[0120] For temperature state update operations, the error sensitivity level is calculated based on the old temperature value, temperature increment, update frequency, and propagation relationship. For example, when the old temperature is approximately 300K and the single-step increment is approximately 0.001K, there is a risk of low-bit loss during single-precision alignment. For the cumulative summation process of temperature corrections, the error sensitivity is calculated based on the number of contributing terms, their magnitude distribution, the ratio of positive to negative terms, and the degree of local cancellation. Depending on the operation type, either the first or second compensation method is selected. Based on the obtained error sensitivity level, the compensation frequency and coverage are controlled, and the finally compensated temperature prediction value is output. .
[0121] Through the above applications, the method of this embodiment can take corresponding compensation measures for different types of single-precision floating-point calculation errors in atmospheric numerical prediction. For state update type operations in wind speed prediction, by retaining and feeding back the low-order information lost during rounding in the wind speed state update process, the cumulative deviation of small increments in the multi-time step process is reduced; for accumulation and summation type operations in the convergence process of multi-source contributions such as flux divergence and momentum flux, by maintaining the error compensation term in the summation process, the error propagation caused by continuous rounding and positive and negative cancellation in the accumulation of edge flux, surface flux, and directional flux is reduced.
[0122] Furthermore, in the temperature prediction process, by classifying and compensating the temperature state update process and the calculation processes such as convection transport, diffusion correction, and source-sink term superposition, it is possible to reduce the effective digital loss of temperature increment, spatial discretization correction, and multi-physical process contribution terms in the single-precision calculation process, thereby improving the stability of the temperature field evolution process over time.
[0123] Therefore, when the method of Example 1 is applied to the atmospheric numerical prediction scenario, while keeping the original physical equations, numerical discretization methods and calculation processes basically unchanged, it can reduce the numerical deviation of key physical variables such as wind speed and temperature in the long-term integration process and improve the stability and reliability of atmospheric state variable prediction results.
[0124] In this embodiment, taking the UAV formation positioning and following control scenario as an example, the error compensation processing method for single-precision floating-point program execution described in Embodiment 1 is illustrated in the multi-agent control system. During the formation positioning and follow-up control of UAVs, the state information of the leader UAV and the follower UAVs is acquired, including UAV position, speed, attitude information, preset formation relative position constraints, control cycle, communication adjacency relationship between UAVs, as well as position correction, speed correction and external disturbance correction output by global navigation satellite system, inertial measurement unit, visual positioning device or ranging device.
[0125] Within each control cycle, the follower drone calculates position error, velocity error, and control input based on its own status, the leader drone's status, and the status of neighboring drones, and updates its own position, velocity, and attitude status based on the control input.
[0126] For the The follower drone, in the Within each control cycle, its target position error relative to the leader can be expressed as: ; in, For the location of the leader's drone, For the first The location of a follower drone This is the preset relative position offset.
[0127] When the control input also needs to incorporate the states of multiple neighboring UAVs, the control quantity can be represented as a combination of multiple contribution terms: ; in, In order to be with the first A set of neighboring drones that interact with each other. For collaborative weights, To preset relative position, and To control the gain, Additional control quantities formed for positioning correction, obstacle avoidance correction, or external disturbance correction.
[0128] Based on the calculated control input, the speed and position of the UAV are updated in discrete time: ; ; in, To control the cycle, Indicates the first The following drone was in Speed status of each control cycle; Indicates the first The following drone was in Position status of each control cycle; After obtaining the single-precision floating-point statements in the above positioning, control rate calculation, and state update program, step 2 of Example 1 is executed to aggregate multiple adjacent UAV contribution items, multiple sensor correction items, or multiple control action items into a single unit. The operation is identified as an accumulation summation operation; the operation of adding the old position, old velocity or old attitude to the current control increment and writing it back to the state variable is identified as a state update operation.
[0129] For the identified target floating-point operations, the error sensitivity level is further determined. Based on the magnitude difference, update frequency, number of variable write-backs, number of contributing items, symbol distribution, degree of local cancellation, and subsequent propagation relationship, the corresponding operation is determined to be high, medium, or low error sensitivity level.
[0130] For state update operations such as UAV position, velocity, and attitude, the first compensation method is adopted. By maintaining the main state value and error compensation value, the low-order error information caused by single-precision rounding during the state update process is retained and fed back for use in subsequent control cycles.
[0131] For cumulative summation operations formed by the combined control quantity, sensor fusion quantity, and multiple correction terms, a second compensation method is adopted to maintain the error compensation term during the summation of control quantities, thereby reducing the error loss caused by continuous accumulation and the cancellation of positive and negative contributions.
[0132] Meanwhile, the frequency and coverage of compensation are adjusted according to the error sensitivity level: for high-sensitivity operations, compensation is performed in every control cycle; for medium-sensitivity operations, compensation is performed in critical control cycles or critical control links; for low-sensitivity operations, the original single-precision calculation is maintained or only error monitoring is performed.
[0133] Final output: compensated drone position ,speed The corresponding control commands reduce state drift and control errors caused by single-precision floating-point rounding during UAV formation control, and improve the stability and reliability of multi-UAV cooperative positioning and following control without the need for overall switching to double-precision calculation.
[0134] The method in this embodiment can also be applied to scenarios such as multi-mobile robot formation control, cooperative positioning and path tracking of autonomous vehicles, aircraft or satellite combined navigation, robotic arm trajectory control, and motor motion control.
[0135] In scenarios involving multiple mobile robots or autonomous vehicles, continuous updates of position, velocity, and heading angle can be identified as state update operations, and multiple corrections from neighboring entities, road constraints, obstacle avoidance modules, and positioning sensors can be aggregated and identified as summation operations, with corresponding compensations performed for each.
[0136] In aircraft or satellite integrated navigation scenarios, the observed measurements and residuals output by satellite positioning, inertial navigation, visual navigation or ranging devices can be collected. The iterative update process of position, velocity and attitude and the accumulation process of multi-source observation residuals can be classified by computational structure and the error sensitivity level can be determined. In robotic arm or motor motion control scenarios, corresponding compensations can be implemented by updating the joint position, rotational speed, and torque, as well as by combining multiple feedback terms, feedforward terms, and disturbance compensation terms. In all the above scenarios, the compensation type and intensity are determined using the method in Example 1 to obtain the compensated positioning results, navigation status, or control output.
[0137] Example 3 Based on Embodiment 1, this embodiment provides an error compensation processing device for single-precision floating-point program execution, such as... Figure 3 As shown, it includes: The acquisition module is configured to acquire the program representation corresponding to the target numerical calculation process for the single-precision floating-point program execution process of the target application scenario. The operation structure identification module is configured to classify the operation structure of the target floating-point operation in the program representation based on the operation expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, and obtain the operation structure type corresponding to the target floating-point operation. The error feature identification module is configured to determine the error features of each type of target floating-point operation and obtain the error sensitivity level of each target floating-point operation. The compensation module is configured to select the appropriate compensation method based on the operational structure type of the target floating-point operation and determine the compensation intensity based on its error sensitivity level, thereby generating a matching compensation strategy; and to perform compensation calculations according to the compensation strategy to obtain the result value of the compensated target calculation process.
[0138] The error compensation processing device for single-precision floating-point program execution in this embodiment is a computing device or system capable of running program analysis and compensation calculation logic. It can be a server, terminal device, embedded computing device, parallel computing node, or other electronic device with data processing capabilities. This error compensation processing device may include a processor, a memory, and a computer program stored in the memory and executable by the processor. When the processor executes the computer program, it implements the functions of an acquisition module, an operational structure identification module, an error feature identification module, and a compensation module.
[0139] It should be noted that each module in this embodiment corresponds one-to-one with each step in embodiment 1, and their specific implementation process is the same, so it will not be repeated here.
[0140] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0141] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. An error compensation method for single-precision floating-point program execution, characterized in that, Includes the following steps: For the execution process of a single-precision floating-point program in the target application scenario, obtain the program representation corresponding to the target numerical calculation process; Based on the operational expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, the operational structure of the target floating-point operation in the program representation is classified to obtain the operational structure type corresponding to the target floating-point operation. For each type of target floating-point operation, error characteristics are determined to obtain the error sensitivity level of each target floating-point operation; The appropriate compensation method is selected based on the type of the target floating-point operation structure, and the compensation intensity is determined based on its error sensitivity level, thereby generating a matching compensation strategy. The compensation calculation is performed according to the compensation strategy to obtain the result value of the target calculation process after compensation. The output result of the target application scenario prediction or control process is updated based on the compensation result value.
2. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, Target application scenarios include atmospheric numerical prediction, multi-agent cooperative control, cooperative localization and path planning for autonomous vehicles, aircraft or satellite combined navigation, robotic arm trajectory control, and motor motion control.
3. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, The method for obtaining the program representation corresponding to the target numerical calculation process includes the following steps: Static scanning is performed on the target program for the target numerical calculation process to identify single-precision floating-point assignment statements in the target program. Each single-precision floating-point assignment statement is used as a statement-level analysis unit. For each statement-level analysis unit, update frequency characteristics are calculated based on variable update data; For each statement-level analysis unit, loop accumulation features are extracted based on loop execution relationships; For each statement-level analysis unit, state write-back features are extracted based on variable usage relationships; For the right-hand expression in a single-precision floating-point assignment statement, multi-source contribution convergence features are extracted based on the data source of the expression. Based on the extracted update frequency features, cyclic accumulation features, state write-back features, and multi-source contribution convergence features, the propagation association between each statement-level analysis unit is established according to the variable definition relationship and variable usage relationship. Each single-precision floating-point operation statement is connected according to the variable propagation relationship to form a structured program representation that includes calculation statements, variable dependencies, and execution propagation paths.
4. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, The target floating-point operations are divided into state update operations and accumulation summation operations; State update operations are operations in which the new value of a variable is obtained by adding the increment to the old value. Target floating-point operations that satisfy the following characteristics are classified as state update operations: Target floating-point operations are single-precision floating-point operations that assign or update target variables or target storage locations; The new value of the target variable is the sum of the old value of the target variable or the equivalent stored value corresponding to the target variable and the increment term; The updated results of the target variable are reused in subsequent time steps, subsequent iterations, or subsequent sub-steps; The auxiliary judgment conditions for state update type operation are: the numerical magnitude of the increment term relative to the old value is less than a preset ratio threshold; the new value of the target variable is written back to the original variable or the corresponding state storage location; the target floating-point operation is located in the program structure corresponding to time advancement, stage step update, state quantity correction or iterative write-back.
5. The error compensation processing method for single-precision floating-point program execution as described in claim 4, characterized in that, Target floating-point operations that satisfy the following characteristics are classified as summation operations: The target floating-point operation is a single-precision floating-point operation that updates the accumulated variable or the accumulated storage location; The current value of the cumulative variable or cumulative storage location is recalculated in the expression on the right and added to the newly added contribution item to obtain the updated cumulative value; The auxiliary judgment condition for cumulative summation operations is: the number of newly added contribution items participating in the accumulation is greater than the preset number of items threshold; The update chain length of the cumulative variable is greater than the preset length threshold; the numerical relationship between the newly added contribution item and the current cumulative value is not fixed; the newly added contribution item has different data sources or calculation sources in different loop steps or iteration steps.
6. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, The method for classifying the operational structures of target floating-point operations in program representation includes the following steps: The structural features corresponding to the target floating-point operations in the program representation are extracted and encoded to obtain a structural feature vector, including target variable self-reference features, increment term features, loop triggering features, variable write-back features, multi-source input features, and contribution term convergence features; The self-reference feature, increment feature, loop triggering feature, and variable write-back feature are weighted and summed to obtain the state update structure score. The cumulative summation structure score is obtained by weighting and summing the cyclic trigger features, multi-source input features, contribution item aggregation features, and the number of newly added contribution items. ; Based on the obtained state-updated structure score Sum-of-the-products type scoring The size and difference determine the classification results of the operation structure type, including state update type operation, cumulative summation type operation and operation to be confirmed; For confirmation operations, the state update structure is scored based on the variable propagation relationship, loop execution relationship, and variable write-back relationship corresponding to the target floating-point operation. Sum-of-the-products type scoring The size is adjusted and judged to determine the type of operation structure.
7. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, For each target floating-point operation, error characteristics are determined to obtain the error sensitivity level of each target floating-point operation. The specific process includes the following steps: Based on the error sources of different types of target floating-point operations, error-related data are extracted to construct error-sensitive indicators; The error sensitivity scores are obtained by weighted summation of the corresponding error sensitivity indices for different computational structures. The error sensitivity level is determined by using a threshold judgment method based on the error sensitivity score.
8. The error compensation processing method for single-precision floating-point program execution as described in claim 1, characterized in that, The compensation strategy is determined based on the target floating-point operation structure type and error sensitivity level. Compensation is then performed during the operation execution process by rewriting the target statement or calling the corresponding compensation interface. The result of the compensated target calculation process includes the following steps: Step 41: Select the corresponding compensation method according to the type of operation structure; When the target floating-point operation is identified as a state update operation, the first compensation method is selected: read the old state master value and the corresponding compensation value, update it in combination with the current increment item, obtain the new master value and the new compensation value, and write the new master value and the new compensation value back to the storage location; When the target floating-point operation is identified as an accumulation and summation operation, the second compensation method is selected; the cumulative amount and compensation item are initialized, each contribution item is read in a loop, the updated cumulative value is calculated and the compensation item is updated based on the current cumulative amount, newly added item and compensation item, until all contribution items are accumulated and the compensated cumulative result is obtained; Step 42: Determine the compensation intensity corresponding to the target floating-point operation based on the error sensitivity level; the compensation intensity includes the compensation enable flag, compensation execution frequency, compensation coverage, and compensation value retention period; Step 43: Based on the determined compensation type and compensation intensity, integrate the compensation calculation into the target program execution flow, execute the compensation calculation process, and obtain the compensated result value.
9. The error compensation processing method for single-precision floating-point program execution as described in claim 8, characterized in that, Based on the error sensitivity level, determine the corresponding compensation strength for the target floating-point operation, specifically: For floating-point operations on high-sensitivity targets, the compensation enable flag is set to enabled, the compensation execution frequency is set to each execution, the compensation coverage is set to the complete time progression process or the complete summation chain, and the corresponding compensation value is continuously saved. For floating-point operations of targets with medium sensitivity level, partial compensation is performed according to the preset compensation window, and the compensation value is updated or reset after the compensation window ends. For floating-point operations with low sensitivity levels, disable the compensation enable flag, or only collect error indicators and re-enable compensation after the sensitivity level increases.
10. An error compensation processing device for single-precision floating-point program execution, characterized in that, include: The acquisition module is configured to acquire the program representation corresponding to the target numerical calculation process for the single-precision floating-point program execution process of the target application scenario. The operation structure identification module is configured to classify the operation structure of the target floating-point operation in the program representation based on the operation expression form, data dependency relationship, loop execution relationship and result write-back relationship in the program representation, and obtain the operation structure type corresponding to the target floating-point operation. The error feature identification module is configured to determine the error features of each type of target floating-point operation and obtain the error sensitivity level of each target floating-point operation. The compensation module is configured to select the appropriate compensation method based on the type of the target floating-point operation structure and determine the compensation intensity based on its error sensitivity level, thereby generating a matching compensation strategy. The compensation calculation is performed according to the compensation strategy to obtain the result value of the target calculation process after compensation. The output results in the prediction or control process of the target application scenario are updated based on the compensation value results.