LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getAvgNode.m
1function [QNn,UNn,RNn,TNn,ANn,WNn] = getAvgNode(self, Q, U, R, T, A, W)
2% [QNN,UNN,RNN,TNN,ANn,WNn] = GETNODEAVG(Q, U, R, T, A, W)
3%
4% Compute average utilizations at steady-state for all nodes
5
6if nargin == 1 % no parameter
7 if isempty(self.model.handles) || ~isfield(self.model.handles,'Q') || ...
8 ~isfield(self.model.handles,'U') || ~isfield(self.model.handles,'R') || ...
9 ~isfield(self.model.handles,'T') || ~isfield(self.model.handles,'A') || ...
10 ~isfield(self.model.handles,'W')
11 reset(self); % reset in case there are partial results saved
12 end
13 [Q,U,R,T,A,W] = self.getAvgHandles;
14elseif nargin == 2
15 handlers = Q;
16 [Q,U,R,T,A,W] = deal(handlers{:}); % set Q=handlers{1}, U=handlers{2}, ...
17end
18
19[QN,UN,RN,TN,AN,WN] = self.getAvg(Q,U,R,T,A,W);
20if isempty(QN)
21 [QNn, UNn, RNn, TNn, ANn, WNn] = deal([]); % set each to []
22 return
23end
24
25sn = self.model.getStruct; % must be called after getAvg eg for caches
26
27I = sn.nnodes; % Physical nodes only
28M = sn.nstations;
29R = sn.nclasses;
30F = sn.nregions; % Number of FCR virtual nodes
31
32% Total nodes includes physical nodes + FCR virtual nodes
33totalNodes = I + F;
34
35% get average metrics that are zero at non-station nodes
36QNn = zeros(totalNodes, R);
37UNn = zeros(totalNodes, R);
38RNn = zeros(totalNodes, R);
39WNn = zeros(totalNodes, R);
40
41% Map station metrics to node metrics
42for ist=1:M
43 ind = sn.stationToNode(ist);
44 QNn(ind,:) = QN(ist,:);
45 UNn(ind,:) = UN(ist,:);
46 RNn(ind,:) = RN(ist,:);
47 WNn(ind,:) = WN(ist,:);
48end
49
50% get the remaining node average metrics
51ANn = sn_get_node_arvr_from_tput(sn, TN(1:M,:), T, AN);
52TNn = sn_get_node_tput_from_tput(sn, TN(1:M,:), T, ANn);
53
54% Fix arrival rates for ClassSwitch and Sink nodes for cache hit/miss classes
55% The arrival rate at these nodes for hit/miss classes equals the Cache throughput
56for cacheInd = 1:I
57 if sn.nodetype(cacheInd) == NodeType.Cache
58 hitclass = sn.nodeparam{cacheInd}.hitclass;
59 missclass = sn.nodeparam{cacheInd}.missclass;
60 % Update arrival rates at ClassSwitch and Sink nodes for hit/miss classes
61 for ind = 1:I
62 if sn.nodetype(ind) == NodeType.ClassSwitch || sn.nodetype(ind) == NodeType.Sink
63 for classIdx = 1:R
64 % Check if this class is a hit class from the cache
65 if any(classIdx == hitclass(hitclass > 0))
66 ANn(ind, classIdx) = TNn(cacheInd, classIdx);
67 end
68 % Check if this class is a miss class from the cache
69 if any(classIdx == missclass(missclass > 0))
70 ANn(ind, classIdx) = TNn(cacheInd, classIdx);
71 end
72 end
73 end
74 end
75 end
76end
77
78% Extend ANn and TNn to include FCR rows
79if F > 0
80 ANn = [ANn; NaN(F, R)]; % FCR A is NaN (JMT doesn't provide)
81 TNn = [TNn; zeros(F, R)];
82end
83
84% Map FCR pseudo-station metrics to FCR node indices
85% FCR metrics are stored at station indices M+1 to M+F in self.result.Avg
86% FCR node indices are I+1 to I+F in node-level matrices
87% Note: getAvg() only returns station-level metrics (1:M), so we access FCR
88% metrics directly from self.result.Avg
89if F > 0 && isfield(self.result, 'Avg') && size(self.result.Avg.Q, 1) > M
90 for f = 1:F
91 fcrStationIdx = M + f; % FCR pseudo-station index in result matrices
92 fcrNodeIdx = I + f; % FCR node index in nodenames
93 QNn(fcrNodeIdx,:) = self.result.Avg.Q(fcrStationIdx,:);
94 UNn(fcrNodeIdx,:) = self.result.Avg.U(fcrStationIdx,:);
95 RNn(fcrNodeIdx,:) = self.result.Avg.R(fcrStationIdx,:);
96 WNn(fcrNodeIdx,:) = self.result.Avg.W(fcrStationIdx,:);
97 TNn(fcrNodeIdx,:) = self.result.Avg.T(fcrStationIdx,:);
98 % ANn for FCR is NaN (already set above)
99 end
100end
101
102end
Definition mmt.m:92