This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Array stored on GPU


gpuArray converts an array in the MATLAB workspace into a gpuArray with elements stored on the GPU device.

Also, the following create gpuArrays:


For class specific help on the three methods with the gpuArray prefix, type

help gpuArray.methodname

where methodname is the name of the method. For example, to get help on colon, type

help gpuArray.colon

The following methods control the random number stream on the GPU:



A gpuArray object represents an array stored on the GPU. You can use the array for direct calculations, or in CUDA kernels that execute on the GPU. You can return the array to the MATLAB workspace with the gather function.


arrayfunApply function to each element of array on GPU
bsxfunBinary singleton expansion function for gpuArray
classUnderlyingClass of elements within gpuArray or distributed array
existsOnGPUDetermine if gpuArray or CUDAKernel is available on GPU
eyeIdentity matrix
falseArray of logical 0 (false)
gatherTransfer distributed array or gpuArray to local workspace
InfArray of infinity
NaNArray of Not-a-Numbers
onesArray of ones
pagefunApply function to each page of array on GPU
randArray of rand values
randiArray of random integers
randnArray of randn values
trueArray of logical 1 (true)
zerosArray of zeros

Other methods for a gpuArray object are too numerous to list here. Most resemble and behave the same as built-in MATLAB functions. See Run Built-In Functions on a GPU.

Among the gpuArray methods there are several for examining the characteristics of a gpuArray object. Most behave like the MATLAB functions of the same name:

classUnderlyingClass (data type) of the elements in the array
existsOnGPUIndication if array exists on the GPU and is accessible
isrealIndication if array elements are real
lengthLength of vector or largest array dimension
ndimsNumber of dimensions in the array
sizeSize of array dimensions

Was this topic helpful?