'\" t .\" Title: Data Types .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "DATA TYPES" "3clc" "01/14/2021" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" Data_Types \- OpenCL data types\&. .SH "DESCRIPTION" .PP 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\&. .TS allbox tab(:); lB lB. T{ Data type category T}:T{ Included data types T} .T& l l l l l l l l l l. T{ \fBscalarDataTypes\fR(3clc) T}:T{ \fBbool\fR, \fBchar\fR, \fBcl_char\fR, \fBunsigned char\fR, \fBuchar\fR, \fBcl_uchar\fR, \fBshort\fR, \fBcl_short\fR, \fBunsigned short\fR, \fBushort\fR, \fBint\fR, \fBunsigned int\fR, \fBuint\fR, \fBlong\fR, \fBunsigned long\fR, \fBulong\fR, \fBfloat\fR, \fBhalf\fR, \fBsize_t\fR, \fBptrdiff_t\fR, \fBintptr_t\fR, \fBuintptr_t\fR, \fBvoid\fR, \fBdouble\fR, and \fBhalf\fR floating point types\&. T} T{ \fBvectorDataTypes\fR(3clc) T}:T{ \fBchar\fR\fB\fIn\fR\fR, \fBuchar\fR\fB\fIn\fR\fR, \fBshort\fR\fB\fIn\fR\fR, \fBushort\fR\fB\fIn\fR\fR, \fBint\fR\fB\fIn\fR\fR, \fBuint\fR\fB\fIn\fR\fR, \fBlong\fR\fB\fIn\fR\fR, \fBulong\fR\fB\fIn\fR\fR, \fBfloat\fR\fB\fIn\fR\fR, double\fIn\fR, and optional half\fIn\fR types\&. T} T{ \fBabstractDataTypes\fR(3clc) T}:T{ \fBcl_platform_id\fR, \fBcl_device_id\fR, \fBcl_context\fR, \fBcl_command_queue\fR, \fBcl_mem\fR, \fBcl_program\fR, \fBcl_kernel\fR, \fBcl_event\fR, and \fBcl_sampler\fR\&. T} T{ \fBreservedDataTypes\fR(3clc) T}:T{ \fBbool\fR\fB\fIn\fR\fR, \fBhalf\fR\fB\fIn\fR\fR, \fBquad\fR, \fBquad\fR\fB\fIn\fR\fR, \fBcomplex half\fR, \fBcomplex half\fR\fB\fIn\fR\fR, \fBimaginary half\fR, \fBimaginary half\fR\fB\fIn\fR\fR, \fBcomplex float\fR, \fBcomplex float\fR\fB\fIn\fR\fR, \fBimaginary float\fR, \fBimaginary float\fR\fB\fIn\fR\fR, \fBcomplex double\fR, \fBcomplex double\fR\fB\fIn\fR\fR, \fBimaginary double\fR, \fBimaginary double\fR\fB\fIn\fR\fR, \fBcomplex quad\fR, \fBcomplex quad\fR\fB\fIn\fR\fR, \fBimaginary quad\fR, \fBimaginary quad\fR\fB\fIn\fR\fR, \fBfloat\fR\fB\fIn\fR\fRx\fIm\fR, \fBdouble\fR\fB\fIn\fR\fRx\fIm\fR, \fBlong double\fR, \fBlong double\fR\fB\fIn\fR\fR, \fBlong long\fR, \fBlong long\fR\fB\fIn\fR\fR, \fBunsigned long long\fR, \fBulong long\fR, and \fBulong long\fR\fB\fIn\fR\fR\&. T} T{ \fBotherDataTypes\fR(3clc) T}:T{ \fBimage2d_t\fR, \fBimage3d_t\fR, \fBimage2d_array_t\fR, \fBimage1d_t\fR, \fBimage31_buffer_t\fR, \fBimage1d_array_t\fR, \fBsampler_t\fR, and \fBevent_t\fR\&. T} .TE .sp 1 .SH "ALIGNMENT OF TYPES" .PP 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 \fBfloat4\fR variable will be aligned to a 16\-byte boundary, and a \fBchar2\fR variable will be aligned to a 2\-byte boundary\&. .PP 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 \fBvloadn\fR(3clc) and \fBvstoren\fR(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\&. .PP 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\&. .PP The OpenCL compiler is responsible for aligning data items to the appropriate alignment as required by the data type\&. For arguments to a \fBfunctionQualifiers\fR(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 \fBvloadn\fR(3clc), \fBvload_halfn\fR(3clc), \fBvstoren\fR(3clc), and \fBvstore_halfn\fR(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\&. .PP 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 \fBCL_MEM_USE_HOST_PTR\fR 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\&. \fIimage_num_channels\fR * sizeof(\fIimage_channel_data_type\fR)) except for \fBCL_RGB\fR and \fBCL_RGBx\fR images where the data must be aligned to the granularity of a single channel in a pixel (i\&.e\&. sizeof(\fIimage_channel_data_type\fR))\&. .PP 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\&. \fB__cl_float4\fR) where defined shall be directly accessible as such using appropriate named fields in the \fBcl_type\fR union\&. Nevertheless, it is recommended that the cl_platform\&.h header should attempt to naturally align OpenCL defined application data types (e\&.g\&. \fBcl_float4\fR) according to their type\&. .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2010 The Khronos Group Inc. .br 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. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 195, section 6.1.1 - Built-in Scalar Data Types .RE