LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_nc_cacheqn_analyzer.m
1function [QN,UN,RN,TN,CN,XN,lG,hitprob,missprob,runtime,it,method] = solver_nc_cacheqn_analyzer(self, options)
2% [Q,U,R,T,C,X,LG,RUNTIME,ITER] = SOLVER_NC_CACHEQN_ANALYZER(SELF, OPTIONS)
3%
4% Integrated cache-queueing analyzer: delegates the decomposition-
5% aggregation alternation between the isolated caches and the queueing
6% network to da_cacheqn, supplying the NC-specific isolated-cache miss
7% algorithm (exact recursion or SPM approximation) and network solver.
8
9% Copyright (c) 2012-2026, Imperial College London
10% All rights reserved.
11
12snorig = self.model.getStruct;
13sn = snorig;
14K = sn.nclasses;
15
16line_debug('NC cacheqn analyzer starting: method=%s, nclasses=%d', options.method, K);
17
18caches = find(sn.nodetype == NodeType.Cache);
19for ci = 1:length(caches)
20 ch = sn.nodeparam{caches(ci)};
21 if ch.nitems < sum(ch.itemcap) + 2
22 line_error(mfilename,'NC requires the number of items to exceed the cache capacity at least by 2.');
23 end
24end
25
26switch options.method
27 case 'exact'
28 missfun = @miss_exact;
29 method = 'exact';
30 otherwise
31 missfun = @miss_spm;
32 method = 'spm';
33end
34
35[res, hitprob_pc, missprob_pc, it] = da_cacheqn(sn, missfun, @netsolve, options);
36QN = res.Q; UN = res.U; RN = res.R; TN = res.T; CN = res.C; XN = res.X;
37lG = res.lG; runtime = res.runtime;
38
39% legacy contract: hit/miss probabilities indexed by node row
40hitprob = zeros(length(caches), K);
41missprob = zeros(length(caches), K);
42for ci = 1:length(caches)
43 hitprob(caches(ci),:) = hitprob_pc(ci,:);
44 missprob(caches(ci),:) = missprob_pc(ci,:);
45end
46
47 function missrate = miss_exact(gamma, m, lambda_cache, ~)
48 u = size(lambda_cache, 1);
49 pij = cache_prob_erec(gamma, m);
50 missrate = zeros(1, u);
51 for v = 1:u
52 missrate(v) = lambda_cache(v,:,1) * pij(:,1);
53 end
54 end
55
56 function missrate = miss_spm(gamma, m, lambda_cache, ~)
57 line_debug('Default method: using SPM approximation for cache\n');
58 line_debug('Using SPM approximation, calling cache_miss_spm');
59 [~, missrate] = cache_miss_spm(gamma, m, lambda_cache);
60 end
61
62 function res = netsolve(snit)
63 res = struct();
64 if ~isempty(snit.lldscaling) || ~isempty(snit.cdscaling)
65 [res.Q,res.U,res.R,res.T,res.C,res.X,res.lG,res.runtime] = solver_ncld_analyzer(snit, options);
66 else
67 [res.Q,res.U,res.R,res.T,res.C,res.X,res.lG,res.runtime] = solver_nc_analyzer(snit, options);
68 end
69 res.XN = res.X;
70 end
71end
Definition Station.m:245