Floating-point data processing method and device, computer device and storage medium

By embedding a coprocessor in the main processor to perform inverse trigonometric function calculations and utilizing coordinate space mapping and vector iteration, the problem of low efficiency in inverse tangent function calculations is solved, and efficient and accurate floating-point data processing is achieved.

CN119473216BActive Publication Date: 2025-10-17SUZHOU WATECH ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411621011.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-10-17
Estimated Expiration
2044-11-13

AI Technical Summary

Technical Problem

The calculation efficiency of the inverse tangent function in the prior art is low, especially when high precision requirements are difficult to meet, and the table lookup method is slow.

Method used

The coprocessor embedded in the main processor is used to perform inverse trigonometric function calculations by converting floating-point variables into fixed-point variables, mapping them to the preset coordinate space after shifting, and performing vector iteration and inverse mapping to finally convert them into floating-point results.

Benefits of technology

It improves the computational efficiency of inverse trigonometric functions, reduces information interaction delay, meets different precision requirements, and reduces hardware resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473216B_ABST
    Figure CN119473216B_ABST
Patent Text Reader

Abstract

The application relates to the field of computer data technology, in particular to a floating point data processing method and device, computer equipment and a storage medium. The floating point data processing method is applied to a main processor, the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, the method comprises the following steps: obtaining an inverse trigonometric function to-be-processed floating point variable and corresponding data processing information from the coprocessor according to a preset floating point instruction; converting the to-be-processed floating point variable into a to-be-processed fixed point variable and performing shift processing according to an index part and a mantissa part of the to-be-processed floating point variable; mapping a target fixed point variable after the shift processing to a preset coordinate space; performing vector iteration on the mapped fixed point variable; obtaining an initial output result after the iteration; performing inverse mapping on the initial output result to obtain a target output result after the inverse mapping; and performing floating point conversion on the target output result to obtain a target floating point variable. An inverse trigonometric function floating point data processing method with higher efficiency is provided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer data, in particular to a floating point data processing method and device, computer equipment and storage medium. BACKGROUND

[0002] The arctangent function mainly implements the hardware acceleration function of arctan (arctangent function) / arctan2 (arctangent function of two arguments), which is widely used in current-voltage phase calculation, angle control, aircraft attitude adjustment and digital signal processing. The arctangent function is usually implemented by cordic algorithm (Coordinate Rotation Digital Computer), which achieves the predetermined precision value through multiple iterations. The cordic algorithm contains simple shift and addition operations, which significantly reduces the complexity of operation design. The traditional arctangent function arctan is implemented in a three-dimensional Cartesian coordinate system, and a lookup table is used to obtain the arctangent function value. When the accuracy requirement is high, the lookup table method is difficult to meet, and each time it needs to be read through instructions, which is slow.

[0003] Therefore, there is an urgent need for a floating point data processing method for arctangent function with higher efficiency. SUMMARY

[0004] The present application provides a floating point data processing method, device, computer equipment and storage medium.

[0005] The first aspect of the present application provides a floating point data processing method applied to a main processor, wherein the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, and the method is used for data processing of the inverse trigonometric function, and the method comprises:

[0006] According to a preset floating point instruction, a to-be-processed floating point variable of the inverse trigonometric function and data processing information corresponding to the to-be-processed floating point variable are obtained from the coprocessor;

[0007] The to-be-processed floating point variable is converted into a to-be-processed fixed point variable, and shift processing is performed according to the exponent part and the mantissa part of the to-be-processed floating point variable to obtain a target fixed point variable after shift processing;

[0008] The target fixed point variable is mapped to a preset coordinate space to obtain a mapped fixed point variable of the target fixed point variable in the preset coordinate space;

[0009] According to the data processing information, the mapped fixed point variable is subjected to vector iteration to obtain an initial output result after iteration.

[0010] mapping the initial output result based on the preset coordinate space to obtain a target output result after reflection mapping;

[0011] performing floating point conversion on the target output result to obtain the target floating point quantity of the inverse trigonometric function.

[0012] In an optional embodiment of the present application, the processing information includes at least one of a function calculation type and an iteration number of the inverse trigonometric function.

[0013] In an optional embodiment of the present application, the processing information includes at least a function calculation type of the inverse trigonometric function, and correspondingly, the function calculation type includes at least one of an inverse tangent function and an inverse tangent variant function.

[0014] In an optional embodiment of the present application, if the function calculation type includes the inverse tangent function, the mapping of the target fixed point variable to a preset coordinate space to obtain a mapped fixed point variable of the target fixed point variable in the preset coordinate space includes:

[0015] If the to-be-processed floating point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, the target fixed point variable is mapped to the first quadrant of the preset coordinate space to obtain the mapped fixed point variable of the target fixed point variable in the first quadrant.

[0016] Correspondingly, the reflection mapping of the initial output result based on the preset coordinate space to obtain a target output result after reflection mapping includes:

[0017] If the to-be-processed floating point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, the target output result is determined as a negative radian value.

