From 84c4d6fdc47185057e8da12a5627517bdca33805 Mon Sep 17 00:00:00 2001 From: remicres <remi.cresson@teledetection.fr> Date: Tue, 6 Sep 2016 13:33:05 +0000 Subject: [PATCH] REFAC: MPI related functions now explicitely called in graphOperations --- include/lsgrmGraphOperations.txx | 6 ++++++ include/lsgrmHeader.h | 15 ++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/lsgrmGraphOperations.txx b/include/lsgrmGraphOperations.txx index 1a64a72..203063c 100644 --- a/include/lsgrmGraphOperations.txx +++ b/include/lsgrmGraphOperations.txx @@ -175,7 +175,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy { for(unsigned int col = 0; col < nbTilesX; col++) { +#ifdef OTB_USE_MPI if (MyTurn(row*nbTilesX + col)) +#endif { // Get the current tile std::cout << "Processing tile " << row << ", " << col << std::endl; @@ -252,7 +254,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy { for(unsigned int col = 0; col < nbTilesX; col++) { +#ifdef OTB_USE_MPI if (MyTurn(row*nbTilesX + col)) +#endif { // Get current tile ProcessingTile currentTile = tiles[row*nbTilesX + col]; @@ -653,7 +657,9 @@ long long unsigned int RunFirstPartialSegmentation( { for(unsigned int col = 0; col < nbTilesX; col++) { +#ifdef OTB_USE_MPI if (MyTurn(row*nbTilesX + col)) +#endif { // Reading images ProcessingTile currentTile = tiles[row*nbTilesX + col]; diff --git a/include/lsgrmHeader.h b/include/lsgrmHeader.h index 877da15..35bca3c 100644 --- a/include/lsgrmHeader.h +++ b/include/lsgrmHeader.h @@ -21,27 +21,26 @@ #include "otbImageFileWriter.h" #endif +/* MPI related functions */ + +#ifdef OTB_USE_MPI /* * This function returns TRUE if the process #myrank is assigned * to the task #div in a pool of #nprocs processes */ bool MyTurn(int div = 0) { -#ifdef OTB_USE_MPI otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance(); unsigned int proc = 0; if (mpiConfig->GetNbProcs() != 0) proc = div % mpiConfig->GetNbProcs(); return (proc == mpiConfig->GetMyRank()); -#endif - return true; } /* * This function gather the given value in other process, and update it * TODO: MPI implementation using OTB MPI Wrapper */ -#ifdef OTB_USE_MPI template<typename T> void GatherMe(T& x, MPI_Datatype dataType) { @@ -166,21 +165,17 @@ void BroadcastImage(typename TImageType::Pointer & inPtr) it1.Set(it2.Get()); } } // recopy image - } // while data to transmit } -#endif - /* * Gather accumulatedMemory and isFusion variables * TODO: MPI implementation using OTB MPI Wrapper */ void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFusion) { -#ifdef OTB_USE_MPI otb::MPIConfig::Instance()->barrier(); int isFusionInteger = 0; long long int accumulatedMemoryLLI = static_cast<long long int>(accumulatedMemory); @@ -191,9 +186,11 @@ void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFu accumulatedMemory = static_cast<long long unsigned int>(accumulatedMemoryLLI); if (isFusionInteger>0) isFusion = true; -#endif } + +#endif + /* * Print time elapsed */ -- GitLab