Merge branch 'openmp' of ssh://eodev.git.sourceforge.net/gitroot/eodev/eodev into openmp

This commit is contained in:
Caner Candan 2011-03-08 00:20:37 +01:00
commit 9597010673
5 changed files with 94 additions and 7 deletions

View file

@ -44,7 +44,12 @@ void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
#ifdef _OPENMP
double t1 = omp_get_wtime();
double t1 = 0;
if ( eo::parallel.enableResults() )
{
t1 = omp_get_wtime();
}
if (!eo::parallel.isDynamic())
{
@ -59,10 +64,12 @@ void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
for (size_t i = 0; i < size; ++i) { _proc(_pop[i]); }
}
double t2 = omp_get_wtime();
eoLogger log;
log << eo::file(eo::parallel.prefix()) << t2 - t1 << ' ';
if ( eo::parallel.enableResults() )
{
double t2 = omp_get_wtime();
eoLogger log;
log << eo::file(eo::parallel.prefix()) << t2 - t1 << ' ';
}
#else // _OPENMP

View file

@ -28,13 +28,30 @@ Caner Candan <caner.candan@thalesgroup.com>
#include <omp.h>
#include "eoParallel.h"
#include "eoLogger.h"
eoParallel::eoParallel() :
_isEnabled( false, "parallelize-loop", "Enable memory shared parallelization into evaluation's loops", '\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' ),
_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' ),
_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
{
@ -71,6 +88,8 @@ void eoParallel::_createParameters( eoParser& parser )
parser.processParam( _isDynamic, section );
parser.processParam( _prefix, section );
parser.processParam( _nthreads, section );
parser.processParam( _enableResults, section );
parser.processParam( _doMeasure, section );
}
void make_parallel(eoParser& parser)
@ -85,6 +104,11 @@ void make_parallel(eoParser& parser)
omp_set_num_threads( eo::parallel.nthreads() );
}
}
if ( eo::parallel.doMeasure() )
{
eo::parallel._t_start = omp_get_wtime();
}
#endif // !_OPENMP
}

View file

@ -44,6 +44,7 @@ class eoParallel : public eoObject
{
public:
eoParallel();
~eoParallel();
virtual std::string className() const;
@ -54,6 +55,9 @@ public:
inline unsigned int nthreads() const { return _nthreads.value(); }
inline bool enableResults() const { return _enableResults.value(); }
inline bool doMeasure() const { return _doMeasure.value(); }
friend void make_parallel(eoParser&);
private:
@ -64,6 +68,9 @@ private:
eoValueParam<bool> _isDynamic;
eoValueParam<std::string> _prefix;
eoValueParam<unsigned int> _nthreads;
eoValueParam<bool> _enableResults;
eoValueParam<bool> _doMeasure;
double _t_start;
};
void make_parallel(eoParser&);

View file

@ -1,3 +1,29 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
/*
(c) Thales group, 2010
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:
Caner Candan <caner.candan@thalesgroup.com>
*/
//-----------------------------------------------------------------------------
// t-openmp.cpp
//-----------------------------------------------------------------------------

View file

@ -1,5 +1,28 @@
#!/usr/bin/env python
#
# (c) Thales group, 2010
#
# 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:
# Caner Candan <caner.candan@thalesgroup.com>
#
import optparse, logging, sys, os
from datetime import datetime