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

Scalar_Data_Types - Built-in scalar data types.

Authors

TheKhronosGroup

Description

       These are the data types available in the OpenCL C programming language used to create kernels that are
       executed on OpenCL device(s). The OpenCL C programming language (also referred to as OpenCL C) is based
       on the ISO/IEC 9899:1999 C language specification (a.k.a. C99 specification) with specific extensions and
       restrictions. Please refer to the ISO/IEC 9899:1999 specification for a detailed description of the
       language grammar. This section describes modifications and restrictions to ISO/IEC 9899:1999 supported in
       OpenCL C.

       Most built-in scalar data types are also declared as appropriate types in the OpenCL API (and header
       files) that can be used by an application. The following table describes the built-in scalar data type in
       the OpenCL C programming language and the corresponding data type available to the application:
       ┌────────────────────────────┬──────────────────────────────┬──────────────────────────┐
       │ TypeinOpenCLCLanguageDescriptionAPItypeforapplication │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ bool                       │ A conditional data type      │ n/a                      │
       │                            │ which is either true or      │                          │
       │                            │ false. The value true        │                          │
       │                            │ expands to the integer       │                          │
       │                            │ constant 1 and the value     │                          │
       │                            │ false expands to the integer │                          │
       │                            │ constant 0. When any scalar  │                          │
       │                            │ value is converted to bool,  │                          │
       │                            │ the result is 0 if the value │                          │
       │                            │ compares equal to 0;         │                          │
       │                            │ otherwise, the result is 1.  │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ char                       │ A signed two's complement    │ cl_char                  │
       │                            │ 8-bit integer.               │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │            unsignedchar,  │ An unsigned 8-bit integer.   │ cl_uchar                 │
       │            uchar           │                              │                          │
       │                            │                              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ short                      │ A signed two's complement    │ cl_short                 │
       │                            │ 16-bit integer.              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │            unsignedshort, │ An unsigned 16-bit integer.  │ cl_ushort                │
       │            ushort          │                              │                          │
       │                            │                              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ int                        │ A signed two's complement    │ cl_int                   │
       │                            │ 32-bit integer.              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │            unsignedint,   │ An unsigned 32-bit integer.  │ cl_uint                  │
       │            uint            │                              │                          │
       │                            │                              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ long                       │ A signed two's complement    │ cl_long                  │
       │                            │ 64-bit integer.              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │            unsignedlong,  │ An unsigned 64-bit integer.  │ cl_ulong                 │
       │            ulong           │                              │                          │
       │                            │                              │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ float                      │ A 32-bit floating point. The │ cl_float                 │
       │                            │ float data type must conform │                          │
       │                            │ to the IEEE 754 single       │                          │
       │                            │ precision storage format.    │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ double                     │ A 64-bit floating point. The │ cl_double                │
       │                            │ double data type must        │                          │
       │                            │ conform to the IEEE 754      │                          │
       │                            │ double precision storage     │                          │
       │                            │ format. The double scalar    │                          │
       │                            │ type is an optional type     │                          │
       │                            │ that is supported if         │                          │
       │                            │ CL_DEVICE_DOUBLE_FP_CONFIG   │                          │
       │                            │ for a device is not zero.    │                          │
       │                            │ See the table for param_name │                          │
       │                            │ for clGetDeviceInfo(3clc)    │                          │
       │                            │ for details.                 │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half                       │ A 16-bit float. The halfcl_half                  │
       │                            │ data type must conform to    │                          │
       │                            │ the IEEE 754-2008 half       │                          │
       │                            │ precision storage format.    │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ size_t                     │ The unsigned integer type of │ n/a                      │
       │                            │ the result of the sizeof     │                          │
       │                            │ operator. This is a 32-bit   │                          │
       │                            │ unsigned integer if          │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS       │                          │
       │                            │ defined in                   │                          │
       │                            │ clGetDeviceInfo(3clc) is     │                          │
       │                            │ 32-bits and is a 64-bit      │                          │
       │                            │ unsigned integer if          │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS is    │                          │
       │                            │ 64-bits.                     │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ ptrdiff_t                  │ A signed integer type that   │ n/a                      │
       │                            │ is the result of subtracting │                          │
       │                            │ two pointers.  This is a     │                          │
       │                            │ 32-bit signed integer if     │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS       │                          │
       │                            │ defined in                   │                          │
       │                            │ clGetDeviceInfo(3clc) is     │                          │
       │                            │ 32-bits and is a 64-bit      │                          │
       │                            │ signed integer if            │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS is    │                          │
       │                            │ 64-bits.                     │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ intptr_t                   │ A signed integer type with   │ n/a                      │
       │                            │ the property that any valid  │                          │
       │                            │ pointer to void can be       │                          │
       │                            │ converted to this type, then │                          │
       │                            │ converted back to pointer to │                          │
       │                            │ void, and the result will    │                          │
       │                            │ compare equal to the         │                          │
       │                            │ original pointer. This is a  │                          │
       │                            │ 32-bit signed integer if     │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS       │                          │
       │                            │ defined in table 4.3 is      │                          │
       │                            │ 32-bits and is a 64-bit      │                          │
       │                            │ signed integer if            │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS is    │                          │
       │                            │ 64-bits.                     │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ uintptr_t                  │ An unsigned integer type     │ n/a                      │
       │                            │ with the property that any   │                          │
       │                            │ valid pointer to void can be │                          │
       │                            │ converted to this type, then │                          │
       │                            │ converted back to pointer to │                          │
       │                            │ void, and the result will    │                          │
       │                            │ compare equal to the         │                          │
       │                            │ original pointer. This is a  │                          │
       │                            │ 32-bit signed integer if     │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS       │                          │
       │                            │ defined in table 4.3 is      │                          │
       │                            │ 32-bits and is a 64-bit      │                          │
       │                            │ signed integer if            │                          │
       │                            │ CL_DEVICE_ADDRESS_BITS is    │                          │
       │                            │ 64-bits.                     │                          │
       ├────────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ void                       │ The void type comprises an   │ void                     │
       │                            │ empty set of values; it is   │                          │
       │                            │ an incomplete type that      │                          │
       │                            │ cannot be completed.         │                          │
       └────────────────────────────┴──────────────────────────────┴──────────────────────────┘