[0018] In an optional embodiment of the present application, if the function calculation type includes the inverse tangent variant function, the mapping of the target fixed point variable to a preset coordinate space to obtain a mapped fixed point variable of the target fixed point variable in the preset coordinate space includes:

[0019] If the to-be-processed floating point variable of the inverse tangent variant function is located in the second quadrant or the third quadrant of the preset coordinate space, the target fixed point variable is mapped to the first quadrant or the fourth quadrant of the preset coordinate space to obtain the mapped fixed point variable of the target fixed point variable in the first quadrant or the fourth quadrant.

[0020] Correspondingly, the reflection mapping of the initial output result based on the preset coordinate space to obtain a target output result after reflection mapping includes:

[0021] if the to-be-processed floating-point variable of the arctangent variant function is located in the second quadrant of the preset coordinate space, the target output result is determined as a positive radian value and greater than 90°;

[0022] if the to-be-processed floating-point variable of the arctangent variant function is located in the third quadrant of the preset coordinate space, the target output result is determined as a negative radian value and less than -90°.

[0023] In an optional embodiment of the present application, the conversion of the to-be-processed floating-point variable into the to-be-processed fixed-point variable and the shift processing according to the exponent part and the mantissa part of the to-be-processed floating-point variable to obtain the target fixed-point variable after shifting include:

[0024] the conversion of the to-be-processed floating-point variable into the to-be-processed fixed-point variable;

[0025] the calculation of a first shift amount in a first direction of the to-be-processed fixed-point variable according to the exponent part of the to-be-processed floating-point variable;

[0026] the first direction shift operation on the mantissa part of the to-be-processed floating-point variable based on the first shift amount, to obtain the target fixed-point variable after shifting.

[0027] In an optional embodiment of the present application, the floating-point conversion of the target output result to obtain the target floating-point variable of the inverse trigonometric function includes:

[0028] the floating-point conversion of the target output result to obtain a converted floating-point output result;

[0029] the second direction shift operation on the floating-point output result according to the first shift amount, to obtain the target floating-point variable of the inverse trigonometric function after shifting; wherein the second direction is opposite to the first direction.

[0030] A second aspect of the embodiment of the present application provides a floating-point data processing device, applied to a main processor, wherein the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, the device is used for data processing of an inverse trigonometric function, and the device includes:

[0031] an obtaining module, configured to obtain, from the coprocessor according to a preset floating-point instruction, a to-be-processed floating-point variable of the inverse trigonometric function and data processing information corresponding to the to-be-processed floating-point variable;

[0032] a first shift module, configured to convert the to-be-processed floating-point variable into a to-be-processed fixed-point variable, and perform shift processing according to an exponent part and a mantissa part of the to-be-processed floating-point variable, to obtain a target fixed-point variable after shifting;

[0033] The first mapping module is configured to map the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space.

[0034] The iteration module is configured to perform vector iteration on the mapped fixed-point variable according to the data processing information to obtain an initial output result after iteration.

[0035] The second mapping module is configured to perform inverse mapping on the initial output result based on the preset coordinate space to obtain a target output result after inverse mapping.

[0036] The second shift module is configured to perform floating-point conversion on the target output result to obtain the inverse trigonometric function target floating-point variable.

[0037] In a third aspect, the embodiment of the present application provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.

[0038] In a fourth aspect, the embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of any one of the above methods.

[0039] The floating-point data processing method provided by the embodiment of the present application has the following advantages. First, in the traditional scheme, the inverse trigonometric function module is hung below the bus of the main processor. After the main processor fetches an instruction and executes the instruction, the main processor sends the to-be-processed floating-point variable obtained to the inverse trigonometric function module through the AMBA bus, and then waits for the inverse trigonometric function module to finish calculation, and then sends the calculation result back to the main processor through the AMBA bus. The path is long and the corresponding delay is longer. In the embodiment of the present application, the main processor can directly obtain the to-be-processed floating-point variable of the inverse trigonometric function and the data processing information corresponding to the to-be-processed floating-point variable from the coprocessor according to a preset floating-point instruction. After the main processor obtains the preset floating-point instruction, the main processor directly sends the preset floating-point instruction to the coprocessor embedded in the main processor for subsequent processing, thereby avoiding the multiple information interactions in the traditional scheme and greatly improving the data processing efficiency.

[0040] Second, in the traditional scheme, the inverse trigonometric function is generally calculated by using a lookup table, and it is difficult to meet the requirement for high accuracy. In the embodiment of the present application, the mapped fixed-point variable is iterated according to the data processing information, for example, the cordic algorithm can be used to implement the iteration, the hardware resource consumption is small, the iteration times are controllable, and the requirement for accuracy in different scenarios can be met, thereby greatly improving the calculation accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0041] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:

[0042] Figure 1 An application scenario diagram of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0043] Figure 2 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0044] Figure 3 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0045] Figure 4 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0046] Figure 5 A preset floating point instruction diagram for an inverse trigonometric function in a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0047] Figure 6 A preset floating point instruction diagram for an inverse tangent function in a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0048] Figure 7 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0049] Figure 8 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0050] Figure 9 A flowchart of a floating point data processing method provided by an embodiment of the application is shown in the figure.

