CN106997284A - The method and apparatus for realizing floating-point arithmetic operation - Google Patents
The method and apparatus for realizing floating-point arithmetic operation Download PDFInfo
- Publication number
- CN106997284A CN106997284A CN201710161711.0A CN201710161711A CN106997284A CN 106997284 A CN106997284 A CN 106997284A CN 201710161711 A CN201710161711 A CN 201710161711A CN 106997284 A CN106997284 A CN 106997284A
- Authority
- CN
- China
- Prior art keywords
- floating
- point
- source operand
- point operation
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/57—Arithmetic logic units [ALU], i.e. arrangements or devices for performing two or more of the operations covered by groups G06F7/483 – G06F7/556 or for performing logical operations
Abstract
The present invention provides a kind of method and apparatus for realizing floating-point arithmetic operation.This method includes:Floating-point operation instruction is received, floating-point operation indicates source operand information and performance accuracy require information, and performance accuracy require information indicates the precision of floating-point operation result;Circulation floating-point arithmetic operation processing is carried out to the corresponding source operand of source operand information according to performance accuracy require information, untill floating-point operation result meets precision;Middle the floating point values acquisition floating-point operation result obtained according to floating-point arithmetic operation processing during each circulation before meeting the requirement of precision.What the present invention was provided realizes that the method for floating-point arithmetic operation can perform the circulation of arbitrary number of times, saves the execution time, reduces power consumption.
Description
Technical field
The present invention relates to floating-point operation field, more particularly to a kind of method and apparatus for realizing floating-point arithmetic operation.
Background technology
With the increase of user's request, requirement more and more higher of the user to the performance of computer, floating-point operation is used as calculating
The basic module of machine data processing, its performance determines the performance of computer.
Existing floating-point division computing, floating-point square-root extract computing, fixed point division computing, fixed point rem computing generally using superfluous
Remainder iterative algorithm (SRT algorithms).But, the floating number meeting of being substantially all being transformed due to floating number or fixed-point operation number
Using the form of single precision as defined in IEEE754-2008 and double precision, when being calculated using SRT algorithms, Zhi Nengjin
The circulation of row fixed number of times.For example, with the SRT algorithms that base is 2,2 quotient words are calculated every time, the floating-point operation of single precision is led to
Often need to carry out 12 iteration, calculate 24 effective digitals, and the floating-point operation of double precision usually requires to carry out 20 successive ignitions,
Calculate 53 effective digitals.
When user is relatively low to the accuracy requirement of data, existing SRT algorithms can expend when performing division arithmetic every time
Longer time, calculates user and unwanted a part of result, reduces the performance entirely applied.Therefore, existing SRT
Algorithm causes calculating flexibility ratio poor because the circulation of fixed number of times can only be performed, and performs time increase, and power consumption increase causes money
Source is wasted.
The content of the invention
The present invention provides a kind of method and apparatus for realizing floating-point arithmetic operation, for solve can only in existing floating-point operation
The circulation of fixed number of times is performed, causes the execution time to increase, power consumption increase, the problem of causing the wasting of resources.
One aspect of the present invention provides a kind of method for realizing floating-point arithmetic operation, including:
Floating-point operation instruction is received, the floating-point operation indicates source operand information and performance accuracy requirement letter
Breath, the performance accuracy require information indicates the precision of floating-point operation result;
Circulation floating-point is carried out to the corresponding source operand of the source operand information according to the performance accuracy require information
Arithmetic operation processing, untill the floating-point operation result meets the precision;
The centre that the floating-point arithmetic operation processing is obtained during according to each circulation before the requirement for meeting the precision
Floating point values obtains floating-point operation result.
The as described above method for realizing floating-point arithmetic operation, it is described according to the performance accuracy require information to the source
The corresponding source operand of operand information carries out circulation floating-point arithmetic operation processing, until the floating-point operation result is met
Untill the precision, including:
Instructed according to the floating-point operation, cycle-index is set to 0, floating-point operation processing is carried out to the source operand
Agent and middle remainder are obtained, the cycle-index is added 1, new cycle-index is obtained, the new cycle-index is judged
It is whether consistent with the performance accuracy require information;
Obtained if it is not, then carrying out the floating-point operation processing to the middle remainder more than new agent and Xin centre
Number, adds 1 by the cycle-index again, obtains new cycle-index, and judge the new cycle-index and the behaviour again
Make whether required precision information consistent, if it is not, then repeat this step to new middle remainder, until new cycle-index with
The performance accuracy require information is consistent.
The method as described above for realizing floating-point arithmetic operation, the performance accuracy require information includes default floating-point operation
Result accuracy value;It is then described to judge whether the new cycle-index is consistent with the performance accuracy require information, including:
Preset loop number of times is obtained according to the default floating-point operation result accuracy value, the new circulation time is judged
Whether number is consistent with the preset loop number of times;Or,
The performance accuracy require information includes preset loop number of times;Then it is described judge the new cycle-index with it is described
Whether performance accuracy require information is consistent, including:
Judge whether the new cycle-index is consistent with the preset loop number of times.
The method as described above for realizing floating-point arithmetic operation, after the reception floating-point operation instruction, methods described
Also include:
According to the source operand information, the precision for obtaining floating-point operation result requires to believe as the performance accuracy
Breath.
The method as described above for realizing floating-point arithmetic operation, the floating-point operation indicates that source operand information has
Body is:Indicate the address information for the first register for storing the source operand;After the reception floating-point operation instruction, institute
Stating method also includes:
The address information of the first register of the storage source operand indicated is instructed according to the floating-point operation, is read
First register, obtains the source operand.
The method as described above for realizing floating-point arithmetic operation, if floating-point operation instruction also indicates the floating-point fortune
Calculation is processed as division, then the source operand includes divisor and dividend;It is described that the floating-point fortune is carried out to the middle remainder
Calculation processing obtains new agent and Xin middle remainder, including:
The centre that the floating-point operation processing obtains new agent and Xin is carried out to the middle remainder and the divisor
Remainder;
If the floating-point operation instruction also indicates that the floating-point operation is processed as evolution, the source operand includes quilt
Evolution number, the agent is intermediate square root.
The method as described above for realizing floating-point arithmetic operation, it is described according to each before the requirement for meeting the precision
The middle floating point values that the floating-point arithmetic operation processing is obtained during circulation obtains floating-point operation result, including:
The centre that the floating-point arithmetic operation processing is obtained during according to each circulation before the requirement for meeting the precision
Business, carries out normalization processing and obtains the floating-point operation result.
The method as described above for realizing floating-point arithmetic operation, the floating-point operation instruction also indicates the storage centre
The address information of the second register of business;
Methods described also includes:The agent that will be obtained after the floating-point operation processing every time, is stored in described second and posts
In storage;
Corresponding, the floating-point arithmetic operation is handled during each circulation according to before the requirement for meeting the precision
Obtained middle floating point values obtains floating-point operation result, including:
Second register is read, the floating-point operation result is obtained.
Another aspect of the present invention provides a kind of device for realizing floating-point arithmetic operation, for performing the reality in above-described embodiment
The method of existing floating-point arithmetic operation, with identical technical characteristic and technique effect, the present invention is repeated no more to this.
The present invention provides a kind of device for realizing floating-point arithmetic operation, including:At receiving module, circulation floating-point arithmetic operation
Manage module and output module;
The receiving module, for receiving floating-point operation instruction, the floating-point operation indicates source operand information
With performance accuracy require information, the performance accuracy require information indicates the precision of floating-point operation result;
The circulation floating-point arithmetic operation processing module, for being operated according to the performance accuracy require information to the source
The corresponding source operand of number information carries out circulation floating-point arithmetic operation processing, until the floating-point operation result meets described
Untill precision;
The output module, the floating-point operation is grasped during for according to each circulation before the requirement for meeting the precision
Deal with obtained middle floating point values and obtain floating-point operation result.
The device as described above for realizing floating-point arithmetic operation, the circulation floating-point arithmetic operation processing module includes:It is defeated
Enter unit, loop control unit and floating-point arithmetic operation processing unit;
The input block is used for, and receives the corresponding source operand of the source operand information, the source operand is sent out
Give the floating-point arithmetic operation processing unit;
The loop control unit is used for, and receives the performance accuracy require information, cycle-index is set into 0, to institute
State floating-point arithmetic operation processing unit and send the first computing signal;The performance accuracy require information indicates that floating-point operation is handled
As a result precision;
The floating-point arithmetic operation processing unit is used for, when receiving the first computing signal, and the source is operated
Number carries out floating-point operation processing and obtains agent and middle remainder, is transmitted completion signal to the loop control unit, will be described
Agent is sent to the output module, and the middle remainder is sent into the input block;
The loop control unit is additionally operable to, and when receiving the completion signal, is added 1 by the cycle-index, is obtained
New cycle-index, judges whether the new cycle-index is consistent with the performance accuracy require information;If consistent, to institute
State output module and send end signal;If inconsistent, the second computing signal is sent to the floating-point arithmetic operation processing unit;
The input block is additionally operable to, when receiving the middle remainder, the middle remainder is sent to described floating
Point processing operates processing unit;
The floating-point arithmetic operation processing unit is additionally operable to, when receiving the second computing signal, to the centre
Remainder carries out middle the remainder that floating-point operation processing obtains new agent and Xin, described complete to loop control unit transmission
Into signal, the new agent is sent to the output module, it is single that the new middle remainder is sent into the input
Member.
The device as described above for realizing floating-point arithmetic operation, the performance accuracy require information includes default floating-point operation
Result accuracy value;The loop control unit specifically for,
Preset loop number of times is obtained according to the default floating-point operation result accuracy value, the new circulation time is judged
Whether number is consistent with the preset loop number of times;And/or,
The performance accuracy require information includes preset loop number of times;The loop control unit specifically for,
Judge whether the new cycle-index is consistent with the preset loop number of times.
The device as described above for realizing floating-point arithmetic operation, the circulation floating-point arithmetic operation processing module is specifically used
In,
According to the source operand information, the precision for obtaining floating-point operation result requires to believe as the performance accuracy
Breath.
The device as described above for realizing floating-point arithmetic operation, the floating-point operation indicates that source operand information has
Body is:Indicate the address information for the first register for storing the source operand;The circulation floating-point arithmetic operation processing mould
Block specifically for,
The address information of the first register of the storage source operand indicated is instructed according to the floating-point operation, is read
First register, obtains the source operand.
The device as described above for realizing floating-point arithmetic operation, if floating-point operation instruction also indicates the floating-point fortune
Calculation is processed as division, then the source operand includes divisor and dividend;
Corresponding, the input block is additionally operable to, when receiving the middle remainder, by the middle remainder and described
Source operand is sent to the floating-point arithmetic operation processing unit;
The floating-point arithmetic operation processing unit is additionally operable to, when receiving the second computing signal, and the source is grasped
Count and carry out the middle remainder that floating-point operation processing obtains new agent and Xin with the middle remainder, to the loop control
Unit sends the completion signal, and the new agent is sent into the output module, and the new middle remainder is sent out
Give the input block;
If the floating-point operation instruction also indicates that the floating-point operation is processed as evolution, the source operand includes quilt
Evolution number, the agent is intermediate square root.
The as described above device for realizing floating-point arithmetic operation, the output module specifically for,
When receiving end signal, to all agents received, carry out normalization processing and obtain described floating
Point processing result.
The device as described above for realizing floating-point arithmetic operation, the floating-point operation instruction also indicates the storage centre
The address information of the second register of business;
The output module is specifically for being stored in the agent received every time in second register;
When receiving end signal, second register is read, the floating-point operation result is obtained.
Another aspect of the present invention provides a kind of processor, includes the device for realizing floating-point arithmetic operation as described above.
The method and apparatus that what the present invention was provided realize floating-point arithmetic operation, by increasing performance accuracy require information, and
During circulation floating-point arithmetic operation processing is carried out, first judge whether the precision of floating-point operation result meets operation essence
The precision indicated in degree require information, and stop circulation in the case where precision is met so that the floating-point operation that the present invention is provided
Method can perform the circulation of arbitrary number of times, save the execution time, reduce power consumption.
Brief description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, being used required in being described below to embodiment
Accompanying drawing be briefly described, it should be apparent that, drawings in the following description are some embodiments of the present invention, for ability
For the those of ordinary skill of domain, without having to pay creative labor, it can also obtain other according to these accompanying drawings
Accompanying drawing.
The schematic flow sheet for the embodiment of the method one for realizing floating-point arithmetic operation that Fig. 1 provides for the present invention;
The structural representation for the device embodiment one for realizing floating-point arithmetic operation that Fig. 2 provides for the present invention;
The structural representation for the device embodiment two for realizing floating-point arithmetic operation that Fig. 3 provides for the present invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
A part of embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
The schematic flow sheet for the embodiment of the method one for realizing floating-point arithmetic operation that Fig. 1 provides for the present invention, such as Fig. 1 institutes
Show, the embodiment of the present invention provides a kind of method for realizing floating-point arithmetic operation, the executive agent of this method is to realize floating-point operation
The device of operation, the device can realize that the present invention is not limited this by software or hardware.This method includes:
S101, reception floating-point operation instruction, floating-point operation indicate source operand information and performance accuracy requirement letter
Breath, performance accuracy require information indicates the precision of floating-point operation result;
S102, according to performance accuracy require information to the corresponding source operand of source operand information carry out circulation floating-point operation
Operation is handled, untill floating-point operation result meets precision;
S103, according to the middle floating-point that floating-point arithmetic operation processing is obtained during each circulation before meeting the requirement of precision
Value obtains floating-point operation result.
It will be understood by those skilled in the art that floating-point operation is instructed for indicating to carry out floating-point operation processing, floating-point is obtained
Calculation process result.The process of floating-point operation processing includes circulation floating-point arithmetic operation processing, that is, multiple floating-point arithmetic operations
Processing constitutes floating-point operation processing.The number of times that performs of floating-point arithmetic operation processing depends on the floating-point that floating-point operation instructs instruction
The precision of calculation process result.
Exemplary, floating-point operation processing can be floating-point division operation, or floating-point square-root extract computing, can also pass through
Increase pretreatment module and post-processing module in the device for realize floating-point arithmetic operation, it is fixed that floating-point division computing is extended to
Point division arithmetic and fixed point rem computing.It is exemplary, for fixed point division computing, can by the fixed point divisor of input and by except
Number switchs to floating number by pretreatment module, reapplies the method provided in an embodiment of the present invention for realizing floating-point arithmetic operation and carries out
Calculate, after floating-point operation result is obtained, floating-point operation result by post-processing module can be switched to fixed-point number again,
So as to realize the fixed point division computing of default precision.In the following embodiment of the present invention implementation routine is carried out only in conjunction with floating-point operation
Explanation.
Specifically, in S101, receiving floating-point operation instruction, floating-point operation indicates source operand information, source behaviour
Information of counting indicates the source operand of pending floating-point operation.Exemplary, when floating-point operation is division arithmetic, source operand
Including divisor and dividend.Optionally, source operand also includes the radix of SRT algorithms.Exemplary, when floating-point operation is evolution
During computing, source operand includes radicand.Floating-point operation instruction also indicates division operation required precision information, performance accuracy requirement
Information indicates the precision of floating-point operation result.The precision can according to demand be set by user.
Optionally, after S101, in addition to source operand detecting step, for detecting whether source operand is legal.Show
Example property, when floating-point operation is division arithmetic, the divisor in source operand can not be 0.When detecting illegal source operand
Pause floating-point operation simultaneously sends warning information.Exemplary, also it can directly export fortune when detecting source operand for certain number
Calculate result.Such as, when dividend is 0, it is 0 directly to export floating-point operation result.
Specifically, in S102, source operand corresponding to source operand information carries out circulation floating-point arithmetic operation processing,
Untill floating-point operation result meets precision.
Exemplary, circulation floating-point arithmetic operation processing is specifically included:
S1021, instructed according to floating-point operation, cycle-index is set to 0, carrying out floating-point operation to source operand is handled
To agent and middle remainder, cycle-index plus 1, new cycle-index is obtained, judge new cycle-index and performance accuracy
Whether require information is consistent;If it is not, then performing S1022;If so, then performing S103;
S1022, the middle remainder that floating-point operation processing obtains new agent and Xin is carried out to middle remainder, will followed again
Ring number of times adds 1, obtains new cycle-index, and judges whether new cycle-index is consistent with performance accuracy require information again,
If it is not, then this step is repeated to new middle remainder, until new cycle-index is consistent with performance accuracy require information.
Specifically, when receiving floating-point operation instruction, counter is set into 0 first, the reading of counter turns into
Cycle-index.Then, floating-point operation processing is carried out to source operand and obtains agent and middle remainder, and cycle-index is added 1,
Obtain new cycle-index.Judge whether new cycle-index is consistent with performance accuracy require information.
When new cycle-index and performance accuracy require information are inconsistent, illustrate the precision of floating-point operation result not
Reach the requirement that user wants, then middle remainder and source operand are carried out again floating-point operation processing obtain new agent and
New middle remainder.And cycle-index is added 1 again, new cycle-index is obtained, and judge new cycle-index and behaviour again
Whether consistent make required precision information.When new cycle-index and performance accuracy require information are still inconsistent, to new centre
Remainder repeats this step, until new cycle-index is consistent with performance accuracy require information.
When new cycle-index is consistent with performance accuracy require information, illustrate that the precision of floating-point operation result reaches
The requirement that user wants.Now, circulation floating-point arithmetic operation processing can be stopped, the agent obtained during according to each circulation obtains
Take floating-point operation result.
Specifically, in S103, when floating-point operation result meets precision, stopping circulation, being transported according to each floating-point
The middle floating point values that operation processing is obtained is calculated, such as agent obtains floating-point operation result.
It is worth noting that, during each circulation met before the requirement of precision in above-mentioned S103 at floating-point arithmetic operation
Obtained middle floating point values is managed, the middle floating point values that floating-point arithmetic operation processing is obtained when both including circulating every time before is also wrapped
Include the middle floating point values that the processing of this floating-point arithmetic operation is obtained.Namely also include when cycle-index and performance accuracy require information
When consistent, last time circulates resulting middle floating point values.
The method that what the present invention was provided realize floating-point arithmetic operation, by increasing performance accuracy require information, and is being carried out
During circulating floating-point arithmetic operation processing, first judge whether the precision of floating-point operation result meets performance accuracy requirement
The precision indicated in information, and stop circulation in the case where precision is met so that the floating-point operation method that the present invention is provided can
The circulation of arbitrary number of times is performed, the execution time is saved, power consumption is reduced.
Optionally, on the basis of embodiment illustrated in fig. 1, carried out in detail for the particular content of performance accuracy require information
Explanation.Performance accuracy require information it is exemplary can be following three kinds of feasible implementations:
The first feasible implementation:
Performance accuracy require information includes default floating-point operation result accuracy value;Now, new cycle-index is judged
It is whether consistent with performance accuracy require information, specifically include:
Preset loop number of times is obtained according to default floating-point operation result accuracy value, judges new cycle-index with presetting
Whether cycle-index is consistent.
Exemplary, when performance accuracy require information includes default floating-point operation result accuracy value, then need according to pre-
If floating-point operation result accuracy value obtains preset loop number of times.After preset loop number of times is obtained, it may compare each
Whether the cycle-index obtained after circulation reaches preset loop number of times.
Second of feasible implementation:
Performance accuracy require information can directly include preset loop number of times.Now, new cycle-index and operation are judged
Whether required precision information is consistent, specifically includes:
Judge whether new cycle-index is consistent with preset loop number of times.
The third feasible implementation:
According to source operand information, the precision for obtaining floating-point operation result is used as performance accuracy require information.
Exemplary, after floating-point operation instruction is received, the source operand information indicated can be instructed according to floating-point operation
Corresponding source operand, obtains the precision of floating-point operation result.For example, the precision of source operand is obtained, by source operand
Precision as floating-point operation result precision, namely performance accuracy require information indicate precision.
Exemplary, when receiving source operand, also preset loop number of times directly can be obtained according to source operand.Obtain
The mode of preset loop number of times is specific as follows shown:
Assuming that dividend is A in source operand, divisor is that B, A and B are the unsigned number of m, and m is just whole more than 1
Number, A divided by B obtain the result of a unsigned number.Assuming that A is 00 ..., (0 before 1 occurred first is for leading the 0 of 01 ..., A
Leading number 0) is designated as za;B is 000 ... 01 ..., B leading 0 number is zb.
Then basisPreset loop number of times is obtained, wherein,
1.a×2m-za-1For A scientific notation representation, 1.b × 2m-zb-1For B scientific notation representation.
(1) za is worked as>During zb, as a result one is set to 0, therefore can learn that preset loop number of times is 0.
(2) as za=zb, if a>=b, then preset loop number of times is 1;If a<B, then preset loop number of times is 0.
(3) za is worked as<During zb, if a>=b, the then business obtained is zb-za+1, therefore preset loop number of times isIt is secondary;If a<B, the then business obtained is zb-za, and preset loop number of times isIt is secondary.Wherein,
Represent to obtain the smallest positive integral more than or equal to *.
Exemplary, when application floating-point operation method provided in an embodiment of the present invention carries out floating-point operation:
When the business determined according to source operand is more than default value (i.e. business is normalized floating point number), single precision division is floated
Point processing is circulatedIt is secondary, the circulation of double precision division floating-point operationSecondary, wherein r is the radix of SRT algorithms.
When the business determined according to source operand is less than default value (i.e. business is unnormalized floating point number), it is assumed that counted
Business is 1.c × 2exp, wherein c is the fractional part of business, for the floating number of double precision formats, index offset amount bias=-
1023, for the floating number of single-precision format, index offset amount bias=-127, in order to which the result of floating-point operation is directly turned to
The form of unnormalized floating point number, due to 1.c × 2exp=1.c × 2exp+bias-1×2-bias+1, and exp<- bias+1, therefore need
1.c is moved to right | exp+bias-1 | position.Therefore business's number of significant digit in result is:It is 53- during double precision | exp+bias-1 |
Position, is 24- during single precision | exp+bias-1 | position.Therefore preset loop number of times during double precision isIt is secondary.Preset loop number of times is during single precision
Further, on the basis of any of the above-described embodiment, floating-point operation indicates that source operand information is specific
For:Indicate the address information of the first register of storage source operand;Receive after floating-point operation instruction, method also includes:
The address information of the first register of the storage source operand indicated is instructed according to floating-point operation, first is read and deposits
Device, obtains source operand.
Exemplary, the source operand information that floating-point operation instruction is indicated in indicating is the storage address of source operand, i.e.,
Store the address information of the first register of source operand.So as to reduce the length of floating-point operation instruction.
Optionally, if floating-point operation instruction also indicates that floating-point operation is processed as division, source operand include divisor and
Dividend.The middle remainder that floating-point operation processing obtains new agent and Xin is carried out to middle remainder, including:
The middle remainder that floating-point operation processing obtains new agent and Xin is carried out to middle remainder and divisor.
When carrying out division floating-point operation, when being circulated except first time, agent and middle remainder are obtained according to source operation, it
In each circulation afterwards, new agent and Xin middle remainder are obtained according to divisor and middle remainder.
Optionally, if floating-point operation instruction also indicates that floating-point operation is processed as evolution, source operand is included by evolution
Number, agent is intermediate square root.
Optionally, on the basis of any of the above-described embodiment, according to floating when meeting each circulation before the requirement of precision
The middle floating point values that point processing operation processing is obtained obtains floating-point operation result, including:
According to the agent that floating-point arithmetic operation processing is obtained during each circulation before meeting the requirement of precision, enter professional etiquette
Processing of formatting obtains floating-point operation result.
Exemplary, the agent obtained according to each circulation floating-point arithmetic operation processing carries out normalization processing and obtained
Floating-point operation result.All agents, are arranged by vertical order, in conjunction with symbolic information, index information etc.,
It can obtain floating-point operation result.
Optionally, with reference to above-described embodiment, floating-point operation instruction also indicates the ground of the second register of storage agent
Location information;The above-mentioned method for realizing floating-point arithmetic operation also includes:The agent that will be obtained after the processing of each floating-point operation, storage
In the second register;
It is corresponding, floated according to the centre that floating-point arithmetic operation processing is obtained during each circulation before meeting the requirement of precision
Point value obtains floating-point operation result, including:
The second register is read, floating-point operation result is obtained.
Exemplary, floating-point operation instruction may also indicate the address information of the second register of storage agent.When every
When secondary circulation obtains agent, agent is stored in the second register so that after circulation terminates, can directly go second to post
Floating-point operation result is read in storage.Wherein, the digit of the second register can be determined according to performance accuracy require information.
Another aspect of the present invention provides a kind of device for realizing floating-point arithmetic operation, for performing the reality in above-described embodiment
The method of existing floating-point arithmetic operation, with identical technical characteristic and technique effect.
The structural representation for the device embodiment one for realizing floating-point arithmetic operation that Fig. 2 provides for the present invention.Such as Fig. 2 institutes
Show, floating point calculator includes:Receiving module 201, circulation floating-point arithmetic operation processing module 202 and output module 203;
Receiving module 201, for receiving floating-point operation instruction, floating-point operation indicates source operand information and operation
Required precision information, performance accuracy require information indicates the precision of floating-point operation result;
Circulate floating-point arithmetic operation processing module 202, for according to performance accuracy require information to source operand information pair
The source operand answered carries out circulation floating-point arithmetic operation processing, untill floating-point operation result meets precision;
Output module 203, for being handled according to floating-point arithmetic operation during each circulation before meeting the requirement of precision
The middle floating point values arrived obtains floating-point operation result.
Optionally, on the basis of embodiment illustrated in fig. 2, the dress for realizing floating-point arithmetic operation that Fig. 3 provides for the present invention
Put the structural representation of embodiment two.As shown in figure 3, circulation floating-point arithmetic operation processing module 202 includes:Input block
2021st, loop control unit 2022 and floating-point arithmetic operation processing unit 2023;
Input block 2021 is used for, and receives the corresponding source operand of source operand information, source operand is sent into floating-point
Arithmetic operation processing unit;
Loop control unit 2022 is used for, and receives performance accuracy require information, cycle-index is set into 0, transported to floating-point
Calculate operation processing unit and send the first computing signal;Performance accuracy require information indicates the precision of floating-point operation result;
Floating-point arithmetic operation processing unit 2023 is used for, and when receiving the first computing signal, source operand is floated
Point processing processing obtains agent and middle remainder, is transmitted completion signal to loop control unit 2022, agent is sent to
Output module 203, input block 2021 is sent to by middle remainder;
Loop control unit 2022 is additionally operable to, and when receiving completion signal, plus 1 by cycle-index, is obtained new circulation
Number of times, judges whether new cycle-index is consistent with performance accuracy require information;If consistent, send and tie to output module 203
Beam signal;If inconsistent, the second computing signal is sent to floating-point arithmetic operation processing unit 2023;
Input block 2021 is additionally operable to, when receiving middle remainder, and middle remainder is sent at floating-point arithmetic operation
Manage unit 2023;
Floating-point arithmetic operation processing unit 2023 is additionally operable to, when receiving the second computing signal, and middle remainder is carried out
Floating-point operation processing obtains new agent and Xin middle remainder, is transmitted completion signal to loop control unit 2022, will be newly
Agent be sent to output module 203, new middle remainder is sent to input block 2021.
Wherein, after loop control unit 2022 sends end signal to output module 203, this time floating-point operation processing knot
Beam, loop control unit 2022 no longer sends the second computing signal to floating-point arithmetic operation processing unit 2023.
Optionally, performance accuracy require information includes default floating-point operation result accuracy value;Loop control unit
2022 specifically for,
Preset loop number of times is obtained according to default floating-point operation result accuracy value, judges new cycle-index with presetting
Whether cycle-index is consistent;And/or,
Performance accuracy require information includes preset loop number of times;Loop control unit 2022 specifically for,
Judge whether new cycle-index is consistent with preset loop number of times.
Optionally, circulation floating-point arithmetic operation processing module 202 specifically for,
According to source operand information, the precision for obtaining floating-point operation result is used as performance accuracy require information.
Optionally, floating-point operation indicates that source operand information is specially:Indicate the first of storage source operand
The address information of register;Circulate floating-point arithmetic operation processing module 202 specifically for,
The address information of the first register of the storage source operand indicated is instructed according to floating-point operation, first is read and deposits
Device, obtains source operand.
Optionally, if floating-point operation instruction also indicates that floating-point operation is processed as division, source operand include divisor and
Dividend;
Corresponding, input block 2021 is additionally operable to, when receiving middle remainder, and middle remainder and source operand are sent
To floating-point arithmetic operation processing unit 2023;
Floating-point arithmetic operation processing unit 2023 is additionally operable to, when receiving the second computing signal, to source operand with
Between remainder carry out the middle remainder that floating-point operation processing obtains new agent and Xin, be sent completely to loop control unit 2022
Signal, output module 203 is sent to by new agent, and new middle remainder is sent into input block 2021;
If floating-point operation instruction also indicates that floating-point operation is processed as evolution, source operand includes radicand, middle
Business is intermediate square root.
Optionally, output module 203 specifically for,
When receiving end signal, to all agents received, carry out normalization processing and obtain at floating-point operation
Manage result.
Optionally, floating-point operation instruction also indicates the address information of the second register of storage agent;
Output module is specifically for being stored in the agent received every time in the second register;Receiving end
During signal, the second register is read, floating-point operation result is obtained.
Another aspect of the present invention provides a kind of processor, includes the dress for realizing floating-point arithmetic operation as shown in Figure 2 or Figure 3
Put.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent
The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to
The technical scheme described in foregoing embodiments can so be modified, or which part or all technical characteristic are entered
Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology
The scope of scheme.
Claims (17)
1. a kind of method for realizing floating-point arithmetic operation, it is characterised in that including:
Floating-point operation instruction is received, the floating-point operation indicates source operand information and performance accuracy require information, institute
State the precision that performance accuracy require information indicates floating-point operation result;
Circulation floating-point operation is carried out to the corresponding source operand of the source operand information according to the performance accuracy require information
Operation is handled, untill the floating-point operation result meets the precision;
The middle floating-point that the floating-point arithmetic operation processing is obtained during according to each circulation before the requirement for meeting the precision
Value obtains floating-point operation result.
2. according to the method described in claim 1, it is characterised in that it is described according to the performance accuracy require information to the source
The corresponding source operand of operand information carries out circulation floating-point arithmetic operation processing, until the floating-point operation result is met
Untill the precision, including:
Instructed according to the floating-point operation, cycle-index is set to 0, floating-point operation processing is carried out to the source operand and is obtained
Agent and middle remainder, add 1 by the cycle-index, obtain new cycle-index, judge the new cycle-index and institute
Whether consistent state performance accuracy require information;
If it is not, the middle remainder that the floating-point operation processing obtains new agent and Xin is then carried out to the middle remainder, then
It is secondary that the cycle-index is added 1, new cycle-index is obtained, and judge the new cycle-index and the performance accuracy again
Whether require information is consistent, if it is not, then this step is repeated to new middle remainder, until new cycle-index and the behaviour
Make required precision information consistent.
3. method according to claim 2, it is characterised in that
The performance accuracy require information includes default floating-point operation result accuracy value;It is then described to judge the new circulation
Whether number of times is consistent with the performance accuracy require information, including:
Preset loop number of times is obtained according to the default floating-point operation result accuracy value, judge the new cycle-index and
Whether the preset loop number of times is consistent;Or,
The performance accuracy require information includes preset loop number of times;It is then described to judge the new cycle-index and the operation
Whether required precision information is consistent, including:
Judge whether the new cycle-index is consistent with the preset loop number of times.
4. according to the method described in claim 1, it is characterised in that after the reception floating-point operation instruction, methods described
Also include:
According to the source operand information, the precision for obtaining floating-point operation result is used as the performance accuracy require information.
5. the method according to any one of Claims 1-4, it is characterised in that the floating-point operation indicates that source is grasped
Information of counting is specially:Indicate the address information for the first register for storing the source operand;The reception floating-point operation
After instruction, methods described also includes:
The address information of the first register of the storage source operand indicated is instructed according to the floating-point operation, is read described
First register, obtains the source operand.
6. according to the method in claim 2 or 3, it is characterised in that if floating-point operation instruction also indicates described float
Point processing is processed as division, then the source operand includes divisor and dividend;It is described that described float is carried out to the middle remainder
Point processing processing obtains new agent and Xin middle remainder, including:
The middle remainder that the floating-point operation processing obtains new agent and Xin is carried out to the middle remainder and the divisor;
If the floating-point operation instruction also indicates that the floating-point operation is processed as evolution, the source operand is included by evolution
Number, the agent is intermediate square root.
7. according to the method in claim 2 or 3, it is characterised in that described according to before the requirement for meeting the precision
The middle floating point values that the floating-point arithmetic operation processing is obtained during circulation every time obtains floating-point operation result, including:
The agent that the floating-point arithmetic operation processing is obtained during according to each circulation before the requirement for meeting the precision, enters
Professional etiquette processing of formatting obtains the floating-point operation result.
8. according to the method in claim 2 or 3, it is characterised in that the floating-point operation instruction also indicates that storage is described
The address information of the second register of agent;
Methods described also includes:The agent that will be obtained after the floating-point operation processing every time, is stored in second register
In;
Corresponding, the floating-point arithmetic operation processing is obtained during each circulation according to before the requirement for meeting the precision
Middle floating point values obtain floating-point operation result, including:
Second register is read, the floating-point operation result is obtained.
9. a kind of device for realizing floating-point arithmetic operation, it is characterised in that including:At receiving module, circulation floating-point arithmetic operation
Manage module and output module;
The receiving module, for receiving floating-point operation instruction, the floating-point operation indicates source operand information and behaviour
Make required precision information, the performance accuracy require information indicates the precision of floating-point operation result;
The circulation floating-point arithmetic operation processing module, for being believed according to the performance accuracy require information the source operand
Cease corresponding source operand and carry out circulation floating-point arithmetic operation processing, until the floating-point operation result meets the precision
Untill;
The output module, at according to floating-point arithmetic operation during each circulation before the requirement for meeting the precision
Manage obtained middle floating point values and obtain floating-point operation result.
10. device according to claim 9, it is characterised in that the circulation floating-point arithmetic operation processing module includes:It is defeated
Enter unit, loop control unit and floating-point arithmetic operation processing unit;
The input block is used for, and receives the corresponding source operand of the source operand information, the source operand is sent to
The floating-point arithmetic operation processing unit;
The loop control unit is used for, and receives the performance accuracy require information, cycle-index is set into 0, is floated to described
Point processing operation processing unit sends the first computing signal;The performance accuracy require information indicates floating-point operation result
Precision;
The floating-point arithmetic operation processing unit is used for, and when receiving the first computing signal, the source operand is entered
The processing of row floating-point operation obtains agent and middle remainder, is transmitted completion signal to the loop control unit, by the centre
Business is sent to the output module, and the middle remainder is sent into the input block;
The loop control unit is additionally operable to, and when receiving the completion signal, is added 1 by the cycle-index, is obtained new
Cycle-index, judges whether the new cycle-index is consistent with the performance accuracy require information;If consistent, to described defeated
Go out module and send end signal;If inconsistent, the second computing signal is sent to the floating-point arithmetic operation processing unit;
The input block is additionally operable to, when receiving the middle remainder, and the middle remainder is sent into the floating-point transports
Calculate operation processing unit;
The floating-point arithmetic operation processing unit is additionally operable to, when receiving the second computing signal, to the middle remainder
Middle the remainder that floating-point operation processing obtains new agent and Xin is carried out, is sent to the loop control unit and described completes letter
Number, the new agent is sent to the output module, the new middle remainder is sent to the input block.
11. device according to claim 10, it is characterised in that
The performance accuracy require information includes default floating-point operation result accuracy value;The loop control unit is specifically used
In,
Preset loop number of times is obtained according to the default floating-point operation result accuracy value, judge the new cycle-index and
Whether the preset loop number of times is consistent;And/or,
The performance accuracy require information includes preset loop number of times;The loop control unit specifically for,
Judge whether the new cycle-index is consistent with the preset loop number of times.
12. device according to claim 9, it is characterised in that the circulation floating-point arithmetic operation processing module is specifically used
In,
According to the source operand information, the precision for obtaining floating-point operation result is used as the performance accuracy require information.
13. the device according to any one of claim 9 to 12, it is characterised in that the floating-point operation indicates source
Operand information is specially:Indicate the address information for the first register for storing the source operand;The circulation floating-point fortune
Calculate operation processing module specifically for,
The address information of the first register of the storage source operand indicated is instructed according to the floating-point operation, is read described
First register, obtains the source operand.
14. the device according to claim 10 or 11, it is characterised in that if floating-point operation instruction also indicate it is described
Floating-point operation is processed as division, then the source operand includes divisor and dividend;
Corresponding, the input block is additionally operable to, when receiving the middle remainder, and the middle remainder and the source are grasped
Count and be sent to the floating-point arithmetic operation processing unit;
The floating-point arithmetic operation processing unit is additionally operable to, when receiving the second computing signal, to the source operand
The middle remainder that floating-point operation processing obtains new agent and Xin is carried out with the middle remainder, to the loop control unit
The completion signal is sent, the new agent is sent to the output module, the new middle remainder is sent to
The input block;
If the floating-point operation instruction also indicates that the floating-point operation is processed as evolution, the source operand is included by evolution
Number, the agent is intermediate square root.
15. the device according to claim 10 or 11, it is characterised in that the output module specifically for,
When receiving end signal, to all agents received, carry out normalization processing and obtain the floating-point fortune
Calculate result.
16. the device according to claim 10 or 11, it is characterised in that the floating-point operation instruction also indicates storage institute
State the address information of the second register of agent;
The output module is specifically for being stored in the agent received every time in second register;Connecing
When receiving end signal, second register is read, the floating-point operation result is obtained.
17. a kind of processor, it is characterised in that comprising realizing floating-point arithmetic operation as described in any one of claim 9 to 16
Device.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710161711.0A CN106997284B (en) | 2017-03-17 | 2017-03-17 | Method and device for realizing floating point operation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710161711.0A CN106997284B (en) | 2017-03-17 | 2017-03-17 | Method and device for realizing floating point operation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106997284A true CN106997284A (en) | 2017-08-01 |
CN106997284B CN106997284B (en) | 2021-05-04 |
Family
ID=59430985
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710161711.0A Active CN106997284B (en) | 2017-03-17 | 2017-03-17 | Method and device for realizing floating point operation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106997284B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110287085A (en) * | 2019-06-28 | 2019-09-27 | 龙芯中科技术有限公司 | Detection method, device, equipment and the readable storage medium storing program for executing of flop operating speed |
CN112527239A (en) * | 2021-02-10 | 2021-03-19 | 北京微核芯科技有限公司 | Floating point data processing method and device |
CN113672198A (en) * | 2021-08-18 | 2021-11-19 | 南京英锐创电子科技有限公司 | Binary floating-point number addition operation method, circuit and computing device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7085940B2 (en) * | 2002-05-09 | 2006-08-01 | International Business Machines Corporation | Floating point unit power reduction via inhibiting register file write during tight loop execution |
CN103984522A (en) * | 2014-05-27 | 2014-08-13 | 中国人民解放军国防科学技术大学 | Method for achieving fixed point and floating point mixed division in general-purpose digital signal processor (GPDSP) |
CN105389157A (en) * | 2015-10-29 | 2016-03-09 | 中国人民解放军国防科学技术大学 | Goldschmidt algorithm-based floating-point divider |
-
2017
- 2017-03-17 CN CN201710161711.0A patent/CN106997284B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7085940B2 (en) * | 2002-05-09 | 2006-08-01 | International Business Machines Corporation | Floating point unit power reduction via inhibiting register file write during tight loop execution |
CN103984522A (en) * | 2014-05-27 | 2014-08-13 | 中国人民解放军国防科学技术大学 | Method for achieving fixed point and floating point mixed division in general-purpose digital signal processor (GPDSP) |
CN105389157A (en) * | 2015-10-29 | 2016-03-09 | 中国人民解放军国防科学技术大学 | Goldschmidt algorithm-based floating-point divider |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110287085A (en) * | 2019-06-28 | 2019-09-27 | 龙芯中科技术有限公司 | Detection method, device, equipment and the readable storage medium storing program for executing of flop operating speed |
CN112527239A (en) * | 2021-02-10 | 2021-03-19 | 北京微核芯科技有限公司 | Floating point data processing method and device |
CN113672198A (en) * | 2021-08-18 | 2021-11-19 | 南京英锐创电子科技有限公司 | Binary floating-point number addition operation method, circuit and computing device |
CN113672198B (en) * | 2021-08-18 | 2024-01-26 | 南京英锐创电子科技有限公司 | Binary floating point number addition operation circuit control method, circuit and computing device |
Also Published As
Publication number | Publication date |
---|---|
CN106997284B (en) | 2021-05-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10649733B2 (en) | Multiply add functional unit capable of executing scale, round, getexp, round, getmant, reduce, range and class instructions | |
CN106126189B (en) | Method in microprocessor | |
CN103793203B (en) | Reducing power consumption in a fused multiply-add (FMA) unit responsive to input data values | |
TWI455021B (en) | Functional unit, method and computer system for vector integer multiply add instruction | |
US11175891B2 (en) | Systems and methods to perform floating-point addition with selected rounding | |
JP2017062804A (en) | Floating-point processor with reduced power requirements for selectable subprecision | |
CN104899004B (en) | A kind of data processing equipment and method for floating-point operation number to be multiplied | |
CN106997284A (en) | The method and apparatus for realizing floating-point arithmetic operation | |
US7395297B2 (en) | Floating point system that represents status flag information within a floating point operand | |
RU2413972C2 (en) | Controlled-precision iterative arithmetic logic unit | |
WO2013109532A1 (en) | Algebraic processor | |
US5828591A (en) | Method and apparatus for using a cache memory to store and retrieve intermediate and final results | |
US20210279038A1 (en) | Using fuzzy-jbit location of floating-point multiply-accumulate results | |
Cody | Analysis of proposals for the floating-point standard | |
Schulte et al. | A variable-precision interval arithmetic processor | |
US7219117B2 (en) | Methods and systems for computing floating-point intervals | |
US20040249877A1 (en) | Fast integer division with minimum number of iterations in substraction-based hardware divide processor | |
Goldstein | Significance arithmetic on a digital computer | |
US10459689B2 (en) | Calculation of a number of iterations | |
US7236999B2 (en) | Methods and systems for computing the quotient of floating-point intervals | |
US20070233774A1 (en) | Rounding of binary integers | |
US20090216823A1 (en) | Method, system and computer program product for verifying floating point divide operation results | |
CN114691082A (en) | Multiplier circuit, chip, electronic device, and computer-readable storage medium | |
JP2010033275A (en) | Data processing method and data processor | |
Petersen | A SWAR approach to counting ones |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant after: Loongson Zhongke Technology Co.,Ltd. Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |