gpuArray

Array stored on GPU

Constructor

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

Also, the following create gpuArrays:

eye(___,'gpuArray')rand(___,'gpuArray')
false(___,'gpuArray')randi(___,'gpuArray')
Inf(___,'gpuArray')randn(___,'gpuArray')
NaN(___,'gpuArray')gpuArray.colon
ones(___,'gpuArray')gpuArray.linspace
true(___,'gpuArray')gpuArray.logspace
zeros(___,'gpuArray') 

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:

parallel.gpu.RandStream
parallel.gpu.rng

Description

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.

Methods

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 overloaded 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:

FunctionDescription
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?