Пример #1
0
        public void Schedule <T>(ControlFlowGraph <T> cfg, SchedulingConstraints constraints, ISchedulingAdapter <T> scha) where T : IInstruction
        {
            foreach (var bb in cfg.BasicBlocks)
            {
                if (bb.IsExitBlock)
                {
                    break;
                }

                var  fdsa         = new FDSAdapter <T>(scha);
                var  asapa        = new ASLAPAdapter <T>(scha, fdsa.ASAPIndex);
                var  alapa        = new ASLAPAdapter <T>(scha, fdsa.ALAPIndex);
                long oldStartTime = constraints.StartTime;
                ASAPScheduler.InstanceUnlimitedResources.Schedule(bb.Range, asapa, constraints);
                ALAPScheduler.InstanceUnlimitedResources.Schedule(bb.Range, alapa, constraints);
                constraints.StartTime = oldStartTime;
                ForceDirectedSchedulerImpl <T> .Schedule(fdsa, bb.Range, constraints);

                constraints.StartTime = constraints.EndTime;
            }
        }
Пример #2
0
        public void Schedule <T>(IEnumerable <T> tasks, ISchedulingAdapter <T> scha, SchedulingConstraints constraints)
        {
            var fdsa  = new FDSAdapter <T>(scha);
            var asapa = new ASLAPAdapter <T>(scha, fdsa.ASAPIndex);
            var alapa = new ASLAPAdapter <T>(scha, fdsa.ALAPIndex);

            ASAPScheduler.InstanceUnlimitedResources.Schedule(tasks, asapa, constraints);

            int maxConcurrency = tasks.GroupBy(i => asapa.CStep[i])
                                 .Sum(grp => grp.GroupBy(j => asapa.IClass[j]).Max(g => g.Count() - 1));

            long maxExtent    = constraints.EndTime - constraints.StartTime + maxConcurrency;
            long scaledExtent = (long)Math.Ceiling((constraints.EndTime - constraints.StartTime) * constraints.SchedScale);
            long extent       = Math.Min(maxExtent, scaledExtent);
            long oldStartTime = constraints.StartTime;

            constraints.EndTime = constraints.StartTime + extent;
            ALAPScheduler.InstanceUnlimitedResources.Schedule(tasks, alapa, constraints);
            constraints.StartTime = oldStartTime;
            ForceDirectedSchedulerImpl <T> .Schedule(fdsa, tasks.ToList(), constraints);
        }