Ejemplo n.º 1
0
        internal void RegenerateGraph(Runtime.InternalGraphManager manager)
        {
            var maxIdentifier = 0;

            if (manager.Stages.Count > 0)
            {
                maxIdentifier = Math.Max(manager.Stages.Keys.Max(), maxIdentifier);
            }

            if (manager.Edges.Count > 0)
            {
                maxIdentifier = Math.Max(manager.Edges.Keys.Max(), maxIdentifier);
            }

            this.Graph = new GraphNode[maxIdentifier + 1];

            for (int i = 0; i < this.Graph.Length; i++)
            {
                if (manager.Stages.ContainsKey(i))
                {
                    this.Graph[i] = new GraphNode(manager.Stages[i]);
                }
                else if (manager.Edges.ContainsKey(i))
                {
                    this.Graph[i] = new GraphNode(manager.Edges[i]);
                }
                else  // else it is processing a progress edge, because they are allocated differentyl
                {
                    this.Graph[i] = new GraphNode(i, new int[] { });
                }
            }
        }
Ejemplo n.º 2
0
        internal StreamingInputStage(DataSource <R> source, Placement placement, Runtime.InternalGraphManager graphManager, string inputName)
        {
            this.inputName = inputName;

            this.stage = Foundry.NewStage(new OpaqueTimeContext <Epoch>(graphManager.ContextManager.RootContext), (i, v) => new StreamingInputVertex <R>(i, v), this.inputName);

            this.output = stage.NewOutput(shard => shard.output);

            this.stage.Materialize();

            this.localShards = placement.Where(x => x.ProcessId == graphManager.Controller.Configuration.ProcessID)
                               .Select(x => this.stage.GetShard(x.VertexId) as StreamingInputVertex <R>)
                               .ToArray();

            source.RegisterInputs(this.localShards);

            this.completedCalled             = false;
            this.hasActivatedProgressTracker = false;

            // results in pointstamp comparisons which assert w/o this.
            this.InternalGraphManager.Reachability.UpdateReachabilityPartialOrder(graphManager);
            this.InternalGraphManager.Reachability.DoNotImpersonate(stage.StageId);

            var initialVersion = new Scheduling.Pointstamp(stage.StageId, new int[] { 0 });

            graphManager.ProgressTracker.BroadcastProgressUpdate(initialVersion, placement.Count);
        }
Ejemplo n.º 3
0
        internal Stage(Placement placement, Runtime.InternalGraphManager graphManager, OperatorType operatorType, string name)
        {
            this.graphManager   = graphManager;
            this.targets        = new List <Edge>();
            this.StageId        = this.InternalGraphManager.Register(this);
            this.collectionType = operatorType;
            this.Placement      = placement;
            this.name           = name;

            MyName = string.Format("{0}[{1}]", name, this.StageId);
        }
Ejemplo n.º 4
0
        internal void RegenerateGraph(Runtime.InternalGraphManager manager)
        {
            var maxIdentifier = 0;

            if (manager.Stages.Count() > 0)
            {
                maxIdentifier = Math.Max(manager.Stages.Max(x => x.Key), maxIdentifier);
            }

            if (manager.Edges.Count() > 0)
            {
                maxIdentifier = Math.Max(manager.Edges.Max(x => x.Key), maxIdentifier);
            }

            this.Graph = new GraphNode[maxIdentifier + 1];

#if true
            for (int i = 0; i < this.Graph.Length; i++)
            {
                this.Graph[i] = new GraphNode(i, new int[] { });
            }

            foreach (var stage in manager.Stages)
            {
                this.Graph[stage.Key] = new GraphNode(stage.Value);
            }

            foreach (var edge in manager.Edges)
            {
                this.Graph[edge.Key] = new GraphNode(edge.Value);
            }
#else
            for (int i = 0; i < this.Graph.Length; i++)
            {
                if (manager.Stages.ContainsKey(i))
                {
                    this.Graph[i] = new GraphNode(manager.Stages[i]);
                }
                else if (manager.Edges.ContainsKey(i))
                {
                    this.Graph[i] = new GraphNode(manager.Edges[i]);
                }
                else  // else it is processing a progress edge, because they are allocated differently
                {
                    this.Graph[i] = new GraphNode(i, new int[] { });
                }
            }
#endif
        }
