Speed of code GPU

1 visualización (últimos 30 días)
Tiki Tiki
Tiki Tiki el 9 de Ag. de 2018
Comentada: Tiki Tiki el 9 de Ag. de 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 comentario
Tiki Tiki
Tiki Tiki el 9 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by