vec_type_hint - 2020.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
Release Date
2020.2 English


Important: This is a compiler hint which the compiler can ignore.

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.


Place this attribute before the kernel definition, or before the primary function specified for the kernel.


  • <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.
Table 1. Vector Types


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.
Note: <n> is assumed to be 1 when not specified. The vector data type names defined above where <n> is any value other than 2, 3, 4, 8 and 16, are also reserved. Therefore, < n> can only be specified as 2,3,4,8, and 16.


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__ ((reqd_work_group_size(16, 1, 1)))
__kernel void