Documentation of MPI examples.
This commit is contained in:
parent
d2816d530a
commit
b92f17fce5
4 changed files with 219 additions and 21 deletions
|
|
@ -1,3 +1,34 @@
|
|||
/*
|
||||
(c) Thales group, 2012
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation;
|
||||
version 2 of the License.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Contact: http://eodev.sourceforge.net
|
||||
|
||||
Authors:
|
||||
Benjamin Bouvier <benjamin.bouvier@gmail.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file shows an example of how to wrap a handler of a job store. Here, the wrapped handler is the "IsFinished"
|
||||
* one. The only function that has been added is that the wrapper prints a message on standard output, indicating what
|
||||
* the wrapped function returns as a result.
|
||||
*
|
||||
* This test is performed on a parallel apply job, the same as in parallelApply. The main difference is when
|
||||
* instanciating the store.
|
||||
*/
|
||||
|
||||
# include <mpi/eoMpi.h>
|
||||
# include <mpi/eoParallelApply.h>
|
||||
# include <mpi/eoTerminateJob.h>
|
||||
|
|
@ -9,6 +40,7 @@ using namespace std;
|
|||
|
||||
using namespace eo::mpi;
|
||||
|
||||
// Job functor.
|
||||
struct plusOne : public eoUF< int&, void >
|
||||
{
|
||||
void operator() ( int & x )
|
||||
|
|
@ -17,6 +49,10 @@ struct plusOne : public eoUF< int&, void >
|
|||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Shows the wrapped result of IsFinished, prints a message and returns the wrapped value.
|
||||
* times is an integer counting how many time the wrapper (hence the wrapped too) has been called.
|
||||
*/
|
||||
template< class EOT >
|
||||
struct ShowWrappedResult : public IsFinishedParallelApply<EOT>
|
||||
{
|
||||
|
|
@ -39,7 +75,6 @@ struct ShowWrappedResult : public IsFinishedParallelApply<EOT>
|
|||
int times;
|
||||
};
|
||||
|
||||
// These tests require at least 3 processes to be launched.
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// eo::log << eo::setlevel( eo::debug );
|
||||
|
|
@ -63,7 +98,11 @@ int main(int argc, char** argv)
|
|||
|
||||
ParallelApplyStore< int > store( plusOneInstance, eo::mpi::DEFAULT_MASTER, 1 );
|
||||
store.data( v );
|
||||
store.wrapIsFinished( new ShowWrappedResult<int> );
|
||||
// This is the only thing which changes: we wrap the IsFinished function.
|
||||
// According to RAII, we'll delete the invokated wrapper at the end of the main ; the store won't delete it
|
||||
// automatically.
|
||||
IsFinishedParallelApply* wrapper = new ShowWrappedResult<int>;
|
||||
store.wrapIsFinished( wrapper );
|
||||
|
||||
ParallelApply<int> job( assign, eo::mpi::DEFAULT_MASTER, store );
|
||||
// Equivalent to:
|
||||
|
|
@ -86,6 +125,8 @@ int main(int argc, char** argv)
|
|||
cout << endl;
|
||||
}
|
||||
|
||||
delete wrapper;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue