Improving speed of 1D fft over 3D data

3 Ansichten (letzte 30 Tage)
Yong Guk Kang
Yong Guk Kang am 2 Mär. 2020
Bearbeitet: Yong Guk Kang am 2 Mär. 2020
HI. I am trying to make an image reconstruction script for OCT data.
I vectorized all the code, but it is still quite slow and memory consuming.
I tried using gpuArray but the size of the data(raw_3D) exceedings the size of videoram.
So, as second trial, I split the data to multiple of 2D images([N,sx] of sy) and put this 2D images to gpuArray.
But it took much longer than vectorized CPU code. might be overhead of cpu-gpu data transfer..
Also, I have no clue using 'arrayfun' for my scripts. using 'parfor' also doesn't help...
I need to run this script at least 600 times per experiments, so reducing this time really matters.
Please Help! cc
% raw_3D : [N,sx,sy], 1d (2048 points)spectrometer data with 1000x1000 of points
% shiftMap : [sx,sy], contains shifting value per each data points
% IMGContrast : constant
% IMGBrightness : constant
raw_3D = rand(2048,1000,1000);
shiftMap = zeros(sx,sy);
N = size(row_3D,1);
sx = size(raw_3D,2);
sy = size(raw_3D,3);
%windows
win_tukey = tukeywin(N);
windows = repmat(coef_tukey,1,sx,sy);
clear basicImage
%% (1) Original script: vectorized CPU code
tic
basicImage = fft(raw_3D.*windows,[],1);
toc
%when variable 'basicImage' exists : 59sec, 70sec, 50sec..., when variable 'basicImage' doesn't exists : 18sec, 20sec
%%-------------
%% (2) GPU implementation
tic
basicImage=zeros(N,sx,sy);
for index=1:sy
gpuRaw=gpuArray(raw_3D(:,:,index));
basicImage(:,:,index) =gather(fft(gpuRaw));
end
toc
%%------------ 78 seconds
%% (3) Parfor
tic
basicImage=zeros(N,sx,sy);
parfor index=1:sy
gpuRaw=gpuArray(raw_3D(:,:,index));
basicImage(:,:,index) =gather(fft(gpuRaw));
end
toc
%%------------
% 225 second
% doesn't help because have only one GPU?

Antworten (0)

Kategorien

Mehr zu GPU Computing finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by