フィルターのクリア

Speed of code GPU

1 回表示 (過去 30 日間)
Tiki Tiki
Tiki Tiki 2018 年 8 月 9 日
コメント済み: Tiki Tiki 2018 年 8 月 9 日
Hi everyone,
Can you help me optimize this code?
clear all
BatchSize = 100;
SP_Size = [32 32];
InputOverlap = rand(SP_Size(1)*SP_Size(2),BatchSize,'gpuArray');
Radius =4;
InputOverlap = reshape(InputOverlap,SP_Size(1),SP_Size(2),size(InputOverlap,2));
test_size2 = size (InputOverlap) ;
test_size = test_size2(1:2);
test_Overlap = InputOverlap;
test = zeros(test_size2,'gpuArray') ;
InputOverlap = [InputOverlap(:,1:Radius,:) InputOverlap InputOverlap(:,end+1-Radius:end,:)];
InputOverlap = [InputOverlap(1:Radius,:,:) ; InputOverlap ; InputOverlap(end+1-Radius:end,:,:) ];
t5 = tic;
parfor r=1:test_size(1)
InputOverlapTemp = InputOverlap;
temp = zeros(1,test_size(1),test_size2(3),'gpuArray');
Kmax = zeros(1,1,test_size2(3),'gpuArray');
for c=1:test_size(1)
Neighbour = InputOverlap(r:r+2*Radius,c:c+2*Radius,:);
Kmax(1,1,:) = max(max(Neighbour)) ;
temp(1,c,:) = ((test_Overlap(r,c,:)>= Kmax));
end
test(r,:,:) = temp;
end
time5 = toc(t5)
even I use GPU, but time simulation still big. Thank.
  1 件のコメント
Tiki Tiki
Tiki Tiki 2018 年 8 月 9 日
I've already written on CPU, and it takes nearly same time, so I couldnot see any advantage of GPU. in my code, if I donot use parfor, the time is even worse. So can you explain for my why I cannot speed up this code?
Thanks.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by