Name Strings

SPV_EXT_arithmetic_fence

Contact

To report problems with this extension, please open a new issue at:

Contributors

  • Dmitry Sidorov, Intel

  • Joe Garvey, Intel

  • Arvind Sudarsanam, Intel

  • Pawel Jurek, Intel

  • Ben Ashbaugh, Intel

  • Greg Lueck, Intel

  • Kévin Petit, ARM

Notice

Copyright (c) 2024 The Khronos Group Inc. Copyright terms at http://www.khronos.org/registry/speccopyright.html

Status

  • Complete

Version

Last Modified Date

2024-07-16

Revision

2

Dependencies

This extension is written against the SPIR-V Specification, Version 1.6 Revision 3.

This extension requires SPIR-V 1.0.

Overview

The extension adds OpArithmeticFenceEXT instruction that prevents fast-math optimizations between its argument and the expression that contains it. For example for fast FP model a compiler can perform reassociation:

If all these OpFAdd instructions have the "Fast" FP fast math mode then:

%ab = OpFAdd %float %a %b
%abc = OpFAdd %float %ab %c
%abc_fence = OpArithmeticFenceEXT %float %abc
%result = OpFAdd %float %abc_fence %d

can be transformed into:

%bc = OpFAdd %float %b %c
%abc = OpFAdd %float %a %bc
%abc_fence = OpArithmeticFenceEXT %float %abc
%result = OpFAdd %float %abc_fence %d

but not into:

%ab = OpFAdd %float %a %b
%ab_fence = OpArithmeticFenceEXT %float %ab
%cd = OpFAdd %float %c %d
%result = OpFAdd %float %ab_fence %cd

This instruction is an equivalent of llvm.arithmetic.fence intrinsic function.

Extension Name

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

OpExtension "SPV_EXT_arithmetic_fence"

New Capabilities

This extension introduces a new capability:

ArithmeticFenceEXT

New Instructions

Instructions added under the ArithmeticFenceEXT capability:

OpArithmeticFenceEXT

Token Number Assignments

ArithmeticFenceEXT

6144

OpArithmeticFenceEXT

6145

Modifications to the SPIR-V Specification, Version 1.5

Capabilities

Modify Section 3.31, "Capability", adding these rows to the Capability table:

Capability Depends On

6144

ArithmeticFenceEXT
Allow to use OpArithmeticFenceEXT instruction

Instructions

In section 3.49.1. Miscellaneous Instructions, add a new instruction:

OpArithmeticFenceEXT
Return Target. Indicates that the optimizer can not move or combine Target with the expression that uses Result of the instruction.

Target must be scalar or vector of floating-point type.

Result Type must be the same as the return type of the Target instruction.

Capability: ArithmeticFenceEXT

4

6145

Result Type <id>

Result <id>

Target <id>

Issues

Revision History

Rev Date Author Changes

1

2021-05-26

Dmitry Sidorov

Initial revision

2

2024-07-16

Dmitry Sidorov

Prepare for publication