예제 #1
0
        static ExperimentalUnit FirstFittingExperiment(List <ExperimentalUnit> pendingExperiments, int numFreeCores, bool bAgentUsed, HerdAgentInfo agent)
        {
            foreach (ExperimentalUnit experiment in pendingExperiments)
            {
                AppVersion bestMatchingVersion = agent.BestMatch(experiment.AppVersions);
                if (bestMatchingVersion != null)
                {
                    //run-time requirements are calculated when a version is selected
                    experiment.SelectedVersion = agent.BestMatch(experiment.AppVersions);
                    if (experiment.SelectedVersion == null)
                    {
                        return(null);
                    }

                    experiment.GetRuntimeRequirements(experiment.SelectedVersion, experiment.AppVersions);
                    if (experiment.RunTimeReqs == null)
                    {
                        return(null);
                    }


                    //Check that the version chosen for the agent supports the architecture requested by the run-time
                    if ((experiment.RunTimeReqs.Architecture == Herd.Network.PropValues.None ||
                         experiment.RunTimeReqs.Architecture == experiment.SelectedVersion.Requirements.Architecture)
                        &&
                        //If NumCPUCores = "all", then the experiment only fits the agent in case it hasn't been given any other experimental unit
                        ((experiment.RunTimeReqs.NumCPUCores == 0 && !bAgentUsed)
                         //If NumCPUCores != "all", then experiment only fits the agent if the number of cpu cores used is less than those available
                         || (experiment.RunTimeReqs.NumCPUCores > 0 && experiment.RunTimeReqs.NumCPUCores <= numFreeCores)))
                    {
                        return(experiment);
                    }
                }
            }
            return(null);
        }
예제 #2
0
 /// <summary>
 /// Returns the first experimental unit that fits the agent
 /// </summary>
 /// <param name="pendingExperiments">The pending experimental units</param>
 /// <param name="numFreeCores">The number agent's free cores</param>
 /// <param name="bAgentUsed">Is the agent already being used for another experimental unit?</param>
 /// <param name="agent">The herd agent</param>
 /// <returns></returns>
 static ExperimentalUnit FirstFittingExperiment(List <ExperimentalUnit> pendingExperiments, int numFreeCores, bool bAgentUsed, HerdAgentInfo agent)
 {
     foreach (ExperimentalUnit experiment in pendingExperiments)
     {
         experiment.SelectedVersion = agent.BestMatch(experiment);
         if (experiment.SelectedVersion != null)
         {
             //If NumCPUCores = "all", then the experiment only fits the agent in case it hasn't been given any other experimental unit
             if ((experiment.RunTimeReqs.NumCPUCores == 0 && !bAgentUsed)
                 //If NumCPUCores != "all", then experiment only fits the agent if the number of cpu cores used is less than those available
                 || (experiment.RunTimeReqs.NumCPUCores > 0 && experiment.RunTimeReqs.NumCPUCores <= numFreeCores))
             {
                 return(experiment);
             }
         }
     }
     return(null);
 }