SCALARDATATYPES(3clc)

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

SCALAR DATA TYPES(3clc) β€” okay so this is the OpenCL manual page for scalar data types, and it's giving part 1 of 3. Buckle up, bestie. πŸ’–

✨ NAME ✨

  • Scalar_Data_Types β€” built-in scalar data types. That's the whole vibe. Periodt. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so these are the data types available in the OpenCL C programming language. And what's that for? It's for creating kernels that get executed on OpenCL device(s). You know, the whole reason we're here. ✨

Now, OpenCL C (also referred to as OpenCL C, yes bestie, same thing) is based on the ISO/IEC 9899:1999 C language specification β€” a.k.a. the C99 specification. But plot twist: it has its own specific extensions and restrictions. πŸ™ˆ

If you want a detailed description of the language grammar, please refer to the ISO/IEC 9899:1999 specification. Like, go read it, fr fr. πŸ“š

And this section? It describes the modifications and restrictions to ISO/IEC 9899:1999 that are supported in OpenCL C. That's it, that's the tea. πŸ“

Okay so here's the tea, bestie: most of the built-in scalar data types are ALSO declared as the appropriate types in the OpenCL API (and its header files) so your application can actually use them. πŸ’–

So like, here's the rundown of every built-in scalar type in the OpenCL C programming language and the matching type you get on the application side:

  • bool β€” a conditional data type that 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 gets converted to bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1. API type for application: n/a ✨
  • char β€” a signed two's complement 8-bit integer. API type: cl_char
  • unsigned char, uchar β€” an unsigned 8-bit integer. API type: cl_uchar
  • short β€” a signed two's complement 16-bit integer. API type: cl_short
  • unsigned short, ushort β€” an unsigned 16-bit integer. API type: cl_ushort
  • int β€” a signed two's complement 32-bit integer. API type: cl_int
  • unsigned int, uint β€” an unsigned 32-bit integer. API type: cl_uint
  • long β€” a signed two's complement 64-bit integer. API type: cl_long
  • unsigned long, ulong β€” an unsigned 64-bit integer. API type: cl_ulong
  • float β€” a 32-bit floating point. The float data type must conform to the IEEE 754 single precision storage format. API type: cl_float 🌸
  • double β€” a 64-bit floating point. The 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. Peep the table for param_name in clGetDeviceInfo(3clc) for the details. API type: cl_double πŸ‘‘
  • half β€” a 16-bit float. The half data type must conform to the IEEE 754-2008 half precision storage format. API type: cl_half 🧚
  • size_t β€” the unsigned integer type of 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. API type: n/a πŸ’…
  • ptrdiff_t β€” a signed integer type that 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. API type: n/a ⭐
no cap, the double one is lowkey the main character here β€” it's optional, so check your device before you build your whole personality around it πŸ’€

  • intptr_t β€” a signed integer type with this iconic lil superpower: any valid pointer to void can be converted into it, then converted right back to a pointer to void, and the result will compare equal to the original pointer. πŸ’« It's a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS (defined in table 4.3, bestie, keep up 🫢) is 32-bits, and it's a 64-bit signed integer if CL_DEVICE_ADDRESS_BITS is 64-bits.
  • uintptr_t β€” an unsigned integer type with the same adorable party trick: any valid pointer to void can be converted to it, converted back to a pointer to void, and the result compares equal to the original pointer. It's a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS defined in table 4.3 is 32-bits, and a 64-bit signed integer if CL_DEVICE_ADDRESS_BITS is 64-bits. (Yes that's what the spec says, I'm reading it to you verbatim, don't come for me 😭)
  • void β€” the void type comprises an empty set of values. It's an incomplete type that cannot be completed. It's giving mysterious. It's giving "no thoughts, head empty." Its API type for your application is void.

✨ OPTIONAL HALF FLOATING POINT ✨

Okay so the half floating-point is supported as an optional extension β€” meaning it's not guaranteed to be there, it's a bonus 🎁. An application that wants to use half and halfn will need to include the cl_khr_fp16(3clc) directive. Doing that extends the list of built-in vector and scalar data types to include the following cuties:

  • half2 β€” a 2-component half-precision floating-point vector. API type for your application: cl_half2
  • half3 β€” a 3-component half-precision floating-point vector. API type: cl_half3
  • half4 β€” a 4-component half-precision floating-point vector. API type: cl_half4
  • half8 β€” an 8-component half-precision floating-point vector. API type: cl_half8
  • half16 β€” a 16-component half-precision floating-point vector. API type: cl_half16

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. πŸ”₯

And the OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed as a half. Periodt. πŸ’…


🌸 SPECIFICATION 🌸

OpenCL Specification[1]


πŸ¦‹ SEE ALSO πŸ¦‹

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


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group


Copyright Β© 2007-2011 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 following conditions: the above copyright notice and this 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

And that's a wrap on the whole page, bestie!! πŸŽ€ This lil masterpiece was brought to you by The Khronos Group, dated 01/14/2021, and its proper title is SCALAR DATA TYPES(3clc). Now go forth and type your scalars correctly, you absolute icon. πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from