logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Reinterpreting_Types_Using_as_type()_and_as_typen()

Authors

TheKhronosGroup

Description

       All data types described in scalarDataTypes(3clc) and vectorDataTypes(3clc) (except bool, half (unless
       the cl_khr_fp16(3clc) extension is supported), and void) may be also reinterpreted as another data type
       of the same size using the as_type() operator for scalar data types and the as_typen() operator for
       vector data types. When the operand and result type contain the same number of elements, the bits in the
       operand shall be returned directly without modification as the new type. The usual type promotion for
       function arguments shall not be performed.

       For example, as_float(0x3f800000) returns 1.0f, which is the value that the bit pattern 0x3f800000 has if
       viewed as an IEEE-754 single precision value.

       When the operand and result type contain a different number of elements, the result shall be
       implementation-defined except if the operand is a 4-component vector and the result is a 3-component
       vector. In this case, the bits in the operand shall be returned directly without modification as the new
       type. That is, a conforming implementation shall explicitly define a behavior, but two conforming
       implementations need not have the same behavior when the number of elements in the result and operand
       types does not match. The implementation may define the result to contain all, some or none of the
       original bits in whatever order it chooses. It is an error to use the as_type() or as_typen() operators
       to reinterpret data to a type of a different number of bytes.

Name

       Reinterpreting_Types_Using_as_type()_and_as_typen()

       as_type()
       as_typen()

Notes

        1. OpenCL Specification
           page 212, section 6.2.4.2 - Reinterpreting Types Using as_typen()

The Khronos Group                                  11/18/2024                         REINTERPRETINGTYPES(3clc)

See Also

scalarDataTypes(3clc), vectorDataTypes(3clc)

Specification

OpenCLSpecification[1]

See Also