Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
Fix bug in bounding-box calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
chuck.yount committed Jun 21, 2019
1 parent b97d52d commit 722ece8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/kernel/lib/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ namespace yask {
// Finalize interior BB if there are multiple ranks and overlap enabled.
if (env->num_ranks > 1 && opts->overlap_comms) {
mpi_interior.update_bb("interior", this, true);
TRACE_MSG("MPI interior BB: [" << mpi_interior.bb_begin.makeDimValStr() <<
" ... " << mpi_interior.bb_end.makeDimValStr() << ")");
TRACE_MSG("MPI interior BB: [" << mpi_interior.make_range_string(domain_dims) << "]");
}

// At this point, we have all the buffers configured.
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/lib/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ namespace yask {
adj_block_idxs.begin.makeValStr() << " ... " <<
adj_block_idxs.end.makeValStr() <<
") with mini-block stride " <<
adj_block_idxs.stride.makeValStr(nsdims));
adj_block_idxs.stride.makeValStr());

// Loop thru shapes.
for (idx_t shape = 0; shape < nshapes; shape++) {
Expand Down
38 changes: 18 additions & 20 deletions src/kernel/lib/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,7 @@ namespace yask {

// If there is no condition, just add full BB to list.
if (!is_sub_domain_expr()) {
TRACE_MSG("adding 1 sub-BB: [" << _bundle_bb.bb_begin.makeDimValStr() <<
" ... " << _bundle_bb.bb_end.makeDimValStr() << ")");
TRACE_MSG("adding 1 sub-BB: [" << _bundle_bb.make_range_string(domain_dims) << "]");
_bb_list.push_back(_bundle_bb);
return;
}
Expand Down Expand Up @@ -904,17 +903,17 @@ namespace yask {
// Visit all points in slice, looking for a new
// valid beginning point, 'ib*pt'.
Indices ibspt(stencil_dims); // in stencil dims.
ibspt[step_posn] = 0;
Indices ibdpt(domain_dims); // in domain dims.
slice_len.visitAllPoints
([&](const IdxTuple& ofs, size_t idx) {

// Find global point from 'ofs' in domain
// and stencil dims.
Indices iofs(ofs);
ibdpt = islice_begin.addElements(iofs); // domain tuple.
DOMAIN_VAR_LOOP(i, j) {
ibspt[i] = ibdpt[j]; // stencil tuple.
}
ibdpt = islice_begin.addElements(iofs); // domain indices.
DOMAIN_VAR_LOOP(i, j)
ibspt[i] = ibdpt[j]; // stencil indices.

// Valid point must be in sub-domain and
// not seen before in this slice.
Expand All @@ -938,6 +937,7 @@ namespace yask {

// End point to be found, 'ie*pt'.
Indices iespt(stencil_dims); // stencil dims.
iespt[step_posn] = 0;
Indices iedpt(domain_dims); // domain dims.

// Repeat scan until no adjustment is made.
Expand All @@ -946,20 +946,19 @@ namespace yask {
do_scan = false;

TRACE_MSG("scanning " << scan_len.makeDimValStr(" * ") <<
" starting at " << bdpt.makeDimValStr());
" starting at " << ibdpt.makeDimValStr(domain_dims));
scan_len.visitAllPoints
([&](const IdxTuple& eofs, size_t eidx) {

// Make sure scan_len range is observed.
for (int i = 0; i < nddims; i++)
assert(eofs[i] < scan_len[i]);
DOMAIN_VAR_LOOP(i, j)
assert(eofs[j] < scan_len[j]);

// Find global point from 'eofs'.
Indices ieofs(eofs);
iedpt = ibdpt.addElements(ieofs); // domain tuple.
DOMAIN_VAR_LOOP(i, j) {
DOMAIN_VAR_LOOP(i, j)
iespt[i] = iedpt[j]; // stencil tuple.
}

// Valid point must be in sub-domain and
// not seen before in this slice.
Expand All @@ -979,18 +978,18 @@ namespace yask {

// Adjust 1st dim that is beyond its starting pt.
// This will reduce the range of the scan.
for (int i = 0; i < nddims; i++) {
DOMAIN_VAR_LOOP(i, j) {

// Beyond starting point in this dim?
if (iedpt[i] > ibdpt[i]) {
scan_len[i] = iedpt[i] - ibdpt[i];
if (iedpt[j] > ibdpt[j]) {
scan_len[j] = iedpt[j] - ibdpt[j];

// restart scan for
// remaining dims.
// TODO: be smarter
// about where to
// restart scan.
if (i < nddims - 1)
if (j < nddims - 1)
do_scan = true;

return false; // stop this scan.
Expand All @@ -1002,7 +1001,8 @@ namespace yask {
}); // Looking for invalid point.
} // while scan is adjusted.
TRACE_MSG("found BB " << scan_len.makeDimValStr(" * ") <<
" starting at " << bdpt.makeDimValStr());
" starting at " << ibdpt.makeDimValStr(domain_dims));
iscan_len.setFromTuple(scan_len);

// 'scan_len' now contains sizes of the new BB.
BoundingBox new_bb;
Expand Down Expand Up @@ -1033,8 +1033,7 @@ namespace yask {

// BBs in slice 'n'.
for (auto& bbn : cur_bb_list) {
TRACE_MSG(" sub-BB: [" << bbn.bb_begin.makeDimValStr() <<
" ... " << bbn.bb_end.makeDimValStr() << ")");
TRACE_MSG(" sub-BB: [" << bbn.make_range_string(domain_dims) << "]");

// Don't bother with empty BB.
if (bbn.bb_size == 0)
Expand Down Expand Up @@ -1075,8 +1074,7 @@ namespace yask {

// Merge by just increasing the size of 'bb'.
bb.bb_end[odim] = bbn.bb_end[odim];
TRACE_MSG(" merging to form [" << bb.bb_begin.makeDimValStr() <<
" ... " << bb.bb_end.makeDimValStr() << ")");
TRACE_MSG(" merging to form [" << bb.make_range_string(domain_dims) << "]");
bb.update_bb("sub-bb", _context, true);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/lib/stencil_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ namespace yask {
// Full rectilinear polytope of aligned clusters: use optimized code.
if (do_clusters) {
TRACE_MSG("calc_sub_block_vec: using cluster code for [" <<
sub_block_fcidxs.begin.makeValStr(nsdims) <<
" ... " << sub_block_fcidxs.end.makeValStr(nsdims) <<
sub_block_fcidxs.begin.makeValStr() <<
" ... " << sub_block_fcidxs.end.makeValStr() <<
") by region thread " << region_thread_idx <<
" and block thread " << block_thread_idx);

Expand Down

0 comments on commit 722ece8

Please sign in to comment.