CN111104091B - Detection and conversion method for precision specific calculation in dynamic floating point error analysis - Google Patents
Detection and conversion method for precision specific calculation in dynamic floating point error analysis Download PDFInfo
- Publication number
- CN111104091B CN111104091B CN201911275775.9A CN201911275775A CN111104091B CN 111104091 B CN111104091 B CN 111104091B CN 201911275775 A CN201911275775 A CN 201911275775A CN 111104091 B CN111104091 B CN 111104091B
- Authority
- CN
- China
- Prior art keywords
- precision
- instruction
- operand
- execution
- floating point
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/483—Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computational Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Nonlinear Science (AREA)
- General Engineering & Computer Science (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a detection and conversion method for precision specific calculation in dynamic floating point error analysis, which can effectively improve the accuracy of a high-precision execution result and the accuracy of error analysis. The method comprises the following steps: detecting bit operation and converting the bit operation from low-precision program execution to high-precision program execution in a mode of monitoring floating point instructions and operand addresses; detecting the multiplication operation by monitoring a floating point instruction execution sequence of the multiplication operation, and completing the conversion of the multiplication operation from low-precision program execution to high-precision program execution according to the floating point instruction execution sequence of the multiplication operation; detecting the rounding operation by monitoring the operation sequence of addition and subtraction and the corresponding operand, and completing the conversion of the rounding operation from the execution of a low-precision program to the execution of a high-precision program; the specific constant is detected in a constant value matching mode, and the low-precision specific constant is converted into an accurate value of the corresponding constant under high precision. The invention relates to the technical field of computer and software engineering.
Description
Technical Field
The invention relates to the technical field of computer and software engineering, in particular to a detection and conversion method for precision specific calculation in dynamic floating point error analysis.
Background
Due to the limitations of computer memory space and word size, most computers perform scientific calculations (such as numerical nuclear reactor simulation programs) under the Institute of Electrical and Electronics Engineers (IEEE)754 floating point arithmetic standard, rounding errors are inevitable in floating point calculations, and the cumulative effect of rounding errors may have serious effects on the calculation results, even catastrophic results. Error Analysis (Error Analysis) is a technical means for analyzing, estimating, locating, repairing the calculation errors in the scientific calculation program.
The first prior art is as follows: dynamic error analysis methods (e.g., FpDebaug, HerbGrind, et al) (Benz F, Hildebrandt A, Hack S.A. dynamic program analysis to fine flow-point acutacity schemes [ C]//ACM SIGPLAN Notices.ACM,2012,47(6):453-462.)(Sanchez-Stern A,Panchekha P,Lerner S,et al.Finding root causes of floating point error[C]Acm, 2018, 53(4): 256-: operand) to be executed in a multi-precision floating-point library (MPFR), and all floating-point instructions and corresponding operands can be executed synchronously at high precision, so that a high-precision program is obtained. The value of variable x (i.e., operand x) in the original program is fp(x) (hereinafter referred to as Origin Value), the Value of the variable x in the MPFR high-precision program is f (x) (hereinafter referred to as high-precision calculation result, when f (x) is 0, in order to ensure that the denominator is not 0, the parameter δ is 10-30) The relative error Related error (x) of the variable x is calculated by equation (1):
however, only by monitoring the floating point instruction and synchronously converting the floating point instruction into a high-precision program, the result of the variable x at high precision is not necessarily an accurate result, which may result in inaccurate f (x), and finally, the error of the variable relative error calculation affects the accuracy of the error analysis.
The second prior art is: ran Wang (Wang R, zhou D, He X, et al, detection and localization of precision-localization errors for measurement-localization errors C// Proceedings of the 201624 th ACM sigoft International Symposium on foundation of Software engineering.acm, 2016:619-630.) et al propose a detection method based on precision-specific computation of two heuristic rules, and "set boundaries" before and after the precision-specific computation respectively by means of static program rewriting. The method can be summarized as that floating point instructions and corresponding floating point operands are still synchronized to be executed under high precision outside the boundary, and high-precision variables are converted into low-precision execution original programs inside the boundary, namely precision specific calculation is still executed under original precision, so that the accuracy of the precision specific calculation is ensured. However, this method has three prominent problems:
1) the high-precision execution results are inaccurate, and not all operations are converted to be executed with high precision, but only a part which does not contain precision-specific calculation is selected to be converted to high precision, and the original precision is still used by the precision-specific calculation.
2) The high-precision execution result is possibly incorrect, the detection mode of the precision specific calculation is based on two heuristic rules, the time cost is large (the detection time is more than 200 times of the execution time of the original program), and the false alarm rate and the false missing rate are high.
3) The original program execution result may be inaccurate, the first step of the operation within the boundary is to perform the conversion of the variable used in the precision-specific calculation from high precision to low precision, and the variable value in the original program after the conversion may be incorrect due to the incorrect corresponding variable value at high precision.
Disclosure of Invention
The invention aims to solve the technical problem of providing a detection and conversion method for precision specific calculation in dynamic floating point error analysis, so as to solve the problems of low accuracy of high-precision execution results and low accuracy of error floating point analysis in the prior art.
To solve the above technical problem, an embodiment of the present invention provides a method for detecting and converting a median operation in a dynamic floating point error analysis, including:
acquiring a current instruction and an operand corresponding to the current instruction, inquiring whether the operand exists in a HashMap, and if the operand does not exist, inserting the operand into the HashMap, wherein the instruction is a floating point instruction, the operand is a floating point operand, and the HashMap represents HashMap and is used for storing a high-precision execution result and a write-in address of the operand;
judging whether the current instruction is a write instruction or not, if so, inquiring whether addr or (addr-4) exists in the HashMap or not if the write instruction is the write instruction and the write address of the operand is addr;
if yes, converting the high-order 32 bits of the operand to MPFR format floating point numbers under high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of mantissa in MPFR format at high precision, where MPFR represents a multi-precision floating-point library, completing the conversion of bit operations from low precision program execution to high precision program execution.
Further, if the operand exists, converting the upper 32 bits of the operand to MPFR format floating point number under high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of the MPFR format with high precision, and the conversion of the bit operation from the low precision program execution to the high precision program execution is accomplished by:
if yes, dividing and extracting sign bit s, exponent bit ex and mantissa bit sig of the operand according to IEEE754 floating point arithmetic standard, and assigning sign ms, exponent mex and mantissa msig of floating point representation value of MPFR under the high precision of the operand according to the extraction result; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of the MPFR format at high precision, completing the conversion of the bit operation from low precision program execution to high precision program execution.
The embodiment of the invention also provides a method for detecting and converting multiplication operation in dynamic floating point error analysis, which comprises the following steps:
acquiring an execution sequence of an instruction and an operand corresponding to the execution sequence of the instruction, and detecting whether the current operation is a multiplication operation or not according to the acquired execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction; the instruction is a floating point instruction, and the operand is a floating point operand;
and if the operation is the multiplication operation, determining the precision of the operand, executing the execution sequence according to the determined precision of the operand, and finishing the conversion from the execution of the low-precision program to the execution of the high-precision program of the multiplication operation.
Further, the obtaining the execution sequence of the instruction and the operand corresponding thereto, and detecting whether the current operation is a multiplication operation according to the obtained execution sequence of the instruction and the operand corresponding thereto includes:
b1, initializing operation state as the first identifier;
b2, judging whether the current instruction is a multiply instruction, if so, one operand is 227+1, setting the state as a second identifier, and recording another operand as mularg 2;
b3, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtraction number is mularg2, if so, setting the state as a third identifier, otherwise, setting the state as a first identifier, and deleting an operand mularg 2;
b4, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtracted number is factor + mularg2, if so, judging whether the state is a third identifier; where factor represents operand precision.
Further, if the multiplication operation is performed, determining operand precision, and executing the execution sequence according to the determined operand precision, the conversion of the multiplication operation from the low-precision program execution to the high-precision program execution includes:
b5, if the decrement is factor + mularg2, it indicates that the multiplication instruction in B2, the subtraction instruction in B3, and the subtraction instruction in B4 are the execution sequence of the multiplication operation, execute step B6, otherwise, set state to the first flag, and delete operand mularg 2; b6, according toAnd updating the factor, executing the multiplication instruction in B2, the subtraction instruction in B3 and the subtraction instruction in B4 according to the updated factor, and completing the conversion from low-precision program execution to high-precision program execution of the multiplication operation, wherein p represents the high-precision program execution precision.
The embodiment of the invention also provides a method for detecting and converting rounding operation in dynamic floating point error analysis, which comprises the following steps:
c1, determining whether the current instruction is an add instruction, if yes, recording two operands: addarg1 and addarg 2; the instruction is a floating point instruction, and the operand is a floating point operand;
c2, determining whether the next instruction is a subtraction instruction, if so, determining whether the subtraction number is addarg1 or addarg2, and if so, indicating that the addition instruction in C1 and the subtraction instruction in C2 are the execution sequence of the rounding operation, then performing step C3;
and C3, converting the other operand of the non-reduction number into low precision, executing an addition instruction of C1 and a subtraction instruction of C2, and completing the conversion of the rounding operation from the low-precision program execution to the high-precision program execution.
The embodiment of the invention also provides a method for detecting and converting the precision specific constant in the dynamic floating point error analysis, which comprises the following steps:
initializing a HashMap, wherein key value pairs in the HashMap are low-precision memory binary data and high-precision constant values of a plurality of low-precision specific constants; the instruction is a floating point instruction, the operand is a floating point operand, and HashMap represents HashMap;
judging whether the current instruction is a reading instruction or not, judging whether the data reading mode is constant reading or not, and inquiring whether the binary data of the current constant in the memory is in the HashMap or not if the current instruction is the reading instruction and the data reading mode is constant reading;
if the current constant is in the HashMap, assigning the corresponding high-precision constant value in the HashMap to the high-precision variable corresponding to the current constant, otherwise, synchronizing the current constant operation result of the original program to the high-precision variable corresponding to the current constant, and realizing the conversion of the precision specific constant from the execution of the low-precision program to the execution of the high-precision program.
The technical scheme of the invention has the following beneficial effects:
according to the scheme, the type of the precision specific calculation can be accurately detected, the original program can be correctly converted to the high precision for execution, so that the result of the operand calculation under the high precision can be closer to an accurate value, the variable calculation result under the low precision is still correct, and the accuracy of the error floating point analysis of the dynamic error analysis method by improving the program precision is improved.
Drawings
FIG. 1 is a schematic flow chart illustrating a method for detecting and converting a bit operation in a dynamic floating point error analysis according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a process of converting the upper 32 bits of the operand into the floating point number in the MPFR format with high precision according to IEEE754 according to an embodiment of the present invention.
Detailed Description
In order to make the technical problems, technical solutions and advantages of the present invention more apparent, the following detailed description is given with reference to the accompanying drawings and specific embodiments.
The invention provides a detection and conversion method for precision specific calculation in dynamic floating point error analysis, aiming at the problems of low accuracy of the existing high-precision execution result and low accuracy of the error floating point analysis.
In this embodiment, in order to better perform the detection and conversion method of Precision-Specific calculation, the types of known Precision-Specific Calculations (PSCs) in the dynamic floating point error analysis method are counted, and are classified into the following four types:
1) bit operation
2) Multiplication operations
3) Rounding operations
4) Precision specific constant
In this embodiment, four types of precision-specific calculation types, namely, a bit operation, a multiplication operation, a rounding operation, and a precision-specific constant, are analyzed, and corresponding detection and conversion methods are respectively provided, which are sequentially the first embodiment, the second embodiment, the third embodiment, and the fourth embodiment.
It is also to be emphasized that:
the low-precision program refers to an original program, and the high-precision program refers to an MPFR program corresponding to the original program.
Example one
As shown in fig. 1, a method for detecting and converting a median operation in a dynamic floating point error analysis according to an embodiment of the present invention includes:
s101, acquiring a current instruction and an operand corresponding to the current instruction, inquiring whether the operand exists in a HashMap, and if the operand does not exist, inserting the operand into the HashMap, wherein the instruction is a floating point instruction, the operand is a floating point operand, and the HashMap represents HashMap and is used for storing information such as a high-precision execution result and a write-in address of the operand;
s102, judging whether the current instruction is a write instruction, if so, inquiring whether addr or (addr-4) exists in the HashMap;
s103, if the floating point number exists, converting the high-order 32 bits of the operand into the MPFR format floating point number under high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of mantissa in MPFR format at high precision, where MPFR represents a multi-precision floating-point library, completing the conversion of bit operations from low precision program execution to high precision program execution.
The detection and conversion method for precision specific calculation in dynamic floating point error analysis, provided by the embodiment of the invention, comprises the steps of obtaining a current instruction and an operand corresponding to the current instruction, inquiring whether the operand exists in a HashMap, and inserting the operand into the HashMap if the operand does not exist; judging whether the current instruction is a write instruction or not, if so, inquiring whether addr or (addr-4) exists in the HashMap or not if the write instruction is the write instruction and the write address of the operand is addr; if yes, converting the high-order 32 bits of the operand to MPFR format floating point numbers under high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of the MPFR format at high precision, completing the conversion of the bit operation from low precision program execution to high precision program execution. Therefore, bit operation can be accurately detected and an original program can be correctly converted to high precision for execution, so that the result of operand calculation under high precision can be closer to an accurate value, and the variable calculation result under low precision is still correct, and the accuracy of the error floating point analysis of the dynamic error analysis method by improving the program precision is improved.
In this embodiment, before S101, an empty HashMap needs to be initialized, and is used to store information such as a high-precision execution result and a write address when an operand is dynamically run.
In this embodiment, if the floating point number exists, the upper 32 bits of the operand are converted into the floating point number in the MPFR format with high precision; otherwise, converting the lower 32 bits of the operand into 21 to 53 bits of the mantissa in MPFR format at high precision, and the conversion of the bit operation from the low-precision program execution to the high-precision program execution (S103) includes:
s1031, if yes, indicating that the write instruction is the high-order 32 bits of the modified operand, and jumping to S1032 for execution; otherwise, the write instruction is the lower 32 bits of the modified operand, and the execution is skipped to S1033, and at this time, the detection of bit operation is completed;
s1032, segmenting and extracting the upper 32 bits of the operand according to IEEE754 floating point arithmetic standard, assigning a sign bit S, an exponent bit ex, and a mantissa bit sig of a floating point representation value of MPFR of the operand at high precision according to an extraction result, as shown in fig. 2, ms represents a sign part of MPFR, and when the sign S of the original floating point operand is 0, ms is set to 0xfffffff, and when the sign bit is 1, ms is set to 0x 1; mex represents the exponent part of MPFR, the exponent part of the original floating point operand is processed according to the IEEE754 rule to obtain an exponent value (ex-0x3FF +1), and the exponent value is assigned to mex; the MPFR _ dl is a self-defined part, because the MPFR mantissa is stored in the shaping array msig, for the small-end storage mode, the floating point operand has 32 high bits, and only the first 21 bits in the msig [ pos ] are modified, and pos is an index subscript of the last element in the array, so that the msig [ pos ] is shifted left by 21 to obtain a result of shifting left by 21 bits with 11 low bits, and then the lower 11 bits need to be shifted right for restoration; next, msig [ pos ] is modified: the high 21 bits of msig [ pos ] are set according to the mantissa of sig, and added with the right-shifted 21 bits of _ mpfr _ dl saved in the previous step to restore the low 11-bit data.
S1033, the low-order 32 bits (all mantissa bits sig) of the operand are converted into mantissas 21 to 53 bits in MPFR format at high precision, completing the conversion of the bit operation from low-precision program execution to high-precision program execution.
In this embodiment, the bit operations are only concerned with bit operations related to floating point operands. For the particularity of the bit operation operand (related to the floating point number), the detection of the bit operation and the conversion of the bit operation from the execution of a low-precision program to the execution of a high-precision program are completed by monitoring the floating point operation instruction plus the operand address (S101-S103), so that all the operations on the floating point operand can be synchronously executed with high precision.
Example two
The method for detecting and converting multiplication operation in dynamic floating point error analysis provided by the embodiment of the invention comprises the following steps:
acquiring an execution sequence of an instruction and an operand corresponding to the execution sequence of the instruction, and detecting whether the current operation is a multiplication operation or not according to the acquired execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction; the instruction is a floating point instruction, and the operand is a floating point operand;
and if the operation is the multiplication operation, determining the precision of the operand, executing the execution sequence according to the determined precision of the operand, and finishing the conversion from the execution of the low-precision program to the execution of the high-precision program of the multiplication operation.
The method for detecting and converting the multiplication operation in the dynamic floating point error analysis obtains the execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction, and detects whether the current operation is the multiplication operation according to the obtained execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction; and if the operation is the multiplication operation, determining the precision of the operand, executing the execution sequence according to the determined precision of the operand, and finishing the conversion from the execution of the low-precision program to the execution of the high-precision program of the multiplication operation. Therefore, multiplication operation can be accurately detected and an original program can be correctly converted to high precision for execution, so that the result of operand calculation under high precision can be closer to an accurate value, and the variable calculation result under low precision is still correct, and the accuracy of the error floating point analysis of the dynamic error analysis method by improving the program precision is improved.
In an embodiment of the method for detecting and converting a multiply operation in dynamic floating point error analysis, the obtaining an execution sequence of an instruction and an operand corresponding to the execution sequence of the instruction, and detecting whether a current operation is a multiply operation according to the obtained execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction further includes:
b1, initializing operation state as the first identifier;
b2, judging whether the current instruction is a multiply instruction, if so, one operand is 227+1, setting the state as a second identifier, and recording another operand as mularg 2; if neither operand is 227+1, set state to the first flag (e.g., 0), exiting the detection and conversion of the multiply operation;
b3, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtraction number is mularg2, if so, setting the state as a third identifier, otherwise, setting the state as a first identifier, and deleting an operand mularg 2;
b4, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtracted number is factor + mularg2, if so, judging whether the state is a third identifier; where factor represents operand precision.
In this embodiment, for example, the first identifier may be 0, the second identifier may be 1, and the third identifier may be 2, and in practical application, values of the first identifier, the second identifier, and the third identifier may be determined according to an actual situation.
In an embodiment of the foregoing method for detecting and converting a multiply operation in dynamic floating point error analysis, further, if the multiply operation is performed, determining operand precision, and executing the execution sequence according to the determined operand precision, where the converting of the multiply operation from low-precision program execution to high-precision program execution includes:
b5, if the decrement is factor + mularg2, it indicates that the multiplication instruction in B2, the subtraction instruction in B3, and the subtraction instruction in B4 are the execution sequence of the multiplication operation, execute step B6, otherwise, set state to the first flag, and delete operand mularg 2; b6, according toUpdating the factor, and executing the multiplication instruction in B2, the subtraction instruction in B3 and the subtraction in B4 according to the updated factorAnd a normal instruction, which completes the conversion of the multiplication operation from low-precision program execution to high-precision program execution, wherein p represents the high-precision program execution precision.
In this embodiment, the multiply operation is detected by monitoring the floating point instruction execution sequence of the multiply operation (including the multiply operation in B2, the subtract operation in B3, and the subtract operation in B4), and the most suitable factor value is determined to complete the conversion of the multiply operation from low-precision program execution to high-precision program execution according to the high-precision program execution precision p.
EXAMPLE III
The method for detecting and converting rounding operation in dynamic floating point error analysis provided by the embodiment of the invention comprises the following steps:
c1, determining whether the current operation is an add operation, if yes, recording two operands: addarg1 and addarg 2;
c2, determining whether the next operation is subtraction, if so, determining whether the subtraction number is addarg1 or addarg2, if so, indicating that the addition operation in C1 and the subtraction operation in C2 are the execution sequence of rounding operations, then executing step C3;
and C3, converting the other operand of the non-reduction number into low precision, executing addition operation of C1 and subtraction operation of C2, and completing conversion of rounding operation from low-precision program execution to high-precision program execution.
In the present embodiment, by monitoring the operation sequence of addition in C1 and subtraction in C2 and the corresponding operands, the rounding operation is detected, and the conversion of the rounding operation from low-precision program execution to high-precision program execution is completed. Therefore, the rounding operation can be accurately detected and the original program can be correctly converted to be executed under high precision, so that the result of operand calculation under high precision can be closer to an accurate value, and the variable calculation result under low precision is still correct, and the accuracy of the error floating point analysis of the dynamic error analysis method by improving the program precision is improved.
Example four
The method for detecting and converting the precision specific constant in the dynamic floating point error analysis, provided by the embodiment of the invention, comprises the following steps:
d1, initializing HashMap, wherein key-value pairs (key-values) in the HashMap are low-precision memory binary data and high-precision constant values of a plurality of low-precision specific constants;
d2, judging whether the current operation is a reading instruction, judging whether the data reading mode is constant reading, if so, inquiring whether the binary data of the current constant in the memory is in the HashMap;
d3, if in HashMap, assigning the high precision constant value corresponding to HashMap to the high precision variable corresponding to the current constant, otherwise, synchronizing the current constant operation result of the original program to the high precision variable corresponding to the current constant, and realizing the conversion of the precision specific constant from the low precision program execution to the high precision program execution.
In this embodiment, the precision of the sample is determined for a precision-specific constant (e.g., pi,v 2), the numerical calculation program largely uses approximation such as taylor expansion to realize a mathematical function, and uses a large number of infinite decimals. The existing dynamic error analysis method only converts floating point variables into high precision and completes corresponding operations under high precision, and does not convert constant coefficients into numerical values with corresponding high precision, for example, 1/3, the double type is represented as 0.3333333333333333, and 120-bit precision can be represented to 36-bit decimal places. Therefore, in the embodiment, the specific constants are detected by a constant value matching mode (steps D1-D3), so that a plurality of common low-precision specific constants (including pi, pi/2, 1/pi, 2/pi, e, ln2, 1/ln2, ln10, 1/ln10, gamma (Euler's constant), K (Catalan's constant), + -1/3, + -1/5, + -1/7, + -1/9 and (+ -1/11) can be converted into accurate values of corresponding constants under high precision, and the accuracy of the error floating point analysis of the dynamic error analysis method is improved by improving the program precision.
The detection and conversion method provided by the first, second, third and fourth embodiments is used for expanding and developing a tool named FpDebaug-PSC on a tool floating point error analysis tool (FpDebaug). In order to test the effect of the method provided by the embodiment, fpdbug and the existing improvement measure (fpdbug-Wang) are compared, and 40 functions in the GLIBC 2.19math library functions commonly used by the scientific computing program are selected for testing, so that more than 999 functions in each group are sampled in the correct definition domain, and the following three contents are respectively compared:
1) the main factor of the error analysis effect affecting the method for performing dynamic error analysis by improving the program precision is the variable high-precision execution result, so the high-precision average relative error of the output results of different functions under FpDebug, FpDebug-Wang, FpDebug-PSC (Oracle for calculating the relative error of the high-precision execution result is the MPFR 120-bit precision calculation result) is selected and tested, as shown in table 1:
TABLE 1 average relative error contrast table
As can be seen from Table 1, the high-precision calculation of the average relative ratios of all 40 functions in FpDebaug-PSC
The errors are all less than or equal to FpDebaug, and the average relative error of the high-precision calculation results of the 39 functions in the FpDebaug-PSC is less than the average relative error of the high-precision calculation results calculated in the FpDebaug-Wang. Comparing FpDebaug-Wang, the average relative error of the high-precision calculation results of 57.5% (23/40) of the 40 functions was smaller than FpDebaug-Wang. And the relative error of the high-precision calculation result of pow in FpDebaug-Wang is even larger than that of the calculation result under the original precision.
2) The total execution time of the different functions at fpdbug, fpdbug-Wang, fpdbug-PSC was tested, executed 5 times, the average execution time calculated, and the time overhead of fpdbug-Wang, fpdbug-PSC was compared, as shown in table 2:
TABLE 2 time overhead comparison Table
As can be seen from Table 2, the average time overhead of detection and analysis of FpDebaug-Wang is 200 times, and our time overhead is increased by only 35%.
3) Comparing the number and accuracy of FpDebaug-Wang and FpDebaug-PSC probe PSCs, wherein the PSC number and accuracy comparison chart is shown in Table 3:
TABLE 3 PSC quantity and accuracy comparison table
As can be seen from table 3, the accuracy of the FpDebug-PSC probed PSC reached 100% and there were no false positives. While only 45 of the 88 detected by FpDebug-Wang were correct, with an accuracy of 53.41%, and there was a false negative.
Therefore, the detection and conversion method for precision specific calculation in dynamic floating point error analysis provided by the embodiment of the invention ensures that the time overhead is still within an acceptable range while the program can accurately perform error analysis, and is obviously superior to the existing method in terms of accuracy and time overhead.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the appended claims.
Claims (5)
1. A method for detecting and converting a dynamic floating point error analysis median operation, comprising:
acquiring a current instruction and an operand corresponding to the current instruction, inquiring whether the operand exists in a HashMap, and if the operand does not exist, inserting the operand into the HashMap, wherein the instruction is a floating point instruction, the operand is a floating point operand, and the HashMap represents HashMap and is used for storing a high-precision execution result and a write-in address of the operand;
judging whether the current instruction is a write instruction or not, if so, inquiring whether addr or (addr-4) exists in the HashMap or not if the write instruction is the write instruction and the write address of the operand is addr;
if yes, converting the high-order 32 bits of the operand to MPFR format floating point numbers under high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of mantissa in MPFR format at high precision, where MPFR represents a multi-precision floating-point library, completing the conversion of bit operations from low precision program execution to high precision program execution.
2. The method of claim 1, wherein if present, converting the upper 32 bits of the operand to MPFR format floating point number with high precision; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of the MPFR format with high precision, and the conversion of the bit operation from the low precision program execution to the high precision program execution is accomplished by:
if yes, dividing and extracting sign bit s, exponent bit ex and mantissa bit sig of the operand according to IEEE754 floating point arithmetic standard, and assigning sign ms, exponent mex and mantissa msig of floating point representation value of MPFR under the high precision of the operand according to the extraction result; otherwise, the lower 32 bits of the operand are converted to 21 to 53 bits of the MPFR format at high precision, completing the conversion of the bit operation from low precision program execution to high precision program execution.
3. A method for detecting and converting multiplication operations in dynamic floating point error analysis, comprising:
acquiring an execution sequence of an instruction and an operand corresponding to the execution sequence of the instruction, and detecting whether the current operation is a multiplication operation or not according to the acquired execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction; the instruction is a floating point instruction, and the operand is a floating point operand;
if the operation is the multiplication operation, determining the precision of the operand, executing the execution sequence according to the determined precision of the operand, and completing the conversion of the multiplication operation from the execution of a low-precision program to the execution of a high-precision program;
wherein, the obtaining the execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction, and the detecting whether the current operation is a multiplication operation according to the obtained execution sequence of the instruction and the operand corresponding to the execution sequence of the instruction comprises:
b1, initializing operation state as the first identifier;
b2, judging whether the current instruction is a multiply instruction, if so, one operand is 227+1, setting the state as a second identifier, and recording another operand as mularg 2;
b3, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtraction number is mularg2, if so, setting the state as a third identifier, otherwise, setting the state as a first identifier, and deleting an operand mularg 2;
b4, judging whether the next instruction is a subtraction instruction, if so, judging whether the subtracted number is factor + mularg2, if so, judging whether the state is a third identifier; wherein factor represents operand precision;
wherein, if the multiplication operation is performed, determining the precision of the operand, and executing the execution sequence according to the determined precision of the operand, and completing the conversion from the execution of the low-precision program to the execution of the high-precision program of the multiplication operation comprises:
b5, if the decrement is factor + mularg2, it indicates that the multiplication instruction in B2, the subtraction instruction in B3, and the subtraction instruction in B4 are the execution sequence of the multiplication operation, execute step B6, otherwise, set state to the first flag, and delete operand mularg 2; b6, according toUpdating the factor, executing the multiplication instruction in B2, the subtraction instruction in B3 and the subtraction instruction in B4 according to the updated factor, and finishing the multiplication operation from the low-precision program executionLine to high precision program execution, where p represents high precision program execution precision.
4. A method for detecting and converting rounding operations in dynamic floating point error analysis, comprising:
c1, determining whether the current instruction is an add instruction, if yes, recording two operands: addarg1 and addarg 2; the instruction is a floating point instruction, and the operand is a floating point operand;
c2, determining whether the next instruction is a subtraction instruction, if so, determining whether the subtraction number is addarg1 or addarg2, and if so, indicating that the addition instruction in C1 and the subtraction instruction in C2 are the execution sequence of the rounding operation, then performing step C3;
and C3, converting the other operand of the non-reduction number into low precision, executing an addition instruction of C1 and a subtraction instruction of C2, and completing the conversion of the rounding operation from the low-precision program execution to the high-precision program execution.
5. A method for detecting and converting precision specific constants in dynamic floating point error analysis is characterized by comprising the following steps:
initializing a HashMap, wherein key value pairs in the HashMap are low-precision memory binary data and high-precision constant values of a plurality of low-precision specific constants; the instruction is a floating point instruction, the operand is a floating point operand, and HashMap represents HashMap;
judging whether the current instruction is a reading instruction or not, judging whether the data reading mode is constant reading or not, and inquiring whether the binary data of the current constant in the memory is in the HashMap or not if the current instruction is the reading instruction and the data reading mode is constant reading;
if the current constant is in the HashMap, assigning the corresponding high-precision constant value in the HashMap to the high-precision variable corresponding to the current constant, otherwise, synchronizing the current constant operation result of the original program to the high-precision variable corresponding to the current constant, and realizing the conversion of the precision specific constant from the execution of the low-precision program to the execution of the high-precision program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911275775.9A CN111104091B (en) | 2019-12-12 | 2019-12-12 | Detection and conversion method for precision specific calculation in dynamic floating point error analysis |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911275775.9A CN111104091B (en) | 2019-12-12 | 2019-12-12 | Detection and conversion method for precision specific calculation in dynamic floating point error analysis |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111104091A CN111104091A (en) | 2020-05-05 |
CN111104091B true CN111104091B (en) | 2021-11-26 |
Family
ID=70422675
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911275775.9A Active CN111104091B (en) | 2019-12-12 | 2019-12-12 | Detection and conversion method for precision specific calculation in dynamic floating point error analysis |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111104091B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114662294B (en) * | 2022-03-09 | 2022-12-06 | 中国科学院国家空间科学中心 | Picometer-level satellite orbit simulation method and system for deep space exploration |
CN114860190B (en) * | 2022-04-28 | 2023-03-24 | 中国人民解放军战略支援部队信息工程大学 | Subinterval division method and subinterval division system for large error in specified interval of floating point arithmetic expression in high-performance calculation function library |
CN115291834B (en) * | 2022-07-07 | 2023-08-22 | 华东师范大学 | N-system floating point addition operation system and method |
CN116431479B (en) * | 2023-03-16 | 2024-06-28 | 河南省核芯微电子科技有限公司 | Dyninst-based floating point program precision loss detection method |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101847087A (en) * | 2010-04-28 | 2010-09-29 | 中国科学院自动化研究所 | Reconfigurable transverse summing network structure for supporting fixed and floating points |
CN102576304A (en) * | 2009-06-19 | 2012-07-11 | 奇异计算有限公司 | Processing with compact arithmetic processing element |
CN103982491A (en) * | 2014-05-27 | 2014-08-13 | 北京敬科海工科技有限公司 | DSP (Digital Signal Processor) based electro-hydraulic position servo driver and control method |
CN104951503A (en) * | 2015-05-18 | 2015-09-30 | 中国科学院信息工程研究所 | Freshness sensitive big data summary information maintenance and aggregate value query method |
CN106331678A (en) * | 2016-09-20 | 2017-01-11 | 四川长虹电器股份有限公司 | Hardware-implemented floating-point type viewpoint processing method in glasses-free 3D display system |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP2435986A4 (en) * | 2009-05-27 | 2015-04-22 | Oblong Ind Inc | Spatial, multi-modal control device for use with spatial operating system |
CN102073280B (en) * | 2011-01-13 | 2012-07-11 | 北京科技大学 | Fuzzy singular perturbation modeling and attitude control method for complex flexible spacecraft |
US10235177B2 (en) * | 2016-07-02 | 2019-03-19 | Intel Corporation | Register reclamation |
CN110187928A (en) * | 2019-04-25 | 2019-08-30 | 平安科技(深圳)有限公司 | Method, apparatus, equipment and the storage medium that JAVA cluster configuration item comes into force in real time |
-
2019
- 2019-12-12 CN CN201911275775.9A patent/CN111104091B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102576304A (en) * | 2009-06-19 | 2012-07-11 | 奇异计算有限公司 | Processing with compact arithmetic processing element |
CN101847087A (en) * | 2010-04-28 | 2010-09-29 | 中国科学院自动化研究所 | Reconfigurable transverse summing network structure for supporting fixed and floating points |
CN103982491A (en) * | 2014-05-27 | 2014-08-13 | 北京敬科海工科技有限公司 | DSP (Digital Signal Processor) based electro-hydraulic position servo driver and control method |
CN104951503A (en) * | 2015-05-18 | 2015-09-30 | 中国科学院信息工程研究所 | Freshness sensitive big data summary information maintenance and aggregate value query method |
CN106331678A (en) * | 2016-09-20 | 2017-01-11 | 四川长虹电器股份有限公司 | Hardware-implemented floating-point type viewpoint processing method in glasses-free 3D display system |
Non-Patent Citations (2)
Title |
---|
Arb: Efficient Arbitrary-Precision Midpoint-Radius Interval Arithmetic;F. Johansson;《in IEEE Transactions on Computers》;20170404;1281-1292 * |
高精度可靠浮点计算及舍入误差分析研究;姜浩;《中国博士学位论文全文数据库 基础科学辑》;20150115(第01期);A002-61 * |
Also Published As
Publication number | Publication date |
---|---|
CN111104091A (en) | 2020-05-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111104091B (en) | Detection and conversion method for precision specific calculation in dynamic floating point error analysis | |
US8397187B2 (en) | Verifying the error bound of numerical computation implemented in computer systems | |
KR101464810B1 (en) | Decimal floating point quantum exception detection | |
CN111767004B (en) | Digital oscilloscope mathematical operation processing method based on inverse Polish algorithm | |
TW201737115A (en) | Method and system for training machine learning system | |
US20190369962A1 (en) | Transcendental function evaluation | |
US7448026B1 (en) | Method and apparatus for accuracy-aware analysis | |
Silva et al. | AlcoR: alignment-free simulation, mapping, and visualization of low-complexity regions in biological data | |
GB2488665A (en) | Detecting a valid square root, multiplicative inverse or division of floating point numbers by checking if the error is less than a predetermined margin | |
CN115686961A (en) | Processor testing method and device and electronic equipment | |
US10635395B2 (en) | Architecture and instruction set to support interruptible floating point division | |
US8626816B2 (en) | Method, system and computer program product for detecting errors in fixed point division operation results | |
Martel | Enhancing the implementation of mathematical formulas for fixed-point and floating-point arithmetics | |
CN109542927B (en) | Effective data screening method, readable storage medium and terminal | |
CN115525660A (en) | Data table verification method, device, equipment and medium | |
US8175844B2 (en) | Determining an encoding type of data | |
CN111290946A (en) | Floating point number error detection method and device based on atomic state function | |
CN109522300B (en) | Effective data screening device | |
Jorgensen et al. | Assurance of accuracy in floating-point calculations-a software model study | |
US11487506B2 (en) | Condition code anticipator for hexadecimal floating point | |
CN117725889A (en) | Data processing method, device, equipment and storage medium | |
Jorgensen et al. | Bounded Floating Point: Identifying and Revealing Floating-Point Error | |
JP2018133774A (en) | Packet analysis device, method and non-temporary computer readable medium therefor | |
US10176001B2 (en) | Simulation device, simulation method, and computer readable medium | |
Chen | Roundoff and Truncation Errors |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |