diary driver_plot.dia

fprintf('%s\n', datestr(now));
fprintf('%s\n', pwd);

problemname = 'power';
fprintf('problemname: %s\n', problemname);

legendstr = {'n =  8192'; 'n = 16384'; 'n = 32768'};
vdirnames = {'n08192'; 'n16384'; 'n32768'};
vpdirectories = {'n01ppn01';'n01ppn02';'n01ppn04';'n01ppn08'; ...
      'n02ppn08';'n04ppn08';'n08ppn08';'n16ppn08'}; % ;'n32ppn08'};
lenvd = length(vdirnames);
lenpd = length(vpdirectories);
times = zeros(lenvd,lenpd);

for id = 1 : lenvd
  dirname = vdirnames{id};
  for jp = 1 : lenpd
    pdirname = vpdirectories{jp};
    filename = [dirname,'/',pdirname,'/diag_time.dat'];

    fid = fopen(filename);
    A = textscan(fid, '%s%f%f%f');
    fclose(fid);
    HHMMSS = A{1};
    thrs   = A{2};
    tmin   = A{3};
    tsec   = A{4};

    times(id,jp) = tsec;
  end;
end;

format bank
S = zeros(size(times));
E = zeros(size(times));
[m,n] = size(times);
vp = 2.^[0 : (n-1)];
for i = 1 : m % compute S and E one row at a time:
  S(i,:) = times(i,1) ./ times(i,:);
  E(i,:) = S(i,:) ./ vp;
end;

fprintf('\n');
fprintf('Observed times in seconds:\n');
lenlegendstr1 = length(legendstr{1});
for j = 1 : lenlegendstr1
  fprintf(' ');
end;
for j = 1 : n
  fprintf('  p=%3d', vp(j));
end;
fprintf('\n');
for i = 1 : m
  fprintf('%s',legendstr{i});
  for j = 1 : n
    fprintf('%7.2f',times(i,j));
  end;
  fprintf('\n');
end;
fprintf('\n');
fprintf('Observed speedup:\n');
lenlegendstr1 = length(legendstr{1});
for j = 1 : lenlegendstr1
  fprintf(' ');
end;
for j = 1 : n
  fprintf('  p=%3d', vp(j));
end;
fprintf('\n');
for i = 1 : m
  fprintf('%s',legendstr{i});
  for j = 1 : n
    fprintf('%7.2f',S(i,j));
  end;
  fprintf('\n');
end;
fprintf('\n');
fprintf('Observed efficiency:\n');
lenlegendstr1 = length(legendstr{1});
for j = 1 : lenlegendstr1
  fprintf(' ');
end;
for j = 1 : n
  fprintf('  p=%3d', vp(j));
end;
fprintf('\n');
for i = 1 : m
  fprintf('%s',legendstr{i});
  for j = 1 : n
    fprintf('%7.2f',E(i,j));
  end;
  fprintf('\n');
end;
fprintf('\n');

% the following assumes that you have 3 different n values,
% if not, you might want to use different markers.
figure('DefaultAxesFontSize',20);
H = plot(vp,S(1,:),'b-o', vp,S(2,:),'g-x', vp,S(3,:),'r-+', vp,vp,'k--');
axis([1 vp(end) 1 vp(end)]);
set(H(1:end-1), 'LineWidth',3, 'MarkerSize',12);
set(H(end), 'LineWidth',2);
grid on;
xlabel('Number of parallel processes p');
ylabel('Observed speedup S_p');
legend(H, legendstr{1}, legendstr{2}, legendstr{3}, 'optimal', ...
       'location','NorthWest');
print('-djpeg100',[problemname,'_speedup.jpg']);

figure('DefaultAxesFontSize',20);
oo = ones(size(vp));
H = plot(vp,E(1,:),'b-o', vp,E(2,:),'g-x', vp,E(3,:),'r-+', vp,oo,'k--');
axis([1 vp(end) 0.0 1.1]);
set(H(1:end-1), 'LineWidth',3, 'MarkerSize',12);
set(H(end), 'LineWidth',2);
grid on;
xlabel('Number of parallel processes p');
ylabel('Observed efficiency E_p');
legend(H, legendstr{1}, legendstr{2}, legendstr{3}, 'optimal', ...
       'location','NorthEast');
print('-djpeg100',[problemname,'_efficiency.jpg']);

diary off

