* eoParallel: added the both parameters enable_results and do_measure
This commit is contained in:
parent
7add23931b
commit
9e95eefb52
3 changed files with 35 additions and 5 deletions
|
|
@ -44,7 +44,12 @@ void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
|
|
||||||
double t1 = omp_get_wtime();
|
double t1 = 0;
|
||||||
|
|
||||||
|
if ( eo::parallel.enableResults() )
|
||||||
|
{
|
||||||
|
t1 = omp_get_wtime();
|
||||||
|
}
|
||||||
|
|
||||||
if (!eo::parallel.isDynamic())
|
if (!eo::parallel.isDynamic())
|
||||||
{
|
{
|
||||||
|
|
@ -59,10 +64,9 @@ void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
|
||||||
for (size_t i = 0; i < size; ++i) { _proc(_pop[i]); }
|
for (size_t i = 0; i < size; ++i) { _proc(_pop[i]); }
|
||||||
}
|
}
|
||||||
|
|
||||||
double t2 = omp_get_wtime();
|
|
||||||
|
|
||||||
if ( eo::parallel.enableResults() )
|
if ( eo::parallel.enableResults() )
|
||||||
{
|
{
|
||||||
|
double t2 = omp_get_wtime();
|
||||||
eoLogger log;
|
eoLogger log;
|
||||||
log << eo::file(eo::parallel.prefix()) << t2 - t1 << ' ';
|
log << eo::file(eo::parallel.prefix()) << t2 - t1 << ' ';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,30 @@ Caner Candan <caner.candan@thalesgroup.com>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
|
||||||
#include "eoParallel.h"
|
#include "eoParallel.h"
|
||||||
|
#include "eoLogger.h"
|
||||||
|
|
||||||
eoParallel::eoParallel() :
|
eoParallel::eoParallel() :
|
||||||
_isEnabled( false, "parallelize-loop", "Enable memory shared parallelization into evaluation's loops", '\0' ),
|
_isEnabled( false, "parallelize-loop", "Enable memory shared parallelization into evaluation's loops", '\0' ),
|
||||||
_isDynamic( false, "parallelize-dynamic", "Enable dynamic memory shared parallelization", '\0' ),
|
_isDynamic( false, "parallelize-dynamic", "Enable dynamic memory shared parallelization", '\0' ),
|
||||||
_prefix( "results", "parallelize-prefix", "Here's the prefix filename where the results are going to be stored", '\0' ),
|
_prefix( "results", "parallelize-prefix", "Here's the prefix filename where the results are going to be stored", '\0' ),
|
||||||
_nthreads( 0, "parallelize-nthreads", "Define the number of threads you want to use, nthreads = 0 means you want to use all threads available", '\0' ),
|
_nthreads( 0, "parallelize-nthreads", "Define the number of threads you want to use, nthreads = 0 means you want to use all threads available", '\0' ),
|
||||||
_enableResults( false, "parallelize-enable-results", "Enable the generation of results", '\0' )
|
_enableResults( false, "parallelize-enable-results", "Enable the generation of results", '\0' ),
|
||||||
{}
|
_doMeasure( false, "parallelize-do-measure", "Do some measures during execution", '\0' ),
|
||||||
|
_t_start(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
eoParallel::~eoParallel()
|
||||||
|
{
|
||||||
|
#ifdef _OPENMP
|
||||||
|
if ( doMeasure() )
|
||||||
|
{
|
||||||
|
double _t_end = omp_get_wtime();
|
||||||
|
eoLogger log;
|
||||||
|
log << eo::file("measure_" + prefix()) << _t_end - _t_start << std::endl;
|
||||||
|
}
|
||||||
|
#endif // !_OPENMP
|
||||||
|
}
|
||||||
|
|
||||||
std::string eoParallel::className() const
|
std::string eoParallel::className() const
|
||||||
{
|
{
|
||||||
|
|
@ -73,6 +89,7 @@ void eoParallel::_createParameters( eoParser& parser )
|
||||||
parser.processParam( _prefix, section );
|
parser.processParam( _prefix, section );
|
||||||
parser.processParam( _nthreads, section );
|
parser.processParam( _nthreads, section );
|
||||||
parser.processParam( _enableResults, section );
|
parser.processParam( _enableResults, section );
|
||||||
|
parser.processParam( _doMeasure, section );
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_parallel(eoParser& parser)
|
void make_parallel(eoParser& parser)
|
||||||
|
|
@ -87,6 +104,11 @@ void make_parallel(eoParser& parser)
|
||||||
omp_set_num_threads( eo::parallel.nthreads() );
|
omp_set_num_threads( eo::parallel.nthreads() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( eo::parallel.doMeasure() )
|
||||||
|
{
|
||||||
|
eo::parallel._t_start = omp_get_wtime();
|
||||||
|
}
|
||||||
#endif // !_OPENMP
|
#endif // !_OPENMP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ class eoParallel : public eoObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
eoParallel();
|
eoParallel();
|
||||||
|
~eoParallel();
|
||||||
|
|
||||||
virtual std::string className() const;
|
virtual std::string className() const;
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ public:
|
||||||
inline unsigned int nthreads() const { return _nthreads.value(); }
|
inline unsigned int nthreads() const { return _nthreads.value(); }
|
||||||
|
|
||||||
inline bool enableResults() const { return _enableResults.value(); }
|
inline bool enableResults() const { return _enableResults.value(); }
|
||||||
|
inline bool doMeasure() const { return _doMeasure.value(); }
|
||||||
|
|
||||||
friend void make_parallel(eoParser&);
|
friend void make_parallel(eoParser&);
|
||||||
|
|
||||||
|
|
@ -67,6 +69,8 @@ private:
|
||||||
eoValueParam<std::string> _prefix;
|
eoValueParam<std::string> _prefix;
|
||||||
eoValueParam<unsigned int> _nthreads;
|
eoValueParam<unsigned int> _nthreads;
|
||||||
eoValueParam<bool> _enableResults;
|
eoValueParam<bool> _enableResults;
|
||||||
|
eoValueParam<bool> _doMeasure;
|
||||||
|
double _t_start;
|
||||||
};
|
};
|
||||||
|
|
||||||
void make_parallel(eoParser&);
|
void make_parallel(eoParser&);
|
||||||
|
|
|
||||||
Reference in a new issue