functor operator applying to population in parallel

This commit is contained in:
Caner Candan 2010-11-17 14:43:18 +01:00
commit ad1ec3669d
3 changed files with 10 additions and 2 deletions

View file

@ -44,6 +44,12 @@ ENABLE_LANGUAGE(C)
### 2) Include required modules / configuration files
#####################################################################################
FIND_PACKAGE(OpenMP REQUIRED)
IF(OPENMP_FOUND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS}")
ENDIF()
INCLUDE(CMakeBackwardCompatibilityCXX)
INCLUDE(FindDoxygen)

View file

@ -51,9 +51,9 @@ with a member like: operator()(eoPop<EOT>). Once called on a given population, i
search for the optimum of a given problem.
Generally, operators are instanciated once and then binded in an algorithm by reference.
Thus, you can easily build you own algorithm by trying several combination of operators.
Thus, you can easily build your own algorithm by trying several combination of operators.
For an more detailled introduction to the design of %EO you can look at the
For a more detailled introduction to the design of %EO you can look at the
slides from a talk at EA 2001 or at the corresponding
article in Lecture Notes In Computer Science, 2310, Selected Papers from the 5th European Conference on Artificial Evolution:
- http://portal.acm.org/citation.cfm?id=727742

View file

@ -37,8 +37,10 @@
template <class EOT>
void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
{
#pragma omp parallel for default(none) shared(_proc, _pop)
for (unsigned i = 0; i < _pop.size(); ++i)
{
#pragma omp critical
_proc(_pop[i]);
}
}