[0051] Figure 10 A structure diagram of a floating point data processing device provided by an embodiment of the application is shown in the figure.

[0052] Figure 11 A structure diagram of a computer device provided by an embodiment of the application is shown in the figure. DETAILED DESCRIPTION

[0053] In the implementation of the application, the inventors have found that there is an urgent need for a floating point data processing method with higher efficiency for inverse trigonometric functions.

[0054] To solve the above problems, the application provides a floating point data processing method, device, computer device and storage medium.

[0055] The technical solutions in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming languages such as Java and interpreted scripting languages such as JavaScript.

[0056] In order to make the technical solutions and advantages in the embodiments of the present application clearer, the exemplary embodiments of the present application are further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0057] The application environment of the floating-point data processing method provided by the embodiments of the present application is briefly described as follows:

[0058] Please refer to Figure 1 The floating-point data processing method provided by the embodiments of the present application is applied to a main processor, the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, that is, the inverse trigonometric function module is directly embedded into the main processor as a coprocessor, for example, the main processor can be an ARM core or other device with high-level operation capability and EPCDE interface, the embodiments of the present application are not limited, and the main processor can use VCX2 or VCX3 floating-point instructions to interact with the coprocessor. The coprocessor implements floating-point calculation of inverse trigonometric functions, for example, arctangent function arctan(x0) and arctangent variant function arctan2(x0, y0), the two-dimensional coordinate (x0, y0) input range is [-1, 1], and the output result is the radian value without π, the coprocessor is embedded into the ARM core through the EPCDE interface, runs at the same clock frequency as the ARM core, and interacts with the main processor using floating-point instructions.

[0059] The main processor includes an instruction fetching module and a data processing module, wherein the instruction fetching unit is used to fetch an execution instruction from the cache of the ARM core, wherein the main processor accesses the coprocessor through a floating-point instruction, the floating-point instruction is a VCX floating-point instruction (generally provided by the main processor itself, for example, ARM itself provides a VCX1 / 2 / 3 floating-point instruction corresponding to different access types), and the EPCDE interface is a data interface between the ARM core and the coprocessor, used for data interaction between the two. The data processing module is used to execute the floating-point data processing method provided by the embodiments of the present application.

[0060] Please refer to Figure 2 and Figure 3The following embodiments take the above main processor as the execution subject, apply the floating-point data processing provided by the embodiments to the main processor, and take the processing of the floating-point data of the inverse trigonometric function as an example for specific description. The floating-point data processing method provided by the embodiments includes the following steps 201-206:

[0061] Step 201, obtaining the to-be-processed floating-point variable of the inverse trigonometric function and the data processing information corresponding to the to-be-processed floating-point variable from the coprocessor according to a preset floating-point instruction;

[0062] The inverse trigonometric function in the embodiments cannot be understood in a narrow sense as the inverse function of the trigonometric function, and is a multi-valued function. For example, it can be the inverse sine function arcsin x, the inverse cosine function arccos x, the inverse tangent function arctan x, the inverse cotangent function arccot x, and the like, as well as the variants of the trigonometric functions, each of which represents an angle whose sine, cosine, tangent, or cotangent is x. Here, a complete list is not given, and it can be adjusted flexibly according to the actual situation. For example, the preset floating-point instruction is VCX2 or VCX3, and the input (x0, y0) single-precision floating-point variable of the inverse tangent function arctan(x0) or the inverse tangent variant function arctan2(x0, y0) is obtained from the coprocessor according to the floating-point instruction.

[0063] Step 202, converting the to-be-processed floating-point variable into a to-be-processed fixed-point variable, and performing a shift processing on the exponent part and the mantissa part of the to-be-processed floating-point variable to obtain a target fixed-point variable after the shift processing;

[0064] The exponent part refers to the byte bit information representing the exponent set by the to-be-processed floating-point variable, and correspondingly, the mantissa part refers to the byte bit information representing the mantissa set by the to-be-processed floating-point variable. Of course, the to-be-processed floating-point variable can also include other byte bit information, which is not listed here. The shift processing can be a one-time shift or a multiple-time shift, and the specific shift processing can be adjusted flexibly according to the actual situation. The embodiments of the present application do not make specific limitations, as long as the conversion purpose of the floating-point data to the fixed-point data is met.

[0065] Step 203, mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space;

[0066] The preset coordinate space can be a three-dimensional coordinate space, including at least three direction dimensions: branch x, branch y, and branch z. The branch x represents the target fixed-point variable, the branch y represents the direction of iteration, and the branch z represents the final fixed-point initial output result. For example, the corresponding mapped fixed-point variable can be obtained by mapping according to the quadrant in which the branch x in the to-be-processed floating-point variable is located in the preset coordinate space.

[0067] When the target fixed-point variable x0 of the arctangent function arctan is located in the third quadrant, it needs to be mapped to the first quadrant and marked with a first mark, such as mark90 in Table 1; when the target fixed-point variable (x0, y0) of the arctangent variant function arctan2 is located in the second or third quadrant, it needs to be mapped to the first or fourth quadrant and marked with a second mark, such as {mark, mark90} in Table 1, in preparation for subsequent quadrant remapping. The following Table 1 takes the arctangent function arctan(x0) and the arctangent variant function arctan2(x0, y0) as examples:

[0068] The arctangent function arctan(x0) only takes one floating-point variable x, and when performing cordic vector iteration, it needs to be extended to a two-dimensional rectangular coordinate system xy. According to the properties of odd functions, the parameters in the interval [-1, 0) can be mapped to the interval [0, 1]. Since the angle value of the cordic vector iteration is in the range [-99°, 99°], the parameters of the arctangent variant function arctan2(x0, y0) in the second and third quadrants also need to be mapped to the first and fourth quadrants.

[0069] Table 1

[0070]

[0071] Step 204, performing vector iteration on the mapped fixed-point variable according to the data processing information to obtain an initial output result after iteration;

[0072] For example, according to the number of iterations in the data processing information issued under the VCX2 or VCX3 floating-point instruction, cordic vector iteration can be performed, the y branch provides the direction of iteration, and the z branch obtains the final initial output result, such as the output result value of the arctangent function arctan or the arctangent function variant arctan2. The inverse trigonometric function is calculated by cordic circular vector iteration, and its expression is as follows:

[0073] x i+1 =x i -d i y i 2 -i

[0074] y i+1 =y i +d i x i 2 -i

[0075] z i+1 =z i -d i arctan 2-i (1)

[0076] The rotation direction di is expressed as the following formula (2):

[0077] d i = +1, y i < 0

[0078] d i = -1, y i ≥ 0 (2)

[0079] In the formula (1) and the formula (2), x i+1 represents the initial output result (i.e., the output fixed-point quantity) of the branch x after the i-th iteration, y i+1 represents the initial output result (i.e., the output fixed-point quantity) of the branch y after the i-th iteration, and z i+1 represents the initial output result (i.e., the output fixed-point quantity) of the branch z after the i-th iteration; x i represents the mapping fixed-point variable (i.e., the input fixed-point quantity) of the branch x at the i-th iteration, y i represents the mapping fixed-point variable (i.e., the input fixed-point quantity) of the branch y at the i-th iteration, and z i represents the mapping fixed-point variable (i.e., the input fixed-point quantity) of the branch z at the i-th iteration; arctan2 -i represents the iteration step of the branch z at the i-th iteration; d i represents the rotation direction of the branch z, and the iteration direction di is provided by the branch y, di = -1 when yi is greater than or equal to 0, and di = +1 when yi is less than 0. After the vector iteration, the branch z corresponds to the initial output result value, i.e., zn = arctan (y0 / x0).

[0080] The above formula can greatly improve the calculation efficiency of the inverse trigonometric function in the computer processing process.

[0081] In step 204, the initial output result is de-mapped based on the preset coordinate space to obtain a target output result after de-mapping.

[0082] After the iteration is completed, the output fixed-point quantity can be de-mapped according to the target coordinate interval in which the to-be-processed floating-point variable is located in the preset coordinate space in step 203, for example, the to-be-processed floating-point variable is located in the target coordinate interval [-1, 0) in the mapping process in step 203, the value of the branch x is negative in the mapping process, and the value of the branch y is unchanged. In the de-mapping process in this step, the value of the branch x of the initial output result is positive, and the value of the branch y is unchanged. After the de-mapping, the conversion between the fixed-point data and the floating-point data is performed according to the conversion rule, and then the data is written back to the target module. The target module can be a floating-point register, and the embodiments of the present application are not limited in this regard, and can be flexibly set according to the actual situation.

[0083] With the above step 203 and the example in Table 1, in this step, the initial output result of the z branch can be remapped according to the first mark or the second mark described above. For example, when the target fixed-point variable x0 of the arctangent function arctan(x0) is located in the third quadrant, the target output result is a negative radian value; when the target fixed-point variable (x0, y0) of the arctangent variant function arctan2 is located in the second quadrant, the target output result is a positive radian value and greater than 0.5 (i.e., greater than 90°); when the target fixed-point variable (x0, y0) of the arctangent variant function arctan2 is located in the third quadrant, the target output result is a negative radian value and less than -0.5 (i.e., less than -90°).

[0084] Step 205, floating-point conversion is performed on the target output result to obtain the inverse trigonometric function target floating-point quantity.

[0085] The reverse shift processing is opposite to the shift processing described above, and the shift amount can be the same or slightly different. The embodiments of the present application are not limited in this regard, and can be flexibly adjusted according to actual conditions.

[0086] The floating-point data processing method provided by the embodiments of the present application is applied to a main processor, the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, the method is used for data processing of an inverse trigonometric function, and the method comprises the following steps: acquiring a to-be-processed floating-point variable of the inverse trigonometric function and data processing information corresponding to the to-be-processed floating-point variable from the coprocessor according to a preset floating-point instruction; converting the to-be-processed floating-point variable into a to-be-processed fixed-point variable, and performing shift processing on the to-be-processed floating-point variable according to an exponent part and a mantissa part of the to-be-processed floating-point variable to obtain a target fixed-point variable after shift processing; mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space; performing vector iteration on the mapped fixed-point variable according to the data processing information to obtain an initial output result after iteration; performing reverse mapping on the initial output result based on the preset coordinate space to obtain a target output result after reverse mapping; and performing floating-point conversion on the target output result to obtain an inverse trigonometric function target floating-point quantity.

[0087] In a first aspect, in the prior art, the inverse trigonometric function module is hung under the bus of the main processor. After the main processor fetches an instruction and executes the instruction, the inverse trigonometric function module is instructed to calculate a to-be-processed floating-point variable, and then the main processor waits for the calculation of the inverse trigonometric function module to be completed, and then transmits the calculation result to the main processor through the AMBA bus. The long interaction path and the longer corresponding delay are caused. According to the present application, the main processor can directly obtain the to-be-processed floating-point variable of the inverse trigonometric function and the data processing information corresponding to the to-be-processed floating-point variable from the coprocessor according to a preset floating-point instruction. After the main processor obtains the preset floating-point instruction, the coprocessor embedded in the main processor is directly transmitted to the coprocessor for subsequent processing, thereby avoiding the multiple information interactions in the prior art and greatly improving the data processing efficiency.

[0088] In a second aspect, in the prior art, the inverse trigonometric function is generally calculated by using a lookup table. When the accuracy requirement is high, it is difficult to meet the requirement. In the present application, the mapping fixed-point variable is iterated according to the data processing information, for example, the cordic algorithm can be used to implement the iteration, the hardware resource consumption is small, and the iteration times are controllable, so that the accuracy requirement in different scenarios can be met, and the calculation accuracy is greatly improved.

[0089] In an optional embodiment of the present application, the processing information includes at least one of the function calculation type of the inverse trigonometric function and the iteration times.

[0090] In an optional embodiment of the present application, the processing information includes at least one of the function calculation type of the inverse trigonometric function and the iteration times.

[0091] Please refer to Figure 4 , the arctangent function arctan(x0) only carries one to-be-processed floating-point variable x0. In a preset coordinate space, the input range of x0 is [-1, 1], and the output range of the target floating-point variable (i.e., the floating-point result) is [-0.25, 0.25], which is the radian value without π. The arctangent function arctan(x0) is accessed by using a preset floating-point instruction of VCX2 single precision. Please refer to Figure 5 , the preset floating-point instruction format can be represented as: "VCX2 <coproc> , <sd> , <sm> ,# <imm>“wherein <coproc>a field characterizing a number of coprocessors, <sd>and <sm>The field characterizes floating point registers within the main processor core, <imm>The field characterizes an opcode type; wherein <sm>The field characterizes a floating-point source operand x0, <sd>The field characterizes the target register to which the floating point result is returned, while the 6-bit wide <imm>The field is encoded, bit0 represents arctan(x0) calculation, bits2~bit1 represent the number of iterations, and other bits are reserved.

[0092] Please continue to see Figure 4 , the arctan2(x0, y0) function has two floating-point variables to be processed (x0, y0), the input range of (x0, y0) in the preset coordinate space is [-1, 1], and the output range of the target floating-point quantity (i.e., the floating-point result) is [-1, 1], which is the radian value without π. The arctan2(x0, y0) function accesses the preset floating-point instruction of VCX3 single precision, please see Figure 6 , the preset floating-point instruction format can be represented as: "VCX3 <coproc> , <sd> , <sn> , <sm> ,# <imm>“wherein <coproc>a field characterizing a number of coprocessors, <sd> 、 <sn>and <sm>The field characterizes floating point registers within the ARM core, <imm>The field characterizes the opcode type. In the embodiments of the present application, the opcode type is also characterized by <sm> 、 <sn>The field characterizes a floating-point source operand (x0, y0), <sd>The field represents the destination register for the floating-point result to be returned, and the 3-bit wide # <imm>The bit 0 represents the arctan2(x, y) function calculation, and the bits 2-1 represent the number of iterations.

[0093] The embodiment of the present application combines the two functions of the inverse trigonometric function arctan(x0) and the inverse tangent variant function arctan2(x0, y0) in one module, and is implemented by using the vector iteration algorithm, so that the structure of the floating point processing system can be simplified, the system overhead can be saved, and the overall data processing efficiency can be improved; the hardware resource consumption is small, and the number of iterations is controllable; experiments show that, according to the number of iterations issued by the preset floating point instruction VCX, the inverse trigonometric function arctan(x0) and the inverse tangent variant function arctan2(x0, y0) can complete the floating point calculation within several cycles, and the performance is significantly improved compared with the traditional floating point calculation.

[0094] Please refer to Figure 4 In an optional embodiment of the present application, if the function calculation type includes the inverse tangent function, the step 203 of mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space includes the following steps:

[0095] If the to-be-processed floating point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, the target fixed-point variable is mapped to the first quadrant of the preset coordinate space to obtain the mapped fixed-point variable of the target fixed-point variable in the first quadrant.

