Skip to content

Commit

Permalink
Revert "[DNM] Optimize live execution of modified graphs (#9485)" (#1…
Browse files Browse the repository at this point in the history
…2834)

This reverts commit dac8353.
  • Loading branch information
aparajit-pratap authored Apr 26, 2022
1 parent dac8353 commit 3ae0768
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 284 deletions.
17 changes: 0 additions & 17 deletions src/DynamoCore/Engine/EngineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,6 @@ private bool VerifyGraphSyncData(IEnumerable<NodeModel> nodes)
}
}

var subtrees = new List<Subtree>();
subtrees.AddRange(graphSyncdata.AddedSubtrees);
subtrees.AddRange(graphSyncdata.ModifiedSubtrees);
foreach (var node in nodes)
{
if (node.IsInputNode)
{
for (int i = 0; i < subtrees.Count; i++)
{
if (subtrees[i].GUID == node.GUID)
{
subtrees[i].IsInput = true;
}
}
}
}

if (graphSyncdata.AddedSubtrees.Any() || graphSyncdata.ModifiedSubtrees.Any() || graphSyncdata.DeletedSubtrees.Any())
{
lock (graphSyncDataQueue)
Expand Down
12 changes: 0 additions & 12 deletions src/Engine/ProtoAssociative/CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5420,18 +5420,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i
EmitCast(castType.UID, castType.rank);
}

if (bnode.IsInputExpression)
{
StackValue regLX = StackValue.BuildRegister(Registers.LX);
EmitInstrConsole(ProtoCore.DSASM.kw.pop, ProtoCore.DSASM.kw.regLX);
EmitPop(regLX, globalClassIndex);

graphNode.updateBlock.updateRegisterStartPC = pc;

EmitInstrConsole(ProtoCore.DSASM.kw.push, ProtoCore.DSASM.kw.regLX);
EmitPush(regLX);
}

