gpuArray performance on 'xcorr' function
显示 更早的评论
Hi,
I am tring to improve a performance on my script, which is using 'xcorr' function heavily.
I found that 'xcorr' function supports gpuArray and I tried it. However, it seems the performance is not good.
I did three simple examples
t = 0:0.001:10-0.001;
x = cos(2*pi*10*t) + randn(size(t));
X = gpuArray(x);
tic
[r,lags] = xcorr(X,X,'normalized');
r = gather(r);
toc
% Elapsed time is 0.017178 seconds.
t = 0:0.001:10-0.001;
x = cos(2*pi*10*t) + randn(size(t));
tic
[r,lags] = xcorr(x,x,'normalized');
r = gather(r);
toc
% Elapsed time is 0.004627 seconds.
t = 0:0.001:10-0.001;
x = cos(2*pi*10*t) + randn(size(t));
X = gpuArray(single(x));
tic
[r,lags] = xcorr(X,X,'normalized');
r = gather(r);
toc
% Elapsed time is 0.015555 seconds.
just normal array is much faster than gpuArray.

For 'single' type data, GPU is much faster!
What should I do to increase the performance on 'xcorr' function?
(I have several thousond of array and each array has 10k elements.)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Correlation and Convolution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!