Exemple #1
0
            public void AddExecution(NodeId pip, SimulationResult result)
            {
                var execution = new PipSpan()
                {
                    Id        = pip,
                    StartTime = Math.Max(EndTime, result.m_simulationCurrentTime),
                    Duration  = result.ExecutionData.Durations[pip],
                    Thread    = Id,
                };

                if (Executions.Count == 0)
                {
                    StartTime = execution.StartTime;
                }

                Executions.Add(execution);
                EndTime     = execution.EndTime;
                ActiveTime += execution.Duration;

                result.CompletePip(execution.StartTime, pip);
            }
Exemple #2
0
        /// <summary>
        /// Attempts to compute how many pips actually ran concurrently (max) during the actual build.
        /// </summary>
        public void ComputeActualConcurrency()
        {
            List <PipSpan> spans = new List <PipSpan>();

            LongestRunningPips       = GetSortedPips(20, true, n => true, n => Durations[n]);
            ShortestRunningProcesses = GetSortedPips(20, false, n => GetPipType(n) == PipType.Process, n => Durations[n]);

            foreach (var node in DataflowGraph.Nodes)
            {
                var pipType = GetPipType(node);
                Interlocked.Increment(ref PipTypeCounts[(int)pipType]);
                var startTime = StartTimes[node];
                if (pipType == PipType.Process)
                {
                    var duration = Durations[node];
                    if (duration > 0)
                    {
                        if (MinStartTime > startTime)
                        {
                            System.Diagnostics.Debugger.Launch();
                        }

                        spans.Add(new PipSpan()
                        {
                            Id        = node,
                            StartTime = startTime - MinStartTime,
                            Duration  = duration,
                        });
                    }
                }
            }

            spans.Sort(new ComparerBuilder <PipSpan>().CompareByAfter(s => s.StartTime).CompareByAfter(s => s.Duration));
            Spans = spans;

            ConcurrentDenseIndex <int> concurrencyIndex = new ConcurrentDenseIndex <int>(false);
            ConcurrentDenseIndex <int> concurrencyCount = new ConcurrentDenseIndex <int>(false);

            for (int i = 0; i < spans.Count; i++)
            {
                PipSpan s       = spans[i];
                ulong   endTime = s.EndTime;
                for (int j = i; j < spans.Count; j++)
                {
                    PipSpan t = spans[j];
                    if (t.StartTime < s.EndTime)
                    {
                        int value = concurrencyIndex[(uint)j] + 1;
                        concurrencyIndex[(uint)j] = value;
                        Max(ref ActualConcurrency, value);
                    }
                    else
                    {
                        break;
                    }
                }

                var c = concurrencyIndex[(uint)i];
                concurrencyCount[(uint)c] = concurrencyCount[(uint)c] + 1;
            }
        }