User`s guide
Run CUDA or PTX Code on GPU
9-23
Integer Types
int8_T, int16_T, int32_T, int64_T
uint8_T, uint16_T, uint32_T, uint64_T
The header file is shipped as matlabroot/extern/include/tmwtypes.h. You include
the file in your program with the line:
#include "tmwtypes.h"
Argument Restrictions
All inputs can be scalars or pointers, and can be labeled const.
The C declaration of a kernel is always of the form:
__global__ void aKernel(inputs ...)
• The kernel must return nothing, and operate only on its input arguments (scalars or
pointers).
• A kernel is unable to allocate any form of memory, so all outputs must be pre-
allocated before the kernel is executed. Therefore, the sizes of all outputs must be
known before you run the kernel.
• In principle, all pointers passed into the kernel that are not const could contain
output data, since the many threads of the kernel could modify that data.
When translating the definition of a kernel in C into MATLAB:
• All scalar inputs in C (double, float, int, etc.) must be scalars in MATLAB, or
scalar (i.e., single-element) gpuArray variables.
• All const pointer inputs in C (const double *, etc.) can be scalars or matrices
in MATLAB. They are cast to the correct type, copied onto the device, and a pointer
to the first element is passed to the kernel. No information about the original size
is passed to the kernel. It is as though the kernel has directly received the result of
mxGetData on an mxArray.
• All nonconstant pointer inputs in C are transferred to the kernel exactly as
nonconstant pointers. However, because a nonconstant pointer could be changed by
the kernel, this will be considered as an output from the kernel.
• Inputs from MATLAB workspace scalars and arrays are cast into the requested type
and then passed to the kernel. However, gpuArray inputs are not automatically cast,
so their type and complexity must exactly match those expected.