From fd2facb14e06440d53034766f162086831fa17f1 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 21 Jun 2012 15:03:41 +0200 Subject: [PATCH] Moved mpi related files into mpi/ and compiling it as an extern library. --- eo/src/CMakeLists.txt | 5 +++-- eo/src/apply.h | 4 ++-- eo/src/mpi/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++ eo/src/{ => mpi}/eoParallelApply.h | 4 ---- eo/src/{ => mpi}/eompi.cpp | 0 eo/src/{ => mpi}/eompi.h | 0 eo/test/t-eoMpiParallelApply.cpp | 4 ++-- 7 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 eo/src/mpi/CMakeLists.txt rename eo/src/{ => mpi}/eoParallelApply.h (83%) rename eo/src/{ => mpi}/eompi.cpp (100%) rename eo/src/{ => mpi}/eompi.h (100%) diff --git a/eo/src/CMakeLists.txt b/eo/src/CMakeLists.txt index 3d46be7a..caeb673a 100644 --- a/eo/src/CMakeLists.txt +++ b/eo/src/CMakeLists.txt @@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ###################################################################################### -### 2) Optionnal: add MPI and Boost MPI dependencies. +### 2) Optional: add MPI and Boost MPI dependencies. ###################################################################################### IF(WITH_MPI) @@ -25,6 +25,8 @@ IF(WITH_MPI) ADD_DEFINITIONS(-DWITH_MPI) LINK_LIBRARIES(boost_mpi boost_serialization) + + ADD_SUBDIRECTORY(mpi) ENDIF() ###################################################################################### @@ -41,7 +43,6 @@ SET(EO_SOURCES eoCtrlCContinue.cpp eoScalarFitnessAssembled.cpp eoSIGContinue.cpp - eompi.cpp ) ADD_LIBRARY(eo STATIC ${EO_SOURCES}) diff --git a/eo/src/apply.h b/eo/src/apply.h index c01ac574..d2006fe0 100644 --- a/eo/src/apply.h +++ b/eo/src/apply.h @@ -34,8 +34,8 @@ #include # ifdef WITH_MPI -# include -# include +# include +# include # endif // WITH_MPI /** diff --git a/eo/src/mpi/CMakeLists.txt b/eo/src/mpi/CMakeLists.txt new file mode 100644 index 00000000..c770acd1 --- /dev/null +++ b/eo/src/mpi/CMakeLists.txt @@ -0,0 +1,32 @@ +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +###################################################################################### +### 2) Define the eompi target +###################################################################################### + +SET(EOMPI_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib) +SET(LIBRARY_OUTPUT_PATH ${EOMPI_LIB_OUTPUT_PATH}) + +SET(EOMPI_SOURCES + eompi.cpp + ) + +ADD_LIBRARY(eompi STATIC ${EOMPI_SOURCES}) +INSTALL(TARGETS eompi ARCHIVE DESTINATION lib COMPONENT libraries) + +FILE(GLOB HDRS *.h) +INSTALL(FILES ${HDRS} DESTINATION include/eo/mpi COMPONENT headers) + +###################################################################################### +### 3) Optionnal +###################################################################################### + +SET(EOMPI_VERSION ${GLOBAL_VERSION}) +SET_TARGET_PROPERTIES(eompi PROPERTIES VERSION "${EOMPI_VERSION}") + +###################################################################################### diff --git a/eo/src/eoParallelApply.h b/eo/src/mpi/eoParallelApply.h similarity index 83% rename from eo/src/eoParallelApply.h rename to eo/src/mpi/eoParallelApply.h index 6a7c6eaa..528d0cb2 100644 --- a/eo/src/eoParallelApply.h +++ b/eo/src/mpi/eoParallelApply.h @@ -31,13 +31,9 @@ class ParallelApply : public MpiJob< EOT > virtual void processTask( ) { EOT ind; - cout << "Receiving individual." << endl; MpiJob::comm.recv( 0, 1, ind ); - cout << "Applying function." << endl; func( ind ); - cout << "Sending result." << endl; MpiJob::comm.send( 0, 1, ind ); - cout << "Leaving processTask" << endl; } protected: diff --git a/eo/src/eompi.cpp b/eo/src/mpi/eompi.cpp similarity index 100% rename from eo/src/eompi.cpp rename to eo/src/mpi/eompi.cpp diff --git a/eo/src/eompi.h b/eo/src/mpi/eompi.h similarity index 100% rename from eo/src/eompi.h rename to eo/src/mpi/eompi.h diff --git a/eo/test/t-eoMpiParallelApply.cpp b/eo/test/t-eoMpiParallelApply.cpp index 77583420..c20cc94f 100644 --- a/eo/test/t-eoMpiParallelApply.cpp +++ b/eo/test/t-eoMpiParallelApply.cpp @@ -1,5 +1,5 @@ -# include -# include +# include +# include # include # include