vec_type_hint

Description

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

The optional__attribute__((vec_type_hint()))is part of the OpenCL Language Specification, and is a hint to the OpenCL compiler representing the computational width of the kernel, providing a basis for calculating processor bandwidth utilization when the compiler is looking to autovectorize 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 run time to handle cases where the compiler decides to merge or separate workitems. This probably means that such 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 may be a code security question for some.

Syntax

Place this attribute before the kernel definition, or before the primary function specified for the kernel:__attribute__((vec_type_hint()))

Where:
  • : 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

Type

Description

charn

A vector ofn8-bit signed two’s complement integer values.

ucharn

A vector ofn8-bit unsigned integer values.

shortn

A vector ofn16-bit signed two’s complement integer values.

ushortn

A vector ofn16-bit unsigned integer values.

intn

A vector ofn32-bit signed two’s complement integer values.

uintn

A vector ofn32-bit unsigned integer values.

longn

A vector ofn64-bit signed two’s complement integer values.

ulongn

A vector ofn64-bit unsigned integer values.

floatn

A vector ofn32-bit floating-point values.

doublen

A vector ofn64-bit floating-point values.

Note: nis 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. That is to say, n can only be specified as 2,3,4,8, and 16.

Examples

The following example autovectorizes assuming double-wide integer as the basic computation width:

#include  // 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 ...

See Also