Exemplo n.º 1
0
        /// <summary>
        /// Gets the counters for the specified core and time period.
        /// </summary>
        /// <param name="core">The core number.</param>
        /// <param name="from">The start time.</param>
        /// <param name="to">The end time.</param>
        /// <returns>The counters for that period.</returns>
        protected virtual EventHwCounters GetCounters(int core, DateTime from, DateTime to)
        {
            // Get corresponding hardware counters
            var hardware = this.Counters
                           .Where(c => c.Time >= from && c.Time <= to)
                           .Where(c => c.Core == core)
                           .ToArray();

            // The total duration of the hw counter samples we have
            var duration = hardware
                           .Where(c => c.Type == TraceCounterType.IPC)
                           .Select(c => c.Duration / 1000)
                           .Sum();

            var hwcount = hardware.Count();

            // If we don't have anything, return zeroes
            var counters = new EventHwCounters();


            // If we harve hardware counters
            if (hwcount == 0)
            {
                return(counters);
            }

            // Absolute numbers
            counters.Cycles   = (long)((hardware.Where(c => c.Type == TraceCounterType.Cycles).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L2Misses = (long)((hardware.Where(c => c.Type == TraceCounterType.L2Miss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L3Misses = (long)((hardware.Where(c => c.Type == TraceCounterType.L3Miss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L2Hits   = (long)((hardware.Where(c => c.Type == TraceCounterType.L2Hit).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L3Hits   = (long)((hardware.Where(c => c.Type == TraceCounterType.L3Hit).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);

            // Average or sum depending on the counter
            counters.IPC     = hardware.Where(c => c.Type == TraceCounterType.IPC).Select(c => c.Value).Average();
            counters.L2Clock = hardware.Where(c => c.Type == TraceCounterType.L2Clock).Select(c => c.Value).Average();
            counters.L3Clock = hardware.Where(c => c.Type == TraceCounterType.L3Clock).Select(c => c.Value).Average();

            // Computed
            counters.L1Misses = counters.L2Misses + counters.L2Hits;


            // The duration of the TLB events
            duration = hardware
                       .Where(c => c.Type == TraceCounterType.TLBMiss)
                       .Select(c => c.Duration / 1000)
                       .Sum();

            counters.TLBMisses = (long)((hardware.Where(c => c.Type == TraceCounterType.TLBMiss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.TLBClock  = hardware.Where(c => c.Type == TraceCounterType.TLBClock).Select(c => c.Value).Average();

            return(counters);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the counters for the specified core and time period.
        /// </summary>
        /// <param name="core">The core number.</param>
        /// <param name="from">The start time.</param>
        /// <param name="to">The end time.</param>
        /// <returns>The counters for that period.</returns>
        protected virtual EventHwCounters GetCounters(int core, DateTime from, DateTime to)
        {
            // Get corresponding hardware counters
            var hardware = this.Counters
                .Where(c => c.Time >= from && c.Time <= to)
                .Where(c => c.Core == core)
                .ToArray();

            // The total duration of the hw counter samples we have
            var duration = hardware
                .Where(c => c.Type == TraceCounterType.IPC)
                .Select(c => c.Duration / 1000)
                .Sum();

            var hwcount = hardware.Count();

            // If we don't have anything, return zeroes
            var counters = new EventHwCounters();

            // If we harve hardware counters
            if (hwcount == 0)
                return counters;

            // Absolute numbers
            counters.Cycles   = (long)((hardware.Where(c => c.Type == TraceCounterType.Cycles).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L2Misses = (long)((hardware.Where(c => c.Type == TraceCounterType.L2Miss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L3Misses = (long)((hardware.Where(c => c.Type == TraceCounterType.L3Miss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L2Hits   = (long)((hardware.Where(c => c.Type == TraceCounterType.L2Hit).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.L3Hits   = (long)((hardware.Where(c => c.Type == TraceCounterType.L3Hit).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);

            // Average or sum depending on the counter
            counters.IPC = hardware.Where(c => c.Type == TraceCounterType.IPC).Select(c => c.Value).Average();
            counters.L2Clock = hardware.Where(c => c.Type == TraceCounterType.L2Clock).Select(c => c.Value).Average();
            counters.L3Clock = hardware.Where(c => c.Type == TraceCounterType.L3Clock).Select(c => c.Value).Average();

            // Computed
            counters.L1Misses = counters.L2Misses + counters.L2Hits;

            // The duration of the TLB events
            duration = hardware
                .Where(c => c.Type == TraceCounterType.TLBMiss)
                .Select(c => c.Duration / 1000)
                .Sum();

            counters.TLBMisses = (long)((hardware.Where(c => c.Type == TraceCounterType.TLBMiss).Select(c => c.Value).Sum() / duration) * this.Interval.TotalMilliseconds);
            counters.TLBClock = hardware.Where(c => c.Type == TraceCounterType.TLBClock).Select(c => c.Value).Average();

            return counters;
        }