- The output is a size or dimension (this is not "data") - so size, numel, ndims for gpuArray data return ordinary MATLAB arrays.
- The input parameter is a size or dimension
If I create a gpuArray variable, do other variables that are derived from that variable go to the gpu too?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
If I declare a variable on the GPU and then I run a function on that variable and return the result of the function to another variable, does the new variable get instantiated on the gpu too? Or, do I need to explicitly send it to the gpu?
For example, in the code below, the variable I is created on the gpu. Does Ig also get created on the gpu? Or is it on the cpu?
Thanks. -Tony
I = gpuArray(imread('test.gif');
Ig = rgb2gray(I);
0 comentarios
Respuestas (1)
Edric Ellis
el 3 de Mayo de 2016
In this case, Ig does indeed get created as a gpuArray. The general rule is that if a parameter of a function is considered to be "data", then a gpuArray passed as an argument for that parameter causes the computation to be performed on the GPU, and the output is a gpuArray.
In practice, this means that generally outputs of functions called with gpuArray arguments are also gpuArrays, except when either:
As an example of the second case, consider
d = gpuArray(2);
x = magic(7);
result = sum(x, d);
In this case, the second argument to sum is a gpuArray - but the "data" in this case is an ordinary MATLAB array. So, d is automatically converted to an ordinary array (using gather behind the scenes), and the sum occurs on the CPU, and result is an ordinary (non-GPU) MATLAB array.
0 comentarios
Ver también
Categorías
Más información sobre GPU Computing in MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!