close all;
clear;

servername='thunder';

linewidth=1;
markersize=7;

data=load(sprintf('%stiming',servername));

COLOR={'kv--' 'ro-' 'bx-' 'g+-' 'c*-' 'yp-' 'ms-','k-h'};

PROCS=[4,8,16,32,64,128,256,512,1024,2048];
SIZE=[262144, 1048576,4194304,16777216, 67108864];
BITS=[32 48 64];
CURVE=[0,1,2];

P=2;
D=3;
C=4;
S=5;
B=6;
T=7;
Ts=8;
Tp=9;
Tc=10;
Ta=11;
To=12;
Tg=13;
Twp=14;
Twc=15;
Twb=16;
c=3;
b=3;
s=3;

close all;
for s=1:length(SIZE)
	close all;
	leg='';
	i=1;
	
	xlabels='';
        for(p=1:length(PROCS))
		xlabels{p}=sprintf('%d',PROCS(p));
	end
											
	index1=find(data(:,B)==BITS(b));
	index=index1;
	index1=find(data(:,C)==CURVE(c));
	index=intersect(index,index1);	
	index1=find(data(:,S)==SIZE(s));
	index=intersect(index,index1);

	if length(index)~=0
		leg{i}='Total Time';
		j=loglog(data(index,P),data(index,T),COLOR{i},'LineWidth',linewidth,'MarkerSize',markersize);
		hold on;
		i=i+1;
		leg{i}='Serial';
		loglog(data(index,P),data(index,Ts),COLOR{i},'LineWidth',linewidth,'MarkerSize',markersize);
		i=i+1;
		leg{i}='Primary';
		loglog(data(index,P),data(index,Tp)+data(index,Twp),COLOR{i},'LineWidth',linewidth,'MarkerSize',markersize);
		i=i+1;
		leg{i}='Cleanup';
		loglog(data(index,P),data(index,Tc)+data(index,Twc),COLOR{i},'LineWidth',linewidth,'MarkerSize',markersize);
		i=i+1;
%		leg{i}='Wait';
%		loglog(data(index,P),data(index,Twp)+data(index,Twc)+data(index,Twb),COLOR{i});
%		i=i+1;
%		leg{i}='Allocation';
%		loglog(data(index,P),data(index,Ta),COLOR{i});
%		i=i+1;
%		leg{i}='AllGather';
%		loglog(data(index,P),data(index,Tg),COLOR{i},'LineWidth',linewidth,'MarkerSize',markersize);
%		i=i+1;
%		leg{i}='Other';
%		loglog(data(index,P),data(index,To),COLOR{i});
%		i=i+1;
	end
	title(sprintf('Time for N=%d',SIZE(s)),'fontsize',16);
	set(gca,'Xtick',PROCS);
	set(gca,'XTickLabel',xlabels);
	xlim([PROCS(1) PROCS(length(PROCS))]);
	xlabel('Processors','fontsize',14);
%	xlabel('Elements per Processor','fontsize',14);
	ylabel('Time','fontsize',14);
	l=legend(leg,0);
%	set(l, 'fontsize', 10);
	pause;
	print('-depsc','-tiff',sprintf('alltimes%d.eps',SIZE(s)));
	
end;
