View | Details | Raw Unified | Return to ticket 688
Collapse All | Expand All

(-)a/src/common/xcgroup_read_config.c (-5 / +11 lines)
Lines 41-46 Link Here
41
#include <pwd.h>
41
#include <pwd.h>
42
#include <stdlib.h>
42
#include <stdlib.h>
43
#include <string.h>
43
#include <string.h>
44
#include <strings.h>
44
#include <time.h>
45
#include <time.h>
45
#include <sys/stat.h>
46
#include <sys/stat.h>
46
#include <sys/types.h>
47
#include <sys/types.h>
Lines 139-145 extern int read_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) Link Here
139
		{"CgroupSubsystems", S_P_STRING},
140
		{"CgroupSubsystems", S_P_STRING},
140
		{"CgroupReleaseAgentDir", S_P_STRING},
141
		{"CgroupReleaseAgentDir", S_P_STRING},
141
		{"ConstrainCores", S_P_BOOLEAN},
142
		{"ConstrainCores", S_P_BOOLEAN},
142
		{"TaskAffinity", S_P_BOOLEAN},
143
		{"TaskAffinity", S_P_STRING},
143
		{"ConstrainRAMSpace", S_P_BOOLEAN},
144
		{"ConstrainRAMSpace", S_P_BOOLEAN},
144
		{"AllowedRAMSpace", S_P_STRING},
145
		{"AllowedRAMSpace", S_P_STRING},
145
		{"MaxRAMPercent", S_P_STRING},
146
		{"MaxRAMPercent", S_P_STRING},
Lines 154-160 extern int read_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) Link Here
154
		{"AllowedDevicesFile", S_P_STRING},
155
		{"AllowedDevicesFile", S_P_STRING},
155
		{NULL} };
156
		{NULL} };
156
	s_p_hashtbl_t *tbl = NULL;
157
	s_p_hashtbl_t *tbl = NULL;
157
	char *conf_path = NULL;
158
	char *conf_path = NULL, *tmp_str = NULL;
158
	struct stat buf;
159
	struct stat buf;
159
160
160
	/* Set initial values */
161
	/* Set initial values */
Lines 206-214 extern int read_slurm_cgroup_conf(slurm_cgroup_conf_t *slurm_cgroup_conf) Link Here
206
		if (!s_p_get_boolean(&slurm_cgroup_conf->constrain_cores,
207
		if (!s_p_get_boolean(&slurm_cgroup_conf->constrain_cores,
207
				     "ConstrainCores", tbl))
208
				     "ConstrainCores", tbl))
208
			slurm_cgroup_conf->constrain_cores = false;
209
			slurm_cgroup_conf->constrain_cores = false;
209
		if (!s_p_get_boolean(&slurm_cgroup_conf->task_affinity,
210
210
				     "TaskAffinity", tbl))
211
		slurm_cgroup_conf->task_affinity = 0;
211
			slurm_cgroup_conf->task_affinity = false;
212
		if (s_p_get_string(&tmp_str, "TaskAffinity", tbl)) {
213
			if (!strcasecmp(tmp_str, "yes"))
214
				slurm_cgroup_conf->task_affinity = 1;
215
			else if (!strcasecmp(tmp_str, "hard"))
216
				slurm_cgroup_conf->task_affinity = 2;
217
		}
212
218
213
		/* RAM and Swap constraints related conf items */
219
		/* RAM and Swap constraints related conf items */
