Skip to content

Commit

Permalink
Delay slurm_verify_cpu_bind after cli_filter_g_pre_submit
Browse files Browse the repository at this point in the history
This allows access to the value set by --cpu-bind in cli_filter plugins,
if --cpu-bind is set in cli_filter_g_pre_submit then cpu_bind_type
should be set based on the modified value.

Bug 13554
  • Loading branch information
cinek810 authored and dannyauble committed Apr 7, 2022
1 parent 4e4b3cc commit 40a3bf3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ documents those changes that are of interest to users and administrators.
-- sacct - allocations made by srun will now always display the allocation and
step(s). Previously, the allocation and step were combined when possible.
-- Steps now allocate gres according to topo data.
-- Add validation of numbers provided to --gpu-bind=map_gpu and
--gpu-bind=mask_gpu=.

* Changes in Slurm 21.08.7
==========================
Expand Down
40 changes: 2 additions & 38 deletions src/common/slurm_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,43 +1090,7 @@ static slurm_cli_opt_t slurm_opt_cores_per_socket = {
.reset_each_pass = true,
};

static int arg_set_cpu_bind(slurm_opt_t *opt, const char *arg)
{
if (!opt->srun_opt)
return SLURM_ERROR;

if (slurm_verify_cpu_bind(arg, &opt->srun_opt->cpu_bind,
&opt->srun_opt->cpu_bind_type))
return SLURM_ERROR;

return SLURM_SUCCESS;
}
static char *arg_get_cpu_bind(slurm_opt_t *opt)
{
char tmp[100];

if (!opt->srun_opt)
return xstrdup("invalid-context");

slurm_sprint_cpu_bind_type(tmp, opt->srun_opt->cpu_bind_type);

return xstrdup(tmp);
}
static void arg_reset_cpu_bind(slurm_opt_t *opt)
{
if (opt->srun_opt) {
bool cpu_bind_verbose = false;
if (opt->srun_opt->cpu_bind_type & CPU_BIND_VERBOSE)
cpu_bind_verbose = true;

xfree(opt->srun_opt->cpu_bind);
opt->srun_opt->cpu_bind_type = 0;
if (cpu_bind_verbose)
slurm_verify_cpu_bind("verbose",
&opt->srun_opt->cpu_bind,
&opt->srun_opt->cpu_bind_type);
}
}
COMMON_SRUN_STRING_OPTION(cpu_bind);
static slurm_cli_opt_t slurm_opt_cpu_bind = {
.name = "cpu-bind",
.has_arg = required_argument,
Expand Down Expand Up @@ -5811,7 +5775,7 @@ static void _validate_threads_per_core_option(slurm_opt_t *opt)
&opt->srun_opt->cpu_bind,
&opt->srun_opt->cpu_bind_type);
} else if (opt->srun_opt &&
(opt->srun_opt->cpu_bind_type == CPU_BIND_VERBOSE)) {
!xstrcmp(opt->srun_opt->cpu_bind, "verbose")) {
verbose("Setting --cpu-bind=threads,verbose as a default of --threads-per-core use");
if (opt->srun_opt)
slurm_verify_cpu_bind("threads,verbose",
Expand Down
8 changes: 8 additions & 0 deletions src/srun/libsrun/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,14 @@ static bool _opt_verify(void)
opt.nodes_set = false;
}

/* slurm_verify_cpu_bind has to be called before validate_hint_option */
if (opt.srun_opt->cpu_bind) {
if (slurm_verify_cpu_bind(opt.srun_opt->cpu_bind,
&opt.srun_opt->cpu_bind,
&opt.srun_opt->cpu_bind_type))
verified = false;
}

if (opt.hint &&
!validate_hint_option(&opt)) {
xassert(opt.ntasks_per_core == NO_VAL);
Expand Down

0 comments on commit 40a3bf3

Please sign in to comment.