In-place operation at gpuarray
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Joss Knight
on 4 Feb 2016
Edited: Joss Knight
on 4 Feb 2016
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.
0 Comments
See Also
Categories
Find more on GPU Computing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!