if (core.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression)
{
if (dimensions == 0)
Expand Down
1 change: 0 additions & 1 deletion src/Engine/ProtoAssociative/CodeGen_SSA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ private void DFSEmitSSA_AST(AssociativeNode node, Stack<AssociativeNode> ssaStac

var bnode = AstFactory.BuildAssignment(leftNode, rightNode);
bnode.isSSAAssignment = isSSAAssignment;
bnode.IsInputExpression = astBNode.IsInputExpression;

astlist.Add(bnode);
ssaStack.Push(bnode);
Expand Down
6 changes: 4 additions & 2 deletions src/Engine/ProtoCore/AssociativeGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ public static ProtoCore.AssociativeGraph.GraphNode GetFirstSSAGraphnode(int inde
/// <param name="core"></param>
/// <param name="nodeList"></param>
/// <returns></returns>
public static AssociativeGraph.GraphNode MarkGraphNodesDirtyAtGlobalScope(
RuntimeCore core, IEnumerable<AST.AssociativeAST.AssociativeNode> nodeList)
public static AssociativeGraph.GraphNode MarkGraphNodesDirtyAtGlobalScope
(RuntimeCore core, IEnumerable<AST.AssociativeAST.AssociativeNode> nodeList)
{
if (nodeList == null)
{
Expand All @@ -767,7 +767,9 @@ public static AssociativeGraph.GraphNode MarkGraphNodesDirtyAtGlobalScope(
{
if (gnode.isActive && gnode.OriginalAstID == bNode.OriginalAstID)
{

gnode.isDirty = true;
gnode.isActive = true;
if (gnode.updateBlock.updateRegisterStartPC != Constants.kInvalidIndex)
{
gnode.updateBlock.startpc = gnode.updateBlock.updateRegisterStartPC;
Expand Down
24 changes: 2 additions & 22 deletions src/Engine/ProtoCore/DSASM/Executive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public RuntimeCore RuntimeCore
private InstructionStream istream;
public RuntimeMemory rmem { get; set; }

private StackValue LX;
public StackValue RX { get; set; }
public StackValue TX { get; set; }

Expand Down Expand Up @@ -67,12 +66,7 @@ enum DebugFlags
/// This is updated for every bounce and function call
/// </summary>
private List<AssociativeGraph.GraphNode> graphNodesInProgramScope;

public void SetAssociativeUpdateRegister(StackValue sv)
{
LX = sv;
}


public Executive(RuntimeCore runtimeCore, bool isFep = false)
{
IsExplicitCall = false;
Expand Down Expand Up @@ -1347,12 +1341,8 @@ private int UpdateGraph(int exprUID, bool isSSAAssign)

// Mark reachable nodes as dirty
Validity.Assert(reachableGraphNodes != null);
//int nextPC;
if (reachableGraphNodes.Count > 0)
{
// Get the next pc to jump to
//nextPC = reachableGraphNodes[0].updateBlock.startpc;
//LX = StackValue.BuildInt(nextPC);
for (int n = 0; n < reachableGraphNodes.Count; ++n)
{
AssociativeGraph.GraphNode gnode = reachableGraphNodes[n];
Expand Down Expand Up @@ -1646,7 +1636,6 @@ private void ResumeRegistersFromStack()
int fp = rmem.FramePointer;
if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize)
{
LX = rmem.GetAtRelative(StackFrame.FrameIndexLX);
RX = rmem.GetAtRelative(StackFrame.FrameIndexRX);
TX = rmem.GetAtRelative(StackFrame.FrameIndexTX);
}
Expand All @@ -1657,7 +1646,6 @@ private void ResumeRegistersFromStackExceptRX()
int fp = rmem.FramePointer;
if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize)
{
LX = rmem.GetAtRelative(StackFrame.FrameIndexLX);
TX = rmem.GetAtRelative(StackFrame.FrameIndexTX);
}
}
Expand All @@ -1667,15 +1655,14 @@ private void SaveRegistersToStack()
int fp = rmem.FramePointer;
if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize)
{
rmem.SetAtRelative(StackFrame.FrameIndexLX, LX);
rmem.SetAtRelative(StackFrame.FrameIndexRX, RX);
rmem.SetAtRelative(StackFrame.FrameIndexTX, TX);
}
}

public List<StackValue> GetRegisters()
{
return new List<StackValue> { RX, TX, LX };
return new List<StackValue> { RX, TX };
}

/// <summary>
Expand Down Expand Up @@ -2352,9 +2339,6 @@ private StackValue GetOperandData(int blockId, StackValue opSymbol, StackValue o
case AddressType.Register:
switch (opSymbol.Register)
{
case Registers.LX:
data = LX;
break;
case Registers.RX:
data = RX;
break;
Expand Down Expand Up @@ -2468,10 +2452,6 @@ protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackVal
StackValue data = opVal;
switch (op1.Register)
{
case Registers.LX:
opPrev = LX;
LX = data;
break;
case Registers.RX:
opPrev = RX;
RX = data;
Expand Down
1 change: 0 additions & 1 deletion src/Engine/ProtoCore/DSASM/InstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace ProtoCore.DSASM
public enum Registers
{
RX,
LX,
}

public enum AddressType: int
Expand Down
14 changes: 2 additions & 12 deletions src/Engine/ProtoCore/DSASM/Stack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public class StackFrame
public const int FrameIndexBlockIndex = -12;
public const int FrameIndexRX = -13;
public const int FrameIndexTX = -14;
public const int FrameIndexLX = -15;
public const int FrameIndexFramePointer = -16;
public const int StackFrameSize = 16;
public const int FrameIndexFramePointer = -15;
public const int StackFrameSize = 15;

private struct AbsoluteIndex
{
Expand All @@ -53,7 +52,6 @@ private struct AbsoluteIndex
public const int BlockIndex = -FrameIndexBlockIndex - 1;
public const int RX = -FrameIndexRX - 1;
public const int TX = -FrameIndexTX - 1;
public const int LX = -FrameIndexLX - 1;
public const int FramePointer = -FrameIndexFramePointer - 1;
}

Expand Down Expand Up @@ -91,7 +89,6 @@ private void Init(
Frame[AbsoluteIndex.BlockIndex] = StackValue.BuildBlockIndex(blockIndex);
Frame[AbsoluteIndex.RX] = registers[0];
Frame[AbsoluteIndex.TX] = registers[1];
Frame[AbsoluteIndex.LX] = registers[2];
Frame[AbsoluteIndex.FramePointer] = StackValue.BuildInt(framePointer);
}

Expand Down Expand Up @@ -220,19 +217,12 @@ public StackValue TX
set { Frame[AbsoluteIndex.TX] = value; }
}

public StackValue LX
{
get { return Frame[AbsoluteIndex.LX]; }
set { Frame[AbsoluteIndex.LX] = value; }
}

public List<StackValue> GetRegisters()
{
List<StackValue> registers = new List<StackValue>();

registers.Add(Frame[AbsoluteIndex.RX]);
registers.Add(Frame[AbsoluteIndex.TX]);
registers.Add(Frame[AbsoluteIndex.LX]);

return registers;
}
Expand Down
1 change: 1 addition & 0 deletions src/Engine/ProtoCore/Lang/FunctionPointerEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public StackValue Evaluate(List<StackValue> args, StackFrame stackFrame)
interpreter.runtime.TX = StackValue.BuildCallingConversion((int)ProtoCore.DSASM.CallingConvention.BounceType.Implicit);

StackValue svBlockDecl = StackValue.BuildBlockIndex(blockDecl);
// interpreter.runtime.SX = svBlockDecl;

List<StackValue> registers = interpreter.runtime.GetRegisters();
var newStackFrame = new StackFrame(thisPtr,
Expand Down
6 changes: 1 addition & 5 deletions src/Engine/ProtoCore/Parser/AssociativeAST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,6 @@ public class BinaryExpressionNode : AssociativeNode
public AssociativeNode LeftNode { get; set; }
public Operator Optr { get; set; }
public AssociativeNode RightNode { get; set; }
public bool IsInputExpression { get; set; }
public bool isSSAPointerAssignment { get; set; }
public bool IsFirstIdentListNode { get; set; }

Expand All @@ -2098,7 +2097,6 @@ public BinaryExpressionNode(AssociativeNode left = null, AssociativeNode right =
LeftNode = left;
Optr = optr;
RightNode = right;
IsInputExpression = false;
IsFirstIdentListNode = false;
}

Expand All @@ -2119,7 +2117,6 @@ public BinaryExpressionNode(BinaryExpressionNode rhs) : base(rhs)
{
RightNode = NodeUtils.Clone(rhs.RightNode);
}
IsInputExpression = rhs.IsInputExpression;
IsFirstIdentListNode = rhs.IsFirstIdentListNode;
}

Expand All @@ -2143,8 +2140,7 @@ public BinaryExpressionNode(IdentifierNode lhs, AssociativeNode rhs)
Optr = Operator.assign;
LeftNode = lhs;
RightNode = NodeUtils.Clone(rhs);
IsInputExpression = false;
IsFirstIdentListNode = false;
IsFirstIdentListNode = false;

}

Expand Down
16 changes: 0 additions & 16 deletions src/Engine/ProtoCore/RuntimeCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.Linq;
using ProtoCore.AssociativeGraph;
using ProtoCore.AST.AssociativeAST;
using ProtoCore.DSASM;
using ProtoCore.Lang;
using ProtoCore.Lang.Replication;
Expand Down Expand Up @@ -334,21 +333,6 @@ public TimeSpan GetCurrentTime()
return ts;
}

/// <summary>
/// Set the value of a variable at runtime
/// Returns the entry pc
/// </summary>
/// <param name="astID"></param>
/// <param name="sv"></param>
/// <returns></returns>
public int SetValue(List<AssociativeNode> modifiedNodes, StackValue sv)
{
ExecutionInstance.CurrentDSASMExec.SetAssociativeUpdateRegister(sv);
GraphNode gnode = AssociativeEngine.Utils.MarkGraphNodesDirtyAtGlobalScope(this, modifiedNodes);
Validity.Assert(gnode != null);
return gnode.updateBlock.startpc;
}

/// <summary>
/// This function determines what the starting pc should be for the next execution session
/// The StartPC takes precedence if set. Otherwise, the entry pc in the global codeblock is the entry point
Expand Down
45 changes: 0 additions & 45 deletions src/Engine/ProtoCore/Utils/CoreUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -952,50 +952,5 @@ public static StackValue AddStackValueString(StackValue sv1, StackValue sv2, Run
}
return StackValue.BuildNull();
}

/// <summary>
/// Checks if an AST node is a primitive
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public static bool IsPrimitiveASTNode(AssociativeNode node)
{
if (node is IntNode
|| node is DoubleNode
|| node is BooleanNode
|| node is StringNode)
{
return true;
}
return false;
}


public static StackValue BuildStackValueForPrimitive(AssociativeNode node, RuntimeCore rt)
{
Validity.Assert(IsPrimitiveASTNode(node) == true);

if (node is IntNode)
{
return StackValue.BuildInt((node as IntNode).Value);
}

if (node is DoubleNode)
{
return StackValue.BuildDouble((node as DoubleNode).Value);
}

if (node is BooleanNode)
{
return StackValue.BuildBoolean((node as BooleanNode).Value);
}

if (node is StringNode)
{
return StackValue.BuildString((node as StringNode).Value, rt.Heap);
}

return StackValue.BuildNull();
}
}
}
Loading

0 comments on commit 3ae0768

Please sign in to comment.