Skip to content

Commit

Permalink
Merged in modifications to allow histogram creation during MPI runs s…
Browse files Browse the repository at this point in the history
…o overviews and histograms are done all at once
  • Loading branch information
Garrett Potts committed Dec 19, 2019
1 parent 8359638 commit fae9533
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 147 deletions.
3 changes: 1 addition & 2 deletions apps/ossim-img2rr/ossim-img2rr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,7 @@ int main(int argc, char* argv[])
bool singlePassHistoFlag = true;
if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN )
{
if ( ( ossimMpi::instance()->getNumberOfProcessors() > 1) ||
( ih->hasOverviews() && histoR0Flag ) ||
if ( ( ih->hasOverviews() && histoR0Flag ) ||
( !ossim::isnan(histoMin) ) ||
( !ossim::isnan(histoMax) ) ||
( histoBins ) ||
Expand Down
2 changes: 2 additions & 0 deletions include/ossim/imaging/ossimOverviewSequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ class OSSIM_DLL ossimOverviewSequencer

/** @brief Clears out the arrays from a scan for min, max, nulls. */
void clearMinMaxNullArrays();

virtual void populateStats(ossimRefPtr<ossimImageData> tile);

ossimRefPtr<ossimImageHandler> m_imageHandler;
ossimRefPtr<ossimBitMaskWriter> m_maskWriter;
Expand Down
52 changes: 28 additions & 24 deletions src/imaging/ossimOverviewSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,30 +361,6 @@ ossimRefPtr<ossimImageData> ossimOverviewSequencer::getNextTile()
}
else if ( inputTile.valid() )
{
if ( m_scanForMinMaxNull )
{
inputTile->computeMinMaxNulPix(m_minValues, m_maxValues, m_nulValues);
}
else if ( m_scanForMinMax )
{
inputTile->computeMinMaxPix(m_minValues, m_maxValues);
}

if ( ( m_histoMode != OSSIM_HISTO_MODE_UNKNOWN ) &&
( (m_currentTileNumber % m_histoTileIndex) == 0 ) )
{
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "ossimOverviewSequencer::getNextTile DEBUG:"
<< "\npopulating histogram for tile: " << m_currentTileNumber
<< "\n";
}
ossimIrect tileRect = inputTile->getImageRectangle();
ossimIrect clipRect = tileRect.clipToRect( m_areaOfInterest );
inputTile->populateHistogram(m_histogram, clipRect);
}

if ( (inputTile->getDataObjectStatus() == OSSIM_PARTIAL) ||
(inputTile->getDataObjectStatus() == OSSIM_FULL ) )
{
Expand All @@ -395,6 +371,7 @@ ossimRefPtr<ossimImageData> ossimOverviewSequencer::getNextTile()
// Scan the resampled pixels for bogus values to be masked out (if masking enabled)
if (m_maskWriter.valid())
m_maskWriter->generateMask(m_tile, m_sourceResLevel+1);
populateStats(m_tile);
}
}
else
Expand Down Expand Up @@ -465,6 +442,33 @@ void ossimOverviewSequencer::clearMinMaxNullArrays()
m_nulValues.clear();
}

void ossimOverviewSequencer::populateStats(ossimRefPtr<ossimImageData> tile)
{
if (m_scanForMinMaxNull)
{
tile->computeMinMaxNulPix(m_minValues, m_maxValues, m_nulValues);
}
else if (m_scanForMinMax)
{
tile->computeMinMaxPix(m_minValues, m_maxValues);
}

if ((m_histoMode != OSSIM_HISTO_MODE_UNKNOWN) &&
((m_currentTileNumber % m_histoTileIndex) == 0))
{
if (traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "ossimOverviewSequencer::populateStats DEBUG:"
<< "\npopulating histogram for tile: " << m_currentTileNumber
<< "\n";
}
ossimIrect tileRect = tile->getImageRectangle();
ossimIrect clipRect = tileRect.clipToRect(m_areaOfInterest);
tile->populateHistogram(m_histogram, clipRect);
}
}

