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

By embedding the coprocessor of the inverse trigonometric function module in the main processor, the floating-point data of the inverse trigonometric function is directly processed, and the traditional low computing efficiency is solved, and efficient and accurate inverse trigonometric function calculation is achieved.

CN119473216AActive Publication Date: 2025-02-18SUZHOU WATECH ELECTRONICS CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

The calculation efficiency of traditional arctangent functions is low, especially when the accuracy requirements are high, the table lookup method is difficult to meet, and multiple information interactions lead to delay.

Method used

By embedding a coprocessor composed of an inverse trigonometric function module in the main processor, we directly obtain the pending floating-point variables and data processing information from the coprocessor, and implement inverse through fixed-point variable processing, vector iteration and reflection steps such as reflection Efficient calculation of trigonometric functions.

Benefits of technology

The calculation efficiency of inverse trigonometric functions is greatly improved, multiple information interactions in traditional solutions are avoided, data processing efficiency is improved, and accuracy needs are met in different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473216A_ABST
    Figure CN119473216A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer data, 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, a coprocessor composed of an anti-trigonometric function module is embedded in the main processor, and the method comprises the steps that a to-be-processed floating point variable of an anti-trigonometric function and corresponding data processing information are obtained from the coprocessor according to a preset floating point instruction; the method comprises the following steps: converting a to-be-processed floating point variable into a to-be-processed fixed point variable, carrying out shift processing according to an index part and a mantissa part of the to-be-processed floating point variable, mapping a shifted target fixed point variable to a preset coordinate space, carrying out vector iteration on the mapped fixed point variable, obtaining an initial output result after iteration, and carrying out reflection mapping to obtain a target fixed point variable; and obtaining a target output result after reflection and carrying out floating point conversion to obtain a target floating point quantity. The invention provides an anti-trigonometric function floating point data processing method with higher efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer data technology, and in particular, to a floating-point data processing method, apparatus, computer equipment and storage medium. Background Art

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

[0003] Therefore, there is an urgent need for a more efficient floating-point data processing method for the inverse tangent function. Summary of the invention

[0004] The embodiments of the present application provide a floating-point data processing method, apparatus, computer equipment, and storage medium.

[0005] According to a first aspect of an embodiment of the present application, a floating-point data processing method is provided, which is 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 to process data of an inverse trigonometric function, and the method comprises:

[0006] Acquire the 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;

[0007] 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;

[0008] 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;

[0009] Performing vector iteration on the mapped fixed-point variable according to the data processing information to obtain an initial output result after iteration;

[0010] De-mapping the initial output result based on the preset coordinate space to obtain a de-mapped target output result;

[0011] The target output result is subjected to floating-point conversion to obtain the target floating-point value 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 the 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 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:

[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, 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;

[0016] Correspondingly, the de-mapping the initial output result based on the preset coordinate space to obtain the de-mapped target output result 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 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:

[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, 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;

[0020] Correspondingly, the de-mapping the initial output result based on the preset coordinate space to obtain the de-mapped target output result includes:

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

[0022] 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 and less than -90°.

[0023] In an optional embodiment of the present application, 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 the shifted target fixed-point variable includes:

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

[0025] 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;

[0026] A shift operation is performed in a first direction on the mantissa of the floating-point variable to be processed based on the first shift amount to obtain the shifted target fixed-point variable.

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

[0028] Performing floating point conversion on the target output result to obtain a converted floating point output result;

[0029] 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 amount of the inverse trigonometric function after the shift; wherein the second direction is opposite to the first direction.

[0030] According to a second aspect of an embodiment of the present application, there is provided a floating-point data processing device, which is applied to a main processor, wherein the main processor is embedded with a coprocessor composed of an inverse trigonometric function module, and the device is used to process data of an inverse trigonometric function, and the device comprises:

[0031] An acquisition module, used for acquiring the floating-point variables to be processed of the inverse trigonometric function and data processing information corresponding to the floating-point variables to be processed from the coprocessor according to a preset floating-point instruction;

[0032] A first shift module, used for 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;

[0033] A first mapping module, used for mapping the target fixed-point variable to a preset coordinate space to obtain a mapping fixed-point variable of the target fixed-point variable in the preset coordinate space;

[0034] An iteration module, used for performing vector iteration on the mapping fixed-point variable according to the data processing information to obtain an initial output result after iteration;

[0035] A second mapping module, de-mapping the initial output result based on the preset coordinate space to obtain a de-mapped target output result;

[0036] The second shift module is used to perform floating point conversion on the target output result to obtain the target floating point value of the inverse trigonometric function.

[0037] According to a third aspect of an embodiment of the present application, a computer device is provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.

[0038] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.

[0039] The floating-point data processing method provided by the embodiment of the present application, in the first aspect, the inverse trigonometric function module is traditionally hung under the bus of the main processor. After the main processor fetches the instruction, it executes the instruction, obtains the floating-point variable to be processed and sends it to the inverse trigonometric function module through the AMBA bus, and then waits for the inverse trigonometric function module to complete the calculation, and then transmits the calculation result back to the main processor through the AMBA bus. The multiple interaction paths are long, and the corresponding delay is longer. In the embodiment of the present application, the main processor can directly obtain the floating-point variable to be processed of the inverse trigonometric function and the data processing information corresponding to the floating-point variable to be processed from the coprocessor according to the preset floating-point instruction. After the main processor obtains the preset floating-point instruction, it can directly transmit it to the coprocessor embedded in the main processor for subsequent processing, avoiding multiple information interactions in the traditional solution, and greatly improving the data processing efficiency;

[0040] Secondly, traditional inverse trigonometric functions are generally calculated by table lookup, which is difficult to meet when high precision requirements are required. In the embodiment of the present application, vector iteration of the mapped fixed-point variables is performed according to the data processing information. For example, the Cordic algorithm can be used to implement it. This consumes less hardware resources and the number of iterations is controllable. It can meet the precision requirements in different scenarios and greatly improve the calculation accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 A schematic diagram of an application scenario of a floating-point data processing method provided by an embodiment of the present application;

[0043] Figure 2 A flowchart of a floating-point data processing method provided by one embodiment of the present application;

[0044] Figure 3 A flowchart of a floating-point data processing method provided by an embodiment of the present application;

[0045] Figure 4 A schematic diagram of a mapping process in a floating-point data processing method provided by an embodiment of the present application;

[0046] Figure 5 A schematic diagram of a preset floating-point instruction for inverse trigonometric functions in a floating-point data processing method provided in one embodiment of the present application;

[0047] Figure 6 A schematic diagram of a preset floating-point instruction for an arc tangent variant function in a floating-point data processing method provided in one embodiment of the present application;

[0048] Figure 7 A schematic diagram of a reverse mapping process in a floating point data processing method provided by one embodiment of the present application;

[0049] Figure 8 A flowchart of a floating-point data processing method provided by one embodiment of the present application;

[0050] Fig. 9 A flowchart of a floating-point data processing method provided by one embodiment of the present application;

[0051] Fig.10 A schematic diagram of the structure of a floating-point data processing device provided in one embodiment of the present application;

[0052] Fig.11 A schematic diagram of the computer device structure provided for one embodiment of the present application. DETAILED DESCRIPTION

[0053] In the process of implementing the present application, the inventors found that there is an urgent need for a more efficient floating-point data processing method for inverse trigonometric functions.

[0054] In response to the above problems, embodiments of the present application provide a floating-point data processing method, apparatus, computer device, and storage medium.

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

[0056] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of 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 following is a brief description of the application environment of the floating-point data processing method provided in the embodiment of the present application:

[0058] See also Figure 1 The floating-point data processing method provided in the embodiment of the present application is applied to a main processor, wherein 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 in the main processor as a coprocessor. The main processor may be, for example, an ARM core or other device with advanced computing capabilities and an EPCDE interface. The embodiment of the present application does not specifically limit this. The main processor may use VCX2 or VCX3 floating-point instructions to interact with the coprocessor for data. The coprocessor implements floating-point calculations of inverse trigonometric functions, such as arctan(x0) and arctan2(x0, y0), etc. The input range of the two-dimensional coordinate (x0, y0) is [-1, 1], and the output result is a radian value without π. The coprocessor is embedded in 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 fetch module and a data processing module, wherein the instruction fetch unit is used to fetch execution instructions from the cache of the ARM core, wherein the main processor accesses the coprocessor through floating-point instructions, the floating-point instructions refer to VCX floating-point instructions (generally provided by the main processor, such as ARM's own VCX1 / 2 / 3, corresponding to different access types respectively), and the EPCDE interface refers to the data interface between the ARM core and the coprocessor, which is used for data exchange between the two. The data processing module is used to execute the floating-point data processing method provided in the embodiment of the present application.

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

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

[0062] The inverse trigonometric function in the embodiment of the present application cannot be narrowly understood as the inverse function of the trigonometric function, but is a multi-valued function, such as the inverse sine function arcsin x, the inverse cosine function sine arccos x, the inverse tangent function arctan x, the inverse cotangent function arccot ​​x, etc., as well as variants of various trigonometric functions, each representing an angle whose sine, cosine, tangent, and cotangent are x, which are not exhaustive here and can be flexibly adjusted according to actual conditions. For example, the preset floating-point instruction is VCX2 or VCX3, and the single-precision floating-point variable of the inverse trigonometric function arctan (x0) output x0 or the input (x0, y0) of the inverse tangent variant function arctan2 (x0, y0) is obtained from the coprocessor according to the floating-point instruction.

[0063] Step 202: 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;

[0064] The exponent part refers to the byte bit information representing the exponent set by the floating-point variable to be processed, and correspondingly, the mantissa part refers to the byte bit information representing the mantissa set by the floating-point variable to be processed. Of course, the floating-point variable to be processed may also include other byte bit information, which are not exhaustively listed here. The shift processing may be a single shift or multiple shifts. The specific shift processing may be flexibly adjusted according to the actual situation. The embodiment of the present application is not specifically limited, and only needs to meet the purpose of converting floating-point data to fixed-point data.

[0065] Step 203: 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;

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

[0067] When the target fixed-point variable x0 of the inverse tangent function arctan is in the third quadrant, it needs to be mapped to the first quadrant and the first mark is made, such as mark90 in Table 1; when the target fixed-point variable (x0, y0) of the inverse tangent variant function arctan2 is in the second and third quadrants, it needs to be mapped to the first and fourth quadrants and the second mark is made, such as the {mark, mark90} mark in Table 1, in preparation for the subsequent quadrant inverse mapping. As shown in Table 1 below, the inverse tangent function arctan(x0) and the inverse tangent variant function arctan2(x0, y0) are taken as examples:

[0068] Since the inverse tangent function arctan(x0) only takes a floating-point variable x, it needs to be expanded to the two-dimensional rectangular coordinate system xy when performing cordic vector iteration. At the same time, according to its odd function properties, the parameters in the interval [-1,0) can be mapped to the interval [0,1]. Since the angle value of cordic vector iteration is in the range of [-99°, 99°], the parameters of the inverse tangent 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, the cordic vector iteration can be performed according to the number of iterations in the data processing information issued by the VCX2 or VCX3 floating-point instruction, the y branch provides the iteration direction, and the z branch obtains the final initial output result, such as the output result value of the inverse tangent function arctan or the inverse tangent function variant arctan2; wherein the inverse trigonometric function uses the cordic circular vector for iterative calculation, 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 expression of the rotation direction di is as follows:

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

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

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

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

[0081] Step 204: De-map the initial output result based on the preset coordinate space to obtain a de-mapped target output result;

[0082] After the iteration is completed, in the preset coordinate space in step 203 above, the target coordinate interval where the floating-point variable to be processed is located corresponding to the output fixed-point quantity can be reversely mapped. For example, in the mapping process in step 203, the floating-point variable to be processed is in the target coordinate interval [-1,0), and in the mapping process, the branch x takes a negative value, and the branch y remains unchanged. In the reverse mapping of this step, the branch x of the initial output result takes a positive value, and the branch y remains unchanged. After reverse mapping, the data is converted according to the conversion rules between fixed-point data and floating-point data, and then written back to the target module. The target module can be a floating-point register, etc., which is not specifically limited in the embodiment of the present application and can be flexibly set according to actual conditions.

[0083] Taking the above step 203 and the example in Table 1, in this step, for example, the initial output result of the z branch can be reverse mapped according to the above first mark or second mark. For example, when the target fixed-point variable x0 of the inverse tangent 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 inverse tangent variant function arctan2 is located in the second quadrant, the target output result is a positive radian value and exceeds 0.5 (i.e., greater than 90°); when the target fixed-point variable (x0, y0) of the inverse tangent variant function arctan2 is located in the third quadrant, the target output result is a negative radian value and is less than -0.5 (i.e., less than -90°).

[0084] Step 205: Perform floating-point conversion on the target output result to obtain the target floating-point value of the inverse trigonometric function.

[0085] Compared with the above-mentioned shift processing, the reverse shift processing has the opposite shift direction, and the shift amount can be the same or slightly different. The embodiment of the present application does not make specific limitations and can be flexibly adjusted according to actual conditions.

[0086] The floating-point data processing method provided in the embodiment of the present application is applied to a main processor, and the main processor is embedded with a coprocessor composed of an inverse trigonometric function module. The method is used to process data of the inverse trigonometric function, and the method includes: obtaining the floating-point variable to be processed of the inverse trigonometric function and the data processing information corresponding to the floating-point variable to be processed from the coprocessor according to a preset floating-point instruction; 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 the 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; performing inverse mapping on the initial output result based on the preset coordinate space to obtain the inverse mapped target output result; performing floating-point conversion on the target output result to obtain the target floating-point quantity of the inverse trigonometric function.

[0087] On the one hand, the inverse trigonometric function module is traditionally hung under the bus of the main processor. After the main processor fetches the instruction, it executes the instruction, obtains the floating-point variable to be processed and sends it to the inverse trigonometric function module through the AMBA bus, and then waits for the inverse trigonometric function module to complete the calculation, and then transmits the calculation result back to the main processor through the AMBA bus. The multiple interaction paths are long and the corresponding delay is longer. In the embodiment of the present application, the main processor can directly obtain the floating-point variable to be processed of the inverse trigonometric function and the data processing information corresponding to the floating-point variable to be processed from the coprocessor according to the preset floating-point instruction. After the main processor obtains the preset floating-point instruction, it can directly transmit it to the coprocessor embedded in the main processor for subsequent processing, thereby avoiding multiple information interactions in the traditional scheme and greatly improving the data processing efficiency;

[0088] Secondly, traditional inverse trigonometric functions are generally calculated by table lookup, which is difficult to meet when high precision requirements are required. In the embodiment of the present application, vector iteration of the mapped fixed-point variables is performed according to the data processing information. For example, the Cordic algorithm can be used to implement it. This consumes less hardware resources and the number of iterations is controllable. It can meet the precision requirements in different scenarios and greatly improve the calculation accuracy.

[0089] 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.

[0090] In an optional embodiment of the present application, the processing information includes at least the 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.

[0091] See also Figure 4 Since the inverse tangent function arctan(x0) only has one floating-point variable x0 to be processed, in the preset coordinate space, the input range of x0 is [-1,1], and the corresponding target floating-point value (i.e. floating-point result) output range is [-0.25,0.25], which is a radian value without π. The inverse tangent function arctan(x0) is accessed using the VCX2 single-precision preset floating-point instruction, see Figure 5 , the default floating-point instruction format can be expressed as: "VCX2 <coproc> , <sd> , <sm> ,# <imm>",in <coproc>The field represents the number of the coprocessor. <sd>and <sm>The field represents the floating point registers in the main processor core, # <imm>The field represents the type of operation code; among them, <sm>The field represents the floating-point source operand x0. <sd>The field represents the destination register for the floating point result to be returned. <imm>The field is encoded, bit0 represents the calculation of the inverse tangent function arctan(x0), bit2 to bit1 represent the number of iterations, and other bits are reserved.

[0092] Please continue to see Figure 4 The arctan2(x0,y0) variant function takes two floating-point variables (x0,y0) to be processed. In the preset coordinate space, the input range of (x0,y0) is [-1,1], and the corresponding target floating-point value (i.e. floating-point result) output range is [-1,1], which is a radian value without π. The arctan2(x0,y0) variant function uses the VCX3 single-precision preset floating-point instruction to access, see Figure 6 , the default floating-point instruction format can be expressed as: "VCX3 <coproc> , <sd> , <sn> , <sm> ,# <imm>",in <coproc>The field represents the number of the coprocessor. <sd> 、 <sn>and <sm>The field represents the floating point register in the ARM core, # <imm>The field represents the type of operation code. <sm> 、 <sn>The field represents the floating point source operand (x0, y0). <sd>The field represents the destination register for the floating point result to be returned. <imm>The field is encoded, bit0 represents the arctan2(x,y) function calculation, and bit2 to bit1 represent the number of iterations.

[0093] The embodiment of the present application combines the inverse trigonometric function arctan(x0) and the inverse tangent variant function arctan2(x0, y0) into one module and implements them using a vector iteration algorithm. This can simplify the structure of the floating-point processing system, save system overhead, and improve the overall data processing efficiency. It also consumes less hardware resources and has a controllable number of iterations. Experiments show that, based on the number of iterations issued by a preset floating-point instruction VCX, the inverse trigonometric function arctan(x0) and the inverse tangent variant function arctan2(x0, y0) can complete floating-point calculations within a few cycles, significantly improving performance compared to traditional floating-point calculations.

[0094] See also Figure 4 In an optional embodiment of the present application, if the function calculation type includes an inverse tangent function, the above 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, 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, 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;

[0096] For corresponding Figure 7 The above step 205, inversely mapping the initial output result based on the preset coordinate space to obtain the target output result after inverse mapping, 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] See also Figure 4 In an optional embodiment of the present application, if the function calculation type includes an inverse tangent variant function, the above 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, 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, 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;

[0100] For corresponding Figure 7 The above step 205, inverse mapping the initial output result based on the preset coordinate space to obtain the target output result after inverse mapping, includes at least the following two situations:

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

[0102] In the second case, 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°.

[0103] The embodiment of the present application performs corresponding mapping and de-mapping for the inverse trigonometric function arctan(x0) and the inverse tangent variant function arctan2(x0, y0), and obtains the corresponding target output results. The obtained target output results are more accurate and precise, which can greatly improve the reliability of the floating-point data processing method of the embodiment of the present application.

[0104] in, Figure 4 and Figure 7 The physical meanings of the letters are as follows:

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

[0106] sub: subtraction operation

[0107] N: the amount of right shift operation

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

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

[0110] mux: selector

[0111] mark: indicates whether the parameter coordinates (x0, y0) are in the second quadrant

[0112] mark90: indicates whether the parameter coordinates (x0, y0) are in the third quadrant

[0113] instr_atan: VCX instruction is atan operation

[0114] map_dout0: The vertical coordinate y parameter after mapping

[0115] map_dout1: lateral coordinate x parameter after mapping

[0116] See also Figure 8 In an optional embodiment of the present application, the above step 202, 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 the shifted target fixed-point variable, includes the following steps 801-803:

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

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

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

[0120] See also Fig. 9 In an optional embodiment of the present application, the above step 206, performing floating point conversion on the target output result to obtain the inverse trigonometric function target floating point value, includes the following steps 901-902:

[0121] Step 901: Perform floating point conversion on the target output result to obtain a converted floating point output result;

[0122] Step 902: Perform 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 amount of the inverse trigonometric function after the shift.

[0123] Wherein, the second direction is opposite to the first direction. For example, to complete the conversion of the floating-point variable to be processed to the target fixed-point variable, the first movement amount in the logical first direction (such as right shift) can be calculated according to the 8-bit exponent part of the floating-point variable to be processed, and then the 23-bit mantissa part of the floating-point variable to be processed is shifted in the second direction (such as left shift) to obtain the shifted target floating-point variable, that is, the floating-point calculation of the inverse trigonometric function is completed, and the calculation result of the target floating-point amount is obtained. In the entire calculation process, there is no need to perform multiple data interactions between the main processor and the inverse trigonometric function module, which can greatly improve the processing efficiency of the floating-point data of the inverse trigonometric function; at the same time, the calculation form of the table lookup in the traditional way is avoided in the calculation process of the inverse trigonometric function. The embodiment of the present application performs vector iteration on the mapped fixed-point variable according to the data processing information, for example, it can be implemented by using the cordic algorithm, etc., with less hardware resource consumption, and the number of iterations can be controlled, which can meet the accuracy requirements in different scenarios, and the calculation accuracy is greatly improved.

[0124] It should be understood that, although the various steps in the flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0125] See also Fig.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, and the device 1000 is used to process data of inverse trigonometric functions, and the device 1000 includes: 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 to acquire 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;

[0127] The first shift module 1020 is used 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;

[0128] The first mapping module 1030 is used to map the target fixed-point variable to a preset coordinate space to obtain a mapping fixed-point variable of the target fixed-point variable in the preset coordinate space;

[0129] The iteration module 1040 is used to perform vector iteration on the mapping fixed-point variable according to the data processing information to obtain an initial output result after iteration;

[0130] The second mapping module 1050 performs 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 to perform floating point conversion on the target output result to obtain the inverse trigonometric function target floating point value.

[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 the 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.

[0134] In an optional embodiment of the present application, the first mapping module 1030 is specifically used 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 mapped fixed-point variable of the target fixed-point variable in the first quadrant;

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

[0136] In an optional embodiment of the present application, the first mapping module 1030 is specifically used to, 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, map 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;

[0137] Correspondingly, the second mapping module 1050 is specifically used to, 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, determine the target output result as a positive radian value greater than 90°; if the floating-point variable to be processed of the inverse tangent variant function is located in the third quadrant of the preset coordinate space, determine the target output result as a negative radian value less than -90°.

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

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

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

[0141] In one embodiment, a computer device is provided, the internal structure diagram of which can be as follows: Fig.11 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a floating-point data processing method as described above is implemented. It includes: a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, any step in the floating-point data processing method as described above is implemented.

[0142] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any step in the above floating-point data processing method can be implemented.

[0143] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0144] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0145] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0147] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0148] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.< / 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, the method is used to process data of the inverse trigonometric function, the method comprises: Acquire the 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 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; The target output result is subjected to floating-point conversion to obtain the target floating-point value of the inverse trigonometric function.

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 at least includes the 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, the de-mapping the initial output result based on the preset coordinate space to obtain the de-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, the de-mapping the initial output result based on the preset coordinate space to obtain the de-mapped target output result includes: If the to-be-processed floating-point variable of the inverse tangent variant function is located in the second quadrant of the preset coordinate space, the target output result is determined to be a positive radian value and 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, characterized in that: 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 the 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 in a first direction on the mantissa of the floating-point variable to be processed 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, characterized in that: 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 amount 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 comprises: An acquisition module, used for acquiring the to-be-processed floating-point variables of the inverse trigonometric function and data processing information corresponding to the to-be-processed floating-point variables from the coprocessor according to a preset floating-point instruction; A first shift module, used for 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; A first mapping module, used for mapping the target fixed-point variable to a preset coordinate space to obtain a mapping fixed-point variable of the target fixed-point variable in the preset coordinate space; An iteration module, used for performing vector iteration on the mapping fixed-point variable according to the data processing information to obtain an initial output result after iteration; A second mapping module, de-mapping the initial output result based on the preset coordinate space to obtain a de-mapped target output result; The second shift module is used to perform floating point conversion on the target output result to obtain the target floating point value of the inverse trigonometric function.

9. A computer device comprising: The method comprises a memory and a processor, wherein the memory stores a computer program, and wherein 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

  • Reconfigurable floating-point operation device based on CORDIC algorithm

    CN109062540A

  • Floating point to fixed point device and method, electronic equipment and storage medium

    CN113625990A

  • Data processing method and device, microcontroller and readable storage medium

    CN117472437A

Cited By

  • Texture coordinate processing method and device, electronic equipment and storage medium

    CN120510266A