Exemplo n.º 1
0
        public void Scenario1_DeadlocksWithoutEager()
        {
            ExecuteMpiProgram(2, mpi =>
            {
                mpi.MpiInit();
                int rank = mpi.GetRank();

                if (rank == 0)
                {
                    // P0
                    SendHandle h00 = mpi.SendAsync(1, "s00", false);
                    mpi.Wait(h00); // DEADLOCKS on wait because the barrier's can't be satisfied
                    mpi.Barrier();
                }
                else
                {
                    // P1
                    mpi.Barrier(); // Never gets past here because P0 is waiting for us to recv first.
                    ReceiveHandle h11 = mpi.ReceiveAsync(0);
                    string msg1       = mpi.Wait(h11);
                    Assert.AreEqual("s00", msg1);
                }

                mpi.MpiFinalize();
            });
        }
Exemplo n.º 2
0
        public void Scenario1_DoesNotDeadlockWhenEager()
        {
            ExecuteMpiProgram(2, mpi =>
            {
                mpi.MpiInit();
                int rank = mpi.GetRank();

                if (rank == 0)
                {
                    // P0
                    SendHandle h00 = mpi.SendAsync(1, "s00", true);
                    // Does Not DEADLOCK on wait because it will return when the string is copied
                    // to a local buffer.
                    mpi.Wait(h00);
                    mpi.Barrier();
                }
                else
                {
                    // P1
                    mpi.Barrier(); // Never gets past here because P0 is waiting for us to recv first.
                    ReceiveHandle h11 = mpi.ReceiveAsync(0);
                    string msg1       = mpi.Wait(h11);
                    Assert.AreEqual("s00", msg1);
                }

                mpi.MpiFinalize();
            });
        }
Exemplo n.º 3
0
        public Error Send(T message)
        {
            if (IsClosed)
            {
                return(Error.ChannelClosed);
            }
            var handle = new SendHandle(message);

            lock (this) {
                unreleasedHandles.Enqueue(handle);
                TrimHandles();
                ProcessMessages();
            }
            handle.Wait();
            return(Error.Nil);
        }