Please re-read my prior email (MCA parameters are not always set as environment
variables):
https://www.mail-archive.com/[email protected]/msg19958.html
If you want to read the value of MCA parameters in MPI applications, you should
be using the MPI_T API. That will work regardless of whether you pass MCA
parameters on the mpirun command line, in the openmpi-mca-params.conf file, or
other mechanism.
> On Feb 24, 2017, at 1:36 PM, Dahai Guo <[email protected]> wrote:
>
> Basically, I like to set apath in the param conf file, and let OMPI broadcast
> it to each MPI rank.
>
> In the following example, it prints the value as NULL, if I just set it in
> the conf file. So My question is how to update some ompi base code to make it
> right?
>
> If I set it in mpirun -mca apath=sth, I can update a bit "setup_folk" and
> get it right for each rank.
>
> Dahai
>
>
> #include <stdlib.h>
> #include <math.h>
> #include <stdio.h>
> #include <mpi.h>
>
> int main(int argc, char *argv[] )
> {
>
> int provided, rank, Size, ierr;
>
> ierr=MPI_Init_thread(&argc,&argv,MPI_THREAD_FUNNELED, &provided);
> ierr=MPI_Comm_rank(MPI_COMM_WORLD, &rank);
> ierr=MPI_Comm_size(MPI_COMM_WORLD, &Size);
>
> char *value = getenv("OMPI_MCA_apath");
>
> printf(" --- Hi from rank = %d, path0 = %s \n", rank, value );
>
> ierr=MPI_Barrier(MPI_COMM_WORLD);
> ierr=MPI_Finalize();
>
> return 0;
> }
>
>
> From: Jeff Squyres (jsquyres) <[email protected]>
> To: Dahai Guo <[email protected]>; Open MPI Developers List
> <[email protected]>
> Cc: Dahai Guo <[email protected]>
> Sent: Friday, February 24, 2017 12:27 PM
> Subject: Re: [OMPI devel] define a new ENV variable in
> etc/openmpi-mca-params.conf
>
> It's still not clear what you're trying to do.
>
> Are you setting an MCA parameter, or are you trying to forward arbitrary
> environment variables? Are you working in MPI processes (or executables
> launched by MPI processes), or in the Open MPI code base itself?
>
> Also, Ralph and I chatted: what he said is not correct for the v2.x series
> (my original answer was correct). We think what Ralph said may have been
> true in prior releases, but without further detailed information on what
> you're trying to do, we didn't dig any further.
>
>
>
>
> > On Feb 24, 2017, at 11:35 AM, Dahai Guo via devel
> > <[email protected]> wrote:
> >
> >
> > I need this parameter used in my other codes related to ompi,
> > do I need to register "OMPI_MCA_apath" in some codes in OMPI? if so,
> > usually in which codes?
> >
> > Dahai
> >
> >
> >
> >
> > From: "[email protected]" <[email protected]>
> > To: OpenMPI Devel <[email protected]>
> > Sent: Friday, February 24, 2017 9:44 AM
> > Subject: Re: [OMPI devel] define a new ENV variable in
> > etc/openmpi-mca-params.conf
> >
> > I think Jeff got lost in the weeds here. If you define a new MCA param in
> > the default param file, we will automatically pick it up and it will be in
> > the environment of your application. You don’t need to do anything.
> > However, you checked for the wrong envar. Anything you provide is going to
> > have an “OMPI_MCA_” attached to the front of it. So for your “apath”
> > example, the envar will be
> >
> > OMPI_MCA_apath
> >
> > HTH
> > Ralph
> >
> > > On Feb 24, 2017, at 7:25 AM, Jeff Squyres (jsquyres) <[email protected]>
> > > wrote:
> > >
> > > On Feb 24, 2017, at 10:11 AM, Dahai Guo <[email protected]> wrote:
> > >>
> > >> oops, I should use the word "MCA parameters". If I define a MCA
> > >> parameter (apath, for example) in etc/openmpi-mca-params.conf, how can
> > >> function setup_fork in ompi/orte/mca/schizo/ompi/schizo_ompi.c get its
> > >> value? I tried to call getenv("apath") there, which return null.
> > >
> > > Settings MCA parameters does not necessarily set environment variables.
> > > More below.
> > >
> > >> However, If I defined it in the cmd line, mpirun -mca apath=sth .., then
> > >> I could get it in setup_fork.
> > >
> > > There are multiple mechanisms in which MCA params are passed to the
> > > back-end MPI processes.
> > >
> > > 1. If they are set via "--mca a b" on the mpirun command line, they are
> > > passed back to the launching orteds as part of the launch schema for the
> > > job. I.e., the MCA param names and values are bundled up and sent in the
> > > network message to each of the orteds that are involved in the launching
> > > of the target processes. IIRC, the launching orteds will fork, setenv a
> > > corresponding environment variable for each of the MCA param values in
> > > the launch schema, and then exec the MPI process. The MPI process then
> > > picks up those MCA param values from the environment variables.
> > >
> > > 2. If they are set via the openmpi-mca-params.conf file, they are not
> > > sent via network message in the launch schema. Instead, each Open MPI
> > > process (including MPI processes and orteds) reads that file upon startup
> > > to get the values (more specifically: all Open MPI processes *always*
> > > read this file before processing whatever MCA param values are sent in
> > > the launch schema). A consequence: if openmpi-mca-params.conf is not on
> > > a network filesystem (and visible to all Open MPI processes on all
> > > servers), you need to copy the change you made to the one
> > > openmpi-mca-params.conf file to all copies of openmpi-mca-params.conf.
> > >
> > > -----
> > >
> > > What are you trying to do?
> > >
> > > If you're working in an MPI application, you can use the MPI_T API to
> > > retrieve MCA parameter names and their current values (regardless of
> > > whether mechanism #1 or #2 -- or another mechanism -- is used).
> > >
> > > If you're working in the Open MPI code base, you should be using the
> > > internal opal_mca_var API to retrieve and/or set MCA param values. See
> > > https://github.com/open-mpi/ompi/blob/master/opal/mca/base/mca_base_var.h
> > > for all the functions available in this API.
> > >
> > > --
> > > Jeff Squyres
> > > [email protected]
> >
> > >
> > > _______________________________________________
> > > devel mailing list
> > > [email protected]
> > > https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
> >
> > _______________________________________________
> > devel mailing list
> > [email protected]
> > https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
> >
> > _______________________________________________
> > devel mailing list
> > [email protected]
> > https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
>
>
>
> --
> Jeff Squyres
> [email protected]
>
>
>
--
Jeff Squyres
[email protected]
_______________________________________________
devel mailing list
[email protected]
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel