% Speedup: general examples clc; clf; clear %% Generate data cpus = [ 1 2 4 8 16 32 64]; % #processors time_cpu = [ 508.74 257.83 132.20 110.17 55.93 28.20 14.11]; % seconds gpus = [2 4 8 16 32 ]; % #processors time_gpu = [7.576 3.509 1.712 0.925 0.692 ]; % seconds %% Speedup on basis of 2 CPUs/GPUs s_cpu = time_cpu(2)./time_cpu; s_gpu = time_gpu(1)./time_gpu; %% ideal speedup wrt. 2 procs best = cpus/2; %% Graphics %plot(cpus,s_cpu,'*-'); % both graphs with special "linespecs" and thicker lines % both axis are logarithmically loglog(cpus,s_cpu,'*-b',gpus,s_gpu,'s-r','LineWidth',2); % Titel and Labels of Axis title('Speedup for GPU vs. CPU implementation') xlabel('Processors'); ylabel('Speedup on basis of 2 procs'); % Tick of axis % 'XTick',[1 2 4 8 16 32 64] set(gca,'XTick',cpus) set(gca,'YTick',cpus/2) %% One more graph hold on % Allows to continue the drawing in the same figure loglog(cpus,best,'-g'); % one more graph in figure legend('CPU','GPU','ideal'); % Legend of graphs %% save graphics saveas(gcf,'speedup_munich.jpg')