LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
buildLayers.m
1function buildLayers(self)
2lqn = self.lqn;
3self.ensemble = cell(lqn.ntasks,1);
4
5self.servt_classes_updmap = cell(lqn.nhosts+lqn.ntasks,1);
6self.call_classes_updmap = cell(lqn.nhosts+lqn.ntasks,1);
7self.arvproc_classes_updmap = cell(lqn.nhosts+lqn.ntasks,1);
8self.thinkt_classes_updmap = cell(lqn.nhosts+lqn.ntasks,1);
9self.actthinkt_classes_updmap = cell(lqn.nhosts+lqn.ntasks,1);
10self.route_prob_updmap = cell(lqn.nhosts+lqn.ntasks,1);
11
12%% build one subnetwork for every processor
13for hidx = 1:lqn.nhosts
14 if ~self.ignore(hidx)
15 callers = lqn.tasksof{hidx};
16 self.buildLayersRecursive(hidx, callers, true);
17 else
18 self.ensemble{hidx} = [];
19 end
20end
21
22%% build one subnetwork for every task
23for t = 1:lqn.ntasks
24 tidx = lqn.tshift + t;
25 if ~self.ignore(tidx) & ~lqn.isref(tidx) & ~(isempty(find(self.lqn.iscaller(tidx,:), 1)) & isempty(find(self.lqn.iscaller(:,tidx), 1))) %#ok<OR2,AND2> % ignore isolated tasks and ref tasks
26 % obtain the activity graph of each task that calls some entry in t
27 [calling_idx, called_entries] = find(lqn.iscaller(:, lqn.entriesof{tidx})); %#ok<ASGLU>
28 callers = intersect(lqn.tshift+(1:lqn.ntasks), unique(calling_idx)');
29 if ~isempty(callers) % true if the server is a software task
30 self.buildLayersRecursive(tidx, callers, false);
31 else
32 self.ensemble{tidx} = [];
33 end
34 else
35 self.ensemble{tidx} = [];
36 end
37end
38
39self.thinkt_classes_updmap = cell2mat(self.thinkt_classes_updmap);
40self.actthinkt_classes_updmap = cell2mat(self.actthinkt_classes_updmap);
41self.call_classes_updmap = cell2mat(self.call_classes_updmap);
42self.servt_classes_updmap = cell2mat(self.servt_classes_updmap);
43self.arvproc_classes_updmap = cell2mat(self.arvproc_classes_updmap);
44self.route_prob_updmap = cell2mat(self.route_prob_updmap);
45
46% we now calculate the new index of the models after removing the empty
47% models associated to 'ref' tasks
48emptymodels = cellfun(@isempty,self.ensemble);
49self.ensemble(emptymodels) = [];
50self.idxhash = [1:length(emptymodels)]' - cumsum(emptymodels);
51self.idxhash(emptymodels) = NaN;
52
53%% Classify layers as host (processor) or task for MOL iteration
54self.hostLayerIndices = [];
55self.taskLayerIndices = [];
56
57% Host layers: indices 1:nhosts (before idxhash remapping)
58for hidx = 1:lqn.nhosts
59 if ~isnan(self.idxhash(hidx))
60 self.hostLayerIndices(end+1) = self.idxhash(hidx);
61 end
62end
63
64% Task layers: indices tshift+1:tshift+ntasks
65for t = 1:lqn.ntasks
66 tidx = lqn.tshift + t;
67 if ~isnan(self.idxhash(tidx))
68 self.taskLayerIndices(end+1) = self.idxhash(tidx);
69 end
70end
71
72self.model.ensemble = self.ensemble;
73end