Run custom function on GPU with Parallel Computing Toolbox?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a function which needs to find min( b -A*x ). The dimensions of b = 5 X 1; A = 5 X 2; x = 2 X 10; The output of A*x would be 5 X 10. and since b is a column vector, the final output will be 5 X 10, [b - A*x] and if we apply min operator we would get 5 X 1. When I try to use the arrayfun function it gives error :- Error using parallel.gpu.GPUArray/arrayfun Matrix dimensions must agree for 'mtimes'
0 Kommentare
Akzeptierte Antwort
Jill Reese
am 18 Mai 2012
Arrayfun on the GPU only supports elementwise operations, so it is not the command that you want to use in this case.
You need to use min and * (mtimes) directly, which are overloaded to run on the GPU. If at least one of A, b, or x are stored on the GPU (i.e. of type parallel.gpu.GPUArray), then your code snippet will run on the GPU.
2 Kommentare
Jill Reese
am 24 Mai 2012
The link you provide is for R2012a. If you upgrade your version of MATLAB to R2012a then you will have access to bsxfun on the gpu.
Weitere Antworten (1)
Walter Roberson
am 18 Mai 2012
column vector minus a matrix is not defined.
You will need to show your arrayfun code; it sounds as if you are using the wrong arguments or wrong function.
Siehe auch
Kategorien
Mehr zu GPU Computing in MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!