Ejemplo n.º 1
0
extern int switch_init( void )
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "switch";
	char *type = NULL;

	if ( init_run && g_context )
		return retval;

	slurm_mutex_lock( &context_lock );

	if ( g_context )
		goto done;

	type = slurm_get_switch_type();
	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock( &context_lock );
	xfree(type);
	return retval;
}
Ejemplo n.º 2
0
static void
_job_init_task_info(stepd_step_rec_t *job, uint32_t **gtid,
		    char *ifname, char *ofname, char *efname)
{
	int          i, node_id = job->nodeid;
	char        *in, *out, *err;

	if (job->node_tasks == 0) {
		error("User requested launch of zero tasks!");
		job->task = NULL;
		return;
	}

#if defined(HAVE_NATIVE_CRAY)
	for (i = 0; i < job->nnodes; i++) {
		int j;
		for (j = 1; j < job->task_cnts[i]; j++) {
			if (gtid[i][j] != gtid[i][j-1] + 1) {
				job->non_smp = 1;
				break;
			}
		}
	}
#endif

	job->task = (stepd_step_task_info_t **)
		xmalloc(job->node_tasks * sizeof(stepd_step_task_info_t *));

	if (((job->flags & LAUNCH_MULTI_PROG) == 0) && job->argv) {
		char *new_path = build_path(job->argv[0], job->env, job->cwd);
		xfree(job->argv[0]);
		job->argv[0] = new_path;
	}

	for (i = 0; i < job->node_tasks; i++) {
		in = _expand_stdio_filename(ifname, gtid[node_id][i], job);
		out = _expand_stdio_filename(ofname, gtid[node_id][i], job);
		err = _expand_stdio_filename(efname, gtid[node_id][i], job);
		job->task[i] = task_info_create(i, gtid[node_id][i], in, out,
						err);
		if ((job->flags & LAUNCH_MULTI_PROG) == 0) {
			job->task[i]->argc = job->argc;
			job->task[i]->argv = job->argv;
		}
	}

	if (job->flags & LAUNCH_MULTI_PROG) {
		char *switch_type = slurm_get_switch_type();
		if (!xstrcmp(switch_type, "switch/cray"))
			multi_prog_parse(job, gtid);
		xfree(switch_type);
		for (i = 0; i < job->node_tasks; i++){
			multi_prog_get_argv(job->argv[1], job->env,
					    gtid[node_id][i],
					    &job->task[i]->argc,
					    &job->task[i]->argv,
					    job->argc, job->argv);
		}
	}
}
Ejemplo n.º 3
0
static void
_job_init_task_info(stepd_step_rec_t *job, uint32_t **gtid,
		    char *ifname, char *ofname, char *efname)
{
	int          i, node_id = job->nodeid;
	char        *in, *out, *err;

	if (job->node_tasks == 0) {
		error("User requested launch of zero tasks!");
		job->task = NULL;
		return;
	}

	job->task = (stepd_step_task_info_t **)
		xmalloc(job->node_tasks * sizeof(stepd_step_task_info_t *));

	for (i = 0; i < job->node_tasks; i++){
		in = _expand_stdio_filename(ifname, gtid[node_id][i], job);
		out = _expand_stdio_filename(ofname, gtid[node_id][i], job);
		err = _expand_stdio_filename(efname, gtid[node_id][i], job);
		job->task[i] = task_info_create(i, gtid[node_id][i], in, out,
						err);
		if (!job->multi_prog) {
			job->task[i]->argc = job->argc;
			job->task[i]->argv = job->argv;
		}
	}

	if (job->multi_prog) {
		char *switch_type = slurm_get_switch_type();
		if (!strcmp(switch_type, "switch/cray"))
			multi_prog_parse(job, gtid);
		xfree(switch_type);
		for (i = 0; i < job->node_tasks; i++){
			multi_prog_get_argv(job->argv[1], job->env,
					    gtid[node_id][i],
					    &job->task[i]->argc,
					    &job->task[i]->argv,
					    job->argc, job->argv);
		}
	}
}
Ejemplo n.º 4
0
extern int switch_init(bool only_default)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "switch";
	char *switch_type = NULL;
	int i, j, plugin_cnt;
	List plugin_names = NULL;
	_plugin_args_t plugin_args = {0};

	if ( init_run && switch_context )
		return retval;

	slurm_mutex_lock( &context_lock );

	if ( switch_context )
		goto done;

	switch_context_cnt = 0;

	switch_type = slurm_get_switch_type();

	plugin_args.plugin_type    = plugin_type;
	plugin_args.default_plugin = switch_type;

	if (only_default) {
		plugin_names = list_create(slurm_destroy_char);
		list_append(plugin_names, xstrdup(switch_type));
	} else {
		plugin_names = plugin_get_plugins_of_type(plugin_type);
	}
	if (plugin_names && (plugin_cnt = list_count(plugin_names))) {
		ops = xmalloc(sizeof(slurm_switch_ops_t) * plugin_cnt);
		switch_context = xmalloc(sizeof(plugin_context_t *) *
					 plugin_cnt);

		list_for_each(plugin_names, _load_plugins, &plugin_args);
	}


	if (switch_context_default == -1)
		fatal("Can't find plugin for %s", switch_type);

	/* Insure that plugin_id is valid and unique */
	for (i = 0; i < switch_context_cnt; i++) {
		for (j = i+1; j < switch_context_cnt; j++) {
			if (*(ops[i].plugin_id) !=
			    *(ops[j].plugin_id))
				continue;
			fatal("switchPlugins: Duplicate plugin_id %u for "
			      "%s and %s",
			      *(ops[i].plugin_id),
			      switch_context[i]->type,
			      switch_context[j]->type);
		}
		if (*(ops[i].plugin_id) < 100) {
			fatal("switchPlugins: Invalid plugin_id %u (<100) %s",
			      *(ops[i].plugin_id),
			      switch_context[i]->type);
		}
	}

	init_run = true;

done:
	slurm_mutex_unlock( &context_lock );
	xfree(switch_type);
	FREE_NULL_LIST(plugin_names);

	return retval;
}