[0096] Correspondingly, please refer to Figure 7 The step 205 of performing inverse mapping on the initial output result based on the preset coordinate space to obtain an inverse mapped target output result includes the following steps:

[0097] If the to-be-processed floating point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, the target output result is determined as a negative radian value.

[0098] Please refer to Figure 4 In an optional embodiment of the present application, if the function calculation type includes the inverse tangent variant function, the step 203 of mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space includes the following steps:

[0099] If the to-be-processed floating point variable of the inverse tangent variant function is located in the second quadrant or the third quadrant of the preset coordinate space, the target fixed-point variable is mapped to the first quadrant or the fourth quadrant of the preset coordinate space to obtain the mapped fixed-point variable of the target fixed-point variable in the first quadrant or the fourth quadrant.

[0100] Correspondingly, see Figure 7 The step 205, based on the preset coordinate space, reflects the initial output result to obtain a target output result after reflection, including at least the following two cases:

[0101] The first case, if the to-be-processed floating-point variable of the arctangent function is located in the second quadrant of the preset coordinate space, the target output result is determined as a positive radian value greater than 90°;

[0102] The second case, if the to-be-processed floating-point variable of the arctangent function is located in the third quadrant of the preset coordinate space, the target output result is determined as a negative radian value less than -90°.

[0103] The embodiments of the present application correspondingly map and reflect the inverse trigonometric function arctan(x0) and the arctangent function arctan2(x0, y0), and obtain the corresponding target output result. The target output result obtained is more accurate and precise, which can greatly improve the reliability of the floating-point data processing method of the embodiments of the present application.

[0104] Wherein, Figure 4 And Figure 7 The physical meanings of the letters in each of the above formulas are as follows:

[0105] sign: sign bit of single-precision floating-point number

[0106] sub: subtraction operation

[0107] N: shift amount of right shift operation

[0108] din0: floating-point number y0 converted to fixed-point number, format q1.31

[0109] din1: floating-point number x0 converted to fixed-point number, format q1.31

[0110] mux: selector

[0111] mark: indicates whether the parameter coordinate (x0, y0) is located in the second quadrant

[0112] mark90: indicates whether the parameter coordinate (x0, y0) is located in the third quadrant

[0113] instr_atan: VCX instruction is atan operation

[0114] map_dout0: mapped vertical coordinate y parameter

[0115] map_dout1: mapped horizontal coordinate x parameter

[0116] See Figure 8 In an optional embodiment of the present application, the step 202, the conversion of the to-be-processed floating-point variable into a to-be-processed fixed-point variable and the shift processing according to the exponent part and the mantissa part of the to-be-processed floating-point variable to obtain the target fixed-point variable after the shift, comprises steps 801-803 as follows:

[0117] Step 801, converting the to-be-processed floating-point variable into the to-be-processed fixed-point variable;

[0118] Step 802, calculating a first shift amount of the to-be-processed fixed-point variable in a first direction according to the exponent part of the to-be-processed floating-point variable;

[0119] Step 803, performing a shift operation in the first direction on the mantissa part of the to-be-processed floating-point variable based on the first shift amount to obtain the target fixed-point variable after the shift.

[0120] Please refer to Figure 9 In an optional embodiment of the present application, the step 206, the floating-point conversion of the target output result to obtain the target floating-point variable of the inverse trigonometric function, comprises steps 901-902 as follows:

[0121] Step 901, performing floating-point conversion on the target output result to obtain a converted floating-point output result;

[0122] Step 902, performing a shift operation in a second direction on the floating-point output result according to the first shift amount to obtain the target floating-point variable of the inverse trigonometric function after the shift.

[0123] The second direction is opposite to the first direction. For example, after the conversion of the to-be-processed floating-point variable into the target fixed-point variable, a first shift amount in a logical first direction (for example, right shift) can be calculated according to the 8-bit exponent part of the to-be-processed floating-point variable, and then a shift operation in a second direction (for example, left shift) can be performed on the 23-bit mantissa part of the to-be-processed floating-point variable to obtain the target floating-point variable after the shift, that is, the floating-point calculation of the inverse trigonometric function is completed to obtain the calculation result of the target floating-point variable. In the entire calculation process, multiple data interactions between the main processor and the inverse trigonometric function module are not required, which can greatly improve the efficiency of the inverse trigonometric function floating-point data processing. At the same time, in the inverse trigonometric function calculation process, the calculation form of the traditional lookup table is avoided, and the vector iteration of the mapping fixed-point variable is performed according to the data processing information, for example, the cordic algorithm can be used for implementation, the hardware resource consumption is small, and the iteration times are controllable, which can meet the accuracy requirements in different scenarios, and the calculation accuracy is greatly improved.

[0124] It should be understood that, although the steps in the flowchart are shown in a sequential order following the arrows, the steps are not necessarily performed in the order shown by the arrows. Unless explicitly stated otherwise, the steps can be performed in other orders. Moreover, at least some of the steps in the flowchart can include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but can be performed at different times, and which are not necessarily performed sequentially, but can be performed in rotation or alternation with at least some of the other steps or sub-steps or stages of other steps.

[0125] See Figure 10 An embodiment of the present application provides a floating point data processing device 1000, which is applied to a main processor, wherein the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, the device 1000 is used for data processing of the inverse trigonometric function, and the device 1000 comprises an acquisition module 1010, a first shift module 1020, a first mapping module 1030, an iteration module 1040, a second mapping module 1050 and a second shift module 1060, wherein:

[0126] The acquisition module 1010 is used for acquiring a to-be-processed floating point variable of the inverse trigonometric function and data processing information corresponding to the to-be-processed floating point variable from the coprocessor according to a preset floating point instruction.

[0127] The first shift module 1020 is used for converting the to-be-processed floating point variable into a to-be-processed fixed point variable, and performing shift processing according to an exponent part and a mantissa part of the to-be-processed floating point variable to obtain a target fixed point variable after shift processing.

[0128] The first mapping module 1030 is used for mapping the target fixed point variable to a preset coordinate space to obtain a mapped fixed point variable of the target fixed point variable in the preset coordinate space.

[0129] The iteration module 1040 is used for performing vector iteration on the mapped fixed point variable according to the data processing information to obtain an initial output result after iteration.

[0130] The second mapping module 1050 is used for performing inverse mapping on the initial output result based on the preset coordinate space to obtain a target output result after inverse mapping.

[0131] The second shift module 1060 is used for performing floating point conversion on the target output result to obtain a target floating point variable of the inverse trigonometric function.

[0132] In an optional embodiment of the present application, the processing information includes at least one of a function calculation type and an iteration number of the inverse trigonometric function.

[0133] In an optional embodiment of the present application, the processing information includes at least one of a function calculation type and an iteration number of the inverse trigonometric function.

[0134] In an optional embodiment of the present application, the first mapping module 1030 is specifically configured to, if the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, map the target fixed-point variable to the first quadrant of the preset coordinate space to obtain the mapping fixed-point variable of the target fixed-point variable in the first quadrant.

[0135] Correspondingly, the second mapping module 1050 is specifically configured to, if the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, determine the target output result as a negative radian value.

[0136] In an optional embodiment of the present application, the first mapping module 1030 is specifically configured to, if the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, map the target fixed-point variable to the first quadrant of the preset coordinate space to obtain the mapping fixed-point variable of the target fixed-point variable in the first quadrant.

[0137] Correspondingly, the second mapping module 1050 is specifically configured to, if the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, determine the target output result as a negative radian value.

[0138] In an optional embodiment of the present application, the first shift module 1020 is specifically configured to convert the to-be-processed floating-point variable into the to-be-processed fixed-point variable, calculate a first shift amount of the to-be-processed fixed-point variable in a first direction according to an exponent part of the to-be-processed floating-point variable, and perform a shift operation on a mantissa part of the to-be-processed floating-point variable in the first direction based on the first shift amount to obtain the target fixed-point variable after the shift.

[0139] In an optional embodiment of the present application, the second shifting module 1060 is specifically configured to perform floating-point conversion on the target output result to obtain a converted floating-point output result; and perform a second direction shifting operation on the floating-point output result according to the first shifting amount, to obtain the target floating-point amount of the inverse trigonometric function after shifting; wherein the second direction is opposite to the first direction.

[0140] The specific definition of the floating-point data processing apparatus 1000 can refer to the definition of the floating-point data processing method, which will not be repeated here. Each module in the floating-point data processing apparatus 1000 can be implemented by software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0141] In an embodiment, a computer device is provided, and an internal structure diagram of the computer device can be as shown in Figure 11 The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the computer device is configured to store data. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a floating-point data processing method as described above. The computer program includes a memory and a processor, the memory stores a computer program, and the processor implements any step of the floating-point data processing method when executing the computer program.

[0142] In an embodiment, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program. The computer program is executed by a processor to implement any step of the floating-point data processing method as described above.

[0143] Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.

[0144] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 means for functionally implementing the steps listed in the flowchart block or blocks.

[0145] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 means for functionally implementing the steps listed in the flowchart block or blocks.

[0146] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 means for functionally implementing the steps listed in the flowchart block or blocks.

[0147] While the preferred embodiments of the application have been described, additional variations and modifications can be employed by those skilled in the art. Therefore, the appended claims intend to cover all such modifications and variations as fall within the true spirit and scope of the application.

[0148] It is apparent that a person skilled in the art can make various changes and modifications to the application without departing from the spirit and scope thereof. Therefore, if these modifications and changes fall within the scope of the claims and their equivalents, it is intended to include them in the application.< / imm> < / sd> < / sn> < / sm> < / imm> < / sm> < / sn> < / sd> < / coproc> < / imm> < / sm> < / sn> < / sd> < / coproc> < / imm> < / sd> < / sm> < / imm> < / sm> < / sd> < / coproc> < / imm> < / sm> < / sd> < / coproc>

Claims

