private static v2008R2.ISchedulerTask AddCleanupTaskToJob(ClusterSubmitterArgs clusterArgs, v2008R2.IScheduler scheduler, v2008R2.ISchedulerJob job, IDistributable distributableJob) { v2008R2.ISchedulerCollection taskList = job.GetTaskList(scheduler.CreateFilterCollection(), scheduler.CreateSortCollection(), true); v2008R2.IStringCollection dependencyTasks = scheduler.CreateStringCollection(); if (!clusterArgs.OnlyDoCleanup) { dependencyTasks.Add(((v2008R2.ISchedulerTask)taskList[0]).Name); } v2008R2.ISchedulerTask cleanupTask = CreateCleanupTask(job, clusterArgs.ExternalRemoteDirectoryName, clusterArgs.StdErrDirName, clusterArgs.StdOutDirName, "cleanup", true); Distribute.Locally local = new Distribute.Locally() { Cleanup = true, TaskCount = clusterArgs.TaskCount, Tasks = new RangeCollection(), ParallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = 1 } }; Distribute.Distribute distributeExe = new Distribute.Distribute() { Distributor = local, Distributable = distributableJob }; string exeName = distributableJob is DistributableWrapper ? clusterArgs.ExeName : distributeExe.GetType().Assembly.GetName().Name; //args.AddOptionalFlag("cleanup"); //args.AddOptional("tasks", "empty"); string taskCommandLine = string.Format("{0}\\{1} {2}", clusterArgs.ExeRelativeDirectoryName, exeName, CreateTaskString(distributeExe, clusterArgs.MinimalCommandLine)); cleanupTask.CommandLine = taskCommandLine; if (!clusterArgs.OnlyDoCleanup) { cleanupTask.DependsOn = dependencyTasks; } job.AddTask(cleanupTask); return(cleanupTask); }
private static v2008R2.ISchedulerTask CreateTask(int?taskNumber, ClusterSubmitterArgs clusterArgs, v2008R2.ISchedulerJob job, IDistributable distributableObj, v2008R2.IStringCollection nodesToUse) { Distribute.Locally local = new Distribute.Locally() { Cleanup = false, TaskCount = clusterArgs.TaskCount, Tasks = taskNumber.HasValue ? new RangeCollection(taskNumber.Value) : null, ParallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = 1 } }; v2008R2.ISchedulerTask task = job.CreateTask(); if (nodesToUse != null) { task.RequiredNodes = nodesToUse; } if (clusterArgs.NumCoresPerTask != null) { task.MinimumNumberOfCores = clusterArgs.NumCoresPerTask.Value; task.MaximumNumberOfCores = clusterArgs.NumCoresPerTask.Value; task.MaximumNumberOfNodes = 1; local.ParallelOptions.MaxDegreeOfParallelism = clusterArgs.NumCoresPerTask.Value; } else if (clusterArgs.IsExclusive) { //task.MinimumNumberOfCores = 1; //task.MaximumNumberOfCores = 8; //task.MaximumNumberOfNodes = 1; } task.WorkDirectory = clusterArgs.ExternalRemoteDirectoryName; Distribute.Distribute distributeExe = new Distribute.Distribute() { Distributable = distributableObj, Distributor = local }; string taskArgString = CreateTaskString(distributeExe, clusterArgs.MinimalCommandLine); string exeName = distributeExe.Distributable is DistributableWrapper ? clusterArgs.ExeName : distributeExe.GetType().Assembly.GetName().Name; string taskCommandLine = null; if (clusterArgs.UseMPI) { taskCommandLine = string.Format("mpiexec -n {0} {1}\\{2} {3}", clusterArgs.NumCoresPerTask, clusterArgs.ExeRelativeDirectoryName, exeName, taskArgString); } else { taskCommandLine = string.Format("{0}\\{1} {2}", clusterArgs.ExeRelativeDirectoryName, exeName, taskArgString); } task.CommandLine = taskCommandLine; string taskNumberAsString = taskNumber.HasValue ? taskNumber.Value.ToString() : "*"; task.Name = Helper.CreateDelimitedString(" ", clusterArgs.Name, taskNumberAsString); task.StdErrFilePath = string.Format(@"{0}\{1}.txt", clusterArgs.StdErrDirName, taskNumberAsString); task.StdOutFilePath = string.Format(@"{0}\{1}.txt", clusterArgs.StdOutDirName, taskNumberAsString); if (task.StdErrFilePath.Length >= 160) { Console.WriteLine("Caution, std error file path is {0} characters, which will probably cause HPC to crash.", task.StdErrFilePath.Length); } return(task); }
private static v1.ITask CreateTask(ClusterSubmitterArgs clusterArgs, int taskNum, IDistributable distributableObj) { v1.ITask task = new v1.Task(); task.WorkDirectory = clusterArgs.InternalRemoteDirectory; Distribute.Locally local = new Distribute.Locally() { Cleanup = false, TaskCount = clusterArgs.TaskCount, ParallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = 1 }, Tasks = new RangeCollection(taskNum) }; Distribute.Distribute distributeExe = new Distribute.Distribute() { Distributable = distributableObj, Distributor = local }; string taskString = CreateTaskString(distributeExe, clusterArgs.MinimalCommandLine); string exeName = distributableObj is DistributableWrapper ? clusterArgs.ExeName : distributeExe.GetType().Assembly.GetName().Name; string taskCommandLine = string.Format("{0}\\{1} {2}", clusterArgs.ExeRelativeDirectoryName, exeName, taskString); task.CommandLine = taskCommandLine; task.Name = Helper.CreateDelimitedString(" ", clusterArgs.Name, taskNum); task.IsExclusive = false; task.MinimumNumberOfProcessors = 1; task.MaximumNumberOfProcessors = 1; task.Stderr = string.Format(@"{0}\{1}.txt", clusterArgs.StdErrDirName, taskNum); task.Stdout = string.Format(@"{0}\{1}.txt", clusterArgs.StdOutDirName, taskNum); task.Runtime = "Infinite"; return(task); }