Ejemplo n.º 5
0
        public RemoteMailbox(int channelID, int processID, int shardID, Runtime.InternalGraphManager manager)
        {
            this.channelID = channelID;
            this.processID = processID;
            this.shardID   = shardID;
            this.graphID   = manager.Index;

            this.networkChannel = manager.Controller.NetworkChannel;

            var controller = manager.Controller;

            this.encodersFromLocalShards = new AutoSerializedMessageEncoder <S, T> [controller.Workers.Count];
            AutoSerializationMode mode = controller.Configuration.OneTimePerMessageSerialization ? AutoSerializationMode.OneTimePerMessage : AutoSerializationMode.Basic;

            for (int i = 0; i < controller.Workers.Count; ++i)
            {
                this.encodersFromLocalShards[i] = new AutoSerializedMessageEncoder <S, T>(this.shardID, this.graphID << 16 | this.channelID, this.networkChannel.GetBufferPool(this.processID, i), this.networkChannel.SendPageSize, mode, SerializedMessageType.Data, () => this.networkChannel.GetSequenceNumber(this.processID));
                this.encodersFromLocalShards[i].CompletedMessage += (o, a) => { this.networkChannel.SendBufferSegment(a.Hdr, this.processID, a.Segment); };
            }
        }
Ejemplo n.º 6
0
 internal TimeContextManager(Runtime.InternalGraphManager g)
 {
     this.graphManager = g;
     this.rootContext  = null;
     this.reporting    = null;
 }
Ejemplo n.º 7
0
        // populates this.ComparisonDepth, indexed by collection and channel identifiers.
        public void UpdateReachabilityPartialOrder(Runtime.InternalGraphManager graphManager)
        {
            RegenerateGraph(graphManager);

            var reachableDepths = new NaiadList <NaiadList <int> >(this.Graph.Length);

            var magicNumber = 37;

            //Console.Error.WriteLine("Updating reachability with {0} objects", Reachability.Graph.Length);
            for (int i = 0; i < this.Graph.Length; i++)
            {
                var reachable = new NaiadList <int>(this.Graph.Length);

                var versionList = new Pointstamp[] { new Pointstamp(i, Enumerable.Repeat(magicNumber, this.Graph[i].Depth).ToArray()) };

                var reachabilityResults = this.DetermineReachabilityList(versionList);

                for (int j = 0; j < reachabilityResults.Length; j++)
                {
                    var depth     = 0;
                    var increment = false;


                    // for each element of the reachable set
                    if (reachabilityResults[j] != null)
                    {
                        for (int k = 0; k < reachabilityResults[j].Count; k++)
                        {
                            for (int l = 0; l < reachabilityResults[j].Array[k].Timestamp.Length && reachabilityResults[j].Array[k].Timestamp[l] >= magicNumber; l++)
                            {
                                if (l + 1 > depth || l + 1 == depth && increment)
                                {
                                    depth     = l + 1;
                                    increment = (reachabilityResults[j].Array[k].Timestamp[l] > magicNumber);
                                }
                            }
                        }
                    }

                    reachable.Array[j] = increment ? -depth : depth;
                }

                reachableDepths.Array[i] = reachable;
            }

            this.ComparisonDepth = reachableDepths;

            #region Set up impersonation

            // consider each stage / edge
            this.Impersonations = new int[this.Graph.Length][];

            for (int i = 0; i < this.Graph.Length; i++)
            {
                // not applicable to exchange edges.
                if (!this.Graph[i].Exchanges && !this.NoImpersonation.Contains(i))
                {
                    var reached = new HashSet <int>();
                    var limits  = new HashSet <int>();
                    var queue   = new List <int>();

                    //reached.Add(i);
                    queue.Add(i);

                    for (int j = 0; j < queue.Count; j++)
                    {
                        var candidate = queue[j];

                        // check if queue[j] is interested in masquerading
                        var available = true;
                        for (int k = 0; k < this.Graph[candidate].Neighbors.Length; k++)
                        {
                            var target = this.Graph[candidate].Neighbors[k];
                            if (this.Graph[target].Exchanges)
                            {
                                available = false;
                            }
                        }

                        if (!reached.Contains(candidate))
                        {
                            reached.Add(candidate);

                            if (available)
                            {
                                for (int k = 0; k < this.Graph[candidate].Neighbors.Length; k++)
                                {
                                    queue.Add(this.Graph[candidate].Neighbors[k]);
                                }
                            }
                            else
                            {
                                limits.Add(candidate);
                            }
                        }
                    }

                    // if we found someone who wants to masquerade
                    if (!limits.Contains(i) && limits.Count > 0)
                    {
                        Impersonations[i] = limits.ToArray();
                    }
                    else
                    {
                        Impersonations[i] = null;
                    }
                }
            }

            #endregion
        }
Ejemplo n.º 8
0
        internal static Stream <S, Epoch> MakeStage(DataSource <S> source, Runtime.InternalGraphManager graphManager, Placement placement, string inputName)
        {
            var stage = new StreamingInputStage <S>(source, placement, graphManager, inputName);

            return(stage);
        }