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

Add new function: build_select_job_res_cpus_array()

/* Rebuild cpus array based upon the values of nhosts, cpu_array_value and
 * cpu_array_reps in an existing data structure */
parent da127f2a
No related branches found
No related tags found
No related merge requests found
......@@ -113,7 +113,7 @@ extern int build_select_job_res(select_job_res_t select_job_res,
}
/* Rebuild cpu_array_cnt, cpu_array_value, and cpu_array_reps based upon the
* values of cpus in an existing data structure */
* values of nhosts and cpus in an existing data structure */
extern int build_select_job_res_cpu_array(select_job_res_t select_job_res_ptr)
{
int i;
......@@ -122,7 +122,7 @@ extern int build_select_job_res_cpu_array(select_job_res_t select_job_res_ptr)
if (select_job_res_ptr->nhosts == 0)
return SLURM_SUCCESS; /* no work to do */
if (select_job_res_ptr->cpus == NULL) {
error("build_select_job_res_cpu_array cpus==NULL");
error("build_select_job_res_cpu_array: cpus==NULL");
return SLURM_ERROR;
}
......@@ -152,6 +152,52 @@ extern int build_select_job_res_cpu_array(select_job_res_t select_job_res_ptr)
return SLURM_SUCCESS;
}
/* Rebuild cpus array based upon the values of nhosts, cpu_array_value and
* cpu_array_reps in an existing data structure */
extern int build_select_job_res_cpus_array(select_job_res_t select_job_res_ptr)
{
int cpu_inx, i, j;
if (select_job_res_ptr->nhosts == 0)
return SLURM_SUCCESS; /* no work to do */
if (select_job_res_ptr->cpu_array_cnt == 0) {
error("build_select_job_res_cpus_array: cpu_array_cnt==0");
return SLURM_ERROR;
}
if (select_job_res_ptr->cpu_array_value == NULL) {
error("build_select_job_res_cpus_array: cpu_array_value==NULL");
return SLURM_ERROR;
}
if (select_job_res_ptr->cpu_array_reps == NULL) {
error("build_select_job_res_cpus_array: cpu_array_reps==NULL");
return SLURM_ERROR;
}
/* clear vestigial data and create new arrays of max size */
xfree(select_job_res_ptr->cpus);
select_job_res_ptr->cpus =
xmalloc(select_job_res_ptr->nhosts * sizeof(uint16_t));
cpu_inx = 0;
for (i=0; i<select_job_res_ptr->cpu_array_cnt; i++) {
for (j=0; j<select_job_res_ptr->cpu_array_reps[i]; j++) {
if (cpu_inx >= select_job_res_ptr->nhosts) {
error("build_select_job_res_cpus_array: "
"cpu_array is too long");
return SLURM_ERROR;
}
select_job_res_ptr->cpus[cpu_inx++] =
select_job_res_ptr->cpus[i];
}
}
if (cpu_inx < select_job_res_ptr->nhosts) {
error("build_select_job_res_cpus_array: "
"cpu_array is incomplete");
return SLURM_ERROR;
}
return SLURM_SUCCESS;
}
extern int valid_select_job_res(select_job_res_t select_job_res,
void *node_rec_table,
uint16_t fast_schedule)
......@@ -510,7 +556,7 @@ extern void pack_select_job_res(select_job_res_t select_job_res_ptr,
xassert(core_cnt == bit_size(select_job_res_ptr->core_bitmap_used));
pack_bit_fmt(select_job_res_ptr->core_bitmap_used, buffer);
host_cnt = bit_size(select_job_res_ptr->node_bitmap);
/* FIXME: don't pack the node_bitmap, but recreate it based upon
/* FIXME: don't pack the node_bitmap, but rebuild it based upon
* select_job_res_ptr->node_list */
pack32(host_cnt, buffer);
pack_bit_fmt(select_job_res_ptr->node_bitmap, buffer);
......
......@@ -139,6 +139,10 @@ extern int build_select_job_res(select_job_res_t select_job_res_ptr,
* values of cpus in an existing data structure */
extern int build_select_job_res_cpu_array(select_job_res_t select_job_res_ptr);
/* Rebuild cpus array based upon the values of nhosts, cpu_array_value and
* cpu_array_reps in an existing data structure */
extern int build_select_job_res_cpus_array(select_job_res_t select_job_res_ptr);
/* Validate a select_job_res data structure originally built using
* build_select_job_res() is still valid based upon slurmctld state.
* NOTE: Reset the node_bitmap field before calling this function.
......
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