Open MPI logo

MTT Devel Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: Re: [MTT devel] [MTT svn] svn:mtt-svn r1377
From: Mike Dubman (mike.ompi_at_[hidden])
Date: 2011-01-03 08:21:08


Hi,
it is c-style *switch* replacement, to simplify statements like this:

transport = &if (&eq('@cycle@', '1'), '@btl_openib@' ,\
                     &if (&eq('@cycle@', '2'), '@btl_openib@',\
                       &if (&eq('@cycle@', '3'), '@btl_eth10g@',\
                         &if (&eq('@cycle@', '4'), '@btl_eth10g@',\
                           &if (&eq('@cycle@', '3a'), '@btl_eth10g@ -x
custom_noswitchconnect=1',\
                             &if (&eq('@cycle@', '4a'), '@btl_eth10g@ -x
custom_noswitchconnect=1',\
                               &if (&eq('@cycle@', '5'), '@btl_eth10g@',\
                                 &if (&eq('@cycle@', '6'), '@btl_eth10g@',\
                                   &if (&eq('@cycle@', '7'), '@btl_eth10g@
',\
                                     &if (&eq('@cycle@', '8'), '@btl_eth10g@
',\
                                       &if (&eq('@cycle@', '11'),
'@btl_eth10g@',\
                                         &if (&eq('@cycle@', '12'),
'@btl_eth10g@',\
                                           '@btl_rdmaoe@'\
                                         )\
                                       )\
                                     )\
                                   )\
                                 )\
                               )\
                             )\
                           )\
                         )\
                       )\
                    )\
                  )

which can be rewritten as:

transport = mtt_switch(@cycle@, 1, @btl_openib@, 2, @btl_eth10g@, ...)

Will update wiki as well.

Regards

On Mon, Jan 3, 2011 at 2:54 PM, Jeff Squyres <jsquyres_at_[hidden]> wrote:

> Mike --
>
> Can you explain this one a little? I don't understand the example you gave
> in the comment.
>
> Also, are you adding all the new funclets to the wiki documentation?
>
>
>
> On Dec 29, 2010, at 3:52 AM, miked_at_[hidden] wrote:
>
> > Author: miked
> > Date: 2010-12-29 03:52:24 EST (Wed, 29 Dec 2010)
> > New Revision: 1377
> > URL: https://svn.open-mpi.org/trac/mtt/changeset/1377
> >
> > Log:
> > added mtt_switch to simplify if-then-else cases in ini files
> >
> > Text files modified:
> > trunk/lib/MTT/Values/Functions.pm | 21 +++++++++++++++++++++
> > 1 files changed, 21 insertions(+), 0 deletions(-)
> >
> > Modified: trunk/lib/MTT/Values/Functions.pm
> >
> ==============================================================================
> > --- trunk/lib/MTT/Values/Functions.pm (original)
> > +++ trunk/lib/MTT/Values/Functions.pm 2010-12-29 03:52:24 EST (Wed, 29
> Dec 2010)
> > @@ -3163,4 +3163,25 @@
> > return $x->{result_stdout};
> > }
> >
> > +#
> > +# Poor man switch statement
> > +# Example: mtt_switch(@np@, 9, "return1", 100, return2", "default", 0);
> > +#
> > +
> > +sub mtt_switch
> > +{
> > + my ($var, %cases) = @_;
> > +
> > + if ($cases{$var}) {
> > + return $cases{$var};
> > + }
> > +
> > + if ($cases{'default'}) {
> > + return $cases{'default'};
> > + }
> > +
> > + Debug("ERROR: Not found case for $var\n");
> > +}
> > +
> > +
> > 1;
> > _______________________________________________
> > mtt-svn mailing list
> > mtt-svn_at_[hidden]
> > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn
>
>
> --
> Jeff Squyres
> jsquyres_at_[hidden]
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>