DATATYPES(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

✨ DATA TYPES (3clc) ✨

okay bestie, welcome to the OpenCL Manual section on data types πŸ’– this is the page where we meet every single type the OpenCL C programming language has to offer, and honestly? it's a lot. but we're gonna get through it together, no cap.


🌸 DESCRIPTION 🌸

these are literally all the data types you get in the OpenCL C programming language 🫢 tap a category name below to see the deets on the specific data types in it (iykyk).

πŸŽ€ Data type category β†’ included data types πŸŽ€

  • scalarDataTypes(3clc) β€” the scalars, bestie: bool, char, cl_char, unsigned char, uchar, cl_uchar, short, cl_short, unsigned short, ushort, int, unsigned int, uint, long, unsigned long, ulong, float, half, size_t, ptrdiff_t, intptr_t, uintptr_t, void, double, and half floating point types.
  • vectorDataTypes(3clc) β€” the vector girlies: charn, ucharn, shortn, ushortn, intn, uintn, longn, ulongn, floatn, doublen, and optional halfn types.
  • abstractDataTypes(3clc) β€” the abstract icons: cl_platform_id, cl_device_id, cl_context, cl_command_queue, cl_mem, cl_program, cl_kernel, cl_event, and cl_sampler.
  • reservedDataTypes(3clc) β€” reserved, aka hands off πŸ™ˆ: booln, halfn, quad, quadn, complex half, complex halfn, imaginary half, imaginary halfn, complex float, complex floatn, imaginary float, imaginary floatn, complex double, complex doublen, imaginary double, imaginary doublen, complex quad, complex quadn, imaginary quad, imaginary quadn, floatnxm, doublenxm, long double, long doublen, long long, long longn, unsigned long long, ulong long, and ulong longn.
  • otherDataTypes(3clc) β€” the other girlies: image2d_t, image3d_t, image2d_array_t, image1d_t, image31_buffer_t, image1d_array_t, sampler_t, and event_t.

πŸ’… ALIGNMENT OF TYPES πŸ’…

so here's the tea, bestie: a data item declared to be a data type in memory is always aligned to the size of the data type in bytes. periodt. like, a float4 variable will be aligned to a 16-byte boundary, and a char2 variable will be aligned to a 2-byte boundary. it's giving very structured, very demure ✨

for 3-component vector data types, the size of the data type is 4 * sizeof(component). that means 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. slay πŸŽ€

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. noted. πŸ“

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. like, undefined undefined. do not test it. πŸ™ˆ

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. cute, matching ✨

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)). yes, that's a whole lot of responsibility. you got this tho 🫢

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. it's a recommendation, not a vibe check, but still 🌈


πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification[1]


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group β€” icons, honestly.


Copyright Β© 2007-2010 The Khronos Group Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.


πŸ¦‹ NOTES πŸ¦‹

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

okay that's the whole page bestie, you ate that πŸ’…

signed off with love by The Khronos Group, dated 01/14/2021, from the OpenCL Manual β€” DATA TYPES(3clc). mwah πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from