1function fjSyncMap = sn_build_fj_sync_map(sn)
2% FJSYNCMAP = SN_BUILD_FJ_SYNC_MAP(SN)
4% Builds a fork-join synchronization
map from LINE
's sn structure.
5% For each (Fork, Join) pair, identifies which source nodes feed into the
6% join and must be synchronized using mmap_max.
9% fjSyncMap.nodeSync(joinIdx, srcIdx) = groupId
10% - groupId > 0 means srcIdx belongs to sync group groupId at joinIdx
11% - groupId == 0 means srcIdx is an independent (non-synced) flow
12% fjSyncMap.forkOfGroup(groupId) = forkIdx
13% fjSyncMap.joinOfGroup(groupId) = joinIdx
14% fjSyncMap.nGroups = total number of sync groups
16% Copyright (c) 2012-2026, Imperial College London
22% nodeSync is indexed by (destination node, source node)
23nodeSync = zeros(I, I);
29% Iterate over all (Fork, Join) pairs from sn.fj
30forkIndices = find(any(sn.fj, 2))';
31for forkIdx = forkIndices
32 joinIdx = find(sn.fj(forkIdx, :));
36 for ji = 1:length(joinIdx)
38 groupId = groupId + 1;
39 forkOfGroup(groupId) = forkIdx;
40 joinOfGroup(groupId) = jnd;
42 % Find
nodes on the parallel path between
this fork and join.
43 % A node
is on the parallel path
if:
44 % 1. The fork routes to it (
for at least one
class), AND
45 % 2. It routes to the join (
for at least one
class)
47 if ind == forkIdx || ind == jnd
50 forkRoutesToNode =
false;
51 nodeRoutesToJoin =
false;
53 if sn.rtnodes((forkIdx-1)*K+k, (ind-1)*K+k) > 0
54 forkRoutesToNode =
true;
56 if sn.rtnodes((ind-1)*K+k, (jnd-1)*K+k) > 0
57 nodeRoutesToJoin =
true;
60 if forkRoutesToNode && nodeRoutesToJoin
61 nodeSync(jnd, ind) = groupId;
67fjSyncMap.nodeSync = nodeSync;
68fjSyncMap.forkOfGroup = forkOfGroup;
69fjSyncMap.joinOfGroup = joinOfGroup;
70fjSyncMap.nGroups = groupId;