Skip to content
Snippets Groups Projects
Commit 1691b876 authored by Moe Jette's avatar Moe Jette
Browse files

Rename opt.cpus to opt.cpus_per_task, distributed tasks appropriately

for various values of cpus_per_task.
parent 2fd4f040
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,8 @@ launch(void *arg)
taskid = 0;
if (opt.distribution == SRUN_DIST_BLOCK) {
for (i=0; ((i<job->nhosts) && (taskid<opt.nprocs)); i++) {
for (j=0; ((j<job->cpus[i]) && (taskid<opt.nprocs)); j++) {
for (j=0; (((j*opt.cpus_per_task)<job->cpus[i]) &&
(taskid<opt.nprocs)); j++) {
task_ids[i][j] = taskid++;
job->ntask[i]++;
}
......
......@@ -151,7 +151,7 @@ struct poptOption runTable[] = {
{"ntasks", 'n', POPT_ARG_INT, &opt.nprocs, OPT_NPROCS,
"number of tasks to run",
"ntasks"},
{"cpus-per-task", 'c', POPT_ARG_INT, &opt.cpus, OPT_CPUS,
{"cpus-per-task", 'c', POPT_ARG_INT, &opt.cpus_per_task, OPT_CPUS,
"number of cpus required per task",
"ncpus"},
{"nodes", 'N', POPT_ARG_INT, &opt.nodes, OPT_NODES,
......@@ -252,7 +252,7 @@ typedef struct env_vars {
env_vars_t env_vars[] = {
{"SLURM_DEBUG", OPT_DEBUG, NULL},
{"SLURM_NPROCS", OPT_INT, &opt.nprocs},
{"SLURM_CPUS_PER_TASK", OPT_INT, &opt.cpus},
{"SLURM_CPUS_PER_TASK", OPT_INT, &opt.cpus_per_task},
{"SLURM_NNODES", OPT_INT, &opt.nodes},
{"SLURM_PARTITION", OPT_STRING, &opt.partition},
{"SLURM_STDINMODE", OPT_INPUT, &opt.input},
......@@ -311,14 +311,6 @@ int initialize_and_process_args(int argc, char *argv[])
/* initialize options with argv */
opt_args(argc, argv);
/* validate results */
if (opt.distribution == SRUN_DIST_UNKNOWN) {
if (opt.nprocs <= opt.nodes)
opt.distribution = SRUN_DIST_CYCLIC;
else
opt.distribution = SRUN_DIST_BLOCK;
}
#if __DEBUG
opt_list();
#endif
......@@ -521,7 +513,7 @@ static void opt_default()
opt.progname = NULL;
opt.nprocs = 1;
opt.cpus = 1;
opt.cpus_per_task = 1;
opt.nodes = 0; /* nodes need not be set */
opt.time_limit = -1;
opt.partition = NULL;
......@@ -836,7 +828,6 @@ static void opt_args(int ac, char **av)
}
}
if (!opt_verify(optctx, nnodes_set, cpus_set, nprocs_set)) {
poptPrintUsage(optctx, stderr, 0);
exit(1);
......@@ -861,6 +852,16 @@ opt_verify(poptContext optctx,
verified = false;
}
if (opt.distribution == SRUN_DIST_UNKNOWN) {
if (opt.nprocs <= opt.nodes)
opt.distribution = SRUN_DIST_CYCLIC;
else
opt.distribution = SRUN_DIST_BLOCK;
}
if (opt.mincpus < opt.cpus_per_task)
opt.mincpus = opt.cpus_per_task;
if ((opt.job_name == NULL) && (remote_argc > 0))
opt.job_name = base_name(remote_argv[0]);
......@@ -908,9 +909,9 @@ opt_verify(poptContext optctx,
verified = false;
}
if (opt.cpus <= 0) {
error("%s: invalid number of cpus per process (-n %d)\n",
opt.progname, opt.cpus);
if (opt.cpus_per_task <= 0) {
error("%s: invalid number of cpus per task (-c %d)\n",
opt.progname, opt.cpus_per_task);
verified = false;
}
......
......@@ -92,9 +92,9 @@ typedef struct srun_options {
char *cwd; /* current working directory */
int nprocs; /* --nprocs=n, -n n */
int cpus; /* --cpus_per_task=n, -c n */
int cpus_per_task; /* --cpus-per-task=n, -c n */
int nodes; /* --nodes=n, -N n */
int time_limit; /* --time, -t */
int time_limit; /* --time, -t */
char *partition; /* --partition=n, -p n */
enum distribution_t
distribution; /* --distribution=, -m dist */
......@@ -113,7 +113,7 @@ typedef struct srun_options {
char *attach; /* --attach=id -a id */
bool join; /* --join, -j */
/* no longer need these, they are set globally : */
/* no longer need these, they are set globally : */
/*int verbose;*/ /* -v, --verbose */
/*int debug;*/ /* -d, --debug */
......
......@@ -298,7 +298,7 @@ allocate_nodes(void)
job.req_nodes = opt.nodelist;
job.num_procs = opt.nprocs;
job.num_procs = opt.nprocs * opt.cpus_per_task;
if (opt.nodes > -1)
job.num_nodes = opt.nodes;
......@@ -409,7 +409,7 @@ create_job_step(job_t *job)
req.job_id = job->jobid;
req.user_id = opt.uid;
req.node_count = job->nhosts;
req.cpu_count = opt.nprocs;
req.cpu_count = opt.nprocs * opt.cpus_per_task;
req.node_list = job->nodelist;
req.relative = false;
if (opt.distribution == SRUN_DIST_BLOCK)
......@@ -594,7 +594,7 @@ run_batch_job(void)
job.req_nodes = opt.nodelist;
job.num_procs = opt.nprocs;
job.num_procs = opt.nprocs * opt.cpus_per_task;
if (opt.nodes > -1)
job.num_nodes = opt.nodes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment