User`s guide
9 GPU Computing
9-10
Ga = rand(1000,'single','gpuArray');
Gfft = fft(Ga);
Gb = (real(Gfft) + Ga) * 6;
G = gather(Gb);
The whos command is instructive for showing where each variable's data is stored.
whos
Name Size Bytes Class
G 1000x1000 4000000 single
Ga 1000x1000 108 gpuArray
Gb 1000x1000 108 gpuArray
Gfft 1000x1000 108 gpuArray
Notice that all the arrays are stored on the GPU (gpuArray), except for G, which is the
result of the gather function.
Sparse Arrays on a GPU
The following functions support sparse gpuArrays.
classUnderlying
conj
ctranspose
end
find
full
gpuArray.speye
imag
isaUnderlying
isempty
isfloat
isinteger
islogical
isnumeric
isreal
issparse
length
mtimes
ndims
nonzeros
nnz
numel
nzmax
real
size
sparse
spones
transpose
You can create a sparse gpuArray either by calling sparse with a gpuArray input, or by
calling gpuArray with a sparse input. For example,
x = [0 1 0 0 0; 0 0 0 0 1]
0 1 0 0 0
0 0 0 0 1
s = sparse(x)