SCALARDATATYPES(3clc)
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 eithertrueorfalse. The valuetrueexpands to the integer constant1, and the valuefalseexpands to the integer constant0. When any scalar value gets converted tobool, the result is0if the value compares equal to0; otherwise, the result is1. API type for application:n/aβ¨charβ a signed two's complement 8-bit integer. API type:cl_charunsigned char,ucharβ an unsigned 8-bit integer. API type:cl_ucharshortβ a signed two's complement 16-bit integer. API type:cl_shortunsigned short,ushortβ an unsigned 16-bit integer. API type:cl_ushortintβ a signed two's complement 32-bit integer. API type:cl_intunsigned int,uintβ an unsigned 32-bit integer. API type:cl_uintlongβ a signed two's complement 64-bit integer. API type:cl_longunsigned long,ulongβ an unsigned 64-bit integer. API type:cl_ulongfloatβ a 32-bit floating point. Thefloatdata type must conform to the IEEE 754 single precision storage format. API type:cl_floatπΈdoubleβ a 64-bit floating point. Thedoubledata type must conform to the IEEE 754 double precision storage format. Thedoublescalar type is an optional type that is supported ifCL_DEVICE_DOUBLE_FP_CONFIGfor a device is not zero. Peep the table for param_name inclGetDeviceInfo(3clc)for the details. API type:cl_doubleπhalfβ a 16-bit float. Thehalfdata 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 thesizeofoperator. This is a 32-bit unsigned integer ifCL_DEVICE_ADDRESS_BITSdefined inclGetDeviceInfo(3clc)is 32-bits, and is a 64-bit unsigned integer ifCL_DEVICE_ADDRESS_BITSis 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 ifCL_DEVICE_ADDRESS_BITSdefined inclGetDeviceInfo(3clc)is 32-bits, and is a 64-bit signed integer ifCL_DEVICE_ADDRESS_BITSis 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 tovoidcan be converted into it, then converted right back to a pointer tovoid, and the result will compare equal to the original pointer. π« It's a 32-bit signed integer ifCL_DEVICE_ADDRESS_BITS(defined in table 4.3, bestie, keep up π«Ά) is 32-bits, and it's a 64-bit signed integer ifCL_DEVICE_ADDRESS_BITSis 64-bits.uintptr_tβ an unsigned integer type with the same adorable party trick: any valid pointer tovoidcan be converted to it, converted back to a pointer tovoid, and the result compares equal to the original pointer. It's a 32-bit signed integer ifCL_DEVICE_ADDRESS_BITSdefined in table 4.3 is 32-bits, and a 64-bit signed integer ifCL_DEVICE_ADDRESS_BITSis 64-bits. (Yes that's what the spec says, I'm reading it to you verbatim, don't come for me π)voidβ thevoidtype 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 isvoid.
β¨ 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_half2half3β a 3-component half-precision floating-point vector. API type:cl_half3half4β a 4-component half-precision floating-point vector. API type:cl_half4half8β an 8-component half-precision floating-point vector. API type:cl_half8half16β 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 π
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 π
- 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
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms