Getting gpuArray output type not currently implemented

7 Ansichten (letzte 30 Tage)
Peter
Peter am 14 Nov. 2013
Kommentiert: Peter am 15 Nov. 2013
I'm trying to write a MATLAB function that will run on an NVIDIA GeForce GTX 660. I'm using MATLAB R2013b and have the parallel toolbox installed.
I tried to model my code using the paralleldemo_gpu_stencil demo.
I have an array of samples (15000x1) and I want to add values to slices of the samples, where I may have 1,000,000 values to add. I have a nested function that I call using arrayfun, that I loop through for the number of values I want to add. I'm getting the error "gpuArray output type not currently implemented". on the arrayfun line.
1 %Inline function
2 function X = addValue(slice)
3 X = (samples + values) * slice;
4 end
5 samples = gpuArray(samples); % previously defined
6 zeroArray = zeros(size(samples));
7 for ii=1:numberValies
8 slice = zeroArray; % Use as a mask to apply to only those indices I care about
9 startSlice = slicePos(ii);
10 slice(startSlice:startSlice-1) = ones(size(startSlice:startSlice-1,1));
11 samples = arrayfun(@addValue, slice);
12 end
I'm getting the error on line 11. Any help would be appreciated.
  2 Kommentare
Ashish Uthama
Ashish Uthama am 14 Nov. 2013
Peter, could you try updating your code sample to something anyone could run to try and reproduce this error? (I tried to make it runnable, but then it didnt reproduce your message)
Peter
Peter am 15 Nov. 2013
Hi Asish, sorry you had problems reproducing the problem. I revisited the problem and found that I didn't understand how the GPU Stencil demo was using arrayfun. I changed my code and got it to work.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Edric Ellis
Edric Ellis am 15 Nov. 2013
The problem here is that 'slice' is not a gpuArray, and so the arrayfun call is executing on the CPU. The problem occurs because the CPU version of arrayfun cannot return the gpuArrays being produced by your 'addValue' function. You need to make 'slice' be a gpuArray to fix this.
It's hard to tell from your reproduction here, but there may very well be other things that you need to change here to get the best performance on the GPU. For instance, 'addValue' currently redundantly calculates the sum "(samples + values)"; line 10 could simply state "slice(startSlice:startSlice-1) = 1;"; ...

Weitere Antworten (1)

Peter
Peter am 15 Nov. 2013
Hi Edric,
I went back and re-examined my code and the sample code and rewrote my function. I was able to get the code to work, and found the same problems you found and a few others. My current problem is trying to the the timing numbers closer to the numbers I get in the sample.
Thanks for taking a look and writing back.

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by