Skip to content

Commit 0290e60

Browse files
committed
job-list: handle per-resource "cores" special cases
Problem: The shell per-resource options are used to work around Jobspec V1 limitations. The per-resource type of "node" was previously handled, but the type of "core" was not. Solution: Handle per-resource "core" special cases and set ntasks accordingly if it is set. Fixes #4593
1 parent a165050 commit 0290e60

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/modules/job-list/job_data.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "src/common/libczmqcontainers/czmq_containers.h"
2121
#include "src/common/librlist/rlist.h"
22+
#include "src/common/librlist/rnode.h"
2223
#include "src/common/libccan/ccan/str/str.h"
2324
#include "src/common/libjob/jj.h"
2425

@@ -220,6 +221,19 @@ static int parse_jobspec_ntasks (struct job *job, struct jj_counts *jj)
220221
job->ntasks = jj->nnodes * count;
221222
return 0;
222223
}
224+
if (streq (type, "core")) {
225+
if (jj->nnodes == 0)
226+
job->ntasks = jj->nslots * jj->slot_size * count;
227+
else {
228+
/* if nnodes > 0, can't determine until nodes
229+
* allocated and number of cores on node(s) are known.
230+
* Set a flag / count to retrieve data later when
231+
* R has been retrieved.
232+
*/
233+
job->ntasks_per_core_on_node_count = count;
234+
}
235+
return 0;
236+
}
223237
}
224238

225239
job->ntasks = jj->nslots;
@@ -350,6 +364,16 @@ int job_parse_R (struct job *job, const char *s)
350364
if (!(job->nodelist = hostlist_encode (hl)))
351365
goto nonfatal_error;
352366

367+
if (job->ntasks_per_core_on_node_count > 0) {
368+
int core_count = 0;
369+
struct rnode *rnode = zlistx_first (rl->nodes);
370+
while (rnode) {
371+
core_count += idset_count (rnode->cores->ids);
372+
rnode = zlistx_next (rl->nodes);
373+
}
374+
job->ntasks = core_count * job->ntasks_per_core_on_node_count;
375+
}
376+
353377
/* nonfatal error - invalid R, but we'll continue on. job listing
354378
* will get initialized data */
355379
nonfatal_error:

src/modules/job-list/job_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct job {
4747
const char *name;
4848
const char *queue;
4949
int ntasks;
50+
int ntasks_per_core_on_node_count; /* flag for ntasks calculation */
5051
double duration;
5152
int nnodes;
5253
char *ranks;

0 commit comments

Comments
 (0)