bool ossimOverviewSequencer::writeOmdFile(const std::string& file)
{
static const char M[] = "ossimOverviewSequencer::writeOmdFile";
Expand Down
33 changes: 13 additions & 20 deletions src/imaging/ossimTiffOverviewBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,7 @@ bool ossimTiffOverviewBuilder::writeRn( ossimImageHandler* imageHandler,

if ( getHistogramMode() != OSSIM_HISTO_MODE_UNKNOWN )
{
// Accumulate a histogram. Can't do with mpi/multi-process.
if(ossimMpi::instance()->getNumberOfProcessors() == 1)
{
sequencer->setHistogramMode(getHistogramMode());
}
sequencer->setHistogramMode(getHistogramMode());
//---
// else{} Not sure if we want an error thrown here. For now will handle at the
// application level.
Expand Down Expand Up @@ -851,23 +847,20 @@ bool ossimTiffOverviewBuilder::writeRn( ossimImageHandler* imageHandler,

if ( firstResLevel )
{
if ( ossimMpi::instance()->getNumberOfProcessors() == 1 )
if ( getHistogramMode() != OSSIM_HISTO_MODE_UNKNOWN )
{
if ( getHistogramMode() != OSSIM_HISTO_MODE_UNKNOWN )
{
// Write the histogram.
ossimFilename histoFilename = getOutputFile();
histoFilename.setExtension("his");
sequencer->writeHistogram(histoFilename);
}
// Write the histogram.
ossimFilename histoFilename = getOutputFile();
histoFilename.setExtension("his");
sequencer->writeHistogram(histoFilename);
}

if ( ( getScanForMinMaxNull() == true ) || ( getScanForMinMax() == true ) )
{
// Write the omd file:
ossimFilename file = getOutputFile();
file = file.setExtension("omd");
sequencer->writeOmdFile(file);
}
if ( ( getScanForMinMaxNull() == true ) || ( getScanForMinMax() == true ) )
{
// Write the omd file:
ossimFilename file = getOutputFile();
file = file.setExtension("omd");
sequencer->writeOmdFile(file);
}
}

Expand Down
107 changes: 7 additions & 100 deletions src/parallel/ossimImageMpiSWriterSequenceConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,103 +215,6 @@ void ossimImageMpiSWriterSequenceConnection::slaveProcessTiles()
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
#if 0
switch(theOutputTile[currentSendRequest]->getScalarType())
{
case OSSIM_UINT8:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_UNSIGNED_CHAR,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_SINT8:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_CHAR,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_UINT16:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_UNSIGNED_SHORT,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_SINT16:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_SHORT,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_UINT32:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_UNSIGNED_LONG,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_SINT32:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_LONG,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_FLOAT32:
case OSSIM_NORMALIZED_FLOAT:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_FLOAT,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
case OSSIM_FLOAT64:
case OSSIM_NORMALIZED_DOUBLE:
{
errorValue = MPI_Isend(buf,
theOutputTile[currentSendRequest]->getSize(),
MPI_DOUBLE,
0,
0,
MPI_COMM_WORLD,
&requests[currentSendRequest]);
break;
}
default:
break;
}
#endif
theCurrentTileNumber += (theNumberOfProcessors-1);
//numberOfTilesSent++;
currentSendRequest++;
Expand All @@ -322,11 +225,15 @@ void ossimImageMpiSWriterSequenceConnection::slaveProcessTiles()
//
while(tempCount < theNumberOfTilesToBuffer)
{
// if (requests[currentSendRequest] != MPI_REQUEST_NULL)
// {
errorValue = MPI_Wait(&requests[currentSendRequest], MPI_STATUS_IGNORE);
currentSendRequest++;
currentSendRequest %= theNumberOfTilesToBuffer;

requests[currentSendRequest] = MPI_REQUEST_NULL;
++tempCount;
// }
//errorValue = MPI_Wait(&requests[currentSendRequest], MPI_STATUS_IGNORE);
currentSendRequest++;
currentSendRequest %= theNumberOfTilesToBuffer;
}

// MPI_Waitall(theNumberOfTilesToBuffer,
Expand Down
5 changes: 4 additions & 1 deletion src/parallel/ossimMpiMasterOverviewSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ ossimRefPtr<ossimImageData> ossimMpiMasterOverviewSequencer::getNextTile()

// Set the tile status.
m_tile->validate();

if(m_tile->getDataObjectStatus() != OSSIM_EMPTY)
{
populateStats(m_tile.get());
}
// Increment the tile index.
++m_currentTileNumber;

Expand Down

0 comments on commit fae9533

Please sign in to comment.