Description
The optional __attribute__((vec_type_hint(<type>)))
is part of the OpenCL Language Specification, and hints to the OpenCL compiler representing the computational width of the
kernel, providing a basis for calculating processor bandwidth usage when the compiler is
looking to auto-vectorize the code.
By default, the kernel is assumed to have the __attribute__((vec_type_hint(int)))
qualifier. This lets you specify a different
vectorization type.
Implicit in autovectorization is the assumption that any libraries called from the kernel must be re-compilable at runtime to handle cases where the compiler decides to merge or separate work items. This means that these libraries can never be hard-coded binaries or that hard-coded binaries must be accompanied either by source or some re-targetable intermediate representation. This might be a code security question for some.
Syntax
__attribute__((vec_type_hint(<type>)))
Where:
- <type>: is one of the built-in vector types listed in the
following table, or the constituent scalar element types. Note: When not specified, the kernel is assumed to have an INT type.
Type |
Description |
---|---|
char<n> | A vector of <n> 8-bit signed two’s complement integer values. |
uchar<n> | A vector of <n> 8-bit unsigned integer values. |
short<n> | A vector of <n> 16-bit signed two’s complement integer values. |
ushort<n> | A vector of <n> 16-bit unsigned integer values. |
int<n> | A vector of <n> 32-bit signed two’s complement integer values. |
uint<n> | A vector of <n> 32-bit unsigned integer values. |
long<n> | A vector of <n> 64-bit signed two’s complement integer values. |
ulong<n> | A vector of <n> 64-bit unsigned integer values. |
float<n> | A vector of <n> 32-bit floating-point values. |
double<n> | A vector of <n> 64-bit floating-point values. |
Examples
The following example autovectorizes assuming double-wide integer as the basic computation width.
#include <clc.h>
// For VHLS OpenCL C kernels, the full work group is synthesized
__attribute__((vec_type_hint(double)))
__attribute__ ((reqd_work_group_size(16, 1, 1)))
__kernel void
...