Name

       Scalar_Data_Types - Built-in scalar data types.

Notes

        1. OpenCL Specification
           page 195, section 6.1.1 - Built-in Scalar Data Types

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

Optional Half Floating Point

       The half floating-point is supported as an optional extension. An application that wants to use half and
       halfn will need to include the cl_khr_fp16(3clc) directive. This will extended the list of built-in
       vector and scalar data types to include the following:

       ┌─────────────────────────┬──────────────────────────────┬──────────────────────────┐
       │ TypeinOpenCLLanguageDescriptionAPItypeforapplication │
       ├─────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half2                   │ A 2-component half-precision │ cl_half2                 │
       │                         │ floating-point vector.       │                          │
       ├─────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half3                   │ A 3-component half-precision │ cl_half3                 │
       │                         │ floating-point vector.       │                          │
       ├─────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half4                   │ A 4-component half-precision │ cl_half4                 │
       │                         │ floating-point vector.       │                          │
       ├─────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half8                   │ An 8-component               │ cl_half8                 │
       │                         │ half-precision               │                          │
       │                         │ floating-point vector.       │                          │
       ├─────────────────────────┼──────────────────────────────┼──────────────────────────┤
       │ half16                  │ A 16-component               │ cl_half16                │
       │                         │ half-precision               │                          │
       │                         │ floating-point vector.       │                          │
       └─────────────────────────┴──────────────────────────────┴──────────────────────────┘

       The relational, equality, logical and logical unary operators can be used with half scalar and halfn
       vector types and shall produce a scalar int and vector shortn result respectively.

       The OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed
       as a half.

See Also

macroLimits(3clc), vectorDataTypes(3clc), reservedDataTypes(3clc), otherDataTypes(3clc),
       abstractDataTypes(3clc), enums(3clc), cl_khr_fp16(3clc), cl_khr_fp64(3clc)

Specification

OpenCLSpecification[1]

See Also