Commit 84c4d6fd authored by remicres's avatar remicres

REFAC: MPI related functions now explicitely called in graphOperations

parent 0c3ae789
......@@ -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];
......
......@@ -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
*/
......
Markdown is supported
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