0001 function [flag,tmdce,texe,test] = run_mdce(scheduler,modes,tpause,nX,datamode,Nmax,N,display_mode)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if nargin < 1,
0025 scheduler.type = 'local';
0026 scheduler.enforce = 0;
0027 scheduler.display = 1;
0028 end
0029 if nargin < 2,
0030 modes = 0:3;
0031 end
0032 if nargin < 3,
0033 tpause = 10;
0034 end
0035 if nargin < 4,
0036 nX = 100;
0037 end
0038 if nargin < 5,
0039 datamode = 0;
0040 end
0041 if nargin < 6,
0042 Nmax = Inf;
0043 end
0044 if nargin < 7,
0045 N = 16;
0046 end
0047 if nargin < 8,
0048 display_mode = 2;
0049 end
0050
0051 if ~isstruct(scheduler),
0052
0053 scheduler.type = scheduler;
0054 scheduler.enforce = 0;
0055 scheduler.display = 1;
0056
0057 end
0058
0059 if ~isfield(scheduler,'memory'),
0060 scheduler.memory = 500 + round(8*nX^2/1e6);
0061 end
0062
0063 dkepath = load_structures_yp('dkepath','','');
0064
0065 modestrs = {'SEQUENTIAL','MDCE JOBS','DCLUKE','MDCE PARFOR'};
0066 colors = {'k','b','r','g'};
0067 markers = {'o','+','s','d'};
0068
0069 nmodes = length(modes);
0070
0071 tmdce = NaN*ones(nmodes,N);
0072 test = NaN*ones(nmodes,N);
0073 flag = cell(nmodes,N);
0074 texe = cell(nmodes,N);
0075
0076 X_in = cell(1,N);
0077 for j = 1:N,
0078 if datamode >= 0,
0079 X_in{j} = rand(nX);
0080 else
0081 X_in{j} = nX;
0082 end
0083 end
0084
0085 for n=[1,1:N],
0086
0087 for imode = 1:nmodes,
0088
0089 mode = modes(imode);
0090 modeindex = mode+1;
0091 modestr = modestrs{modeindex};
0092
0093 scheduler.mode = mode;
0094 scheduler.clustersize = min(n,Nmax);
0095
0096 [flag{imode,n},tmdce(imode,n),texe{imode,n},test(imode,n)] = nloop_mdce(modestr,dkepath,scheduler,X_in(1:n),tpause,datamode);
0097
0098 end
0099 end
0100
0101 if display_mode > 0,
0102
0103 figure(1),clf,set(1,'Name','Calculation time (s)')
0104
0105
0106
0107 leg = cell(1,nmodes);
0108
0109 for imode = 1:nmodes,
0110
0111 mode = modes(imode);
0112 modeindex = mode+1;
0113 mask = find(test(imode,:));
0114 leg{imode} = modestrs{modeindex};
0115
0116 if imode < nmodes,
0117 graph1D_jd(mask,tmdce(imode,mask),0,0,'','','',NaN,[0,N+1],NaN,'-',markers{modeindex},colors{modeindex},2,20+14i,gca);
0118 else
0119 leg = [leg,'Location','NorthWest'];
0120 graph1D_jd(mask,tmdce(imode,mask),0,0,'N processors','time (s)','Distributed computing calculations',leg,[0,N+1],NaN,'-',markers{modeindex},colors{modeindex},2,20+14i,gca,0.9,0.7,0.5);
0121 end
0122
0123 end
0124
0125
0126
0127 for imode = 1:nmodes,
0128
0129 mode = modes(imode);
0130 modeindex = mode+1;
0131 mask = find(test(imode,:));
0132
0133 texemax = NaN(1,N);
0134 for n=mask,
0135 texemax(n) = max(texe{imode,n});
0136 end
0137
0138 graph1D_jd(mask,texemax(mask),0,0,'','','',NaN,[0,N+1],NaN,'--','none',colors{modeindex},0.5,20+14i,gca);
0139
0140 print_jd(display_mode,'mdce_evaluation','./figures',1)
0141 end
0142 end
0143 end
0144
0145 function [flag,tmdce,texe,test] = nloop_mdce(modestr,dkepath,scheduler,X_in,tpause,datamode)
0146
0147 [dkecluster] = clustermode_luke(scheduler,'',dkepath);
0148
0149 dkecluster.scheduler.clustersize = length(X_in);
0150
0151 tinit = tic;
0152 [flag,X_out,texe] = mdce_run(@frun_mdce,{tpause,datamode,''},3,X_in,dkecluster);
0153 tmdce = toc(tinit);
0154 texe = cell2mat(texe.');
0155
0156 if ~all(flag == scheduler.mode),
0157 disp(' --> WARNING: Distributed calculation problem occured.');
0158 disp([' --> flag : ',num2str(flag)]);
0159 end
0160
0161 if datamode == 0,
0162 test = comp_struct_jd(X_in,X_out.',0);
0163 if test == 1,
0164 disp(' --> Outputs and Inputs are identical');
0165 else
0166 disp(' --> WARNING: Outputs are different from inputs. Verify workflow.');
0167 end
0168 else
0169 test = 1;
0170 end
0171
0172 disp([' --> time for n = ',int2str(length(X_in)),' ',modestr,' calculations on ',int2str(dkecluster.scheduler.clustersize),' proc. : ',num2str(tmdce),' s'])
0173 disp([' --> Execution time for frun_mdce : min ',num2str(min(texe)),'; max ',num2str(max(texe)),'; mean ',num2str(mean(texe)),' s'])
0174 disp('-------------------------------------------------------------------------')
0175
0176 end