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

Data_Types - OpenCL data types.

Alignment Of Types

       A data item declared to be a data type in memory is always aligned to the size of the data type in bytes.
       For example, a float4 variable will be aligned to a 16-byte boundary, and a char2 variable will be
       aligned to a 2-byte boundary.

       For 3-component vector data types, the size of the data type is 4 * sizeof(component). This means that a
       3-component vector data type will be aligned to a 4 * sizeof(component) boundary. The vloadn(3clc) and
       vstoren(3clc) built-in functions can be used to read and write, respectively, 3-component vector data
       types from an array of packed scalar data type.

       A built-in data type that is not a power of two bytes in size must be aligned to the next larger power of
       two. This rule applies to built-in types only, not structs or unions.

       The OpenCL compiler is responsible for aligning data items to the appropriate alignment as required by
       the data type. For arguments to a functionQualifiers(3clc) function declared to be a pointer to a data
       type, the OpenCL compiler can assume that the pointee is always appropriately aligned as required by the
       data type. The behavior of an unaligned load or store is undefined, except for the vloadn(3clc),
       vload_halfn(3clc), vstoren(3clc), and vstore_halfn(3clc) functions. The vector load functions can read a
       vector from an address aligned to the element type of the vector. The vector store functions can write a
       vector to an address aligned to the element type of the vector.

       The user is responsible for ensuring that data passed into and out of OpenCL buffers are natively aligned
       relative to the start of the buffer as described above. This implies that OpenCL buffers created with
       CL_MEM_USE_HOST_PTR need to provide an appropriately aligned host memory pointer that is aligned to the
       data types used to access these buffers in a kernel(s). As well, the user is responsible to ensure that
       data passed into and out of OpenCL images are properly aligned to the granularity of the data
       representing a single pixel (e.g.  image_num_channels * sizeof(image_channel_data_type)) except for
       CL_RGB and CL_RGBx images where the data must be aligned to the granularity of a single channel in a
       pixel (i.e. sizeof(image_channel_data_type)).

       OpenCL makes no requirement about the alignment of OpenCL application defined data types outside of
       buffers and images, except that the underlying vector primitives (e.g.  __cl_float4) where defined shall
       be directly accessible as such using appropriate named fields in the cl_type union. Nevertheless, it is
       recommended that the cl_platform.h header should attempt to naturally align OpenCL defined application
       data types (e.g.  cl_float4) according to their type.

Authors

TheKhronosGroup

Description

       These are the data types available in the OpenCL C programming language. Click on a category name in the
       table below to see information about specific data types.
       ┌─────────────────────────┬───────────────────────────────────────┐
       │ DatatypecategoryIncludeddatatypes                   │
       ├─────────────────────────┼───────────────────────────────────────┤
       │ scalarDataTypes(3clc)   │ bool, char, cl_char, unsignedchar,   │
       │                         │ uchar, cl_uchar, short, cl_short,     │
       │                         │ unsignedshort, ushort, int, unsigned │
       │                         │ int, uint, long, unsignedlong,       │
       │                         │ ulong, float, half, size_t,           │
       │                         │ ptrdiff_t, intptr_t, uintptr_t, void, │
       │                         │ double, and half floating point       │
       │                         │ types.                                │
       ├─────────────────────────┼───────────────────────────────────────┤
       │ vectorDataTypes(3clc)   │ charn, ucharn, shortn, ushortn, intn, │
       │                         │ uintn, longn, ulongn, floatn,         │
       │                         │ doublen, and optional halfn types.    │
       ├─────────────────────────┼───────────────────────────────────────┤
       │ abstractDataTypes(3clc) │ cl_platform_id, cl_device_id,         │
       │                         │ cl_context, cl_command_queue, cl_mem, │
       │                         │ cl_program, cl_kernel, cl_event, and  │
       │                         │ cl_sampler.                           │
       ├─────────────────────────┼───────────────────────────────────────┤
       │ reservedDataTypes(3clc) │ booln, halfn, quad, quadn, complex    │
       │                         │ half, complexhalfn, imaginaryhalf,  │
       │                         │ imaginaryhalfn, complexfloat,       │
       │                         │ complexfloatn, imaginaryfloat,      │
       │                         │ imaginaryfloatn, complexdouble,     │
       │                         │ complexdoublen, imaginarydouble,    │
       │                         │ imaginarydoublen, complexquad,      │
       │                         │ complexquadn, imaginaryquad,        │
       │                         │ imaginaryquadn, floatnxm, doublenxm, │
       │                         │ longdouble, longdoublen, longlong, │
       │                         │ longlongn, unsignedlonglong, ulong │
       │                         │ long, and ulonglongn.                │
       ├─────────────────────────┼───────────────────────────────────────┤
       │ otherDataTypes(3clc)    │ image2d_t, image3d_t,                 │
       │                         │ image2d_array_t, image1d_t,           │
       │                         │ image31_buffer_t, image1d_array_t,    │
       │                         │ sampler_t, and event_t.               │
       └─────────────────────────┴───────────────────────────────────────┘

Name

       Data_Types - OpenCL data types.

Notes

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

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

Specification

OpenCLSpecification[1]

See Also