Skip to content
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions sycl/doc/extensions/SPIRV/SPV_INTEL_float_controls2.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
SPV_INTEL_float_controls2
=========================

Name Strings
------------

SPV_INTEL_float_controls2

Contact
-------

To report problems or to provide input on this extension, please open a new issue at:
https://github.com/intel/llvm/issues

Contributors
------------

- Gang Chen, Intel
- Mariusz Merecki, Intel
- Aleksander Us, Intel
- Konstantin Vladimirov, Intel
- Rudenko Nikita, Intel
Notice
------

Copyright (c) 2020 Intel Corporation. All rights reserved.

Status
------

Working Draft

This is a preview extension specification, intended to provide early access to a feature for review and community feedback. When the feature matures, this specification may be released as a formal extension.

Because the interfaces defined by this specification are not final and are subject to change they are not intended to be used by shipping software products. If you are interested in using this feature in your software product, please let us know!


Version
-------

[width="40%",cols="25,25"]
|========================================
| Last Modified Date | 2020-08-03
| Revision | 3
|========================================

Dependencies
------------

This extension is written against the SPIR-V Specification,
Version 1.5, Revision 3, Unified

This extension requires SPIR-V 1.0.

Overview
--------

This extension adds new execution modes and decorations to control floating-point computations.
This extension adds execution modes with round to positive infinity and round to negative infinity default rounding
and execution modes specifying compliance with floating-point arithmetic (IEEE 754) standard.
This extension adds new decorations that can be applied to a function to control floating-point computations inside the function.


Extension Name
--------------

To use this extension within a SPIR-V module, the following
*OpExtension* must be present in the module:

----
OpExtension "SPV_INTEL_float_controls2"
----

Modifications to the SPIR-V Specification, Version 1.5, Revision 3, Unified
---------------------------------------------------------------------------

Modify Section 3.6, Execution Mode, add the following rows to the Execution Mode table:

--
[cols="1,20,10,10",options="header",width = "80%"]
|====
2+^| Execution Mode | Extra Operands | Enabling Capabilities
| 5620 | *RoundingModeRTPINTEL* +
The default rounding mode for floating-point arithmetic and conversions instructions must be round to positive infinity.
If an instruction is decorated with *FPRoundingMode* or defines a rounding mode in its description, that rounding mode is applied and *RoundingModeRTPINTEL* is ignored.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
| <<Literal, 'Literal'>> _Target Width_ | *RoundToInfinityINTEL*
| 5621 | *RoundingModeRTNINTEL* +
The default rounding mode for floating-point arithmetic and conversions instructions must be round to negative infinity.
If an instruction is decorated with *FPRoundingMode* or defines a rounding mode in its description, that rounding mode is applied and *RoundingModeRTNINTEL* is ignored.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
| <<Literal, 'Literal'>> _Target Width_ | *RoundToInfinityINTEL*
| 5622 | *FloatingPointModeALTINTEL* +
The default floating-point operation mode for floating-point arithmetic and conversions instructions must be the Alternative Floating-Point Mode as specified by the client API.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
| <<Literal, 'Literal'>> _Target Width_ | *FloatingPointModeINTEL*
| 5623 | *FloatingPointModeIEEEINTEL* +
The default floating-point operation mode for floating-point arithmetic and conversions instructions must be the IEEE 754 Mode as specified by the client API.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
| <<Literal, 'Literal'>> _Target Width_ | *FloatingPointModeINTEL*
|====
--
Modify Section 3 Binary form, add new sub-sections after 3.16 FP Rounding Mode:
--
[[FP_Denorm_Mode]]*3.17. FP Denorm Mode*

Denormalized values handling mode.

[cols="^.^1,15,15",options="header",width = "50%"]
|====
2+^.^| FP Denorm Mode | Enabling Capabilities
| 0x0 | *Preserve* +
Denormalized values must be preserved. |
| 0x1 | *FlushToZero* +
Denormalized values must be flushed to zero. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming: For the FlushToZero denorm mode denormalized values must be flushed to zero? Or is it possible that some implementations may still preserve denorms? I'm reminded of this text for the -cl-denorms-are-zero build option (link, emphasis mine):