1. A floating point data processing method, characterized in that: Applied to a main processor, the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, and the method is used to process data of inverse trigonometric functions, the method comprising: Obtaining, from a coprocessor according to a preset floating-point instruction, a floating-point variable to be processed of the inverse trigonometric function and data processing information corresponding to the floating-point variable to be processed; Converting the floating-point variable to be processed into a fixed-point variable to be processed, and performing shift processing according to the exponent part and the mantissa part of the floating-point variable to be processed to obtain a shifted target fixed-point variable; Mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space; Performing vector iteration on the mapped fixed-point variable according to the data processing information to obtain an initial output result after iteration; De-mapping the initial output result based on the preset coordinate space to obtain a de-mapped target output result; Perform floating-point conversion on the target output result to obtain the inverse trigonometric function target floating-point value.

2. The floating-point data processing method according to claim 1, wherein The processing information includes at least one of a function calculation type and an iteration number of the inverse trigonometric function.

3. The floating-point data processing method according to claim 2, wherein The processing information includes at least a function calculation type of the inverse trigonometric function. Correspondingly, the function calculation type includes at least one of an inverse tangent function and an inverse tangent variant function.

4. The floating-point data processing method according to claim 3, wherein: If the function calculation type includes an inverse tangent function, mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space includes: If the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, mapping the target fixed-point variable to the first quadrant of the preset coordinate space to obtain the mapped fixed-point variable of the target fixed-point variable in the first quadrant; Correspondingly, performing inverse mapping on the initial output result based on the preset coordinate space to obtain the inverse-mapped target output result includes: If the to-be-processed floating-point variable of the inverse tangent function is located in the third quadrant of the preset coordinate space, the target output result is determined as a negative radian value.

5. The floating-point data processing method according to claim 3, wherein: If the function calculation type includes an inverse tangent variant function, mapping the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space includes: If the to-be-processed floating-point variable of the inverse tangent variant function is located in the second quadrant or the third quadrant of the preset coordinate space, mapping the target fixed-point variable to the first quadrant or the fourth quadrant of the preset coordinate space to obtain the mapped fixed-point variable of the target fixed-point variable in the first quadrant or the fourth quadrant; Correspondingly, performing inverse mapping on the initial output result based on the preset coordinate space to obtain the inverse-mapped target output result includes: If the floating-point variable to be processed of the inverse tangent variant function is located in the second quadrant of the preset coordinate space, determining the target output result as a positive radian value greater than 90°; If the to-be-processed floating-point variable of the inverse tangent variant function is located in the third quadrant of the preset coordinate space, the target output result is determined to be a negative radian value that is less than -90°.

6. The floating-point data processing method according to claim 1, wherein: The converting the floating-point variable to be processed into a fixed-point variable to be processed, and performing shift processing according to the exponent part and the mantissa part of the floating-point variable to be processed to obtain a shifted target fixed-point variable, includes: Converting the floating-point variable to be processed into the fixed-point variable to be processed; Calculating a first shift amount of the fixed-point variable to be processed in a first direction according to an exponential part of the floating-point variable to be processed; A shift operation is performed on the mantissa of the floating-point variable to be processed in a first direction based on the first shift amount to obtain the shifted target fixed-point variable.

7. The floating-point data processing method according to claim 6, wherein: The performing floating-point conversion on the target output result to obtain the inverse trigonometric function target floating-point value includes: Performing floating-point conversion on the target output result to obtain a converted floating-point output result; A shift operation is performed on the floating-point output result in a second direction according to the first shift amount to obtain the target floating-point quantity of the inverse trigonometric function after the shift; wherein the second direction is opposite to the first direction.

8. A floating-point data processing device, characterized in that: Applied to a main processor, the main processor is embedded with a coprocessor consisting of an inverse trigonometric function module, the device is used to process data of inverse trigonometric functions, and the device includes: an acquisition module, configured to acquire, from a coprocessor according to a preset floating-point instruction, a floating-point variable to be processed of the inverse trigonometric function and data processing information corresponding to the floating-point variable to be processed; A first shift module is configured to convert the floating-point variable to be processed into a fixed-point variable to be processed, and perform shift processing according to the exponent part and the mantissa part of the floating-point variable to be processed to obtain a shifted target fixed-point variable; A first mapping module, configured to map the target fixed-point variable to a preset coordinate space to obtain a mapped fixed-point variable of the target fixed-point variable in the preset coordinate space; An iteration module, configured to perform vector iteration on the mapped fixed-point variables according to the data processing information to obtain an initial output result after iteration; a second mapping module, performing inverse mapping on the initial output result based on the preset coordinate space to obtain an inversely mapped target output result; The second shift module is used to perform floating-point conversion on the target output result to obtain the inverse trigonometric function target floating-point value.

9. A computer device comprising: The method comprises a memory and a processor, wherein the memory stores a computer program, and is characterized in that the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Trigonometric function CORDIC iteration operation coprocessor and operation processing method thereof

    CN102073472A

  • Method and device for achieving low delay basic transcendental function based on mixed model CORDIC algorithmic

    CN103677738A