필터 지우기
필터 지우기

Run custom function on GPU with Parallel Computing Toolbox?

조회 수: 3 (최근 30일)
Subhrajit Debnath
Subhrajit Debnath 2012년 5월 18일
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'

채택된 답변

Jill Reese
Jill Reese 2012년 5월 18일
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
Subhrajit Debnath
Subhrajit Debnath 2012년 5월 19일
Thanks a lot. I am trying to do bsxfun(@minus,b,A*x);
It is giving error as: Undefined function 'bsxfun' for input arguments of type 'parallel.gpu.GPUArray'.
It seems this function is not supported. I am using Parallel Computing Toolbox Version 5.2 (R2011b).
But this function is listed in the built in functions that support gpuArray.
http://www.mathworks.in/help/toolbox/distcomp/bsic4fr-1.html#bsloua3-1
Jill Reese
Jill Reese 2012년 5월 24일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 18일
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.
  댓글 수: 1
Subhrajit Debnath
Subhrajit Debnath 2012년 5월 19일
yes it can be done.
bsxfun(@minus,b,A*x); will do matrix column-wise subtraction.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by