Commit 84c4d6fd authored by remicres's avatar remicres
Browse files

REFAC: MPI related functions now explicitely called in graphOperations

Showing with 12 additions and 9 deletions
+12 -9
...@@ -175,7 +175,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy ...@@ -175,7 +175,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy
{ {
for(unsigned int col = 0; col < nbTilesX; col++) for(unsigned int col = 0; col < nbTilesX; col++)
{ {
#ifdef OTB_USE_MPI
if (MyTurn(row*nbTilesX + col)) if (MyTurn(row*nbTilesX + col))
#endif
{ {
// Get the current tile // Get the current tile
std::cout << "Processing tile " << row << ", " << col << std::endl; std::cout << "Processing tile " << row << ", " << col << std::endl;
...@@ -252,7 +254,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy ...@@ -252,7 +254,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy
{ {
for(unsigned int col = 0; col < nbTilesX; col++) for(unsigned int col = 0; col < nbTilesX; col++)
{ {
#ifdef OTB_USE_MPI
if (MyTurn(row*nbTilesX + col)) if (MyTurn(row*nbTilesX + col))
#endif
{ {
// Get current tile // Get current tile
ProcessingTile currentTile = tiles[row*nbTilesX + col]; ProcessingTile currentTile = tiles[row*nbTilesX + col];
...@@ -653,7 +657,9 @@ long long unsigned int RunFirstPartialSegmentation( ...@@ -653,7 +657,9 @@ long long unsigned int RunFirstPartialSegmentation(
{ {
for(unsigned int col = 0; col < nbTilesX; col++) for(unsigned int col = 0; col < nbTilesX; col++)
{ {
#ifdef OTB_USE_MPI
if (MyTurn(row*nbTilesX + col)) if (MyTurn(row*nbTilesX + col))
#endif
{ {
// Reading images // Reading images
ProcessingTile currentTile = tiles[row*nbTilesX + col]; ProcessingTile currentTile = tiles[row*nbTilesX + col];
......
...@@ -21,27 +21,26 @@ ...@@ -21,27 +21,26 @@
#include "otbImageFileWriter.h" #include "otbImageFileWriter.h"
#endif #endif
/* MPI related functions */
#ifdef OTB_USE_MPI
/* /*
* This function returns TRUE if the process #myrank is assigned * This function returns TRUE if the process #myrank is assigned
* to the task #div in a pool of #nprocs processes * to the task #div in a pool of #nprocs processes
*/ */
bool MyTurn(int div = 0) bool MyTurn(int div = 0)
{ {
#ifdef OTB_USE_MPI
otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance(); otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance();
unsigned int proc = 0; unsigned int proc = 0;
if (mpiConfig->GetNbProcs() != 0) if (mpiConfig->GetNbProcs() != 0)
proc = div % mpiConfig->GetNbProcs(); proc = div % mpiConfig->GetNbProcs();
return (proc == mpiConfig->GetMyRank()); return (proc == mpiConfig->GetMyRank());
#endif
return true;
} }
/* /*
* This function gather the given value in other process, and update it * This function gather the given value in other process, and update it
* TODO: MPI implementation using OTB MPI Wrapper * TODO: MPI implementation using OTB MPI Wrapper
*/ */
#ifdef OTB_USE_MPI
template<typename T> template<typename T>
void GatherMe(T& x, MPI_Datatype dataType) void GatherMe(T& x, MPI_Datatype dataType)
{ {
...@@ -166,21 +165,17 @@ void BroadcastImage(typename TImageType::Pointer & inPtr) ...@@ -166,21 +165,17 @@ void BroadcastImage(typename TImageType::Pointer & inPtr)
it1.Set(it2.Get()); it1.Set(it2.Get());
} }
} // recopy image } // recopy image
} // while data to transmit } // while data to transmit
} }
#endif
/* /*
* Gather accumulatedMemory and isFusion variables * Gather accumulatedMemory and isFusion variables
* TODO: MPI implementation using OTB MPI Wrapper * TODO: MPI implementation using OTB MPI Wrapper
*/ */
void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFusion) void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFusion)
{ {
#ifdef OTB_USE_MPI
otb::MPIConfig::Instance()->barrier(); otb::MPIConfig::Instance()->barrier();
int isFusionInteger = 0; int isFusionInteger = 0;
long long int accumulatedMemoryLLI = static_cast<long long int>(accumulatedMemory); long long int accumulatedMemoryLLI = static_cast<long long int>(accumulatedMemory);
...@@ -191,9 +186,11 @@ void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFu ...@@ -191,9 +186,11 @@ void GatherUsefulVariables(unsigned long long int& accumulatedMemory, bool& isFu
accumulatedMemory = static_cast<long long unsigned int>(accumulatedMemoryLLI); accumulatedMemory = static_cast<long long unsigned int>(accumulatedMemoryLLI);
if (isFusionInteger>0) if (isFusionInteger>0)
isFusion = true; isFusion = true;
#endif
} }
#endif
/* /*
* Print time elapsed * Print time elapsed
*/ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment