GPUArray ANDs and ORs
Show older comments
First off, I am very satisfied with matlab's ability to leverage the GPU for parellel computing. It makes so many functions and calculations faster (usually about 3-5x faster). With the pre-release and release of MATLAB 2011a, they have added even more functionality for use with GPUArrays. One troubling thing is there seems to be no support for the "and" and "or" operators on GPUArrays.
To get around this, one could gather their GPUArray each time they would like to run a logical AND or OR. This represents a slow down in performance over using non-distrubuted arrays, and requires a re-write (albeit small) of many the existing functions that I have to handle GPUArrays. There is also a clever way to perform the "AND" and "OR" operators using concatanation and the "all" or "any" functions. I have written two short functions to do so
function obj = and(A,B)
nD = ndims(A)+1;
obj = all(cat(nD,A,B),nD);
return
function obj = or2(A,B)
nD = ndims(A)+1;
obj = any(cat(nD,A,B),nD);
return
Is there away to define the method "AND" and "OR" for an existing class type of parallel.gpu.GPUArray?
Any help or insight would me much appreciated.
Accepted Answer
More Answers (1)
Jill Reese
on 29 Jul 2011
0 votes
Hi Jonathan, if your MATLAB license is up to date you might like to have a look at the pre-release of R2011b which is now available. This includes a number of updates to the GPU features. It can be downloaded by logging in to the main www.mathworks.com page.
Categories
Find more on GPU Computing in MATLAB 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!