public AdjustListHeads( AdjustListHeadsTypes type, string patternElementName, string startingPointNodeName, IncidentEdgeType incidentType, bool parallel) { Debug.Assert(type == AdjustListHeadsTypes.IncidentEdges); Type = type; PatternElementName = patternElementName; StartingPointNodeName = startingPointNodeName; IncidentType = incidentType; Parallel = parallel; }
/// <summary> /// Interpretation plan operations implementing the /// Extend Incoming|Outgoing|IncomingOrOutgoing search plan operation /// are created and inserted into the interpretation plan at the insertion point /// </summary> private void buildIncident( InterpretationPlan insertionPoint, int index, SearchPlanNodeNode source, SearchPlanEdgeNode target, IncidentEdgeType edgeType) { // get candidate = iterate available incident edges insertionPoint = insertIncidentEdgeFromNode(insertionPoint, source, target, edgeType); // check connectedness of candidate insertionPoint = decideOnAndInsertCheckConnectednessOfIncidentEdgeFromNode(insertionPoint, target, source, edgeType == IncidentEdgeType.Incoming); // continue with next operation target.Visited = true; BuildInterpretationPlan(insertionPoint, index + 1); target.Visited = false; }
/// <summary> /// Inserts code to get an incident edge from some node /// receives insertion point, returns new insertion point /// </summary> private InterpretationPlan insertIncidentEdgeFromNode( InterpretationPlan insertionPoint, SearchPlanNodeNode node, SearchPlanEdgeNode currentEdge, IncidentEdgeType incidentType) { int targetType = currentEdge.PatternElement.TypeID; if (incidentType == IncidentEdgeType.Incoming) { currentEdge.edgeMatcher = new InterpretationPlanIncoming(targetType, node.nodeMatcher, currentEdge); } else if (incidentType == IncidentEdgeType.Outgoing) { currentEdge.edgeMatcher = new InterpretationPlanOutgoing(targetType, node.nodeMatcher, currentEdge); } else // IncidentEdgeType.IncomingOrOutgoing { if (currentEdge.PatternEdgeSource == currentEdge.PatternEdgeTarget) { // reflexive edge without direction iteration as we don't want 2 matches currentEdge.edgeMatcher = new InterpretationPlanIncoming(targetType, node.nodeMatcher, currentEdge); } else { currentEdge.directionVariable = new InterpretationPlanBothDirections(); insertionPoint.next = currentEdge.directionVariable; insertionPoint = insertionPoint.next; currentEdge.edgeMatcher = new InterpretationPlanIncomingOrOutgoing(targetType, node.nodeMatcher, currentEdge.directionVariable, currentEdge); } } currentEdge.edgeMatcher.prev = insertionPoint; insertionPoint.next = currentEdge.edgeMatcher; insertionPoint = insertionPoint.next; return(insertionPoint); }
/// <summary> /// Interpretation plan operations implementing the /// Extend Incoming|Outgoing|IncomingOrOutgoing search plan operation /// are created and inserted into the interpretation plan at the insertion point /// </summary> private void buildIncident( InterpretationPlan insertionPoint, int index, SearchPlanNodeNode source, SearchPlanEdgeNode target, IncidentEdgeType edgeType) { // get candidate = iterate available incident edges insertionPoint = insertIncidentEdgeFromNode(insertionPoint, source, target, edgeType); // check connectedness of candidate insertionPoint = decideOnAndInsertCheckConnectednessOfIncidentEdgeFromNode(insertionPoint, target, source, edgeType==IncidentEdgeType.Incoming); // continue with next operation target.Visited = true; BuildInterpretationPlan(insertionPoint, index + 1); target.Visited = false; }
/// <summary> /// Inserts code to get an incident edge from some node /// receives insertion point, returns new insertion point /// </summary> private InterpretationPlan insertIncidentEdgeFromNode( InterpretationPlan insertionPoint, SearchPlanNodeNode node, SearchPlanEdgeNode currentEdge, IncidentEdgeType incidentType) { int targetType = currentEdge.PatternElement.TypeID; if (incidentType == IncidentEdgeType.Incoming) { currentEdge.edgeMatcher = new InterpretationPlanIncoming(targetType, node.nodeMatcher, currentEdge); } else if(incidentType == IncidentEdgeType.Outgoing) { currentEdge.edgeMatcher = new InterpretationPlanOutgoing(targetType, node.nodeMatcher, currentEdge); } else // IncidentEdgeType.IncomingOrOutgoing { if (currentEdge.PatternEdgeSource == currentEdge.PatternEdgeTarget) { // reflexive edge without direction iteration as we don't want 2 matches currentEdge.edgeMatcher = new InterpretationPlanIncoming(targetType, node.nodeMatcher, currentEdge); } else { currentEdge.directionVariable = new InterpretationPlanBothDirections(); insertionPoint.next = currentEdge.directionVariable; insertionPoint = insertionPoint.next; currentEdge.edgeMatcher = new InterpretationPlanIncomingOrOutgoing(targetType, node.nodeMatcher, currentEdge.directionVariable, currentEdge); } } currentEdge.edgeMatcher.prev = insertionPoint; insertionPoint.next = currentEdge.edgeMatcher; insertionPoint = insertionPoint.next; return insertionPoint; }
/// <summary> /// Search program operations implementing the /// parallelized Extend Incoming|Outgoing|IncomingOrOutgoing search plan operation /// are created and inserted into search program /// </summary> private SearchProgramOperation buildParallelIncident( SearchProgramOperation insertionPoint, int currentOperationIndex, SearchPlanNodeNode source, SearchPlanEdgeNode target, IsomorphyInformation isomorphy, IncidentEdgeType edgeType) { #if RANDOM_LOOKUP_LIST_START // insert list heads randomization, thus randomized extend RandomizeListHeads randomizeListHeads = new RandomizeListHeads( RandomizeListHeadsTypes.IncidentEdges, target.PatternElement.Name, source.PatternElement.Name, getIncoming); insertionPoint = insertionPoint.Append(randomizeListHeads); #endif // iterate available incident edges SearchPlanNodeNode node = source; SearchPlanEdgeNode currentEdge = target; IncidentEdgeType incidentType = edgeType; SearchProgramOperation continuationPoint; GetCandidateByIterationParallel incidentIteration; if(incidentType == IncidentEdgeType.Incoming || incidentType == IncidentEdgeType.Outgoing) { incidentIteration = new GetCandidateByIterationParallel( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, incidentType, emitProfiling, packagePrefixedActionName, !firstLoopPassed); firstLoopPassed = true; incidentIteration.NestedOperationsList = new SearchProgramList(incidentIteration); continuationPoint = insertionPoint.Append(incidentIteration); insertionPoint = incidentIteration.NestedOperationsList; } else // IncidentEdgeType.IncomingOrOutgoing { if(currentEdge.PatternEdgeSource == currentEdge.PatternEdgeTarget) { // reflexive edge without direction iteration as we don't want 2 matches incidentIteration = new GetCandidateByIterationParallel( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, IncidentEdgeType.Incoming, emitProfiling, packagePrefixedActionName, !firstLoopPassed); firstLoopPassed = true; incidentIteration.NestedOperationsList = new SearchProgramList(incidentIteration); continuationPoint = insertionPoint.Append(incidentIteration); insertionPoint = incidentIteration.NestedOperationsList; } else { incidentIteration = new GetCandidateByIterationParallel( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, IncidentEdgeType.IncomingOrOutgoing, emitProfiling, packagePrefixedActionName, !firstLoopPassed); firstLoopPassed = true; incidentIteration.NestedOperationsList = new SearchProgramList(incidentIteration); continuationPoint = insertionPoint.Append(incidentIteration); insertionPoint = incidentIteration.NestedOperationsList; } } // check type of candidate insertionPoint = decideOnAndInsertCheckType(insertionPoint, target); // check connectedness of candidate SearchProgramOperation continuationPointOfConnectednessCheck; insertionPoint = decideOnAndInsertCheckConnectednessOfIncidentEdgeFromNode( insertionPoint, target, source, edgeType == IncidentEdgeType.Incoming, out continuationPointOfConnectednessCheck); // check candidate for isomorphy string negativeIndependentNamePrefix = ""; if(isomorphy.CheckIsMatchedBit) { CheckCandidateForIsomorphy checkIsomorphy = new CheckCandidateForIsomorphy( target.PatternElement.Name, isomorphy.PatternElementsToCheckAgainstAsListOfStrings(), negativeIndependentNamePrefix, false, isoSpaceNeverAboveMaxIsoSpace, isomorphy.Parallel, isomorphy.LockForAllThreads); insertionPoint = insertionPoint.Append(checkIsomorphy); } // accept candidate (write isomorphy information) if(isomorphy.SetIsMatchedBit) { AcceptCandidate acceptCandidate = new AcceptCandidate( target.PatternElement.Name, negativeIndependentNamePrefix, false, isoSpaceNeverAboveMaxIsoSpace, isomorphy.Parallel, isomorphy.LockForAllThreads); insertionPoint = insertionPoint.Append(acceptCandidate); } // mark element as visited target.Visited = true; //--------------------------------------------------------------------------- // build next operation insertionPoint = BuildScheduledSearchPlanOperationIntoSearchProgram( currentOperationIndex + 1, insertionPoint); //--------------------------------------------------------------------------- // unmark element for possibly following run target.Visited = false; // abandon candidate (restore isomorphy information) if(isomorphy.SetIsMatchedBit) { // only if isomorphy information was previously written AbandonCandidate abandonCandidate = new AbandonCandidate( target.PatternElement.Name, negativeIndependentNamePrefix, false, isoSpaceNeverAboveMaxIsoSpace, isomorphy.Parallel, isomorphy.LockForAllThreads); insertionPoint = insertionPoint.Append(abandonCandidate); } // everything nested within incident iteration built by now - // continue at the end of the list after incident edges iteration insertionPoint = continuationPoint; return insertionPoint; }
/// <summary> /// Search program operations implementing the /// setup parallelized Extend Incoming|Outgoing|IncomingOrOutgoing search plan operation /// are created and inserted into search program /// </summary> private SearchProgramOperation buildParallelIncidentSetup( SearchProgramOperation insertionPoint, SearchPlanNodeNode source, SearchPlanEdgeNode target, IncidentEdgeType edgeType) { // iterate available incident edges SearchPlanNodeNode node = source; SearchPlanEdgeNode currentEdge = target; IncidentEdgeType incidentType = edgeType; GetCandidateByIterationParallelSetup incidentIteration; PatternGraph patternGraph = patternGraphWithNestingPatterns.Peek(); if(incidentType == IncidentEdgeType.Incoming || incidentType == IncidentEdgeType.Outgoing) { incidentIteration = new GetCandidateByIterationParallelSetup( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, incidentType, rulePatternClassName, patternGraph.name, parameterNames, false, wasIndependentInlined(patternGraph, indexOfSchedule), emitProfiling, packagePrefixedActionName, !firstLoopPassed); return insertionPoint.Append(incidentIteration); } else // IncidentEdgeType.IncomingOrOutgoing { if(currentEdge.PatternEdgeSource == currentEdge.PatternEdgeTarget) { // reflexive edge without direction iteration as we don't want 2 matches incidentIteration = new GetCandidateByIterationParallelSetup( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, IncidentEdgeType.Incoming, rulePatternClassName, patternGraph.name, parameterNames, false, wasIndependentInlined(patternGraph, indexOfSchedule), emitProfiling, packagePrefixedActionName, !firstLoopPassed); return insertionPoint.Append(incidentIteration); } else { BothDirectionsIteration directionsIteration = new BothDirectionsIteration(currentEdge.PatternElement.Name); directionsIteration.NestedOperationsList = new SearchProgramList(directionsIteration); SearchProgramOperation continuationPoint = insertionPoint.Append(directionsIteration); insertionPoint = directionsIteration.NestedOperationsList; incidentIteration = new GetCandidateByIterationParallelSetup( GetCandidateByIterationType.IncidentEdges, currentEdge.PatternElement.Name, node.PatternElement.Name, IncidentEdgeType.IncomingOrOutgoing, rulePatternClassName, patternGraph.name, parameterNames, true, wasIndependentInlined(patternGraph, indexOfSchedule), emitProfiling, packagePrefixedActionName, !firstLoopPassed); return insertionPoint.Append(incidentIteration); } } }
public GetCandidateByIterationParallelSetup( GetCandidateByIterationType type, string patternElementName, string startingPointNodeName, IncidentEdgeType edgeType, string rulePatternClassName, string patternName, string[] parameterNames, bool enclosingLoop, bool wasIndependentInlined, bool emitProfiling, string packagePrefixedActionName, bool emitFirstLoopProfiling) { Debug.Assert(type == GetCandidateByIterationType.IncidentEdges); Type = type; PatternElementName = patternElementName; StartingPointNodeName = startingPointNodeName; EdgeType = edgeType; RulePatternClassName = rulePatternClassName; PatternName = patternName; ParameterNames = parameterNames; EnclosingLoop = enclosingLoop; WasIndependentInlined = wasIndependentInlined; EmitProfiling = emitProfiling; PackagePrefixedActionName = packagePrefixedActionName; EmitFirstLoopProfiling = emitFirstLoopProfiling; }
public GetCandidateByIterationParallel( GetCandidateByIterationType type, string patternElementName, string startingPointNodeName, IncidentEdgeType edgeType, bool emitProfiling, string packagePrefixedActionName, bool emitFirstLoopProfiling) { Debug.Assert(type == GetCandidateByIterationType.IncidentEdges); Type = type; PatternElementName = patternElementName; StartingPointNodeName = startingPointNodeName; EdgeType = edgeType; EmitProfiling = emitProfiling; PackagePrefixedActionName = packagePrefixedActionName; EmitFirstLoopProfiling = emitFirstLoopProfiling; }