MPI distrib exp: added managment of multiples distributions.
This commit is contained in:
parent
7c3eee4ddd
commit
c4af81caeb
1 changed files with 33 additions and 10 deletions
|
|
@ -154,31 +154,54 @@ int main( int argc, char** argv )
|
||||||
Node::init( argc, argv );
|
Node::init( argc, argv );
|
||||||
eoParser parser( argc, argv );
|
eoParser parser( argc, argv );
|
||||||
|
|
||||||
// TODO for each available distribution, check if activated.
|
// General parameters for the experimentation
|
||||||
|
unsigned size = parser.createParam( 10U, "size", "Number of elements to distribute.", 's', "Distribution").value();
|
||||||
|
unsigned packet_size = parser.createParam( 1U, "packet_size", "Number of elements to distribute at each time for a single worker.", 'p', "Parallelization").value();
|
||||||
|
|
||||||
|
std::vector<Distribution*> distribs;
|
||||||
|
distribs.push_back( &uniformDistribution );
|
||||||
|
distribs.push_back( &normalDistribution );
|
||||||
|
|
||||||
|
// for each available distribution, check if activated.
|
||||||
// If no distribution is activated, show an error message
|
// If no distribution is activated, show an error message
|
||||||
// If two distributions or more are activated, show an error message
|
// If two distributions or more are activated, show an error message
|
||||||
// Otherwise, use the activated distribution as distrib
|
// Otherwise, use the activated distribution as distrib
|
||||||
Distribution & distrib = uniformDistribution;
|
bool isChosenDistrib = false;
|
||||||
// Make parser of distribution here
|
Distribution* pdistrib = 0;
|
||||||
distrib.make_parser( parser );
|
for( int i = 0, s = distribs.size(); i < s; ++i )
|
||||||
|
{
|
||||||
unsigned size = parser.createParam( 10U, "size", "Number of elements to distribute.", 's', "Distribution").value();
|
distribs[i]->make_parser( parser );
|
||||||
unsigned packet_size = parser.createParam( 1U, "packet_size", "Number of elements to distribute at each time for a single worker.", 'p', "Parallelization").value();
|
if( distribs[i]->isActive() )
|
||||||
|
{
|
||||||
|
if( isChosenDistrib )
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Only one distribution can be chosen during a launch!");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
isChosenDistrib = true;
|
||||||
|
pdistrib = distribs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
make_parallel( parser );
|
make_parallel( parser );
|
||||||
make_help( parser );
|
make_help( parser );
|
||||||
|
|
||||||
ParallelApplyStore< type> store( wait, DEFAULT_MASTER, packet_size );
|
if( !isChosenDistrib )
|
||||||
|
{
|
||||||
|
throw std::runtime_error("No distribution chosen. One distribution should be chosen.");
|
||||||
|
}
|
||||||
|
|
||||||
// Fill distribution
|
// Fill distribution
|
||||||
|
Distribution& distrib = *pdistrib;
|
||||||
distrib.fill( size );
|
distrib.fill( size );
|
||||||
store.data( distrib );
|
|
||||||
|
|
||||||
|
ParallelApplyStore< type > store( wait, DEFAULT_MASTER, packet_size );
|
||||||
|
store.data( distrib );
|
||||||
DynamicAssignmentAlgorithm scheduling;
|
DynamicAssignmentAlgorithm scheduling;
|
||||||
ParallelApply< type > job( scheduling, DEFAULT_MASTER, store );
|
ParallelApply< type > job( scheduling, DEFAULT_MASTER, store );
|
||||||
|
|
||||||
job.run();
|
job.run();
|
||||||
|
|
||||||
if( job.isMaster() )
|
if( job.isMaster() )
|
||||||
{
|
{
|
||||||
EmptyJob( scheduling, DEFAULT_MASTER ); // to terminate parallel apply
|
EmptyJob( scheduling, DEFAULT_MASTER ); // to terminate parallel apply
|
||||||
|
|
|
||||||
Reference in a new issue