Anyone can help me to benchmark this code on high end GPU (CUDA)?

Hello, I am struggling on the imagesc function. Let's think of the example.
A=uint8(256*rand(1000,1000,30));
figure('position',[461,41,1000,1000]);tic;
for k=1:30;
imagesc(A(:,:,k));
pause(0.01);
end;toc;
I expect to see frame rate 100Hz. But my result is only 17Hz. My core is i5 intel. I don't have GPU.
I am suspicious that my slow rate results from no GPU on my computer.
Can anyone help me to benchmark this code on high end GPU such as NVidea K80 Tesla? So that I can make sure my problem.
A=uint8(256*rand(1000,1000,30));
A=gpuArray(A);
figure('position',[461,41,1000,1000]);tic;
for k=1:30;
imagesc(A(:,:,k));
pause(0.01);
end;toc;

 Accepted Answer

I was able to get your images to display at 30Hz with the help of a Tesla K20c. I can't get any faster than that because the rest of the overhead is rendering time. If I take out the pause the loop runs in 0.1 seconds.

4 Comments

Thank you. If I take out pause(0.01), I also get 0.14 seconds. But, in this case, only the final image take place on a screen. I need every image pop up on a screen in a sequence.
Joss, If you do not mind, please test the below code by your Tesla K20c.
My computer take 8.3s.
figure('position',[461,41,1000,1000]);
r2=randi(18,1000,1000);r21=zeros(1000); randindiv=zeros(1000,1000,18);
r2=gpuArray(r2);r21=gpuArray(r21);randindiv=gpuArray(randindiv);
for k=1:18
r21(r2~=k)=0;
r21(r2==k)=1;
randindiv(:,:,k)=r21;
end;
x_shift=180;
x_shift=gpuArray(x_shift);
R_v=75;
R_v=gpuArray(R_v);
Phi_v=linspace(0,2*pi,19);
Phi_v=gpuArray(Phi_v);
Phi_v(end)=[];
xdis_v=R_v.*cos(Phi_v)+x_shift;
xdis_v=gpuArray(xdis_v);
ydis_v=R_v.*sin(Phi_v);
ydis_v=gpuArray(ydis_v);
xdis_f(1:18)=xdis_v+50;
xdis_f=gpuArray(xdis_f);
ydis_f(1:18)=ydis_v+50;
ydis_f=gpuArray(ydis_f);
% xempty_f=xdis_v;
% yempty_f=ydis_v;
[XX,YY]=meshgrid(-499:500,-499:500);
XX=gpuArray(XX);YY=gpuArray(YY);
trap=zeros(1000,1000,length(xdis_v));
trap=gpuArray(trap);
coeff=0.05;
coeff=gpuArray(coeff);
step=30;xdis(1:18,1:step)=zeros;ydis(1:18,1:step)=zeros;
step=gpuArray(step);xdis=gpuArray(xdis);ydis=gpuArray(ydis);
for k=1:18;
xdis(k,1:step)=linspace(xdis_v(k),xdis_f(k),step);
ydis(k,1:step)=linspace(ydis_v(k),ydis_f(k),step);
end;
tic
for kk=1:step;
for i=1:length(xdis_v)
coeff=0.05;
trap(:,:,i)=XX*coeff*xdis(i,kk)+YY*coeff*ydis(i,kk);
end
doe=sum(trap.*randindiv,3);
% doe=doe+double(lens(540+(-499:500),960+(-499:500)));
doe=uint8(mod(round(doe+128),256));
imagesc(doe);
%pause(0.01);
drawnow;
% java.lang.Thread.sleep(0.01*1000);
% imwrite(doe,'d:\tetris\does\test2s.png');
% imwrite(doe(141:940,561:1360),strcat(filepath,'doe',num2str(num+1000),'.png'));
end
toc

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!