Error using gpuArray/arrayfun ... Use of functional workspace is not supported.

조회 수: 12 (최근 30일)
Soohun
Soohun 2013년 12월 26일
댓글: LASIN T 2022년 8월 10일
I define a simple function of summation.m as follows:
--------------------------------------------
function out = summation(a, b, c, d)
out = a+b+c+d;
--------------------------------------------
Then, I run the following code:
--------------------------------------------
R1 = gpuArray.rand(10,10);
R2 = gpuArray.rand(10,10);
R3 = gpuArray.rand(10,10);
f = @(a,b,c)summation( a, b, c, 5);
R = arrayfun(f,R1,R2,R3);
--------------------------------------------
This works fine. However, if I change the function handle as
--------------------------------------------
R1 = gpuArray.rand(10,10);
R2 = gpuArray.rand(10,10);
R3 = gpuArray.rand(10,10);
*_d = 5;_*
f = @(a,b,c)summation( a, b, c, *_d_* );
R = arrayfun(f,R1,R2,R3);
--------------------------------------------
I get the error message "Error using gpuArray/arrayfun Use of functional workspace is not supported." Is there a way to resolve this issue? I would like to resolve this so that I can use GPU in the case that d is either a vector or a matrix.

답변 (1개)

Jill Reese
Jill Reese 2013년 12월 30일
As of the latest MATLAB release (R2013b) arrayfun on the GPU does not support anonymous functions that have been created using variables from the existing MATLAB workspace. This is the meaning of the error message you have encountered.
Unless I am missing something, you should not need to create your function handle using your variable, d. Arrayfun on the GPU supports scalar expansion so d can be a scalar, a vector, or a matrix as long as its dimensions are either the same as your R1, R2, and R3 variables or the dimension is 1. So for the dimensions you mention above, d can be passed into the arrayfun call in the same way as R1, R2, and R3 and the call will succeed if d has size 1 x 1, 10 x 1, 1 x 10, or 10 x 10. Does this not work for you?
  댓글 수: 1
LASIN T
LASIN T 2022년 8월 10일
I made everything same length and I am still getting the same error, "Use of functional workspace is not supported."

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by