Skip to content

Commit 3028909

Browse files
[BE] Resolve self loop with clocked partition (#9297)
Co-authored-by: kabdelhak <karim.abdelhak@fh-bielefeld.de>
1 parent c42f300 commit 3028909

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ algorithm
725725
//part1,subClk1 is the output of the sub partition interface function calls, this is used for ordering
726726
(infered,part1,var1,subClk1,part2,var2,subClk2) := getConnectedSubPartitions(BackendEquation.get(eqs,subPartEq),varPartMap,vars);
727727
//for adjacency relations, check only concrete sub partition interfaces not infered ones
728-
if not intEq(part1,0) and not intEq(part2,0) then
728+
if part1 <> 0 and part2 <> 0 then
729729
addPartAdjacencyEdge(part1,subClk1,part2,subClk2,partAdjacency);
730730
end if;
731731
//reset previously obtained opposite parent relation if it interfaces clock-variables
@@ -735,21 +735,10 @@ algorithm
735735
end if;
736736
partitionInterfacesClockVars[part1] := not (clockedVarsMask[var1] and clockedVarsMask[var2]);
737737
//avoid mutually dependent parents that would result in stack overflow later on
738-
if not intEq(partitionParents[part2], part1) then
738+
if partitionParents[part2] <> part1 then
739739
partitionParents[part1] := part2;
740740
end if;
741741
end for;
742-
/*
743-
for i in 1:numPartitions loop
744-
for j in arrayGet(partAdjacency,i) loop
745-
print("partition "+intString(i)+" is connected to partition "+intString(Util.tuple21(j))+" with subCLock "+BackendDump.subClockString(Util.tuple22(j))+"\n");
746-
end for;
747-
end for;
748-
749-
for i in 1:numPartitions loop
750-
print("partition "+intString(i)+" has parent "+intString(partitionParents[i])+"\n");
751-
end for;
752-
*/
753742

754743
//get the order
755744
partLst := List.intRange(numPartitions);
@@ -759,19 +748,18 @@ algorithm
759748
part::partLst := partLst;
760749
if not partitionParentsVisited[part] then
761750
//partition without parent, not yet visited
762-
if intEq(partitionParents[part],-1) then
751+
if partitionParents[part] == -1 or partitionParents[part] == part then
763752
orderLst := part::orderLst;
764753
partitionParentsVisited[part] := true;
765-
//partition with parents, parent not yet visited
766-
elseif intNe(partitionParents[part],-1) and intNe(partitionParents[part],part)and not partitionParentsVisited[partitionParents[part]] then
767-
partLst := part::partLst;
768-
partLst := partitionParents[part]::partLst;
769754
//partition with parents, parent visited
770-
elseif intNe(partitionParents[part],-1) and partitionParentsVisited[partitionParents[part]] then
755+
elseif partitionParentsVisited[partitionParents[part]] then
771756
orderLst := part::orderLst;
772757
partitionParentsVisited[part] := true;
758+
//partition with parents, parent not yet visited
759+
else
760+
partLst := part::partLst;
761+
partLst := partitionParents[part]::partLst;
773762
end if;
774-
775763
end if;
776764
end while;
777765
order := listArray(listReverse(orderLst));

0 commit comments

Comments
 (0)