Beispiel #1
0
/*
 * Test if OMPI_MCA_btl_openib_if_include should be set to global device ID or a
 * device ID that always starts at zero (based upon what the application can see).
 * RET true if TaskPlugin=task/cgroup AND ConstrainDevices=yes (in cgroup.conf).
 */
static bool _use_local_device_index(void)
{
	slurm_cgroup_conf_t slurm_cgroup_conf;
	char *task_plugin = slurm_get_task_plugin();
	bool use_cgroup = false, use_local_index = false;

	if (!task_plugin)
		return use_local_index;

	if (strstr(task_plugin, "cgroup"))
		use_cgroup = true;
	xfree(task_plugin);
	if (!use_cgroup)
		return use_local_index;

	/* Read and parse cgroup.conf */
	bzero(&slurm_cgroup_conf, sizeof(slurm_cgroup_conf_t));
	if (read_slurm_cgroup_conf(&slurm_cgroup_conf) != SLURM_SUCCESS)
		return use_local_index;
	if (slurm_cgroup_conf.constrain_devices)
		use_local_index = true;
	free_slurm_cgroup_conf(&slurm_cgroup_conf);

	return use_local_index;
}
Beispiel #2
0
/*
 * Initialize the task plugin.
 *
 * RET - slurm error code
 */
extern int slurmd_task_init(void)
{
	int retval = SLURM_SUCCESS;
	char *task_plugin_type = NULL;

	slurm_mutex_lock( &g_task_context_lock );

	if ( g_task_context )
		goto done;

	task_plugin_type = slurm_get_task_plugin();
	g_task_context = _slurmd_task_context_create( task_plugin_type );
	if ( g_task_context == NULL ) {
		error( "cannot create task context for %s",
			 task_plugin_type );
		retval = SLURM_ERROR;
		goto done;
	}

	if ( _slurmd_task_get_ops( g_task_context ) == NULL ) {
		error( "cannot resolve task plugin operations" );
		_slurmd_task_context_destroy( g_task_context );
		g_task_context = NULL;
		retval = SLURM_ERROR;
	}

 done:
	slurm_mutex_unlock( &g_task_context_lock );
	xfree(task_plugin_type);
	return retval;
}
Beispiel #3
0
static bool _have_task_affinity(void)
{
	bool rc = true;
	char *plugin_name = slurm_get_task_plugin();

	if (plugin_name && !strcmp(plugin_name, "task/none"))
		rc = false;
	xfree(plugin_name);
	return rc;
}
Beispiel #4
0
/*
 * Initialize the task plugin.
 *
 * RET - slurm error code
 */
extern int slurmd_task_init(void)
{
	int retval = SLURM_SUCCESS, i;
	char *task_plugin_type = NULL;
	char *last = NULL, *task_plugin_list, *task_plugin = NULL;

	slurm_mutex_lock( &g_task_context_lock );

	if ( g_task_context_num >= 0 )
		goto done;

	task_plugin_type = slurm_get_task_plugin();
	g_task_context_num = 0; /* mark it before anything else */
	if (task_plugin_type == NULL || task_plugin_type[0] == '\0')
		goto done;

	task_plugin_list = task_plugin_type;
	while ((task_plugin = strtok_r(task_plugin_list, ",", &last))) {
		i = g_task_context_num++;
		xrealloc(g_task_context,
			 (sizeof(slurmd_task_context_t *) * g_task_context_num));
		if (strncmp(task_plugin, "task/", 5) == 0)
			task_plugin += 5; /* backward compatibility */
		task_plugin = xstrdup_printf("task/%s", task_plugin);
		g_task_context[i] = _slurmd_task_context_create( task_plugin );
		if ( g_task_context[i] == NULL ) {
			error( "cannot create task context for %s",
				 task_plugin );
			goto error;
		}

		if ( _slurmd_task_get_ops( g_task_context[i] ) == NULL ) {
			error( "cannot resolve task plugin operations for %s",
			       task_plugin );
			goto error;
		}
		xfree(task_plugin);
		task_plugin_list = NULL; /* for next iteration */
	}

 done:
	slurm_mutex_unlock( &g_task_context_lock );
	xfree(task_plugin_type);
	return retval;

error:
	xfree(task_plugin);
	retval = SLURM_ERROR;
	for (i = 0; i < g_task_context_num; i++)
		if (g_task_context[i])
			_slurmd_task_context_destroy(g_task_context[i]);
	xfree(g_task_context);
	g_task_context_num = -1;
	goto done;
}
Beispiel #5
0
extern bool check_corespec_cgroup_job_confinement(void)
{
	char *task_plugin_type = NULL;
	bool status = false;

	if (read_slurm_cgroup_conf(&slurm_cgroup_conf))
		return false;
	task_plugin_type = slurm_get_task_plugin();
	if (slurm_cgroup_conf.constrain_cores &&
	    strstr(task_plugin_type, "cgroup"))
		status = true;
	xfree(task_plugin_type);
	free_slurm_cgroup_conf(&slurm_cgroup_conf);
	return status;
}
/*
 * init() is called when the plugin is loaded, before any other functions
 *	are called.  Put global initialization here.
 */
extern int init (void)
{
	debug("%s loaded.", plugin_name);

	char *task_plugin = slurm_get_task_plugin();
	char *task_cgroup = strstr(task_plugin, "cgroup");
	char *task_cray = strstr(task_plugin, "cray");

	if (!task_cgroup || !task_cray || task_cgroup < task_cray)
		fatal("task/cgroup must be used with, and listed after, "
		      "task/cray in TaskPlugin");

	xfree(task_plugin);

#ifdef HAVE_NATIVE_CRAY
	int rc;
	struct stat st;

	debug_flags = slurm_get_debug_flags();

	// Create the run directory
	errno = 0;
	rc = mkdir(TASK_CRAY_RUN_DIR, 0755);
	if (rc == -1 &&	errno != EEXIST) {
		CRAY_ERR("Couldn't create %s: %m", TASK_CRAY_RUN_DIR);
		return SLURM_ERROR;
	}

	// Determine whether to track app status with LLI
	rc = stat(LLI_SPOOL_DIR, &st);
	if (rc == -1) {
		debug("stat %s failed, disabling exit status tracking: %m",
			LLI_SPOOL_DIR);
		track_status = 0;
	} else {
		track_status = 1;
	}
#endif

	return SLURM_SUCCESS;
}