Ginkgo
Generated from pipelines/1589998975 branch based on develop. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
|
This class is used to encode storage precisions of low precision algorithms. More...
#include <ginkgo/core/base/types.hpp>
Public Types | |
using | storage_type = uint8 |
The underlying datatype used to store the encoding. | |
Public Member Functions | |
constexpr | precision_reduction () noexcept |
Creates a default precision_reduction encoding. More... | |
constexpr | precision_reduction (storage_type preserving, storage_type nonpreserving) noexcept |
Creates a precision_reduction encoding with the specified number of conversions. More... | |
constexpr | operator storage_type () const noexcept |
Extracts the raw data of the encoding. More... | |
constexpr storage_type | get_preserving () const noexcept |
Returns the number of preserving conversions in the encoding. More... | |
constexpr storage_type | get_nonpreserving () const noexcept |
Returns the number of non-preserving conversions in the encoding. More... | |
Static Public Member Functions | |
constexpr static precision_reduction | autodetect () noexcept |
Returns a special encoding which instructs the algorithm to automatically detect the best precision. More... | |
constexpr static precision_reduction | common (precision_reduction x, precision_reduction y) noexcept |
Returns the common encoding of input encodings. More... | |
This class is used to encode storage precisions of low precision algorithms.
Some algorithms in Ginkgo can improve their performance by storing parts of the data in lower precision, while doing computation in full precision. This class is used to encode the precisions used to store the data. From the user's perspective, some algorithms can provide a parameter for fine-tuning the storage precision. Commonly, the special value returned by precision_reduction::autodetect() should be used to allow the algorithm to automatically choose an appropriate value, though manually selected values can be used for fine-tuning.
In general, a lower precision floating point value can be obtained by either dropping some of the insignificant bits of the significand (keeping the same number of exponent bits, and thus preserving the range of representable values) or using one of the hardware or software supported conversions between IEEE formats, such as double to float or float to half (reducing both the number of exponent, as well as significand bits, and thus decreasing the range of representable values).
The precision_reduction class encodes the lower precision format relative to the base precision used and the algorithm in question. The encoding is done by specifying the amount of range non-preserving conversions and the amount of range preserving conversions that should be done on the base precision to obtain the lower precision format. For example, starting with a double precision value (11 exp, 52 sig. bits), the encoding specifying 1 non-preserving conversion and 1 preserving conversion would first use a hardware-supported non-preserving conversion to obtain a single precision value (8 exp, 23 sig. bits), followed by a preserving bit truncation to obtain a value with 8 exponent and 7 significand bits. Note that non-preserving conversion are always done first, as preserving conversions usually result in datatypes that are not supported by builtin conversions (thus, it is generally not possible to apply a non-preserving conversion to the result of a preserving conversion).
If the specified conversion is not supported by the algorithm, it will most likely fall back to using full precision for storing the data. Refer to the documentation of specific algorithms using this class for details about such special cases.
|
inlineconstexprnoexcept |
Creates a default precision_reduction encoding.
This encoding represents the case where no conversions are performed.
Referenced by common().
|
inlineconstexprnoexcept |
Creates a precision_reduction encoding with the specified number of conversions.
preserving | the number of range preserving conversion |
nonpreserving | the number of range non-preserving conversions |
|
inlinestaticconstexprnoexcept |
Returns a special encoding which instructs the algorithm to automatically detect the best precision.
|
inlinestaticconstexprnoexcept |
Returns the common encoding of input encodings.
The common encoding is defined as the encoding that does not have more preserving, nor non-preserving conversions than the input encodings.
x | an encoding |
y | an encoding |
x
and y
References precision_reduction().
|
inlineconstexprnoexcept |
Returns the number of non-preserving conversions in the encoding.
|
inlineconstexprnoexcept |
Returns the number of preserving conversions in the encoding.
|
inlineconstexprnoexcept |
Extracts the raw data of the encoding.