Commit 23971964 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

When debugging show the dirty brick information as ascii art.

parent 0c08043e
......@@ -1244,13 +1244,15 @@ public:
// histogram range is already fixed. It is safe to tally changes
// to statistics and histogram as they occur.
if (action == FinalizeAction::BuildIncremental) {
std::cout << "Scanned changes " << stats->toString()
<< " histo " << histo->toString() << std::endl;
//std::cout << "Scanned changes " << stats->toString()
// << " histo " << histo->toString() << std::endl;
std::tie(stats, histo) = _accessor_rw->trackedChanges();
std::cout << "Tracked changes " << stats->toString()
<< " histo " << histo->toString() << std::endl;
//std::cout << "Tracked changes " << stats->toString()
// << " histo " << histo->toString() << std::endl;
}
_accessor_rw->trackedBricksShowDirty(/*loglevel=*/6);
// Statistics and histogram are accumulated in storage units
// and we want to store user units on the file.
// Technically I could scale in place since stats and histo
......
......@@ -884,6 +884,62 @@ ZgyInternalBulk::_trackedBricksSetDirty(
}
}
/**
* \brief For debugging, show dirty bricks.
*
* \details
* The ascii art display shows brick-columns (combines all bricks in Z)
* while the numbers printed after each LOD are per brick.
*/
void
ZgyInternalBulk::trackedBricksShowDirty(int loglevel) const
{
if (!_logger(loglevel) || _modified_bricks.size() == 0)
return;
if (std::is_sorted(_modified_bricks.begin(), _modified_bricks.end()) &&
_modified_bricks.front() == _modified_bricks.back()) {
_logger(loglevel, std::stringstream()
<< "All " << _modified_bricks.size() << "bricks are "
<< (_modified_bricks.front() ? "dirty" : "clean"));
}
else {
_logger(loglevel, "Dumping all tracked bricks:");
const InternalZGY::IInfoHeaderAccess& ih = this->_metadata->ih();
for (std::int64_t lod = ih.lodsizes().size() - 1; lod >= 0; --lod) {
_logger(loglevel, "LOD " + std::to_string(lod));
int num_dirty{0}, num_total{0};
for (std::int64_t ii=0; ii<ih.lodsizes()[lod][0]; ++ii) {
std::stringstream line;
for (std::int64_t jj=0; jj<ih.lodsizes()[lod][1]; ++jj) {
char flag = '.';
for (std::int64_t kk=0; kk<ih.lodsizes()[lod][2]; ++kk) {
++num_total;
std::int64_t index = InternalZGY::LookupTable::getBrickLookupIndex
(ii, jj, kk, lod, ih.lodsizes(), ih.brickoffsets());
if (index >= _modified_bricks.size()) {
flag = '?'; // Actually a fatal error
break;
}
if (_modified_bricks[index] & 0x01) {
++num_dirty;
flag = '*'; // written (if lod 0) or need rebuild (lod != 0)
}
else if (flag == '.' && (_modified_bricks[index] & 0x02) != 0) {
flag = 'o'; // written, but only by genlod
}
}
line << flag;
}
_logger(loglevel, line.str()); // After each inline
}
_logger(loglevel, std::stringstream()
<< "Total " << num_dirty << "/" << num_total
<< " dirty."); // After each LOD
}
}
}
/**
* \brief Check if any brick in the region has been modified.
*
......
......@@ -138,6 +138,7 @@ public: // actually internal
const std::array<std::int64_t,3>& start,
const std::array<std::int64_t,3>& size,
int32_t lod) const;
void trackedBricksShowDirty(int loglevel) const;
private:
......
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