필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by