Native support for execution of get exponent, get mantisssa, and scale instructions within a graphics processing unit via reuse of fused multiply-add execution unit hardware logic
Abstract
Embodiments are directed to systems and methods for reuse of FMA execution unit hardware logic to provide native support for execution of get exponent, get mantissa, and/or scale instructions within a GPU. These new instructions may be used to implement branch-free emulation algorithms for mathematical functions and analytic functions (e.g., transcendental functions) by detecting and handling various special case inputs within a pre-processing stage of the FMA execution unit, which allows the main dataflow of the FMA execution unit to be bypassed for such special cases. Since special cases are handled by the FMA execution unit, library functions emulating various functions, including, but not limited to logarithm, exponential, and division operations may be implemented with significantly fewer lines of machine-level code, thereby providing improved performance for HPC applications.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1. A method comprising:
receiving a get mantissa instruction, wherein the get mantissa instruction specifies a first source operand and a destination operand represented in floating-point format and specifies a second source operand containing a plurality of control bits; and
executing the get mantissa instruction on a fused multiply-add (FMA) processing unit of the FPU by:
after a determination indicative of the first source operand representing a special case of a plurality of special cases:
bypassing a main data flow of the FMA processing unit; and
setting the destination operand to a value corresponding to the special case; and
after a determination indicative of the first the first source operand not representing any of the plurality of special cases, following the main data flow of the FMA processing unit, including:
setting a mantissa portion of the destination operand to a mantissa portion of the first source operand;
selectively setting an exponent portion of the destination operand to a bias value or the bias value minus 1 based on a normalization interval encoded within the plurality of control bits and an unbiased exponent value of the first source operand; and
selectively setting a sign portion of the destination operand based on a sign control encoded within the plurality of control bits.
2. The method of claim 1 , further comprising:
determining the first source operand is denormal; and
prior to said setting a mantissa portion of the destination operand and after said determining the first source operand is denormal, normalizing the first source operand.
3. The method of claim 1 , wherein the FMA processing unit also supports execution of a get exponent instruction that extracts an exponent of an input floating point number.
4. The method of claim 1 , wherein the FMA processing unit also supports execution of a scale instruction that outputs a value representing a first input floating point number multiplied by 2 to a power of a second input floating point number rounded downwards to a nearest integer.
5. The method of claim 1 , wherein the special case is:
Not-a-Number (NaN) and wherein the value corresponding to the special case is quiet NaN; or
positive infinity (+INF) or positive zero and wherein the value corresponding to the special case is 1.0.
6. The method of claim 1 , wherein the get mantissa instruction is part of a branch-free algorithm for performing a mathematic or analytic function.
7. The method of claim 6 , wherein the mathematic or analytic function comprises a logarithm operation.
8. A non-transitory computer-readable storage medium embodying a set of instructions, including a scale instruction specifying a first source operand, a second source operand, and a destination operand represented in floating-point format, which when executed by a floating point unit (FPU) of a shader processing unit of a graphics processing unit (GPU) cause the FPU to:
execute the scale instruction on a fused multiply-add (FMA) processing units of the FPU by:
after a determination indicative of the first source operand and the second source operand representing a special case of a plurality of special cases:
bypassing a main data flow of the FMA processing unit; and
setting the destination operand to a value corresponding to the special case; and
after a determination indicative of the first source operand and the second source operand not representing any of the plurality of special cases, following the main data flow of the FMA processing unit, including:
generating a temporary mantissa by extracting a mantissa portion from the first source operand;
generating a temporary integer value by converting the second source operand to integer format;
generating a temporary exponent by adding an exponent portion of the first source operand to the temporary integer value; and
setting the destination operand by applying overflow/underflow logic and rounding logic of the FMA processing unit to the temporary mantissa and the temporary exponent.
9. The non-transitory computer-readable storage medium of claim 8 , wherein the FMA processing unit also supports execution of a get mantissa instruction that extracts a mantissa of an input floating point number.
10. The non-transitory computer-readable storage medium of claim 8 , wherein the FMA processing unit also supports execution of a get exponent instruction that extracts an exponent of an input floating point number.
11. The non-transitory computer-readable storage medium of claim 8 , wherein the scale instruction is part of a branch-free algorithm for performing a mathematic or analytic function.
12. The non-transitory computer-readable storage medium of claim 11 , wherein the mathematic or analytic function comprises an exponential operation or a quotient approximation.
13. A graphics processing unit (GPU) comprising:
a fused multiply-add (FMA) processing unit operable to:
receive a get exponent instruction, wherein the get exponent instruction specifies a source operand and a destination operand represented in floating-point format; and
execute the get exponent instruction by:
after a determination indicative of the source operand representing a special case of a plurality of special cases:
bypassing a main data flow of the FMA processing unit; and
setting the destination operand to a value corresponding to the special case; and
after a determination indicative of the source operand not representing any of the plurality of special cases, following the main data flow of the FMA processing unit, including:
obtaining an integer value of an unbiased representation of a biased exponent of the source operand;
converting the unbiased representation to a floating point number; and
setting the destination operand to the floating point number.
14. The GPU of claim 13 , wherein the FMA processing unit is further operable to prior to said obtaining and after a determination indicative that the source operand is denormal, normalizing the source operand.
15. The GPU of claim 13 , wherein the FMA processing unit also supports execution of a get mantissa instruction that extracts a mantissa of an input floating point number.
16. The GPU of claim 13 , wherein the FMA processing unit also supports execution of a scale instruction that outputs a value representing a first input floating point number multiplied by 2 to a power of a second input floating point number rounded downwards to a nearest integer.
17. The GPU of claim 13 , wherein the special case is Not-a-Number (NaN) and wherein the value corresponding to the special case is quiet NaN.
18. The GPU of claim 13 , wherein the special case is:
positive infinity (+INF) or negative infinity (−INF) and wherein the value corresponding to the special case is +INF; or
zero and wherein the value corresponding to the special case is −INF.
19. The GPU of claim 13 , wherein the get exponent instruction is part of a branch-free algorithm for performing a mathematic or analytic function.
20. The GPU of claim 19 , wherein the mathematic or analytic function comprises a logarithm operation.Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.