In-place operation at gpuarray

I'm using Matlab 2015b on Ubuntu 14.04
I'm unable to perform inplace operations on gpuarray even when both left & right hand variables are the same.
For example:
gpA = ones (N,M,'single','gpuarray');
S = 5;
gpA = gpA.*S;
gpA = abs (gpA);
If N & M are big enough so gpA occupies more than half of the GPU memory, the above operations results in out of memory exception.
How do I perform simple inplace operations without writing a proprietary kernel?
Thanks in advance, David

Réponses (1)

Joss Knight
Joss Knight le 4 Fév 2016
Modifié(e) : Joss Knight le 4 Fév 2016

2 votes

Do it inside a function. On the command line MATLAB cannot operate on the arguments to functions in-place, because (to cite one of the reasons) if a function errors or the user hits Ctrl-C it needs to be able to return your workspace to the state it was in before you ran the function, not some half-completed state.

Catégories

En savoir plus sur Parallel Computing dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by