modifié : include/ArrayTree/ArrayTreeBuilder.tpp

modifié :         include/TreeStats.hpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/TreeStats.cpp
This commit is contained in:
Git Merciol 2018-03-16 14:11:36 +01:00
parent 9ac0b5b752
commit 952f2ddea5
4 changed files with 42 additions and 9 deletions

View File

@ -57,15 +57,22 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
default:
cerr << "*** unknown tree type: " << treeType << endl;
}
globalTreeStats.addTime (buildTreeStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
globalTreeStats.addDim (treeType, leafCount, nodeCount-leafCount);
weightAttributes.setWeightBounds (tree);
leaders.free ();
newCompId = nullptr;
auto startChildren = high_resolution_clock::now ();
buildChildren ();
childCount = nullptr;
auto end = high_resolution_clock::now ();
globalTreeStats.addTime (buildTreeStats, duration_cast<duration<double> > (startChildren-start).count ());
globalTreeStats.addTime (buildChildrenStats, duration_cast<duration<double> > (end-start).count ());
globalTreeStats.addDim (treeType, leafCount, nodeCount-leafCount);
leaders.free ();
newCompId = nullptr;
weightAttributes.setWeightBounds (tree);
SMART_LOG (tree.printTree ());
}
@ -102,6 +109,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
coreCount = tree.getCoreCount ();
// buildParents
auto start = high_resolution_clock::now ();
vector<Edge<WeightT> > allEdges (graphWalker.edgeMaxCount ());
vector<Rect> tiles;
vector<Rect> boundaries;
@ -123,6 +131,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
tileEdges [i] = &allEdges[edgesMaxBounds[i]];
compBases [i] = compTops [i] = vertexMaxBounds [i];
}
auto startParent = high_resolution_clock::now ();
dealThreadRange (tileCount, coreCount, [this, &tileEdges, &weightFunct, &tiles, &compTops] (DimImg threadId) {
buildParents (tileEdges [threadId], weightFunct, tiles [threadId], compTops [threadId]);
});
@ -133,6 +142,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
<< printMap (compWeights, size, 0) << endl << endl
<< tree.printTree (2*leafCount-1));
// merge sub-tree
auto startMerge = high_resolution_clock::now ();
DimImg compCount = compTops [0];
DimImg *topC = NULL;
DimImg compBase = vertexMaxBounds[tileCount];
@ -180,6 +190,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
<< printMap (compWeights, size, 0) << endl << endl
<< tree.printTree (2*leafCount-1));
// compress
auto startIndex = high_resolution_clock::now ();
DimImg maxUsed = max (compTops[tileCount-1], topC != NULL ? *topC : 0);
dealThreadFill_n (maxUsed, coreCount, newCompId, DimImg_MAX);
@ -190,6 +201,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
SMART_LOG ("updateNewId:" << endl
<< printMap (newCompId, size, 0) << endl << endl);
auto startCompress = high_resolution_clock::now ();
compress (maxUsed);
SMART_LOG ("compress:" << endl
<< printMap (newCompId, size, 0) << endl << endl);
@ -207,6 +219,12 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
SMART_LOG ("compWeights:" << endl
<< printMap (compWeights, size, 0) << endl << endl);
auto end = high_resolution_clock::now ();
globalTreeStats.addTime (buildSetupStats, duration_cast<duration<double> > (startParent-start).count ());
globalTreeStats.addTime (buildParentsStats, duration_cast<duration<double> > (startMerge-startParent).count ());
globalTreeStats.addTime (buildMergeStats, duration_cast<duration<double> > (startIndex-startMerge).count ());
globalTreeStats.addTime (buildIndexStats, duration_cast<duration<double> > (startCompress-startIndex).count ());
globalTreeStats.addTime (buildCompressStats, duration_cast<duration<double> > (end-startCompress).count ());
}
// ========================================

View File

@ -31,6 +31,13 @@ namespace otb {
enum TimeType {
buildTreeStats,
buildSetupStats,
buildParentsStats,
buildMergeStats,
buildIndexStats,
buildCompressStats,
buildChildrenStats,
setAPStats,
areaStats,
averageStats,
xyStats,

View File

@ -214,9 +214,10 @@ Option::parse (int argc, char** argv) {
size = Size ((DimSideImg) width, (DimSideImg) height);
cout
<< "Input :" << inputFileName << " " << orgSize << " (" << bandInputCount << " chanels of " << GDALGetDataTypeName (inputType) << ")" << endl
<< "Input:" << inputFileName << " " << orgSize << " (" << bandInputCount << " chanels of " << GDALGetDataTypeName (inputType) << ")" << endl
<< "Crop topLeft:" << topLeft << " size:" << size << " band:" << selectedBand << endl
<< "Output :" << outputFileName << endl;
<< "Output:" << outputFileName << endl
<< "core count:" << coreCount << endl;
if (!selectedBand.empty () &&
(selectedBand.first () < 0 ||
selectedBand.last () >= bandInputCount))

View File

@ -10,6 +10,13 @@ using namespace std;
// ========================================
static string timeTypeLabels [TimeTypeCard] = {
"build tree",
"build setup ",
"build parents ",
"build merge ",
"build index ",
"build compress ",
"build children ",
"set AP",
"area",
"average",
"xy",
@ -114,7 +121,7 @@ TreeStats::CPrintTime::print (ostream &out) const {
if (empty)
return out;
out << endl
<< setw (11) << left << "Time" << "\t"
<< setw (16) << left << "Time" << "\t"
<< setw (15) << left << "Sum" << "\t"
<< setw (3) << left << "Count" << "\t"
<< setw (15) << left << "Mean" << "\t"
@ -123,7 +130,7 @@ TreeStats::CPrintTime::print (ostream &out) const {
for (unsigned int i = 0; i < TimeTypeCard; ++i) {
if (!ba::count (treeStats.timeStats[i]))
continue;
out << setw (11) << right << timeTypeLabels[i] << "\t"
out << setw (16) << right << timeTypeLabels[i] << "\t"
<< ns2string (ba::sum (treeStats.timeStats[i])) << "\t" << setw (3) << ba::count (treeStats.timeStats[i]) << "\t"
<< ns2string (ba::mean (treeStats.timeStats[i])) << "\t"
<< ns2string (ba::min (treeStats.timeStats[i])) << "\t"