MATLAB PARALLEL COMPUTING TOOLBOX - S Uživatelská příručka Strana 473

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 656
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 472
gpuArray
11-129
gpuArray
Create array on GPU
Syntax
G = gpuArray(X)
Description
G = gpuArray(X) copies the numeric array X to the GPU, and returns a gpuArray
object. You can operate on this array by passing its gpuArray to the feval method of
a CUDA kernel object, or by using one of the methods defined for gpuArray objects in
“Establish Arrays on a GPU” on page 9-3.
The MATLAB array X must be numeric (for example: single, double, int8, etc.) or
logical, and the GPU device must have sufficient free memory to store the data.
If the input argument is already a gpuArray, the output is the same as the input.
Use gather to retrieve the array from the GPU to the MATLAB workspace.
Examples
Transfer a 10-by-10 matrix of random single-precision values to the GPU, then use the
GPU to square each element.
X = rand(10,'single');
G = gpuArray(X);
classUnderlying(G)
single
G2 = G .* G; % Performed on GPU
whos G2 % Result on GPU
Name Size Bytes Class
Zobrazit stránku 472
1 2 ... 468 469 470 471 472 473 474 475 476 477 478 ... 655 656

Komentáře k této Příručce

Žádné komentáře