public PostOfficeChannel(StageOutput <S, T> sendBundle, StageInput <S, T> recvBundle, Action <S[], int[], int> routingHashcodeFunction, NetworkChannel networkChannel, int channelId, Channel.Flags flags) { if ((flags & Channel.Flags.SpillOnRecv) == Channel.Flags.SpillOnRecv) { throw new Exception("SpillingLocalMailbox not currently supported"); } this.sendBundle = sendBundle; this.recvBundle = recvBundle; this.channelID = channelId; var computation = sendBundle.ForStage.InternalComputation; // populate mailboxes; [proxy] destinations for sent messages. this.mailboxes = new Mailbox <S, T> [recvBundle.ForStage.Placement.Count]; foreach (VertexLocation loc in recvBundle.ForStage.Placement) { if (loc.ProcessId == computation.Controller.Configuration.ProcessID) { var postOffice = this.recvBundle.GetPin(loc.VertexId).Vertex.Scheduler.State(computation).PostOffice; var progressBuffer = new Runtime.Progress.ProgressUpdateBuffer <T>(this.ChannelId, this.recvBundle.GetPin(loc.VertexId).Vertex.Scheduler.State(computation).Producer); LocalMailbox <S, T> localMailbox = new LocalMailbox <S, T>(postOffice, this.recvBundle.GetPin(loc.VertexId), channelID, loc.VertexId, progressBuffer); this.mailboxes[loc.VertexId] = localMailbox; postOffice.RegisterMailbox(localMailbox); if (networkChannel != null) { networkChannel.RegisterMailbox(localMailbox); } } else { this.mailboxes[loc.VertexId] = new RemoteMailbox <S, T>(this.channelID, loc.ProcessId, loc.VertexId, sendBundle.ForStage.InternalComputation); } } // populate postboxes; collection points for each local worker. this.postboxes = new Dictionary <int, Postbox <S, T> >(); foreach (VertexLocation location in sendBundle.ForStage.Placement) { if (location.ProcessId == sendBundle.ForStage.InternalComputation.Controller.Configuration.ProcessID) { var progressBuffer = new Runtime.Progress.ProgressUpdateBuffer <T>(this.ChannelId, this.sendBundle.GetFiber(location.VertexId).Vertex.Scheduler.State(computation).Producer); // determine type of postbox to use. if (routingHashcodeFunction == null) { this.postboxes[location.VertexId] = new NoHashCodePostbox <S, T>(this.channelID, this.sendBundle.GetFiber(location.VertexId), this.recvBundle, this.mailboxes, networkChannel, progressBuffer); } else { this.postboxes[location.VertexId] = new BufferingPostbox <S, T>(this.channelID, this.sendBundle.GetFiber(location.VertexId), this.recvBundle, this.mailboxes, routingHashcodeFunction, networkChannel, progressBuffer); } } } }
public PostOfficeChannel(StageOutput <S, T> sendBundle, StageInput <S, T> recvBundle, Func <S, int> routingHashcodeFunction, NetworkChannel networkChannel, int channelId, Channel.Flags flags) { this.sendBundle = sendBundle; this.recvBundle = recvBundle; this.postboxes = new Dictionary <int, Postbox <S, T> >(); this.mailboxes = new Mailbox <S, T> [recvBundle.ForStage.Placement.Count]; this.channelID = channelId; var computation = sendBundle.ForStage.InternalComputation; foreach (VertexLocation loc in recvBundle.ForStage.Placement) { if (loc.ProcessId == computation.Controller.Configuration.ProcessID) { var postOffice = this.recvBundle.GetPin(loc.VertexId).Vertex.Scheduler.State(computation).PostOffice; LocalMailbox <S, T> localMailbox; var progressBuffer = new Runtime.Progress.ProgressUpdateBuffer <T>(this.ChannelId, this.recvBundle.GetPin(loc.VertexId).Vertex.Scheduler.State(computation).Producer); if ((flags & Channel.Flags.SpillOnRecv) == Channel.Flags.SpillOnRecv) { //localMailbox = new SpillingLocalMailbox<S, T>(postOffice, this.recvBundle.GetPin(loc.VertexId), channelID, loc.VertexId, progressBuffer); throw new Exception("SpillingLocalMailbox not currently supported"); } else { localMailbox = new LegacyLocalMailbox <S, T>(postOffice, this.recvBundle.GetPin(loc.VertexId), channelID, loc.VertexId, progressBuffer); } this.mailboxes[loc.VertexId] = localMailbox; postOffice.RegisterMailbox(localMailbox); if (networkChannel != null) { networkChannel.RegisterMailbox(localMailbox); } } else { this.mailboxes[loc.VertexId] = new RemoteMailbox <S, T>(this.channelID, loc.ProcessId, loc.VertexId, sendBundle.ForStage.InternalComputation); } } foreach (VertexLocation loc in sendBundle.ForStage.Placement) { if (loc.ProcessId == sendBundle.ForStage.InternalComputation.Controller.Configuration.ProcessID) { var progressBuffer = new Runtime.Progress.ProgressUpdateBuffer <T>(this.ChannelId, this.sendBundle.GetFiber(loc.VertexId).Vertex.Scheduler.State(computation).Producer); this.postboxes[loc.VertexId] = new Postbox <S, T>(this.channelID, this.sendBundle.GetFiber(loc.VertexId), this.recvBundle, this.mailboxes, routingHashcodeFunction, networkChannel, progressBuffer); } } }
// if you provide a destinationCollectionId for the mailbox, it will use progress magic. public LegacyLocalMailbox(PostOffice postOffice, VertexInput <S, T> endpoint, int id, int vertexId, Runtime.Progress.ProgressUpdateBuffer <T> progressBuffer) : this(postOffice, endpoint, id, vertexId) { this.progressBuffer = progressBuffer; }
public Postbox(int channelID, VertexOutput <S, T> sender, StageInput <S, T> receiverBundle, Mailbox <S, T>[] mailboxes, Func <S, int> routingHashcodeFunction, NetworkChannel networkChannel, Runtime.Progress.ProgressUpdateBuffer <T> progressBuffer) : this(channelID, sender, receiverBundle, mailboxes, routingHashcodeFunction, networkChannel) { this.progressBuffer = progressBuffer; }
public SpillingLocalMailbox(PostOffice postoffice, VertexInput <S, T> endpoint, int id, int vertexId, Runtime.Progress.ProgressUpdateBuffer <T> progressBuffer) : base(postoffice, endpoint, id, vertexId) { this.pageSize = this.endpoint.Vertex.Stage.InternalGraphManager.Controller.Configuration.SendPageSize; this.progressBuffer = progressBuffer; this.messagesFromLocalThreads = new SendBufferPage[endpoint.Vertex.Stage.InternalGraphManager.Controller.Workers.Count]; string fileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); this.spillStream = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite, 1 << 20);//, FileOptions.WriteThrough); this.consumeStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); this.pagesWritten = 0; this.pagesRead = 0; this.pagesFlushed = 0; }
public NoHashCodePostbox(int channelID, VertexOutput <S, T> sender, StageInput <S, T> receiverBundle, Mailbox <S, T>[] mailboxes, NetworkChannel networkChannel, Runtime.Progress.ProgressUpdateBuffer <T> progressBuffer) : base(channelID, sender, receiverBundle, mailboxes, null, networkChannel, progressBuffer) { this.destination = this.vertexid % this.mailboxes.Length; }
public BufferingPostbox(int channelID, VertexOutput <S, T> sender, StageInput <S, T> receiverBundle, Mailbox <S, T>[] mailboxes, Action <S[], int[], int> routingHashcodeFunction, NetworkChannel networkChannel, Runtime.Progress.ProgressUpdateBuffer <T> progressBuffer) : base(channelID, sender, receiverBundle, mailboxes, routingHashcodeFunction, networkChannel, progressBuffer) { if (((this.mailboxes.Length - 1) & this.mailboxes.Length) == 0) { this.mask = this.mailboxes.Length - 1; } else { this.mask = -1; } this.Buffers = new Message <S, T> [this.mailboxes.Length]; }