Skip to content

Commit

Permalink
Merge pull request #145 from intel/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chuckyount authored Jun 7, 2018
2 parents 1ef288d + 9fce086 commit dd613b0
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 269 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ api-tests: compiler-api

all-tests: compiler-api
$(MAKE) tuple-test
$(MAKE) combo-api-tests
$(YK_MAKE) $@
$(MAKE) combo-api-tests

all:
$(MAKE) realclean
Expand Down
Binary file modified docs/YASK-intro.pdf
100755 → 100644
Binary file not shown.
2 changes: 1 addition & 1 deletion src/common/common_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace yask {
// for numbers above 9 (at least up to 99).

// Format: "major.minor.patch".
const string version = "2.10.00";
const string version = "2.10.02";

string yask_get_version_string() {
return version;
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ py-api-no-yc:

# Validation runs for each binary.
val1 := -dt 2 -b 16 -d 48
val2 := -dt 2 -b 24 -r 32 -rt 2 -dx 63 -dy 49 -dz 47
val2 := -dt 2 -b 24 -r 32 -rt 2 -d 63
ranks := 2

# Run the kernel binary using several combos of sizes and ranks.
Expand Down
28 changes: 15 additions & 13 deletions src/kernel/lib/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,32 +564,34 @@ namespace yask {
// time-step, the parallelogram may be trimmed based on the
// BB and WF extensions outside of the rank-BB.

// Actual region boundaries must stay within [extended] rank BB.
// Actual region boundaries must stay within [extended] pack BB.
// We have to calculate the posn in the extended rank at each
// value of 'shift_num' because it is being shifted spatially.
bool ok = true;
for (int i = 0; i < ndims; i++) {
auto& pbb = bp->getBB();
for (int i = 0, j = 0; i < ndims; i++) {
if (i == step_posn) continue;
auto& dname = _dims->_stencil_dims.getDimName(i);
auto angle = wf_angles[dname];
auto angle = wf_angles[j];

// Begin point.
idx_t dbegin = rank_bb.bb_begin[dname];
idx_t rbegin = max<idx_t>(start[i], ext_bb.bb_begin[dname]);
idx_t dbegin = rank_bb.bb_begin[j]; // non-extended domain.
idx_t rbegin = max<idx_t>(start[i], pbb.bb_begin[j]);
if (rbegin < dbegin) // in left WF ext?
rbegin = max(rbegin, dbegin - left_wf_exts[dname] + shift_num * angle);
rbegin = max(rbegin, dbegin - left_wf_exts[j] + shift_num * angle);
region_idxs.begin[i] = rbegin;

// End point.
idx_t dend = rank_bb.bb_end[dname];
idx_t rend = min<idx_t>(stop[i], ext_bb.bb_end[dname]);
idx_t dend = rank_bb.bb_end[j]; // non-extended domain.
idx_t rend = min<idx_t>(stop[i], pbb.bb_end[j]);
if (rend > dend) // in right WF ext?
rend = min(rend, dend + right_wf_exts[dname] - shift_num * angle);
rend = min(rend, dend + right_wf_exts[j] - shift_num * angle);
region_idxs.end[i] = rend;

// Anything to do?
if (rend <= rbegin)
ok = false;

j++; // next domain index.
}
TRACE_MSG("calc_region: region span after trimming: " <<
region_idxs.begin.makeValStr(ndims) <<
Expand Down Expand Up @@ -624,13 +626,13 @@ namespace yask {
// left, so region loops must strictly increment. They may do
// so in any order. TODO: shift only what is needed by
// this pack, not the global max.
for (int i = 0; i < ndims; i++) {
for (int i = 0, j = 0; i < ndims; i++) {
if (i == step_posn) continue;
auto& dname = _dims->_stencil_dims.getDimName(i);
auto angle = wf_angles[dname];
auto angle = wf_angles[j];

start[i] -= angle;
stop[i] -= angle;
j++;
}
shift_num++;

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/lib/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace yask {
BoundingBox rank_bb;

// BB with any needed extensions for wave-fronts.
// If WFs are not used, this is the same as rank_bb;
// If WFs are not used, this is the same as 'rank_bb';
BoundingBox ext_bb;

// List of all non-scratch stencil bundles in the order in which
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/lib/grid_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace yask {

// Determine required padding from halos.
Indices left_pads2 = getReqdPad(_left_halos, _left_wf_exts);
Indices right_pads2 = getReqdPad(_right_halos, _left_wf_exts);
Indices right_pads2 = getReqdPad(_right_halos, _right_wf_exts);

// NB: requirements to successful share_storage() is not as strict as
// is_storage_layout_identical(). See note on pad & halo below and API docs.
Expand Down
112 changes: 71 additions & 41 deletions src/kernel/lib/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ namespace yask {
// Myself.
if (rn == me) {
if (mandist != 0)
FORMAT_AND_THROW_YASK_EXCEPTION("Internal error: distance to own rank == " << mandist);
FORMAT_AND_THROW_YASK_EXCEPTION
("Internal error: distance to own rank == " << mandist);
}

// Someone else.
else {
if (mandist == 0)
FORMAT_AND_THROW_YASK_EXCEPTION("Error: ranks " << me <<
" and " << rn << " at same coordinates");
FORMAT_AND_THROW_YASK_EXCEPTION
("Error: ranks " << me <<
" and " << rn << " at same coordinates");
}

// Loop through domain dims.
Expand Down Expand Up @@ -157,13 +159,14 @@ namespace yask {
auto rnsz = rsizes[rn][dj];
if (mysz != rnsz) {
auto& dnamej = _opts->_rank_indices.getDimName(dj);
FORMAT_AND_THROW_YASK_EXCEPTION("Error: rank " << rn << " and " << me <<
" are both at rank-index " << coords[me][di] <<
" in the '" << dname <<
"' dimension , but their rank-domain sizes are " <<
rnsz << " and " << mysz <<
" (resp.) in the '" << dj <<
"' dimension, making them unaligned");
FORMAT_AND_THROW_YASK_EXCEPTION
("Error: rank " << rn << " and " << me <<
" are both at rank-index " << coords[me][di] <<
" in the '" << dname <<
"' dimension , but their rank-domain sizes are " <<
rnsz << " and " << mysz <<
" (resp.) in the '" << dj <<
"' dimension, making them unaligned");
}
}
}
Expand Down Expand Up @@ -316,7 +319,7 @@ namespace yask {
// Determine padded size (also offset to next location).
size_t nbytes = gp->get_num_storage_bytes();
npbytes[numa_pref] += ROUND_UP(nbytes + _data_buf_pad,
CACHELINE_BYTES);
CACHELINE_BYTES);
ngrids[numa_pref]++;
if (pass == 0)
TRACE_MSG(" grid '" << gname << "' needs " << makeByteStr(nbytes) <<
Expand Down Expand Up @@ -880,6 +883,11 @@ namespace yask {
{
assert(_opts);

// If we haven't finished constructing the context, it's too early
// to do this.
if (!stPacks.size())
return;

// Reset halos to zero.
max_halos = _dims->_domain_dims;

Expand Down Expand Up @@ -921,15 +929,19 @@ namespace yask {
// of angles and extensions.
auto& step_dim = _dims->_step_dim;
auto wf_steps = _opts->_region_sizes[step_dim];
assert(wf_steps >= 1);
num_wf_shifts = 0;
if (wf_steps > 1) {

// Need to shift for each bundle pack.
num_wf_shifts = stPacks.size() * wf_steps;
assert(stPacks.size() > 0);
num_wf_shifts = idx_t(stPacks.size()) * wf_steps;
assert(num_wf_shifts > 1);

// Don't need to shift first one.
num_wf_shifts--;
}
assert(num_wf_shifts >= 0);
for (auto& dim : _dims->_domain_dims.getDims()) {
auto& dname = dim.getName();
auto rksize = _opts->_rank_sizes[dname];
Expand All @@ -945,10 +957,12 @@ namespace yask {
if (_opts->_region_sizes[dname] < rksize || nranks > 0)
angle = ROUND_UP(max_halos[dname], _dims->_fold_pts[dname]);
wf_angles[dname] = angle;
assert(angle >= 0);

// Determine the total WF shift to be added in each dim.
idx_t shifts = angle * num_wf_shifts;
wf_shifts[dname] = shifts;
assert(shifts >= 0);

// Is domain size at least as large as halo + wf_ext in direction
// when there are multiple ranks?
Expand Down Expand Up @@ -1117,7 +1131,7 @@ namespace yask {
" rank-domain-offsets: " << rank_domain_offsets.makeDimValOffsetStr() << endl <<
#endif
" rank-domain: " << rank_bb.bb_begin.makeDimValStr() <<
" ... " << rank_bb.bb_end.subElements(1).makeDimValStr() << endl <<
" ... " << rank_bb.bb_end.subElements(1).makeDimValStr() << endl <<
" vector-len: " << VLEN << endl <<
" extra-padding: " << _opts->_extra_pad_sizes.makeDimValStr() << endl <<
" minimum-padding: " << _opts->_min_pad_sizes.makeDimValStr() << endl <<
Expand All @@ -1137,9 +1151,9 @@ namespace yask {
os << endl;

// Info about eqs, packs and bundles.
os << "Num stencil equations: " << NUM_STENCIL_EQS << endl;
os << "Num stencil bundles: " << stBundles.size() << endl;
os << "Num stencil packs: " << stPacks.size() << endl;
os << "Num stencil packs: " << stPacks.size() << endl;
os << "Num stencil bundles: " << stBundles.size() << endl;
os << "Num stencil equations: " << NUM_STENCIL_EQS << endl;

#if NUM_STENCIL_EQS

Expand All @@ -1149,9 +1163,13 @@ namespace yask {
rank_numFpOps_1t = 0;

for (auto& sp : stPacks) {
os << "Bundle(s) in pack '" << sp->get_name() << "':\n";
for (auto* sg : *sp) {
auto& pbb = sp->getBB();
os << "Pack '" << sp->get_name() << "':\n" <<
" num bundles: " << sp->size() << endl <<
" sub-domain scope: " << pbb.bb_begin.makeDimValStr() <<
" ... " << pbb.bb_end.subElements(1).makeDimValStr() << endl;

for (auto* sg : *sp) {
idx_t updates1 = 0, reads1 = 0, fpops1 = 0;

// Loop through all the needed bundles to
Expand Down Expand Up @@ -1325,10 +1343,23 @@ namespace yask {
ext_bb.bb_end = rank_bb.bb_end.addElements(right_wf_exts);
ext_bb.update_bb("extended-rank", *this, true);

// Find BB for each bundle. Each will be a subset within
// 'ext_bb'.
for (auto sg : stBundles)
sg->find_bounding_box();
// Find BB for each pack.
for (auto sp : stPacks) {
auto& spbb = sp->getBB();
spbb.bb_begin = _dims->_domain_dims;
spbb.bb_end = _dims->_domain_dims;

// Find BB for each bundle in this pack.
for (auto sb : *sp) {
sb->find_bounding_box();

// Expand pack BB to encompass bundle BB.
auto& sbbb = sb->getBB();
spbb.bb_begin = spbb.bb_begin.minElements(sbbb.bb_begin);
spbb.bb_end = spbb.bb_end.maxElements(sbbb.bb_end);
}
spbb.update_bb(sp->get_name(), *this, false);
}
}

// Find the bounding-boxes for this bundle in this rank.
Expand All @@ -1352,9 +1383,8 @@ namespace yask {
Indices max_pts(idx_min, nsdims);
idx_t npts = 0;

// Begin, end tuples.
// Scan across domain in this rank including
// any extensions for wave-fronts.
// Begin, end tuples. Use 'ext_bb' to scan across domain in this
// rank including any extensions for wave-fronts.
IdxTuple begin(stencil_dims);
begin.setVals(context.ext_bb.bb_begin, false);
begin[step_dim] = 0;
Expand All @@ -1369,11 +1399,11 @@ namespace yask {

// Define misc-loop function. Since step is always 1, we ignore
// misc_stop. Update only if point is in domain for this bundle.
#define misc_fn(misc_idxs) do { \
if (is_in_valid_domain(misc_idxs.start)) { \
min_pts = min_pts.minElements(misc_idxs.start); \
max_pts = max_pts.maxElements(misc_idxs.start); \
npts++; \
#define misc_fn(misc_idxs) do { \
if (is_in_valid_domain(misc_idxs.start)) { \
min_pts = min_pts.minElements(misc_idxs.start); \
max_pts = max_pts.maxElements(misc_idxs.start); \
npts++; \
} } while(0)

// Define OMP reductions to be used in generated code.
Expand Down Expand Up @@ -1631,11 +1661,11 @@ namespace yask {
bb_is_full = true;
if (bb_num_points != bb_size) {
if (os)
*os << "Note: '" << name << "' domain has only " <<
makeNumStr(bb_num_points) <<
" valid point(s) inside its bounding-box of " <<
makeNumStr(bb_size) <<
" point(s); multiple sub-boxes will be used.\n";
*os << "Note: '" << name << "' domain has only " <<
makeNumStr(bb_num_points) <<
" valid point(s) inside its bounding-box of " <<
makeNumStr(bb_size) <<
" point(s); multiple sub-boxes will be used.\n";
bb_is_full = false;
}

Expand All @@ -1646,9 +1676,9 @@ namespace yask {
if ((bb_begin[dname] - context.rank_domain_offsets[dname]) %
dims->_fold_pts[dname] != 0) {
if (os)
*os << "Note: '" << name << "' domain"
" has one or more starting edges not on vector boundaries;"
" masked calculations will be used in peel and remainder sub-blocks.\n";
*os << "Note: '" << name << "' domain"
" has one or more starting edges not on vector boundaries;"
" masked calculations will be used in peel and remainder sub-blocks.\n";
bb_is_aligned = false;
break;
}
Expand All @@ -1661,9 +1691,9 @@ namespace yask {
if (bb_len[dname] % dims->_cluster_pts[dname] != 0) {
if (bb_is_full && bb_is_aligned)
if (os && bb_is_aligned)
*os << "Note: '" << name << "' domain"
" has one or more sizes that are not vector-cluster multiples;"
" masked calculations will be used in peel and remainder sub-blocks.\n";
*os << "Note: '" << name << "' domain"
" has one or more sizes that are not vector-cluster multiples;"
" masked calculations will be used in peel and remainder sub-blocks.\n";
bb_is_cluster_mult = false;
break;
}
Expand Down
Loading

0 comments on commit dd613b0

Please sign in to comment.