Skip to content

Commit

Permalink
Fix commcount regressions from chapel-lang#22441
Browse files Browse the repository at this point in the history
Signed-off-by: Vassily Litvinov <vasslitvinov@users.noreply.github.com>
  • Loading branch information
vasslitvinov committed Jun 2, 2023
1 parent 1634178 commit da1852d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions modules/internal/ChapelDistribution.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -1191,13 +1191,14 @@ module ChapelDistribution {

// domain assignment helpers

private proc doCastIndices(from, type idxType, param strides) {
type resultType = range(idxType, boundKind.both, strides);
private proc castIndices(from, lhs) {
param rank = lhs.rank;
compilerAssert(rank == from.size);

type resultType = range(lhs.idxType, boundKind.both, lhs.strides);
if from(0).type == resultType then
return from;

// set result = inds with some error checking
param rank = from.size;
var result: rank * resultType;
for param i in 0..rank-1 do
result(i) = from(i).safeCast(resultType);
Expand All @@ -1213,25 +1214,22 @@ module ChapelDistribution {
proc chpl_assignDomainWithGetSetIndices(lhs:?t, rhs: domain)
where isSubtype(_to_borrowed(t),BaseRectangularDom)
{
const rhsInds = rhs.getIndices();
type arrType = lhs.getBaseArrType();
param rank = lhs.rank;
type idxType = lhs.idxType;
param strides = lhs.strides;
compilerAssert(rank == rhs.rank);

const castIndices = doCastIndices(rhs.getIndices(), idxType, strides);
for e in lhs._arrs do {
on e {
if const eCast = e:arrType? then
eCast.dsiReallocate(castIndices);
eCast.dsiReallocate(castIndices(rhsInds, lhs));
// castIndices() is not hoisted because 'lhs' may not have any arrays
else
halt("internal error: ", t:string,
" contains a bad array type ", arrType:string);
}
}

// todo: why we cast indices for dsiReallocate and not for dsiSetIndices?
lhs.dsiSetIndices(rhs.getIndices());
// todo: should we cast indices for dsiSetIndices like for dsiReallocate?
lhs.dsiSetIndices(rhsInds);

for e in lhs._arrs do {
var eCastQ = e:arrType?;
Expand Down

0 comments on commit da1852d

Please sign in to comment.