Effacer les filtres
Effacer les filtres

Speed of code GPU

1 vue (au cours des 30 derniers jours)
Tiki Tiki
Tiki Tiki le 9 Août 2018
Commenté : Tiki Tiki le 9 Août 2018
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 commentaire
Tiki Tiki
Tiki Tiki le 9 Août 2018
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by