Vectorized data types and memory access

We will now look at CUDA's Vectorized Data Types. These are vectorized versions of the standard datatypes, such as int or double, in that they can store multiple values. There are vectorized versions of the 32-bit types of up to size 4 (for example, int2, int3, int4, and float4), while 64-bit variables can only be vectorized to be twice their original size (for example, double2 and long2). For a size 4 vectorized variable, we access each individual element using the C "struct" notation for the members x, y, z, and w, while we use x,y, and z for a 3-member variable and just x and y for a 2-member variable.

These may seem pointless right now, but these datatypes can be used to improve the performance ...

Get Hands-On GPU Programming with Python and CUDA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.