Skip to content

Commit

Permalink
Task/affinity fix for Power7 processor with hyper-threading disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jette committed Dec 13, 2012
1 parent f30736d commit 7913223
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ documents those changes that are of interest to users and admins.
"rack9blade1" should come before "rack10blade1")
-- BGQ - Only poll on initialized blocks instead of calling getBlocks on
each block independently.
-- Fix of task/affinity plugin logic for Power7 processors having hyper-
threading disabled (cpu mask has gaps).

* Changes in SLURM 2.5.0
========================
Expand Down
28 changes: 28 additions & 0 deletions src/plugins/task/affinity/affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,34 @@ int get_cpuset(cpu_set_t *mask, slurmd_job_t *job)
return false;
}

/* Translate global CPU index to local CPU index. This is needed for
* Power7 processors with multi-threading disabled. On those processors,
* the CPU mask has gaps for the unused threads (different from Intel
* processors) which need to be skipped over in the mask used in the
* set system call. */
void reset_cpuset(cpu_set_t *new_mask, cpu_set_t *cur_mask)
{
cpu_set_t newer_mask;
int cur_offset, new_offset = 0, last_set = -1;

CPU_ZERO(&newer_mask);
for (cur_offset = 0; cur_offset < CPU_SETSIZE; cur_offset++) {
if (!CPU_ISSET(cur_offset, cur_mask))
continue;
if (CPU_ISSET(new_offset, new_mask)) {
CPU_SET(cur_offset, &newer_mask);
last_set = cur_offset;
}
new_offset++;
}

CPU_ZERO(new_mask);
for (cur_offset = 0; cur_offset <= last_set; cur_offset++) {
if (CPU_ISSET(cur_offset, &newer_mask))
CPU_SET(cur_offset, new_mask);
}
}

int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask)
{
int rval;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/task/affinity/affinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
/*** from affinity.c ***/
void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval);
int get_cpuset(cpu_set_t *mask, slurmd_job_t *job);
void reset_cpuset(cpu_set_t *new_mask, cpu_set_t *cur_mask);
int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask);
int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask);

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/task/affinity/task_affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ extern int task_pre_launch (slurmd_job_t *job)
pid_t mypid = job->envtp->task_pid;

slurm_getaffinity(mypid, sizeof(cur_mask), &cur_mask);

if (get_cpuset(&new_mask, job) &&
(!(job->cpu_bind_type & CPU_BIND_NONE))) {
reset_cpuset(&new_mask, &cur_mask);
if (conf->task_plugin_param & CPU_BIND_CPUSETS) {
rc = slurm_set_cpuset(base, path, mypid,
sizeof(new_mask),
Expand Down

0 comments on commit 7913223

Please sign in to comment.