This option controls how single precision and double precision denormalized numbers are handled. If specified as a build option, the single precision denormalized numbers may be flushed to zero; double precision denormalized numbers may also be flushed to zero if the optional extension for double precision is supported. This is intended to be a performance hint and the OpenCL compiler can choose not to flush denorms to zero if the device supports single precision (or double precision) denormalized numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have corresponding execution modes whose description uses "is flushed to zero" or "is preserved". We could do the same here (instead of must ) and defer to Client API spec.
Note: Vulkan spec defines a list of instructions that must flush to zero or preserve. Other instructions may flush to zero or preserve.

|====
[[FP_Operation_Mode]]*3.18. FP Operation Mode*

Floating-point operation mode.

[cols="^.^1,15,15",options="header",width = "50%"]
|====
2+^.^| FP Operation Mode | Enabling Capabilities
| 0x0 | *IEEE* +
Floating-point operation mode is IEEE 754 Mode. |
| 0x1 | *ALT* +
Floating-point operation mode is Alternative Mode. |
|====
--

Modify Section 3.20, Decoration, add the following rows to the Decoration table:

--
[cols="1,20,5,5,10",options="header",width = "80%"]
|====
2+^| Decoration 2+| Extra Operands | Enabling Capabilities
| 5822 | *FunctionRoundingModeINTEL* +
Apply to a function to overwrite the default rounding mode for all floating-point arithmetic and conversion instructions inside the function.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
|<<Literal, 'Literal'>> +
_Target Width_|<<FP_Rounding_Mode, 'FP Rounding Mode'>> +
_FP Rounding Mode_| *FunctionFloatControlINTEL*
| 5823 | *FunctionDenormModeINTEL* +
Apply to a function to overwrite the default mode of handling denormalized values for all floating-point arithmetic and conversion instructions inside the function.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
|<<Literal, 'Literal'>> +
_Target Width_|<<FP_Denorm_Mode, 'FP Denorm Mode'>> +
_FP Denorm Mode_| *FunctionFloatControlINTEL*
| 6080 | *FunctionFloatingPointModeINTEL* +
Apply to a function to overwrite the default floating-point operation mode for all floating-point arithmetic and conversion instructions inside the function.
Only affects instructions operating on a floating-point type whose component width is _Target Width_.

_Target Width_ is an unsigned 32-bit integer.
|<<Literal, 'Literal'>> +
_Target Width_|<<FP_Operation_Mode, 'FP_Operation_Mode'>> +
_FP Operation Mode_| *FunctionFloatControlINTEL*
|====

Modify Section 3.31, Capability, add the following rows the 'Capability' table:
--
[cols="1,20,10",options="header",width = "80%"]
|====
2+^| Capability | Implicitly Declares
| 5582 | *RoundToInfinityINTEL* +
Module uses *RoundingModeRTNINTEL* or *RoundingModeRTPINTEL* execution modes.
|
| 5583 | *FloatingPointModeINTEL* +
Module uses *FloatingPointModeIEEEINTEL* or *FloatingPointModeALTINTEL* execution modes.
|
| 5821 | *FunctionFloatControlINTEL* +
Module uses *FunctionRoundingModeINTEL*, *FunctionDenormModeINTEL* or *FunctionFloatingPointModeINTEL* decorations.
|
|====
--

Issues
------
--

Revision History
----------------

[cols="5,15,15,70"]
[grid="rows"]
[options="header"]
|========================================
|Rev|Date|Author|Changes
|1|2020-04-17|Mariusz Merecki|Initial revision
|2|2020-04-24|Mariusz Merecki|Assigned token numbers to *RoundToInfinityINTEL* and *FloatingPointModeINTEL*
|3|2020-08-03|Mariusz Merecki|Rebased to SPIR-V Version 1.5, Revision 3, Unified. Added *FunctionFloatControlINTEL* capability and *FunctionRoundingModeINTEL*, *FunctionDenormModeINTEL*, *FunctionFloatingPointModeINTEL* decorations
|========================================