Error using gpuArray/arrayfun ('MCOS', 'CLASSDEF')

5 ビュー (過去 30 日間)
Bart van Essen
Bart van Essen 2015 年 11 月 12 日
コメント済み: Edric Ellis 2015 年 11 月 13 日
Hello,
i am currently trying to do some calculations of my code on gpu. therefore, i call the following lines:
angles=gpuArray(angles);
[obj.Points(1,:),obj.Points(2,:)]=arrayfun(@(x) laser.calccolpnt(x,cell2mat(Obstacles.Obstaclemap),obj.position,obj.direction,obj.range),angles);
without the first line, this works perfectly fine, anyway, when i add the gpuArray command before, this gives me the following error:
Error using gpuArray/arrayfun
Function passed as first input
argument contains unsupported
'MCOS' language feature 'CLASSDEF'.
i even get this, when the called function looks like this:
function [px,py]=calccolpnt(angle,Obstacles,position,direction,range)
px=angle;
py=angle;
end
does anyone know a solution for this problem?
thanks for help.

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 12 日
MCOS appears to be the name of the newer object-oriented system that uses classdef to define objects.
Restrictions on the called functions for gpuarray and arrayfun are described at http://www.mathworks.com/help/distcomp/run-element-wise-matlab-code-on-a-gpu.html#bsnx7h8-1
I gather that the problem here is that the function you are passing is defined in a classdef and that just is not permitted.
You might be able to call a function outside of a classdef that referred to a user-defined object, but I do not know if it is possible or not.
  2 件のコメント
Bart van Essen
Bart van Essen 2015 年 11 月 12 日
Thanks for your help, i now passed the arguments to a function outside of any class. Anyway, I just found out, that i cannot use a functional workspace, making gpuArray pretty useless for me, because the calculations i make are pretty complex and need around 30 lines of code. is there some trick to run complex code on a gpuArray?
Edric Ellis
Edric Ellis 2015 年 11 月 13 日
What do you mean by "functional workspace"? The gpuArray version of arrayfun can handle nested and anonymous functions which refer to variables defined in the outer context.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing in MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by