2004-01-17 23:07:40 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-17 23:07:40 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
#include "ompi_config.h"
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-03-18 21:35:28 +00:00
|
|
|
#include "include/constants.h"
|
2005-07-04 00:13:44 +00:00
|
|
|
#include "opal/util/cmd_line.h"
|
|
|
|
#include "opal/util/argv.h"
|
2005-07-04 01:36:20 +00:00
|
|
|
#include "opal/util/opal_environ.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mca/base/base.h"
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private variables
|
|
|
|
*/
|
|
|
|
static int mca_param_argc = 0;
|
|
|
|
static char **mca_param_argv = NULL;
|
|
|
|
static int mca_value_argc = 0;
|
|
|
|
static char **mca_value_argv = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add -mca to the possible command line options list
|
|
|
|
*/
|
2005-07-04 00:13:44 +00:00
|
|
|
int mca_base_cmd_line_setup(opal_cmd_line_t *cmd)
|
2004-01-17 23:07:40 +00:00
|
|
|
{
|
2005-07-04 00:13:44 +00:00
|
|
|
return opal_cmd_line_make_opt3(cmd, '\0', "mca", "mca", 2,
|
2005-03-18 03:43:59 +00:00
|
|
|
"General mechanism to pass MCA parameters");
|
2004-01-17 23:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for and handle any -mca options on the command line
|
|
|
|
*/
|
2005-07-04 00:13:44 +00:00
|
|
|
int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd,
|
While waiting for fortran compiles...
Fixes for orterun in handling different MCA params for different
processes (reviewed by Brian):
- By design, if you run the following:
mpirun --mca foo aaa --mca foo bbb a.out
a.out will get a single MCA param for foo with value "aaa,bbb".
- However, if you specify multiple apps with different values for the
same MCA param, you should expect to get the different values for
each app. For example:
mpirun --mca foo aaa a.out : --mca foo bbb b.out
Should yield a.out with a "foo" param with value "aaa" and b.out
with a "foo" param with a value "bbb".
- This did not work -- both a.out and b.out would get a "foo" with
"aaa,bbb".
- This commit fixes this behavior -- now a.out will get aaa and b.out
will get bbb.
- Additionally, if you mix --mca and and app file, you can have
"global" params and per-line-in-the-appfile params. For example:
mpirun --mca foo zzzz --app appfile
where "appfile" contains:
-np 1 --mca bar aaa a.out
-np 1 --mca bar bbb b.out
In this case, a.out will get foo=zzzz and bar=aaa, and b.out will
get foo=zzzz and bar=bbb.
Spiffy.
Ok, fortran build is done... back to Fortran... sigh...
This commit was SVN r5710.
2005-05-13 14:36:36 +00:00
|
|
|
char ***env)
|
2004-01-17 23:07:40 +00:00
|
|
|
{
|
|
|
|
int i, num_insts;
|
While waiting for fortran compiles...
Fixes for orterun in handling different MCA params for different
processes (reviewed by Brian):
- By design, if you run the following:
mpirun --mca foo aaa --mca foo bbb a.out
a.out will get a single MCA param for foo with value "aaa,bbb".
- However, if you specify multiple apps with different values for the
same MCA param, you should expect to get the different values for
each app. For example:
mpirun --mca foo aaa a.out : --mca foo bbb b.out
Should yield a.out with a "foo" param with value "aaa" and b.out
with a "foo" param with a value "bbb".
- This did not work -- both a.out and b.out would get a "foo" with
"aaa,bbb".
- This commit fixes this behavior -- now a.out will get aaa and b.out
will get bbb.
- Additionally, if you mix --mca and and app file, you can have
"global" params and per-line-in-the-appfile params. For example:
mpirun --mca foo zzzz --app appfile
where "appfile" contains:
-np 1 --mca bar aaa a.out
-np 1 --mca bar bbb b.out
In this case, a.out will get foo=zzzz and bar=aaa, and b.out will
get foo=zzzz and bar=bbb.
Spiffy.
Ok, fortran build is done... back to Fortran... sigh...
This commit was SVN r5710.
2005-05-13 14:36:36 +00:00
|
|
|
char *name;
|
|
|
|
|
|
|
|
/* First, wipe out any previous results */
|
|
|
|
|
|
|
|
if (mca_param_argc > 0) {
|
2005-07-04 00:13:44 +00:00
|
|
|
opal_argv_free(mca_param_argv);
|
|
|
|
opal_argv_free(mca_value_argv);
|
While waiting for fortran compiles...
Fixes for orterun in handling different MCA params for different
processes (reviewed by Brian):
- By design, if you run the following:
mpirun --mca foo aaa --mca foo bbb a.out
a.out will get a single MCA param for foo with value "aaa,bbb".
- However, if you specify multiple apps with different values for the
same MCA param, you should expect to get the different values for
each app. For example:
mpirun --mca foo aaa a.out : --mca foo bbb b.out
Should yield a.out with a "foo" param with value "aaa" and b.out
with a "foo" param with a value "bbb".
- This did not work -- both a.out and b.out would get a "foo" with
"aaa,bbb".
- This commit fixes this behavior -- now a.out will get aaa and b.out
will get bbb.
- Additionally, if you mix --mca and and app file, you can have
"global" params and per-line-in-the-appfile params. For example:
mpirun --mca foo zzzz --app appfile
where "appfile" contains:
-np 1 --mca bar aaa a.out
-np 1 --mca bar bbb b.out
In this case, a.out will get foo=zzzz and bar=aaa, and b.out will
get foo=zzzz and bar=bbb.
Spiffy.
Ok, fortran build is done... back to Fortran... sigh...
This commit was SVN r5710.
2005-05-13 14:36:36 +00:00
|
|
|
mca_param_argv = mca_value_argv = NULL;
|
|
|
|
mca_param_argc = mca_value_argc = 0;
|
|
|
|
}
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
/* If no "-mca" parameters were given, just return */
|
|
|
|
|
2005-07-04 00:13:44 +00:00
|
|
|
if (!opal_cmd_line_is_taken(cmd, "mca")) {
|
2005-03-18 03:43:59 +00:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
/* Otherwise, assemble them into an argc/argv */
|
|
|
|
|
2005-07-04 00:13:44 +00:00
|
|
|
num_insts = opal_cmd_line_get_ninsts(cmd, "mca");
|
2005-03-18 03:43:59 +00:00
|
|
|
for (i = 0; i < num_insts; ++i) {
|
2005-07-04 00:13:44 +00:00
|
|
|
mca_base_cmd_line_process_arg(opal_cmd_line_get_param(cmd, "mca", i, 0),
|
|
|
|
opal_cmd_line_get_param(cmd, "mca", i, 1));
|
2005-03-18 03:43:59 +00:00
|
|
|
}
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
/* Now put that argc/argv in the environment */
|
|
|
|
|
2005-03-18 03:43:59 +00:00
|
|
|
if (NULL == mca_param_argv) {
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-01-17 23:07:40 +00:00
|
|
|
|
|
|
|
/* Loop through all the -mca args that we've gotten and make env
|
2004-08-09 15:40:40 +00:00
|
|
|
vars of the form OMPI_MCA_*=value. This is a memory leak, but
|
2004-01-17 23:07:40 +00:00
|
|
|
that's how putenv works. :-( */
|
|
|
|
|
|
|
|
for (i = 0; NULL != mca_param_argv[i]; ++i) {
|
2005-03-18 03:43:59 +00:00
|
|
|
name = mca_base_param_environ_variable(mca_param_argv[i], NULL, NULL);
|
2005-07-04 01:36:20 +00:00
|
|
|
opal_setenv(name, mca_value_argv[i], true, env);
|
2005-03-18 03:43:59 +00:00
|
|
|
free(name);
|
2004-01-17 23:07:40 +00:00
|
|
|
}
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-17 23:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process a single MCA argument. Done as a separate function so that
|
|
|
|
* top-level applications can directly invoke this to effect MCA
|
|
|
|
* command line arguments.
|
|
|
|
*/
|
2004-01-20 23:58:51 +00:00
|
|
|
int mca_base_cmd_line_process_arg(const char *param, const char *value)
|
2004-01-17 23:07:40 +00:00
|
|
|
{
|
2005-05-12 18:56:05 +00:00
|
|
|
int i;
|
2004-01-17 23:07:40 +00:00
|
|
|
char *new_str;
|
|
|
|
|
|
|
|
/* Look to see if we've already got an -mca argument for the same
|
|
|
|
param. Check against the list of MCA param's that we've already
|
|
|
|
saved arguments for. */
|
|
|
|
|
|
|
|
for (i = 0; NULL != mca_param_argv && NULL != mca_param_argv[i]; ++i) {
|
|
|
|
if (0 == strcmp(param, mca_param_argv[i])) {
|
2005-05-12 18:56:05 +00:00
|
|
|
asprintf(&new_str, "%s,%s", mca_value_argv[i], value);
|
2004-02-10 00:09:36 +00:00
|
|
|
free(mca_value_argv[i]);
|
2004-01-17 23:07:40 +00:00
|
|
|
mca_value_argv[i] = new_str;
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-17 23:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't already have an value for the same param, save this
|
|
|
|
one away */
|
|
|
|
|
2005-07-04 00:13:44 +00:00
|
|
|
opal_argv_append(&mca_param_argc, &mca_param_argv, param);
|
|
|
|
opal_argv_append(&mca_value_argc, &mca_value_argv, value);
|
2004-01-17 23:07:40 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-17 23:07:40 +00:00
|
|
|
}
|