From ad1ec3669de3a0657d5a49e274b42ad18cf457be Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Wed, 17 Nov 2010 14:43:18 +0100 Subject: [PATCH] functor operator applying to population in parallel --- eo/CMakeLists.txt | 6 ++++++ eo/doc/index.h | 4 ++-- eo/src/apply.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/eo/CMakeLists.txt b/eo/CMakeLists.txt index eea4df29..07becc2b 100644 --- a/eo/CMakeLists.txt +++ b/eo/CMakeLists.txt @@ -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) diff --git a/eo/doc/index.h b/eo/doc/index.h index 7d7921fe..2fad16e2 100644 --- a/eo/doc/index.h +++ b/eo/doc/index.h @@ -51,9 +51,9 @@ with a member like: operator()(eoPop). 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 diff --git a/eo/src/apply.h b/eo/src/apply.h index 0eb3484e..049983fe 100644 --- a/eo/src/apply.h +++ b/eo/src/apply.h @@ -37,8 +37,10 @@ template void apply(eoUF& _proc, std::vector& _pop) { +#pragma omp parallel for default(none) shared(_proc, _pop) for (unsigned i = 0; i < _pop.size(); ++i) { +#pragma omp critical _proc(_pop[i]); } }