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