Run task on all available cores RRS feed

  • Question

  • I'm using Windows HPC Pack 2008 R2 SP4 to run a MPI application. I'm having problems getting the Job Scheduler to run the app on all available cores. Here's my code...

    using (IScheduler scheduler = new Scheduler())
        var newJob = scheduler.CreateJob();
        newJob.Name = "My job";
        //newJob.IsExclusive = true;
        var singleTask = newJob.CreateTask();
        singleTask.WorkDirectory = @"C:\MpiWorkspace";
        singleTask.CommandLine = @"mpiexec MyMpiApp.exe";
        scheduler.SubmitJob(newJob, null, null);

    Ran like the above I get allocated 1 (measly) core out of the 16 available across the two Compute Nodes in the cluster. The best I can get is by uncommenting the line newJob.IsExclusive = true;, which then allocates me all the cores on one of the Compute Nodes (8 cores).

    If I was running from the command-line I could using the mpiexec switch /np * to use all available cores, but this appears to be overridden by the Job Scheduler.

    How do I get the same effect in-code, how can I run on all available cores without explicitly declaring a minimum and maximum number of cores for the task?

    Wednesday, October 29, 2014 10:29 AM

All replies

  • Hi Matt,

    You need specify the job's resource type = node, and min = max = the number of nodes you want to run your task.

    Please try that out to see whether it works.



    Friday, October 31, 2014 8:49 AM
  • Hi Evan,

    Thanks for the response. The solution I'm using is counting the cores across all nodes and setting the job up using that value...

    using (IScheduler scheduler = new Scheduler())
        // Get nCores...
        var availableCores = 0;
        foreach (int nodeId in scheduler.GetNodeIdList(null, null))
            var node = scheduler.OpenNode(nodeId);
            availableCores += node.GetCores().Count;
        var job = scheduler.CreateJob();
        // Assign min and max nCores to job
        job.UnitType = JobUnitType.Core;
        job.MinimumNumberOfCores = availableCores; 
        job.MaximumNumberOfCores = job.MinimumNumberOfCores;
        job.IsExclusive = true;
        job.AutoCalculateMax = false;
        job.AutoCalculateMin = false;
        //etc., etc.

    ... which is much the same as doing it with nodes as you suggest (though I'm thinking nodes is a better way of doing it).

    Can I just confirm there is no way of getting the behavior I was initially looking for - that there is some magical configuration of the Job object that will allow all available cores to be assigned to the Job at the job's run time? 

    Friday, December 19, 2014 9:24 AM
  • Hi Matt,

      You can check this sample http://msdn.microsoft.com/en-us/library/cc853436(v=vs.85).aspx to get the idle cores numbers in the cluster so that you can set this value. But this needs to be done at submission time instead of activation time.

      A workaround you can try is to use activation filter where you can modify the job resource ask right before the job get run. Please check sample here: http://technet.microsoft.com/en-us/library/dd346641(v=WS.10).aspx


    Qiufang Shi

    Thursday, December 25, 2014 4:09 AM