Ejemplo n.º 1
0
        public void should_calculate_latency_from_first_to_last_time_flit_was_sent()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = flit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = flit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(5);
        }
Ejemplo n.º 2
0
        public void should_correlate_flit_events_in_one_count()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitEvent { ClockCycle = 1, Flit = flit });
            distributor.SendMessage(new FlitEvent { ClockCycle = 2, Flit = flit });
            distributor.Distribute(1, 2);

            evaluator.FlitsSent.Should().Be.EqualTo(1);
        }
Ejemplo n.º 3
0
        public void should_correlate_hops_for_same_flits()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = flit});
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = flit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 3, Flit = flit });
            distributor.Distribute(1, 3);

            evaluator.HopCount.Should().Be.EqualTo(3);
        }
Ejemplo n.º 4
0
        public void should_count_latency_for_separated_flits()
        {
            var firstFlit = new Flit();
            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = secondFlit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(1);
        }
Ejemplo n.º 5
0
        public RoutingAvailabilityExpression HasAvailableChannelFor(Flit flit)
        {
            var channel = routingAlgorithm.Route(Channels);
            var isAvailable = (!channel.IsFull() && !channel.IsReservedForOtherThan(flit));

            return new RoutingAvailabilityExpression(
                isAvailable: isAvailable,
                routeIfAvailableAction: () => { if (isAvailable) this.Route(flit, channel); }
            );
        }
Ejemplo n.º 6
0
        public void should_calculate_average_latency_from_multiple_flits()
        {
            var firstFlit = new Flit();
            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = secondFlit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(1.5);
        }
Ejemplo n.º 7
0
        public void should_be_marked_as_reserved_after_reservation()
        {
            var buffer = MockRepository.GenerateStub<IBuffer>();
            var channel = new Channel(buffer);
            var flit = new Flit();

            channel.Reserve(flit);

            channel.IsReservedForOtherThan(flit).Should().Be.False();
            channel.IsReservedForOtherThan(new Flit()).Should().Be.True();
        }
Ejemplo n.º 8
0
        public void should_calculate_average_hops_for_different_flits()
        {
            var firstFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = firstFlit });

            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 3, Flit = secondFlit });

            distributor.Distribute(1, 3);

            evaluator.HopCount.Should().Be.EqualTo(1.5);
        }
Ejemplo n.º 9
0
        public void peek_should_return_the_first_flit_put_on_queue()
        {
            var bufferDepth = 2;
            var queue = new QueueBuffer(bufferDepth: bufferDepth);
            var flit1 = new Flit();
            var flit2 = new Flit();

            queue.Put(flit1);
            queue.Put(flit2);

            var peek = queue.Peek();
            peek.Should().Be.EqualTo(flit1);
            peek.Should().Not.Be.EqualTo(flit2);
        }
Ejemplo n.º 10
0
        public void should_verify_if_channels_are_available_when_receiving_flit()
        {
            var switchingMatrix = MockRepository.GenerateMock<ISwitchingMatrix>();
            var router = new Router(switchingMatrix);
            distributor.AddListener(router);
            var flit = new Flit();

            switchingMatrix.Expect(x => x.HasAvailableChannelFor(flit))
                .Return(new RoutingAvailabilityExpression(true));

            distributor.SendMessage(new FlitEvent { ClockCycle = 1, Flit = flit, CurrentReceiver = router });
            distributor.Distribute(1);

            switchingMatrix.VerifyAllExpectations();
        }
Ejemplo n.º 11
0
        public void should_not_have_channel_for_flit_when_buffers_full()
        {
            var returningChannel = MockRepository.GenerateMock<IChannel>();
            var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>();
            var flit = new Flit();

            returningChannel.Expect(x => x.IsFull()).Return(true);
            returningChannel.Expect(x => x.IsReservedForOtherThan(flit)).Return(false);
            routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel);

            var switchingMatrix = new SwitchingMatrix(routingAlgorithm);
            switchingMatrix.AddChannel(returningChannel);

            switchingMatrix.HasAvailableChannelFor(flit).IsAvailable.Should().Be.False();
        }
Ejemplo n.º 12
0
        public void should_reserve_channel_for_flit_when_the_head_pass_by()
        {
            var returningChannel = MockRepository.GenerateMock<IChannel>();
            var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>();
            var flit = new Flit { Type = FlitType.Header };

            returningChannel.Stub(x => x.IsFull()).Return(false);
            returningChannel.Stub(x => x.IsReservedForOtherThan(flit)).Return(false);
            routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel);

            var switchingMatrix = new SwitchingMatrix(routingAlgorithm);
            switchingMatrix.AddChannel(returningChannel);

            returningChannel.Expect(x => x.Reserve(flit));
            switchingMatrix.HasAvailableChannelFor(flit).RouteIfAvailable();

            returningChannel.VerifyAllExpectations();
        }
Ejemplo n.º 13
0
        public void take_should_return_the_first_flit_put_on_queue()
        {
            var bufferDepth = 2;
            var queue = new QueueBuffer(bufferDepth: bufferDepth);
            var flit1 = new Flit();
            var flit2 = new Flit();

            queue.Put(flit1);
            queue.Put(flit2);

            var take = queue.Take();
            take.Should().Be.EqualTo(flit1);
            take.Should().Not.Be.EqualTo(flit2);
        }
Ejemplo n.º 14
0
 public void Reserve(Flit flit)
 {
     reservedFor = flit;
 }
Ejemplo n.º 15
0
 public void Release(Flit flit)
 {
     reservedFor = null;
 }
Ejemplo n.º 16
0
 public bool IsReservedForOtherThan(Flit flit)
 {
     return (reservedFor != null) && (reservedFor != flit);
 }
Ejemplo n.º 17
0
 public virtual void Put(Flit flit)
 {
     if (items.Count < bufferDepth)
         items.Enqueue(flit);
 }
Ejemplo n.º 18
0
 public override void Put(Flit flit)
 {
     items.Enqueue(flit);
 }
Ejemplo n.º 19
0
 private void Route(Flit flit, IChannel channel)
 {
     if (flit.Type == FlitType.Header) channel.Reserve(flit);
     if (flit.Type == FlitType.Tail) channel.Release(flit);
 }