MPI Distrib Exp: launch experiments from a file + example file.
This commit is contained in:
parent
bd9767a05d
commit
57dcd01149
2 changed files with 73 additions and 38 deletions
6
eo/test/mpi/experiments.json
Normal file
6
eo/test/mpi/experiments.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"experiments":[
|
||||||
|
{"size":"10", "packet_size":"1", "seed":"1337", "distribution":{"name":"normal", "mean":"500", "stddev":"100"}, "worker_print_waiting_time":"1", "filename":""}
|
||||||
|
{"size":"10", "packet_size":"1", "seed":"1337", "distribution":{"name":"normal", "mean":"100", "stddev":"20"}, "worker_print_waiting_time":"1", "filename":"exp2.result.txt"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -292,7 +292,7 @@ class Experiment : public eoserial::Persistent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Experiment() : _distribution(0), _fileName("")
|
Experiment() : _distribution(0), _worker_print_waiting_time( false ), _fileName("")
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
@ -312,8 +312,8 @@ class Experiment : public eoserial::Persistent
|
||||||
{
|
{
|
||||||
eoserial::Object* obj = new eoserial::Object;
|
eoserial::Object* obj = new eoserial::Object;
|
||||||
obj->add( "size", eoserial::make( _size ) );
|
obj->add( "size", eoserial::make( _size ) );
|
||||||
obj->add( "packet-size", eoserial::make( _packet_size ) );
|
obj->add( "packet_size", eoserial::make( _packet_size ) );
|
||||||
obj->add( "worker-print-waiting-time", eoserial::make( _worker_print_waiting_time ) );
|
obj->add( "worker_print_waiting_time", eoserial::make( _worker_print_waiting_time ) );
|
||||||
obj->add( "seed", eoserial::make( _seed ) );
|
obj->add( "seed", eoserial::make( _seed ) );
|
||||||
if( _distribution )
|
if( _distribution )
|
||||||
{
|
{
|
||||||
|
|
@ -326,8 +326,8 @@ class Experiment : public eoserial::Persistent
|
||||||
void unpack( const eoserial::Object* obj )
|
void unpack( const eoserial::Object* obj )
|
||||||
{
|
{
|
||||||
eoserial::unpack( *obj, "size", _size );
|
eoserial::unpack( *obj, "size", _size );
|
||||||
eoserial::unpack( *obj, "packet-size", _packet_size );
|
eoserial::unpack( *obj, "packet_size", _packet_size );
|
||||||
eoserial::unpack( *obj, "worker-print-waiting-time", _worker_print_waiting_time );
|
eoserial::unpack( *obj, "worker_print_waiting_time", _worker_print_waiting_time );
|
||||||
eoserial::unpack( *obj, "seed", _seed );
|
eoserial::unpack( *obj, "seed", _seed );
|
||||||
eoserial::unpack( *obj, "filename", _fileName );
|
eoserial::unpack( *obj, "filename", _fileName );
|
||||||
|
|
||||||
|
|
@ -432,7 +432,7 @@ int main( int argc, char** argv )
|
||||||
eoParser parser( argc, argv );
|
eoParser parser( argc, argv );
|
||||||
|
|
||||||
// forces the statistics to be retrieved
|
// forces the statistics to be retrieved
|
||||||
parser.setORcreateParam( true, "parallelize-do-measure", "Do some measures during execution" );
|
eo::mpi::timerStat.forceDoMeasure();
|
||||||
|
|
||||||
// General parameters for the experimentation
|
// General parameters for the experimentation
|
||||||
unsigned size = parser.createParam( 10U, "size", "Number of elements to distribute.", 's', "Distribution").value();
|
unsigned size = parser.createParam( 10U, "size", "Number of elements to distribute.", 's', "Distribution").value();
|
||||||
|
|
@ -441,6 +441,11 @@ int main( int argc, char** argv )
|
||||||
unsigned seed = parser.createParam( 0U, "seed", "Seed of random generator", '\0', "General").value();
|
unsigned seed = parser.createParam( 0U, "seed", "Seed of random generator", '\0', "General").value();
|
||||||
std::string fileName = parser.createParam( std::string(""), "filename", "File name to which redirect the results (for a single experiment)", '\0', "General").value();
|
std::string fileName = parser.createParam( std::string(""), "filename", "File name to which redirect the results (for a single experiment)", '\0', "General").value();
|
||||||
|
|
||||||
|
bool useExperimentFile = parser.createParam( false, "use-experiment-file", "Put to true if you want to launch experiments from a file formatted in JSON (see experiment-file).", '\0', "General").value();
|
||||||
|
std::string experimentFile = parser.createParam( std::string("experiments.json"), "experiment-file", "File name of experiments to provide, in format JSON.", '\0', "General").value();
|
||||||
|
|
||||||
|
if( !useExperimentFile )
|
||||||
|
{
|
||||||
std::vector<Distribution*> distribs;
|
std::vector<Distribution*> distribs;
|
||||||
distribs.push_back( &uniformDistribution );
|
distribs.push_back( &uniformDistribution );
|
||||||
distribs.push_back( &normalDistribution );
|
distribs.push_back( &normalDistribution );
|
||||||
|
|
@ -477,12 +482,36 @@ int main( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
Experiment e( pdistrib, size, packet_size, worker_print_waiting_time, seed, fileName );
|
Experiment e( pdistrib, size, packet_size, worker_print_waiting_time, seed, fileName );
|
||||||
eoserial::Object* obj = e.pack();
|
|
||||||
obj->print( std::cout );
|
|
||||||
delete obj;
|
|
||||||
std::cout << '\n' << std::endl;
|
|
||||||
|
|
||||||
e.run();
|
e.run();
|
||||||
|
}
|
||||||
|
else // use experiments file
|
||||||
|
{
|
||||||
|
// read content of file
|
||||||
|
std::ifstream file( experimentFile.c_str() );
|
||||||
|
std::string fileContent;
|
||||||
|
while( file )
|
||||||
|
{
|
||||||
|
char temp[4096];
|
||||||
|
file.getline( temp, 4096, '\n' );
|
||||||
|
fileContent += temp;
|
||||||
|
fileContent += '\n';
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
// transform content into array of experiments
|
||||||
|
eoserial::Object* wrapper = eoserial::Parser::parse( fileContent );
|
||||||
|
eoserial::Array& experiments = *static_cast< eoserial::Array* >( wrapper->find("experiments")->second );
|
||||||
|
|
||||||
|
for( unsigned i = 0, s = experiments.size(); i < s; ++i )
|
||||||
|
{
|
||||||
|
std::cout << "Launching experiment " << (i+1) << "..." << std::endl;
|
||||||
|
eoserial::Object* expObj = static_cast< eoserial::Object* >( experiments[i] );
|
||||||
|
Experiment exp;
|
||||||
|
exp.unpack( expObj );
|
||||||
|
exp.run();
|
||||||
|
}
|
||||||
|
delete wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue