Parallel looped interp1 on GPU
24 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
D. Plotnick
il 18 Mar 2016
Commentato: Harun Cetinkaya
il 11 Giu 2018
I have a set of data where I am interpolating each row onto a different 2-D grid using interp1. I have been using gpuArray to run interp1 using a for loop (which gives me good speed), but since this is a series of independent parallel computations I was hoping for a way to parallelize the operation on the GPU.
I am including a minimum working example. The idea is to remove the for loop and run the interp1 calculations in parallel. Note that the actual datasets will be much larger, so yes the for loop would be great to toss.
%%InterpLoop MWE
Data = gpuArray(rand(100,1000));
x = 1:1000;
y = 1:100;
[X,Y] = meshgrid(x,y);
Xq = X-Y;
imagesc(Xq);
Vqs= cell(100,1);
x = gpuArray(x);
Xq = gpuArray(Xq);
for ii = 1:100
Vqs{ii} = interp1(x,Data(ii,:),Xq+x(ii),'linear',0);
end
Note also that storing the interpolated data in a cell array is also optional. The goal is parallel gpu loop over interp1 operations from 1-D to 2-D grid where the grid varies.
Side question, if somebody knows of an interp1 fast code that will do spline interpolation on the GPU I would love to know about it, interp1 only supports linear and nearest on gpuArray.
0 Commenti
Risposta accettata
Joss Knight
il 21 Mar 2016
The best way to parallelize multiple 1D interpolations is to use 2D interpolation, and just set the Y interp point to (1:M)', i.e:
Vqs = interp2(x, Data, Xq+x, (1:100)', 'linear', 0);
4 Commenti
Harun Cetinkaya
il 11 Giu 2018
Hi Joss Knight,
I have tried to use your code for interpolation issue (interp2). I simply took the same code as you wrote here... Unfortunately it does not work on my computer... But there is an error given as 'The input arguments are invalid. For supported syntaxes, see help gpuArray.interp2'.
I could not understand why it does not work...
thank you in advance for your interest...
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!