1%{ @file sn_get_node_tput_from_tput.m
2 % @brief Computes average throughputs at
nodes from station throughputs
4 % @author LINE Development Team
8 % @brief Computes average throughputs at
nodes from station throughputs
11 % This function calculates
the average throughput at each node in steady-state
12 % from
the station throughputs and node-level routing matrix.
16 % TNn = sn_get_node_tput_from_tput(sn, TN, TH)
17 % TNn = sn_get_node_tput_from_tput(sn, TN, TH, ANn)
22 % <tr><th>Name<th>Description
23 % <tr><td>sn<td>Network structure
24 % <tr><td>TN<td>Average throughputs at stations
25 % <tr><td>TH<td>Throughput handles
26 % <tr><td>ANn<td>(Optional) Average arrival rates at
nodes; computed
if missing
31 % <tr><th>Name<th>Description
32 % <tr><td>TNn<td>Average throughputs at
nodes
35function TNn=sn_get_node_tput_from_tput(sn, TN, TH, ANn)
41 ANn = sn_get_node_arvr_from_tput(sn, TN, TH);
45if ~isempty(TH) && ~isempty(TN)
48 inchain = sn.inchain{c};
49 refstat = sn.refstat(c);
51 if sn.nodetype(ind) ~= NodeType.Source
52 switch sn.nodetype(ind)
54 % For cache
nodes, use actual hit/miss ratios
if available
55 % instead of
nodevisits which don
't account for cache behavior
56 hitclass = sn.nodeparam{ind}.hitclass;
57 missclass = sn.nodeparam{ind}.missclass;
58 totalTput = sum(TN(refstat,inchain));
60 % Check if actual hit/miss probabilities are available in nodeparam
61 if isfield(sn.nodeparam{ind}, 'actualhitprob
') && ~isempty(sn.nodeparam{ind}.actualhitprob)
62 % Use actual hit/miss probabilities from solver result
63 actualHitProb = sn.nodeparam{ind}.actualhitprob;
64 actualMissProb = sn.nodeparam{ind}.actualmissprob;
65 % Delayed hits (retrieval system) depart as the hit
66 % class, so the hit-class throughput is (true hit +
67 % delayed hit) * total arrival. Zero for plain caches.
68 if isfield(sn.nodeparam{ind}, 'actualdelayedhitprob
') && ~isempty(sn.nodeparam{ind}.actualdelayedhitprob)
69 actualDelayedHitProb = sn.nodeparam{ind}.actualdelayedhitprob;
71 actualDelayedHitProb = zeros(size(actualHitProb));
74 % Accumulate the flows of ALL read classes that
75 % share this hit/miss class, each weighted by its
76 % own arrival throughput TN(refstat,origClass);
77 % assigning totalTput*prob per read class would
78 % overwrite the row (last read class wins) and use
79 % the chain total instead of the class's own rate.
80 for origClass = 1:length(hitclass)
81 % Skip classes whose hit/miss probability
is NaN:
82 % retrieval classes may declare
the same miss
class
83 % as
the read
class but carry no probability, and
84 % would otherwise overwrite
the read-class miss
85 % throughput with NaN (dropping
the miss-rate row).
86 % actualHitProb/actualMissProb are indexed by
87 %
the originating (read) class; only read classes
88 % carry a value, so they may be shorter than
89 % hitclass (e.g. when results come back from
the
90 % JAR backend). Guard
the index access.
91 % Arrival rate of
the read
class INTO
the cache
92 % (robust to upstream
class switching, where
the
93 % read
class has no throughput at
the reference
96 arvTput = ANn(ind, origClass);
97 elseif any(origClass == inchain)
98 arvTput = TN(refstat, origClass);
100 arvTput = 0; % read
class outside this chain
102 if hitclass(origClass) == r && origClass <= length(actualHitProb) && ~isnan(actualHitProb(origClass))
103 % This
is a hit
class - use hit probability
104 % (
true hits plus delayed hits)
106 if origClass <= length(actualDelayedHitProb) && ~isnan(actualDelayedHitProb(origClass))
107 dh = actualDelayedHitProb(origClass);
109 TNn(ind, r) = TNn(ind, r) + arvTput * (actualHitProb(origClass) + dh);
110 elseif missclass(origClass) == r && origClass <= length(actualMissProb) && ~isnan(actualMissProb(origClass))
111 % This
is a miss
class - use miss probability
112 TNn(ind, r) = TNn(ind, r) + arvTput * actualMissProb(origClass);
117 if any(find(r==hitclass)) || any(find(r==missclass))
118 TNn(ind, r) = (sn.
nodevisits{c}(ind,r) / sum(sn.visits{c}(sn.stationToStateful(refstat),inchain))) * totalTput;
127 % First, copy station throughputs directly to station
nodes
130 ind = sn.stationToNode(ist);
131 TNn(ind,:) = TN(ist,:);
136 inchain = sn.inchain{c};
138 anystateful = find(sn.visits{c}(:,r));
139 if ~isempty(anystateful)
140 if sn.nodetype(ind) ~= NodeType.Sink && sn.nodetype(ind) ~= NodeType.Join
143 switch sn.nodetype(ind)
145 ist = sn.nodeToStation(ind);
146 TNn(ind, s) = TN(ist,s);
149 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
152 % For station
nodes, throughput
is already set from TN
153 % Only compute
for non-station
nodes (like ClassSwitch, Router)
154 % Note: nodeToStation returns NaN for non-station nodes, so use ~(>0) check
155 if ~(sn.nodeToStation(ind) > 0)
156 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
161 elseif sn.nodetype(ind) == NodeType.Join
164 if sn.nodetype(ind) ~= NodeType.Source
165 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
167 ist = sn.nodeToStation(ind);
168 TNn(ind, s) = TN(ist,s);