SPRUI04G June 2015 – August 2025
The C6000 C/C++ compiler supports the use of TI vector data types, complex data types, and complex vector data types in C/C++ source files.
Vector Data Types: Vector data types are similar to an array, in that a vector contains a specified number of elements of a specified type. However, the vector length can only be one of 2, 3, 4, 8, or 16. Wherever possible, intrinsics that act upon vectors are optimized to make use of efficient single instruction, multiple data (SIMD) instructions on the device.
These types are useful because they can make use of the natural vector width within the processing cores. Vector data types provide a straightforward way to utilize the SIMD instructions that are available on that architecture. Vector data types also provide a more direct mapping from the abstract model of a vector data object to the physical representation of that data object in a register.
You can enable support for vector data types by using the --vectypes compiler option.
All of the vector data types and related built-in functions that are supported in the C6000 programming model are specified in the "c6x_vec.h" header file in the "include" sub-directory where your C6000 CGT was installed. Any C/C++ source file that uses vector data types or any of the related built-in functions must contain the following in that source file:
#include <c6x_vec.h>A vector type name concatenates an element type name and a number representing the vector length. The resulting vector consists of the specified number of elements of the specified type.
The C6000 implementation of vector data types and operations follows the OpenCL C language specification closely. For a detailed description of OpenCL vector data types and operations, please see version 1.2 of The OpenCL Specification, which is available from the Khronos OpenCL Working Group. Section 6.1.2 of the version 1.2 specification provides a detailed description of the built-in vector data types supported in the OpenCL C programming language. The C6000 programming model provides the following built-in vector data types:
| Type | Description | Maximum Elements |
|---|---|---|
| charn | A vector of n 8-bit signed integer values. | 16 |
| ucharn | A vector of n 8-bit unsigned integer values. | 16 |
| shortn | A vector of n 16-bit signed integer values. | 8 |
| ushortn | A vector of n 16-bit unsigned integer values. | 8 |
| intn | A vector of n 32-bit signed integer values. | 4 |
| uintn | A vector of n 32-bit unsigned integer values. | 4 |
| longlongn | A vector of n 64-bit signed integer values. | 2 |
| ulonglongn | A vector of n 64-bit unsigned integer values. | 2 |
| floatn | A vector of n 32-bit single-precision floating-point values. | 4 |
| doublen | A vector of n 64-bit double-precision floating-point values. | 8 |
where n can be a vector length of 2, 3, 4, 8, or 16.
For example, a "uchar8" is a vector of 8 unsigned chars; its length is 8 and its size is 64 bits. A "float4" is a vector of 4 float elements; its length is 4 and its size is 128 bits.
Vectors types are aligned on a boundary equal to the total size of the vector's elements up to 64 bits. Any vector type with a total size of more than 64 bits is aligned to a 64-bit boundary (8 bytes). For example, a short2 has a total size of 32 bits and is aligned on a 4-byte boundary. A longlong2 has a total size of 128 bits and is aligned on an 8-byte boundary.
#define long2 longlong2 or #define
long2 int2, depending the element type and size you want to use.Complex Data Types: The C/C++ compiler supports types that store complex values. Each complex type contains a real component and an imaginary component. The real part occupies the lower address in memory. Both components are of the same type. For example, a cfloat has a real component of type float and an imaginary component of type float. Complex types are aligned to a boundary equal to the alignment of its component types.
A prefix of 'c' is used to indicate complex type names.
There are two keywords for each complex
type, one with a double-underscore prefix (for example, __cint) and one
without (for example, cint). The keywords with a double-underscore prefix
are always available, even in strict ANSI mode (--strict_ansi). The keywords without a double-underscore
prefix are not available by default, but can be enabled by using the --vectypes=on
compiler option. The table that follows and examples in this user guide assume that
--vectypes=on.
The following complex data types are supported. Complex unsigned types are not supported.
| Type | Description |
|---|---|
| cchar | A single pair of 8-bit signed integer values. |
| cshort | A single pair of 16-bit signed integer values. |
| cint | A single pair of 32-bit signed integer values. |
| clonglong | A single pair of 64-bit signed integer values. |
| cfloat | A single pair of 32-bit floating-point values. |
| cdouble | A single pair of 64-bit floating-point values. |
Be aware of the difference between type names such as cchar and
cchar2. If the name of a complex type is followed by a number, it is a
complex vector of the specified length.
Valid operations on complex types are: addition, subtraction, multiplication, division, negation, increment, decrement, comparison for equality. Arithmetic operations on complex types conform to the usual arithmetic rules of complex numbers. Increment and decrement operators affect only the real component.
The following operations are not allowed on complex types: relational comparison (<, >), modulo (%), bitwise operations (& | ~), logical operations (&& ||).
Complex Vector Data Types: The C/C++ compiler also provides an extension for representing vectors of complex types. The complex vector types are as follows:
| Type | Description | Maximum Elements |
|---|---|---|
| ccharn | A vector of n pairs of 8-bit signed integer values. | 8 |
| cshortn | A vector of n pairs of 16-bit signed integer values. | 4 |
| cintn | A vector of n pairs of 32-bit signed integer values. | 2 |
| clonglongn | A vector of n pairs of 64-bit signed integer values. | 1 |
| cfloatn | A vector of n pairs of 32-bit floating-point values. | 2 |
| cdoublen | A vector of n pairs of 64-bit floating-point values. | 1 |
where n can be a vector length of 1, 2, 4, or 8. Note that 16 is not a valid vector length for complex vector types. For example, a "cfloat2" is a vector of 2 complex floats. Its length is 2 and its size is 128 bits. Each "cfloat2" vector element contains a real float and an imaginary float.
In addition, type names with a double-underscore prefix (for example,
__cchar2 and __cint8) are provided as aliases for the
complex vector types.
For information about operators and built-in functions used with vector data types, see Section 7.15.