LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_ssa_analyzer_parallel.m
1function [XN,UN,QN,RN,TN,CN,tranSysState,tranSync,snc]=solver_ssa_analyzer_parallel(sn, init_state, laboptions)
2% [XN,UN,QN,RN,TN,CN]=SOLVER_SSA_ANALYZER_PARALLEL(LABOPTIONS, QN, PH)
3
4snc = sn; % required due to spmd parallelism
5M = snc.nstations; %number of stations
6K = snc.nclasses; %number of classes
7PH = sn.proc;
8S = snc.nservers;
9NK = snc.njobs'; % initial population per class
10
11spmd
12 if isMATLABReleaseOlderThan("R2022b")
13 nLabs = numlabs; %#ok<DNUMLABS>
14 else
15 nLabs = spmdSize;
16 end
17
18 % eventCache is not shared across labs
19 if isfield(laboptions,'config') && isfield(laboptions.config,'eventcache')
20 eventCache = EventCache.create(laboptions.config.eventcache, sn);
21 else
22 eventCache = EventCache.create(false, sn);
23 end
24
25 laboptions.samples = ceil(laboptions.samples / nLabs);
26 laboptions.verbose = VerboseLevel.SILENT;
27
28 [probSysState,SSq,arvRates,depRates,~,~,snc] = solver_ssa(snc, init_state, laboptions, eventCache);
29
30 rates = sn.rates;
31 XN = NaN*zeros(1,K);
32 UN = NaN*zeros(M,K);
33 QN = NaN*zeros(M,K);
34 RN = NaN*zeros(M,K);
35 TN = NaN*zeros(M,K);
36 CN = NaN*zeros(1,K);
37 for k=1:K
38 refsf = snc.stationToStateful(snc.refstat(k));
39 XN(k) = probSysState*depRates(:,refsf,k);
40 for ist=1:M
41 isf = snc.stationToStateful(ist);
42 TN(ist,k) = probSysState*depRates(:,isf,k);
43 QN(ist,k) = probSysState*SSq(:,(ist-1)*K+k);
44 switch snc.sched(ist)
45 case SchedStrategy.INF
46 UN(ist,k) = QN(ist,k);
47 otherwise
48 % we use Little's law, otherwise there are issues in
49 % estimating the fraction of time assigned to class k (to
50 % recheck)
51 if ~isempty(PH{ist}{k})
52 UN(ist,k) = probSysState*arvRates(:,ist,k)/rates(ist,k)/S(ist);
53 end
54 end
55 end
56 end
57
58 for k=1:K
59 for ist=1:M
60 if TN(ist,k)>0
61 RN(ist,k) = QN(ist,k)./TN(ist,k);
62 else
63 RN(ist,k) = 0;
64 end
65 end
66 CN(k) = NK(k)./XN(k);
67 end
68
69 QN(isnan(QN))=0;
70 CN(isnan(CN))=0;
71 RN(isnan(RN))=0;
72 UN(isnan(UN))=0;
73 XN(isnan(XN))=0;
74 TN(isnan(TN))=0;
75
76 % now update the routing probabilities in nodes with state-dependent routing
77 for k=1:K
78 for isf=1:snc.nstateful
79 if snc.nodetype(isf) == NodeType.Cache
80 TNcache(isf,k) = probSysState*depRates(:,isf,k);
81 end
82 end
83 end
84
85 % updates cache actual hit and miss data
86 for k=1:K
87 for isf=1:snc.nstateful
88 if snc.nodetype(isf) == NodeType.Cache
89 ind = snc.statefulToNode(isf);
90 if length(snc.nodeparam{ind}.hitclass)>=k
91 h = snc.nodeparam{ind}.hitclass(k);
92 m = snc.nodeparam{ind}.missclass(k);
93 snc.nodeparam{ind}.actualhitprob(k) = TNcache(isf,h)/sum(TNcache(isf,[h,m]));
94 snc.nodeparam{ind}.actualmissprob(k) = TNcache(isf,m)/sum(TNcache(isf,[h,m]));
95 end
96 end
97 end
98 end
99end
100nLabs = length(QN);
101QN = cellsum(QN)/nLabs;
102UN = cellsum(UN)/nLabs;
103RN = cellsum(RN)/nLabs;
104TN = cellsum(TN)/nLabs;
105CN = cellsum(CN)/nLabs;
106XN = cellsum(XN)/nLabs;
107
108for k=1:K
109 for isf=1:sn.nstateful
110 if sn.nodetype(isf) == NodeType.Cache
111 ind = sn.statefulToNode(isf);
112 sn.nodeparam{ind}.actualhitprob(k) = 0;
113 sn.nodeparam{ind}.actualmissprob(k) = 0;
114 for l=1:nLabs
115 qntmp = snc{l};
116 if length(qntmp.nodeparam{ind}.hitclass)>=k
117 sn.nodeparam{ind}.actualhitprob(k) = sn.nodeparam{ind}.actualhitprob(k) + (1/nLabs) * qntmp.nodeparam{ind}.actualhitprob(k);
118 sn.nodeparam{ind}.actualmissprob(k) = sn.nodeparam{ind}.actualmissprob(k) + (1/nLabs) * qntmp.nodeparam{ind}.actualmissprob(k);
119 end
120 end
121 end
122 end
123end
124snc = sn;
125tranSysState=[];
126tranSync=[];
127end
Definition mmt.m:92