214
		if (!s_p_get_boolean(&slurm_cgroup_conf->constrain_ram_space,
220
		if (!s_p_get_boolean(&slurm_cgroup_conf->constrain_ram_space,
(-)a/src/common/xcgroup_read_config.h (-1 / +1 lines)
Lines 67-73 typedef struct slurm_cgroup_conf { Link Here
67
	char *    cgroup_prepend;
67
	char *    cgroup_prepend;
68
68
69
	bool      constrain_cores;
69
	bool      constrain_cores;
70
	bool      task_affinity;
70
	int       task_affinity;
71
71
72
	bool      constrain_ram_space;
72
	bool      constrain_ram_space;
73
	float     allowed_ram_space;
73
	float     allowed_ram_space;
(-)a/src/plugins/task/cgroup/task_cgroup.c (-2 / +4 lines)
Lines 275-282 extern int task_p_pre_launch (stepd_step_rec_t *job) Link Here
275
275
276
	if (use_cpuset) {
276
	if (use_cpuset) {
277
		/* set affinity if requested */
277
		/* set affinity if requested */
278
		if (slurm_cgroup_conf.task_affinity)
278
		if (slurm_cgroup_conf.task_affinity) {
279
			task_cgroup_cpuset_set_task_affinity(job);
279
			task_cgroup_cpuset_set_task_affinity(
280
				job, slurm_cgroup_conf.task_affinity);
281
		}
280
	}
282
	}
281
283
282
	return SLURM_SUCCESS;
284
	return SLURM_SUCCESS;
(-)a/src/plugins/task/cgroup/task_cgroup_cpuset.c (-13 / +28 lines)
Lines 1086-1092 extern int task_cgroup_cpuset_attach_task(stepd_step_rec_t *job) Link Here
1086
1086
1087
/* affinity should be set using sched_setaffinity to not force */
1087
/* affinity should be set using sched_setaffinity to not force */
1088
/* user to have to play with the cgroup hierarchy to modify it */
1088
/* user to have to play with the cgroup hierarchy to modify it */
1089
extern int task_cgroup_cpuset_set_task_affinity(stepd_step_rec_t *job)
1089
extern int task_cgroup_cpuset_set_task_affinity(stepd_step_rec_t *job,
1090
						int task_affinity)
1090
{
1091
{
1091
	int fstatus = SLURM_ERROR;
1092
	int fstatus = SLURM_ERROR;
1092
1093
Lines 1205-1222 extern int task_cgroup_cpuset_set_task_affinity(stepd_step_rec_t *job) Link Here
1205
1206
1206
	hwtype = HWLOC_OBJ_MACHINE;
1207
	hwtype = HWLOC_OBJ_MACHINE;
1207
	nobj = 1;
1208
	nobj = 1;
1208
	if (npus >= jnpus || bind_type & CPU_BIND_TO_THREADS) {
1209
	if (task_affinity == 2) {
1209
		hwtype = HWLOC_OBJ_PU;
1210
		if (npus >= jnpus || bind_type & CPU_BIND_TO_THREADS) {
1210
		nobj = npus;
1211
			hwtype = HWLOC_OBJ_PU;
1211
	}
1212
			nobj = npus;
1212
	if (ncores >= jnpus || bind_type & CPU_BIND_TO_CORES) {
1213
		} else if (ncores >= jnpus || bind_type & CPU_BIND_TO_CORES) {
1213
		hwtype = HWLOC_OBJ_CORE;
1214
			hwtype = HWLOC_OBJ_CORE;
1214
		nobj = ncores;
1215
			nobj = ncores;
1215
	}
1216
		} else if (nsockets >= jntasks &&
1216
	if (nsockets >= jntasks &&
1217
			   bind_type & CPU_BIND_TO_SOCKETS) {
1217
	    bind_type & CPU_BIND_TO_SOCKETS) {
1218
			hwtype = socket_or_node;
1218
		hwtype = socket_or_node;
1219
			nobj = nsockets;
1219
		nobj = nsockets;
1220
		}
1221
	} else {
1222
		if (npus >= jnpus || bind_type & CPU_BIND_TO_THREADS) {
1223
			hwtype = HWLOC_OBJ_PU;
1224
			nobj = npus;
1225
		}
1226
		if (ncores >= jnpus || bind_type & CPU_BIND_TO_CORES) {
1227
			hwtype = HWLOC_OBJ_CORE;
1228
			nobj = ncores;
1229
		}
1230
		if (nsockets >= jntasks &&
1231
		    bind_type & CPU_BIND_TO_SOCKETS) {
1232
			hwtype = socket_or_node;
1233
			nobj = nsockets;
1234
		}
1220
	}
1235
	}
1221
	/*
1236
	/*
1222
	 * HWLOC returns all the NUMA nodes available regardless of the
1237
	 * HWLOC returns all the NUMA nodes available regardless of the
(-)a/src/plugins/task/cgroup/task_cgroup_cpuset.h (-1 / +2 lines)
Lines 56-61 extern int task_cgroup_cpuset_create(stepd_step_rec_t *job); Link Here
56
extern int task_cgroup_cpuset_attach_task(stepd_step_rec_t *job);
56
extern int task_cgroup_cpuset_attach_task(stepd_step_rec_t *job);
57
57
58
/* set a task affinity based on its local id and job information */
58
/* set a task affinity based on its local id and job information */
59
extern int task_cgroup_cpuset_set_task_affinity(stepd_step_rec_t *job);
59
extern int task_cgroup_cpuset_set_task_affinity(stepd_step_rec_t *job,
60
	int task_affinity);
60
61
61
#endif
62
#endif

Return to ticket 688