How to run a custom function to gpu?

5 views (last 30 days)
Elric on 17 Jul 2020
Answered: Joss Knight on 4 Aug 2020
Hi everyone,
I want to run a custom function in matlab. Actually, in this example is the gctest function from matlab, but I wonder how I can do this with any function.
Suppose that I have an nxm matrix ret, then I want to run the gctest of the first column against the remaining columns.
The code that I use is the following:
ret = gpuArray(ret);
arrayfun( @(i) gctest( ret(:,1), ret(:,i)), sample, 'UniformOutput', true);
but I get the following error:
The following error occurred converting from gpuArray to double: Conversion to double from gpuArray is not possible.
Error in varm/estimate (line 403) Z(:,iColumns) = kron(Y(t-i,:),I);
Error in gctest (line 204) [EstMdl,~,~,~,Sigma] = estimate(Mdl,Data);
So, if I understand correct matlab tries to convert ret back to double.
Any ideas how to solve this?
Thank you in advance.

Answers (1)

Joss Knight
Joss Knight on 4 Aug 2020
I guess the basic problem is that the gctest function doesn't support gpuArray data. You could try taking a copy of it and fixing the issues it has with that support. In this case, the LHS of the assignment, Z, needs to be a gpuArray for that statement to work.

Community Treasure Hunt

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

Start Hunting!