diff --git a/modules/dists/BlockCycDist.chpl b/modules/dists/BlockCycDist.chpl index dfc2d772c079..8e72eb32ff37 100644 --- a/modules/dists/BlockCycDist.chpl +++ b/modules/dists/BlockCycDist.chpl @@ -300,7 +300,7 @@ proc BlockCyclic._locsize { // create a new rectangular domain over this distribution // override proc BlockCyclic.dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, inds) { + param strides: strideKind, inds) { if idxType != this.idxType then compilerError("BlockCyclic domain index type does not match distribution's"); if rank != this.rank then @@ -308,7 +308,7 @@ override proc BlockCyclic.dsiNewRectangularDom(param rank: int, type idxType, var dom = new unmanaged BlockCyclicDom(rank=rank, idxType=idxType, dist=_to_unmanaged(this), - stridable=stridable); + strides=strides); dom.dsiSetIndices(inds); return dom; } @@ -351,8 +351,8 @@ proc BlockCyclic.getStarts(inds, locid) { // // TODO: Does using David's detupling trick work here? // - var D: domain(rank, idxType, stridable=true); - var R: rank*range(idxType, stridable=true); + var D: domain(rank, idxType, strides=strideKind.any); + var R: rank*range(idxType, strides=strideKind.any); for i in 0..rank-1 { var lo, hi: idxType; const domlo = inds.dim(i).lowBound, @@ -452,7 +452,7 @@ class LocBlockCyclic { // to use lclIdxType here is wrong since we're talking about // the section of the global index space owned by the locale. // - const myStarts: rank*range(idxType, boundKind.low, stridable=true); + const myStarts: rank*range(idxType, boundKind.low, strides=strideKind.any); // // Initializer computes what chunk of index(0) is owned by the @@ -465,7 +465,7 @@ class LocBlockCyclic { this.rank = rank; this.idxType = idxType; - var myStarts: rank*range(idxType, boundKind.low, stridable=true); + var myStarts: rank*range(idxType, boundKind.low, strides=strideKind.any); for param i in 0..rank-1 { const locid_i = if isTuple(locid) then locid(i) else locid; const lo = lowIdx(i) + (locid_i * blocksize(i)); @@ -504,14 +504,15 @@ class BlockCyclicDom: BaseRectangularDom { // DOWN LINK: an array of local domain class descriptors -- set up in // setup() below // - var locDomsNil: [dist.targetLocDom] unmanaged LocBlockCyclicDom(rank, idxType, stridable)?; + var locDomsNil: [dist.targetLocDom] unmanaged LocBlockCyclicDom(rank, + idxType, strides)?; inline proc locDoms(idx) do return locDomsNil(idx)!; // // a domain describing the complete domain // - var whole: domain(rank=rank, idxType=idxType, stridable=stridable); + var whole: domain(rank=rank, idxType=idxType, strides=strides); // const startLoc: index(dist.targetLocDom); } @@ -539,7 +540,7 @@ iter BlockCyclicDom.these(param tag: iterKind) where tag == iterKind.leader { const dim = whole.dim(j); const dimLow = dim.lowBound; - var temp : range(idxType, stridable=stridable); + var temp : range(idxType, strides=strides); temp = max(lo, dimLow).. min(lo + dist.blocksize(j):idxType-1, dim.highBound); temp = dim[temp]; @@ -567,7 +568,7 @@ iter BlockCyclicDom.these(param tag: iterKind) where tag == iterKind.leader { // stencil communication will be done on a per-locale basis. // iter BlockCyclicDom.these(param tag: iterKind, followThis) where tag == iterKind.follower { - var t: rank*range(idxType, stridable=stridable); + var t: rank*range(idxType, strides=strides); for param i in 0..rank-1 { const curFollow = followThis(i); @@ -588,15 +589,17 @@ iter BlockCyclicDom.these(param tag: iterKind, followThis) where tag == iterKind // proc BlockCyclicDom.dsiBuildArray(type eltType, param initElts:bool) { const dom = this; - var locArrTemp: [dom.dist.targetLocDom] unmanaged LocBlockCyclicArr(eltType, rank, idxType, stridable)?; - var myLocArrTemp: unmanaged LocBlockCyclicArr(eltType, rank, idxType, stridable)?; + var locArrTemp: [dom.dist.targetLocDom] unmanaged LocBlockCyclicArr(eltType, + rank, idxType, strides)?; + var myLocArrTemp: unmanaged LocBlockCyclicArr(eltType, rank, idxType, + strides)?; const creationLocale = here; // formerly BlockCyclicArr.setup() coforall localeIdx in dom.dist.targetLocDom with (ref myLocArrTemp) { on dom.dist.targetLocales(localeIdx) { const LBCA = new unmanaged LocBlockCyclicArr(eltType, rank, - idxType, stridable, + idxType, strides, dom.locDoms(localeIdx), dom.locDoms(localeIdx), localeIdx, @@ -609,7 +612,7 @@ proc BlockCyclicDom.dsiBuildArray(type eltType, param initElts:bool) { var locArrNN = locArrTemp!; //#15080 var arr = new unmanaged BlockCyclicArr(eltType=eltType, rank=rank, - idxType=idxType, stridable=stridable, + idxType=idxType, strides=strides, locArr = locArrNN, myLocArr = myLocArrTemp, dom=_to_unmanaged(this)); @@ -637,7 +640,7 @@ proc BlockCyclicDom.dsiGetIndices() do return whole.getIndices(); proc BlockCyclicDom.dsiMember(i) do return whole.contains(i); proc BlockCyclicDom.doiToString() do return whole:string; proc BlockCyclicDom.dsiSerialWrite(x) { x.write(whole); } -proc BlockCyclicDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc BlockCyclicDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc BlockCyclicDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc BlockCyclicDom.dsiMyDist() do return dist; @@ -674,8 +677,8 @@ proc BlockCyclicDom.setup() { coforall localeIdx in dist.targetLocDom do on dist.targetLocales(localeIdx) do if (locDomsNil(localeIdx) == nil) then - locDomsNil(localeIdx) = new unmanaged LocBlockCyclicDom(rank, idxType, stridable, _to_unmanaged(this), - dist.getStarts(whole, localeIdx)); + locDomsNil(localeIdx) = new unmanaged LocBlockCyclicDom(rank, idxType, + strides, _to_unmanaged(this), dist.getStarts(whole, localeIdx)); else { locDoms(localeIdx).myStarts = dist.getStarts(whole, localeIdx); locDoms(localeIdx).myFlatInds = {0..#locDoms(localeIdx).computeFlatInds()}; @@ -708,7 +711,7 @@ proc type BlockCyclicDom.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged BlockCyclicDom(rank=this.rank, idxType=this.idxType, - stridable=this.stridable), + strides=this.strides), data); } @@ -718,7 +721,8 @@ proc BlockCyclicDom.dsiGetPrivatizeData() do return dist.pid; proc BlockCyclicDom.dsiPrivatize(privatizeData) { var privateDist = chpl_getPrivatizedCopy(dist.type, privatizeData); - var c = new unmanaged BlockCyclicDom(rank=rank, idxType=idxType, stridable=stridable, dist=privateDist); + var c = new unmanaged BlockCyclicDom(rank=rank, idxType=idxType, + strides=strides, dist=privateDist); c.locDomsNil = locDomsNil; c.whole = whole; return c; @@ -738,12 +742,12 @@ proc BlockCyclicDom.dsiReprivatize(other, reprivatizeData) { class LocBlockCyclicDom { param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; // // UP LINK: a reference to the parent global domain class // - const globDom: unmanaged BlockCyclicDom(rank, idxType, stridable); + const globDom: unmanaged BlockCyclicDom(rank, idxType, strides); // // a local domain describing the indices owned by this locale @@ -752,7 +756,7 @@ class LocBlockCyclicDom { // require a glbIdxType offset in order to get from the global // indices back to the local index type. // - var myStarts: domain(rank, idxType, stridable=true); + var myStarts: domain(rank, idxType, strides=strideKind.any); var myFlatInds: domain(1); } @@ -846,17 +850,18 @@ class BlockCyclicArr: BaseRectangularArr { // // LEFT LINK: the global domain descriptor for this array // - var dom: unmanaged BlockCyclicDom(rank, idxType, stridable); + var dom: unmanaged BlockCyclicDom(rank, idxType, strides); // // DOWN LINK: an array of local array classes // - var locArr: [dom.dist.targetLocDom] unmanaged LocBlockCyclicArr(eltType, rank, idxType, stridable); + var locArr: [dom.dist.targetLocDom] unmanaged LocBlockCyclicArr(eltType, + rank, idxType, strides); // // optimized reference to a local LocBlockCyclicArr instance (or nil) // - var myLocArr: unmanaged LocBlockCyclicArr(eltType, rank, idxType, stridable)?; + var myLocArr: unmanaged LocBlockCyclicArr(eltType, rank, idxType, strides)?; } override proc BlockCyclicArr.dsiGetBaseDom() do return dom; @@ -918,7 +923,7 @@ proc type BlockCyclicArr.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged BlockCyclicArr(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, eltType=this.eltType), data); } @@ -930,7 +935,7 @@ proc BlockCyclicArr.dsiGetPrivatizeData() do return 0; proc BlockCyclicArr.dsiPrivatize(privatizeData) { var privdom = chpl_getPrivatizedCopy(dom.type, dom.pid); var c = new unmanaged BlockCyclicArr(eltType=eltType, rank=rank, - idxType=idxType, stridable=stridable, dom=privdom, locArr=locArr); + idxType=idxType, strides=strides, dom=privdom, locArr=locArr); for localeIdx in dom.dist.targetLocDom do if c.locArr(localeIdx).locale == here then @@ -995,7 +1000,7 @@ iter BlockCyclicArr.these(param tag: iterKind) where tag == iterKind.leader { } iter BlockCyclicArr.these(param tag: iterKind, followThis) ref where tag == iterKind.follower { - var myFollowThis: rank*range(idxType=idxType, stridable=stridable); + var myFollowThis: rank*range(idxType=idxType, strides=strides); for param i in 0..rank-1 { const curFollow = followThis(i); @@ -1082,7 +1087,7 @@ iter BlockCyclicDom.dsiLocalSubdomains(loc: locale) { // TODO -- could be replaced by a privatized myLocDom in BlockCyclicDom // as it is with BlockCyclicArr - var myLocDom:unmanaged LocBlockCyclicDom(rank, idxType, stridable)? = nil; + var myLocDom:unmanaged LocBlockCyclicDom(rank, idxType, strides)? = nil; for (loc, locDom) in zip(dist.targetLocales, locDomsNil) { if loc == here then myLocDom = locDom; @@ -1099,14 +1104,14 @@ class LocBlockCyclicArr { type eltType; param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; // // LEFT LINK: a reference to the local domain class for this array and locale // - const allocDom: unmanaged LocBlockCyclicDom(rank, idxType, stridable); + const allocDom: unmanaged LocBlockCyclicDom(rank, idxType, strides); // MPF TODO: Why do we need indexDom at all? is it always == allocDom? - const indexDom: unmanaged LocBlockCyclicDom(rank, idxType, stridable); + const indexDom: unmanaged LocBlockCyclicDom(rank, idxType, strides); // STATE: @@ -1130,15 +1135,15 @@ class LocBlockCyclicArr { proc init(type eltType, param rank: int, type idxType, - param stridable: bool, - allocDom: unmanaged LocBlockCyclicDom(rank, idxType, stridable), - indexDom: unmanaged LocBlockCyclicDom(rank, idxType, stridable), + param strides: strideKind, + allocDom: unmanaged LocBlockCyclicDom(rank, idxType, strides), + indexDom: unmanaged LocBlockCyclicDom(rank, idxType, strides), localeIndex, param initElts: bool) { this.eltType = eltType; this.rank = rank; this.idxType = idxType; - this.stridable = stridable; + this.strides = strides; this.allocDom = allocDom; this.indexDom = indexDom; this.myElems = this.allocDom.myFlatInds.buildArray(eltType, initElts=initElts); diff --git a/modules/dists/BlockDist.chpl b/modules/dists/BlockDist.chpl index cb52cf07c370..865cbd807992 100644 --- a/modules/dists/BlockDist.chpl +++ b/modules/dists/BlockDist.chpl @@ -350,7 +350,7 @@ class LocBlock { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // dist: reference to distribution class // locDoms: a non-distributed array of local domain classes // whole: a non-distributed domain that defines the domain's indices @@ -358,8 +358,8 @@ class LocBlock { class BlockDom: BaseRectangularDom { type sparseLayoutType; const dist: unmanaged Block(rank, idxType, sparseLayoutType); - var locDoms: [dist.targetLocDom] unmanaged LocBlockDom(rank, idxType, stridable); - var whole: domain(rank=rank, idxType=idxType, stridable=stridable); + var locDoms: [dist.targetLocDom] unmanaged LocBlockDom(rank, idxType, strides); + var whole: domain(rank, idxType, strides); } // @@ -367,14 +367,14 @@ class BlockDom: BaseRectangularDom { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // myBlock: a non-distributed domain that defines the local indices // class LocBlockDom { param rank: int; type idxType; - param stridable: bool; - var myBlock: domain(rank, idxType, stridable); + param strides: strideKind; + var myBlock: domain(rank, idxType, strides); } // @@ -383,7 +383,7 @@ class LocBlockDom { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // dom: reference to domain class // locArr: a non-distributed array of local array classes // myLocArr: optimized reference to here's local array class (or nil) @@ -391,10 +391,11 @@ class LocBlockDom { class BlockArr: BaseRectangularArr { type sparseLayoutType; var doRADOpt: bool = defaultDoRADOpt; - var dom: unmanaged BlockDom(rank, idxType, stridable, sparseLayoutType); - var locArr: [dom.dist.targetLocDom] unmanaged LocBlockArr(eltType, rank, idxType, stridable); + var dom: unmanaged BlockDom(rank, idxType, strides, sparseLayoutType); + var locArr: [dom.dist.targetLocDom] unmanaged LocBlockArr(eltType, + rank, idxType, strides); pragma "local field" - var myLocArr: unmanaged LocBlockArr(eltType, rank, idxType, stridable)?; + var myLocArr: unmanaged LocBlockArr(eltType, rank, idxType, strides)?; const SENTINEL = max(rank*int); } @@ -404,7 +405,7 @@ class BlockArr: BaseRectangularArr { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // locDom: reference to local domain class // myElems: a non-distributed array of local elements // @@ -412,9 +413,9 @@ class LocBlockArr { type eltType; param rank: int; type idxType; - param stridable: bool; - const locDom: unmanaged LocBlockDom(rank, idxType, stridable); - var locRAD: unmanaged LocRADCache(eltType, rank, idxType, chpl_strideKind(stridable))?; // non-nil if doRADOpt=true + param strides: strideKind; + const locDom: unmanaged LocBlockDom(rank, idxType, strides); + var locRAD: unmanaged LocRADCache(eltType, rank, idxType, strides)?; // non-nil if doRADOpt=true pragma "local field" pragma "unsafe" // may be initialized separately var myElems: [locDom.myBlock] eltType; @@ -423,13 +424,13 @@ class LocBlockArr { proc init(type eltType, param rank: int, type idxType, - param stridable: bool, - const locDom: unmanaged LocBlockDom(rank, idxType, stridable), + param strides: strideKind, + const locDom: unmanaged LocBlockDom(rank, idxType, strides), param initElts: bool) { this.eltType = eltType; this.rank = rank; this.idxType = idxType; - this.stridable = stridable; + this.strides = strides; this.locDom = locDom; this.myElems = this.locDom.myBlock.buildArray(eltType, initElts=initElts); } @@ -475,7 +476,7 @@ proc Block.init(boundingBox: domain, if boundingBox.sizeAs(uint) == 0 then halt("Block() requires a non-empty boundingBox"); - this.boundingBox = boundingBox : domain(rank, idxType, stridable = false); + this.boundingBox = boundingBox : domain(rank, idxType); if !allowDuplicateTargetLocales { var checkArr: [LocaleSpace] bool; @@ -599,28 +600,28 @@ override proc Block.dsiDisplayRepresentation() { } override proc Block.dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, inds) { + param strides: strideKind, inds) { if idxType != this.idxType then compilerError("Block domain index type does not match distribution's"); if rank != this.rank then compilerError("Block domain rank does not match distribution's"); - const whole = createWholeDomainForInds(rank, idxType, stridable, inds); + const whole = createWholeDomainForInds(rank, idxType, strides, inds); - const dummyLBD = new unmanaged LocBlockDom(rank, idxType, stridable); + const dummyLBD = new unmanaged LocBlockDom(rank, idxType, strides); var locDomsTemp: [this.targetLocDom] - unmanaged LocBlockDom(rank, idxType, stridable) = dummyLBD; + unmanaged LocBlockDom(rank, idxType, strides) = dummyLBD; coforall (localeIdx, loc, locDomsTempElt) in zip(this.targetLocDom, this.targetLocales, locDomsTemp) { on loc { - locDomsTempElt = new unmanaged LocBlockDom(rank, idxType, stridable, - // the cast to domain supports deprecation by Vass in 1.31 for #17131 - this.getChunk(whole, localeIdx): domain(rank, idxType, stridable)); + locDomsTempElt = new unmanaged LocBlockDom(rank, idxType, strides, + // todo: can/should we get a more specific return type out of getChunk? + this.getChunk(whole, localeIdx): domain(rank, idxType, strides)); } } delete dummyLBD; - var dom = new unmanaged BlockDom(rank, idxType, stridable, sparseLayoutType, + var dom = new unmanaged BlockDom(rank, idxType, strides, sparseLayoutType, this: unmanaged, locDomsTemp, whole); if debugBlockDist { @@ -634,7 +635,7 @@ override proc Block.dsiNewSparseDom(param rank: int, type idxType, dom: domain) { var ret = new unmanaged SparseBlockDom(rank=rank, idxType=idxType, sparseLayoutType=sparseLayoutType, - stridable=dom.stridable, + strides=dom.strides, dist=_to_unmanaged(this), whole=dom._value.whole, parentDom=dom); ret.setup(); @@ -894,14 +895,11 @@ iter BlockDom.these(param tag: iterKind) where tag == iterKind.leader { // TODO: Can we just re-use the DefaultRectangularDom follower here? // iter BlockDom.these(param tag: iterKind, followThis) where tag == iterKind.follower { - proc anyStridable(rangeTuple, param i: int = 0) param do - return if i == rangeTuple.size-1 then rangeTuple(i).stridable - else rangeTuple(i).stridable || anyStridable(rangeTuple, i+1); - if chpl__testParFlag then chpl__testParWriteln("Block domain follower invoked on ", followThis); - var t: rank*range(idxType, stridable=stridable||anyStridable(followThis)); + var t: rank*range(idxType, strides = chpl_strideProduct(whole.strides, + chpl_strideUnion(followThis))); for param i in 0..rank-1 { const wholeDim = whole.dim(i); const followDim = followThis(i); @@ -922,19 +920,19 @@ iter BlockDom.these(param tag: iterKind, followThis) where tag == iterKind.follo proc BlockDom.dsiBuildArray(type eltType, param initElts:bool) { const dom = this; const creationLocale = here.id; - const dummyLBD = new unmanaged LocBlockDom(rank, idxType, stridable); + const dummyLBD = new unmanaged LocBlockDom(rank, idxType, strides); const dummyLBA = new unmanaged LocBlockArr(eltType, rank, idxType, - stridable, dummyLBD, false); + strides, dummyLBD, false); var locArrTemp: [dom.dist.targetLocDom] - unmanaged LocBlockArr(eltType, rank, idxType, stridable) = dummyLBA; - var myLocArrTemp: unmanaged LocBlockArr(eltType, rank, idxType, stridable)?; + unmanaged LocBlockArr(eltType, rank, idxType, strides) = dummyLBA; + var myLocArrTemp: unmanaged LocBlockArr(eltType, rank, idxType, strides)?; // formerly in BlockArr.setup() coforall (loc, locDomsElt, locArrTempElt) in zip(dom.dist.targetLocales, dom.locDoms, locArrTemp) with (ref myLocArrTemp) { on loc { - const LBA = new unmanaged LocBlockArr(eltType, rank, idxType, stridable, + const LBA = new unmanaged LocBlockArr(eltType, rank, idxType, strides, locDomsElt, initElts=initElts); locArrTempElt = LBA; @@ -945,7 +943,7 @@ proc BlockDom.dsiBuildArray(type eltType, param initElts:bool) { delete dummyLBA, dummyLBD; var arr = new unmanaged BlockArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, sparseLayoutType=sparseLayoutType, + strides=strides, sparseLayoutType=sparseLayoutType, dom=_to_unmanaged(dom), locArr=locArrTemp, myLocArr=myLocArrTemp); // formerly in BlockArr.setup() @@ -974,7 +972,7 @@ proc BlockDom.dsiGetIndices() do return whole.getIndices(); proc BlockDom.dsiMember(i) do return whole.contains(i); proc BlockDom.doiToString() do return whole:string; proc BlockDom.dsiSerialWrite(x) { x.write(whole); } -proc BlockDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc BlockDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc BlockDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc BlockDom.dsiMyDist() do return dist; @@ -1071,7 +1069,8 @@ proc BlockArr.setupRADOpt() { myLocArr.locRAD = nil; } if disableBlockLazyRAD { - myLocArr.locRAD = new unmanaged LocRADCache(eltType, rank, idxType, stridable, dom.dist.targetLocDom); + myLocArr.locRAD = new unmanaged LocRADCache(eltType, rank, idxType, + strides, dom.dist.targetLocDom); for l in dom.dist.targetLocDom { if l != localeIdx { myLocArr.locRAD!.RAD(l) = locArr(l).myElems._value.dsiGetRAD(); @@ -1145,7 +1144,8 @@ proc BlockArr.nonLocalAccess(i: rank*idxType) ref { if myLocArr.locRAD == nil { myLocArr.locRADLock.lock(); if myLocArr.locRAD == nil { - var tempLocRAD = new unmanaged LocRADCache(eltType, rank, idxType, stridable, dom.dist.targetLocDom); + var tempLocRAD = new unmanaged LocRADCache(eltType, rank, idxType, + strides, dom.dist.targetLocDom); tempLocRAD.RAD.blk = SENTINEL; myLocArr.locRAD = tempLocRAD; } @@ -1212,10 +1212,6 @@ proc BlockArr.dsiDynamicFastFollowCheck(lead: domain) { } iter BlockArr.these(param tag: iterKind, followThis, param fast: bool = false) ref where tag == iterKind.follower { - proc anyStridable(rangeTuple, param i: int = 0) param do - return if i == rangeTuple.size-1 then rangeTuple(i).stridable - else rangeTuple(i).stridable || anyStridable(rangeTuple, i+1); - if chpl__testParFlag { if fast then chpl__testParWriteln("Block array fast follower invoked on ", followThis); @@ -1226,7 +1222,8 @@ iter BlockArr.these(param tag: iterKind, followThis, param fast: bool = false) r if testFastFollowerOptimization then writeln((if fast then "fast" else "regular") + " follower invoked for Block array"); - var myFollowThis: rank*range(idxType=idxType, stridable=stridable || anyStridable(followThis)); + var myFollowThis: rank*range(idxType=idxType, strides=chpl_strideProduct( + strides, chpl_strideUnion(followThis))); var lowIdx: rank*idxType; for param i in 0..rank-1 { @@ -1324,7 +1321,7 @@ proc _extendTuple(type t, idx, args) { return tup; } -override proc BlockArr.dsiReallocate(bounds:rank*range(idxType,boundKind.both,stridable)) +override proc BlockArr.dsiReallocate(bounds:rank*range(idxType,boundKind.both,strides)) { // // For the default rectangular array, this function changes the data @@ -1415,7 +1412,7 @@ proc type BlockDom.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged BlockDom(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, sparseLayoutType=this.sparseLayoutType), data); } @@ -1436,11 +1433,11 @@ proc BlockDom.dsiPrivatize(privatizeData) { var privdist = chpl_getPrivatizedCopy(dist.type, privatizeData.distpid); var locDomsTemp: [privdist.targetLocDom] - unmanaged LocBlockDom(rank, idxType, stridable) + unmanaged LocBlockDom(rank, idxType, strides) = privatizeData.locdoms; // in initializer we have to pass sparseLayoutType as it has no default value - const c = new unmanaged BlockDom(rank, idxType, stridable, + const c = new unmanaged BlockDom(rank, idxType, strides, privdist.sparseLayoutType, privdist, locDomsTemp, {(...privatizeData.dims)}); return c; @@ -1462,7 +1459,7 @@ proc type BlockArr.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged BlockArr(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, eltType=this.eltType, sparseLayoutType=this.sparseLayoutType), data); @@ -1483,16 +1480,16 @@ proc BlockArr.dsiPrivatize(privatizeData) { var privdom = chpl_getPrivatizedCopy(dom.type, privatizeData.dompid); var locArrTemp: [privdom.dist.targetLocDom] - unmanaged LocBlockArr(eltType, rank, idxType, stridable) + unmanaged LocBlockArr(eltType, rank, idxType, strides) = privatizeData.locarr; - var myLocArrTemp: unmanaged LocBlockArr(eltType, rank, idxType, stridable)?; + var myLocArrTemp: unmanaged LocBlockArr(eltType, rank, idxType, strides)?; for localeIdx in privdom.dist.targetLocDom do if locArrTemp(localeIdx).locale.id == here.id then myLocArrTemp = locArrTemp(localeIdx); const c = new unmanaged BlockArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, sparseLayoutType=sparseLayoutType, + strides=strides, sparseLayoutType=sparseLayoutType, dom=privdom, locArr=locArrTemp, myLocArr = myLocArrTemp); return c; } @@ -1532,7 +1529,7 @@ proc BlockArr.dsiLocalSubdomain(loc: locale) { if const myLocArrNN = myLocArr then return myLocArrNN.locDom.myBlock; // if not, we must not own anything - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } else { return dom.dsiLocalSubdomain(loc); @@ -1551,7 +1548,7 @@ proc BlockDom.dsiLocalSubdomain(loc: locale) { return whole[(...inds)]; } } else { - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } } @@ -1629,7 +1626,7 @@ proc BlockArr.canDoOptimizedSwap(other) { // TODO: stridability causes issues with RAD swap, and somehow isn't captured by // the formal type when we check whether this resolves. proc BlockArr.doiOptimizedSwap(other: this.type) - where this.stridable == other.stridable { + where this.strides == other.strides { if(canDoOptimizedSwap(other)) { if debugOptimizedSwap { diff --git a/modules/dists/CyclicDist.chpl b/modules/dists/CyclicDist.chpl index f8ee7fb91680..2316107c11bb 100644 --- a/modules/dists/CyclicDist.chpl +++ b/modules/dists/CyclicDist.chpl @@ -350,12 +350,12 @@ proc Cyclic.dsiReprivatize(other, reprivatizeData) { dataParMinGranularity = other.dataParMinGranularity; } -override proc Cyclic.dsiNewRectangularDom(param rank: int, type idxType, param stridable: bool, inds) { +override proc Cyclic.dsiNewRectangularDom(param rank: int, type idxType, param strides: strideKind, inds) { if idxType != this.idxType then compilerError("Cyclic domain index type does not match distribution's"); if rank != this.rank then compilerError("Cyclic domain rank does not match distribution's"); - const whole = createWholeDomainForInds(rank, idxType, stridable, inds); + const whole = createWholeDomainForInds(rank, idxType, strides, inds); const dummyLCD = new unmanaged LocCyclicDom(rank, idxType); var locDomsTemp: [this.targetLocDom] unmanaged LocCyclicDom(rank, idxType) @@ -363,10 +363,10 @@ override proc Cyclic.dsiNewRectangularDom(param rank: int, type idxType, param s coforall localeIdx in this.targetLocDom do on this.targetLocs(localeIdx) do locDomsTemp(localeIdx) = new unmanaged LocCyclicDom(rank, idxType, - this.getChunk(whole, localeIdx)); + this.getChunk(whole, localeIdx): myBlockType(rank, idxType)); delete dummyLCD; - var dom = new unmanaged CyclicDom(rank, idxType, stridable, + var dom = new unmanaged CyclicDom(rank, idxType, strides, this: unmanaged, locDomsTemp, whole); return dom; } @@ -435,13 +435,13 @@ proc Cyclic.dsiIndexToLocale(i: rank*idxType) { proc chpl__computeCyclicDim(type idxType, lo, myloc, numlocs) { const lower = min(idxType)..(lo+myloc) by -numlocs; const upper = lo+myloc..max(idxType) by numlocs; - return lower.last..upper.last by numlocs; + return lower.last..upper.last by numlocs:uint; } proc chpl__computeCyclic(type idxType, locid, targetLocBox, startIdx) { type strType = chpl__signedType(idxType); param rank = targetLocBox.size; - var inds: rank*range(idxType, stridable=true); + var inds: rank*range(idxType, strides=strideKind.positive); for param i in 0..rank-1 { // NOTE: Not bothering to check to see if these can fit into idxType const lo = chpl__tuplify(startIdx)(i): idxType; @@ -457,7 +457,7 @@ class LocCyclic { param rank: int; type idxType; - const myChunk: domain(rank, idxType, true); + const myChunk: domain(rank, idxType, strideKind.positive); proc init(param rank, type idxType, locid, distStartIdx: rank*idxType, distLocDims) { @@ -473,7 +473,7 @@ class LocCyclic { else for param i in 0..rank-1 do locidx(i) = locid(i):idxType; - var inds: rank*range(idxType, stridable=true); + var inds: rank*range(idxType, strides=strideKind.positive); inds = chpl__computeCyclic(idxType, locid, distLocDims, startIdx); myChunk = {(...inds)}; @@ -492,7 +492,7 @@ class CyclicDom : BaseRectangularDom { var locDoms: [dist.targetLocDom] unmanaged LocCyclicDom(rank, idxType); - var whole: domain(rank, idxType, stridable); + var whole: domain(rank, idxType, strides); } proc CyclicDom.setup() { @@ -535,7 +535,7 @@ proc CyclicDom.dsiBuildArray(type eltType, param initElts:bool) { delete dummyLCA, dummyLCD; var arr = new unmanaged CyclicArr(eltType=eltType, rank=rank, - idxType=idxType, stridable=stridable, + idxType=idxType, strides=strides, dom=_to_unmanaged(dom), locArr=locArrTemp, myLocArr=myLocArrTemp); // formerly in CyclicArr.setup() @@ -571,7 +571,7 @@ proc CyclicDom.dsiGetIndices() do return whole.getIndices(); proc CyclicDom.dsiMember(i) do return whole.contains(i); proc CyclicDom.doiToString() do return whole:string; //proc CyclicDom.dsiSerialWrite(x) { x.write(whole); } -proc CyclicDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc CyclicDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc CyclicDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc CyclicDom.dsiMyDist() do return dist; @@ -646,12 +646,15 @@ iter CyclicDom.these(param tag: iterKind) where tag == iterKind.leader { // distribution (at least, I couldn't figure out a way to not go // back and forth without breaking tests) const zeroShift = {(...newFollowThis)}.chpl__unTranslate(wholeLow); - var result: rank*range(idxType=idxType, stridable=true); + var result: rank*range(idxType=idxType, strides=chpl_strideProduct( + whole.strides, chpl_strideUnion(zeroShift) )); type strType = chpl__signedType(idxType); for param i in 0..rank-1 { const wholestride = chpl__tuplify(wholeStride)(i); const ref dim = zeroShift.dim(i); - result(i) = (dim.first / wholestride:idxType)..(dim.last / wholestride:idxType) by (dim.stride:strType / wholestride); + result(i).chpl_setFields(dim.first / wholestride:idxType, + dim.last / wholestride:idxType, + dim.stride:strType / wholestride); } yield result; } @@ -662,7 +665,7 @@ iter CyclicDom.these(param tag: iterKind) where tag == iterKind.leader { // of 'whole' private proc chpl__followThisToOrig(type idxType, followThis, whole) { param rank = followThis.size; - var t: rank*range(idxType, stridable=true); + var t: rank*range(idxType, strides=strideKind.any); if debugCyclicDist then writeln(here.id, ": follower whole is: ", whole, " follower is: ", followThis); @@ -693,7 +696,7 @@ proc CyclicDom.chpl__serialize() { proc type CyclicDom.chpl__deserialize(data) { return chpl_getPrivatizedCopy(unmanaged CyclicDom(rank=this.rank, idxType=this.idxType, - stridable=this.stridable), + strides=this.strides), data); } @@ -703,7 +706,7 @@ proc CyclicDom.dsiGetPrivatizeData() do return 0; proc CyclicDom.dsiPrivatize(privatizeData) { var privdist = chpl_getPrivatizedCopy(dist.type, dist.pid); - return new unmanaged CyclicDom(rank, idxType, stridable, + return new unmanaged CyclicDom(rank, idxType, strides, privdist, locDoms, whole); } @@ -721,9 +724,12 @@ class LocCyclicDom { // The local block type is always stridable // (because that's inherent to the cyclic distribution) - var myBlock: domain(rank, idxType, stridable=true); + var myBlock: myBlockType(rank, idxType); } +private proc myBlockType(param rank, type idxType) type do + return domain(rank, idxType, strides=strideKind.any); + // // Added as a performance stopgap to avoid returning a domain // @@ -732,7 +738,7 @@ proc LocCyclicDom.contains(i) do return myBlock.contains(i); class CyclicArr: BaseRectangularArr { var doRADOpt: bool = defaultDoRADOpt; - var dom: unmanaged CyclicDom(rank, idxType, stridable); + var dom: unmanaged CyclicDom(rank, idxType, strides); var locArr: [dom.dist.targetLocDom] unmanaged LocCyclicArr(eltType, rank, idxType); var myLocArr: unmanaged LocCyclicArr(eltType=eltType, rank=rank, idxType=idxType)?; @@ -770,7 +776,7 @@ override proc CyclicArr.dsiIteratorYieldsLocalElements() param { // the RAD cache. // proc CyclicArr.setupRADOpt() { - if !stridable { // for now, no support for strided cyclic arrays + if hasUnitStride() { // for now, no support for strided cyclic arrays for localeIdx in dom.dist.targetLocDom { on dom.dist.targetLocs(localeIdx) { const myLocArr = locArr(localeIdx); @@ -780,7 +786,7 @@ proc CyclicArr.setupRADOpt() { } if disableCyclicLazyRAD { myLocArr.locRAD = new unmanaged LocRADCache(eltType, rank, idxType, - stridable=true, dom.dist.targetLocDom); + strideKind.any, dom.dist.targetLocDom); myLocArr.locCyclicRAD = new unmanaged LocCyclicRADCache(rank, idxType, dom.dist.startIdx, dom.dist.targetLocDom); for l in dom.dist.targetLocDom { if l != localeIdx { @@ -831,7 +837,7 @@ proc CyclicArr.chpl__serialize() proc type CyclicArr.chpl__deserialize(data) { return chpl_getPrivatizedCopy(unmanaged CyclicArr(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, eltType=this.eltType), data); } @@ -843,7 +849,7 @@ proc CyclicArr.dsiGetPrivatizeData() do return 0; proc CyclicArr.dsiPrivatize(privatizeData) { var privdom = chpl_getPrivatizedCopy(dom.type, dom.pid); var c = new unmanaged CyclicArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, dom=privdom, locArr=locArr); + strides=strides, dom=privdom, locArr=locArr); for localeIdx in dom.dist.targetLocDom do if c.locArr(localeIdx).locale == here then c.myLocArr = c.locArr(localeIdx); @@ -852,14 +858,14 @@ proc CyclicArr.dsiPrivatize(privatizeData) { inline proc _remoteAccessData.getDataIndex( - param stridable, + param strides, myStr: rank*chpl__signedType(idxType), ind: rank*idxType, startIdx, dimLen) { // modified from DefaultRectangularArr var sum = origin; - if stridable { + if ! strides.isOne() { compilerError("RADOpt not supported for strided cyclic arrays."); } else { for param i in 0..rank-1 do { @@ -879,7 +885,7 @@ proc CyclicArr.dsiAccess(i:rank*idxType) ref { if myLocArrNN.locDom.contains(i) then return myLocArrNN.this(i); } - if !stridable && doRADOpt { + if hasUnitStride() && doRADOpt { if const myLocArr = this.myLocArr { var rlocIdx = dom.dist.targetLocsIdx(i); if !disableCyclicLazyRAD { @@ -887,7 +893,7 @@ proc CyclicArr.dsiAccess(i:rank*idxType) ref { myLocArr.locRADLock.lock(); if myLocArr.locRAD == nil { var tempLocRAD = new unmanaged LocRADCache(eltType, rank, idxType, - stridable=true, dom.dist.targetLocDom); + strideKind.any, dom.dist.targetLocDom); if myLocArr.locCyclicRAD != nil { delete myLocArr.locCyclicRAD; myLocArr.locCyclicRAD = nil; @@ -919,7 +925,7 @@ proc CyclicArr.dsiAccess(i:rank*idxType) ref { pragma "no copy" pragma "no auto destroy" var whole = dom.whole; str(i) = whole.dim(i).stride; } - var dataIdx = radata(rlocIdx).getDataIndex(stridable, str, i, startIdx, dimLength); + var dataIdx = radata(rlocIdx).getDataIndex(strides, str, i, startIdx, dimLength); return radata(rlocIdx).dataElem(dataIdx); } } @@ -964,17 +970,20 @@ iter CyclicArr.these(param tag: iterKind, followThis, param fast: bool = false) if testFastFollowerOptimization then writeln((if fast then "fast" else "regular") + " follower invoked for Cyclic array"); - var t: rank*range(idxType=idxType, stridable=true); + var t: rank*range(idxType=idxType, strides=chpl_strideProduct( + chpl_strideUnion(followThis), dom.whole.strides)); for param i in 0..rank-1 { type strType = chpl__signedType(idxType); - const wholestride = dom.whole.dim(i).stride:chpl__signedType(idxType); - if wholestride < 0 && idxType != strType then + const wholestride = dom.whole.dim(i).stride; + if !dom.whole.strides.isPositive() && idxType != strType then + if wholestride < 0 then halt("negative stride with unsigned idxType not supported"); const iStride = wholestride:idxType; const lo = (followThis(i).lowBound * iStride):idxType, hi = (followThis(i).highBound * iStride):idxType, stride = (followThis(i).stride*wholestride):strType; - t(i) = (lo..hi by stride) + dom.whole.dim(i).low; + t(i).chpl_setFields(lo, hi, stride); + t(i) = t(i) + dom.whole.dim(i).low; } const myFollowThisDom = {(...t)}; if fast { @@ -1021,7 +1030,8 @@ proc CyclicArr.dsiSerialWrite(f) { chpl_serialReadWriteRectangular(f, this); } -override proc CyclicArr.dsiReallocate(bounds:rank*range(idxType,boundKind.both,stridable)) { +override proc CyclicArr.dsiReallocate(bounds:rank*range( + idxType, boundKind.both, strides)) { // The reallocation happens when the LocCyclicDom.myBlock field is changed // in CyclicDom.setup(). Nothing more needs to happen here. } @@ -1142,8 +1152,8 @@ where canDoAnyToCyclic(this, destDom, Src, srcDom) { const end = bulkCommConvertCoordinate(regionDest.last, destDom, srcDom); const sb = chpl__tuplify(regionSrc.stride); - var r1,r2: rank * range(idxType = el,stridable = true); - r2 = regionDest.dims(); + var r1: rank * range(idxType = el, strides = strideKind.any); + const r2 = regionDest.dims(); //In the case that the number of elements in dimension t for r1 and r2 //were different, we need to calculate the correct stride in r1 for param t in 0..rank-1 { @@ -1184,8 +1194,8 @@ where useBulkTransferDist { //r2 is the domain to refer the elements of A in locale j //r1 is the domain to refer the corresponding elements of Dest - var r1,r2: rank * range(idxType = el,stridable = true); - r2 = inters.dims(); + var r1: rank * range(idxType = el, strides = strideKind.any); + const r2 = inters.dims(); //In the case that the number of elements in dimension t for r1 and r2 //were different, we need to calculate the correct stride in r1 @@ -1226,8 +1236,8 @@ where useBulkTransferDist { const end = bulkCommConvertCoordinate(inters.last, destDom, srcDom); const sb = chpl__tuplify(srcDom.stride); - var r1,r2: rank * range(idxType = el,stridable = true); - r2 = inters.dims(); + var r1: rank * range(idxType = el, strides = strideKind.any); + const r2 = inters.dims(); //In the case that the number of elements in dimension t for r1 and r2 //were different, we need to calculate the correct stride in r1 for param t in 0..rank-1 { @@ -1287,7 +1297,7 @@ proc CyclicArr.dsiLocalSubdomain(loc: locale) { if const myLocArrNN = myLocArr then return myLocArrNN.locDom.myBlock; // if not, we must not own anything - var d: domain(rank, idxType, stridable=true); + var d: myBlockType(rank, idxType); return d; } else { return dom.dsiLocalSubdomain(loc); @@ -1296,11 +1306,9 @@ proc CyclicArr.dsiLocalSubdomain(loc: locale) { proc CyclicDom.dsiLocalSubdomain(loc: locale) { const (gotit, locid) = dist.chpl__locToLocIdx(loc); if (gotit) { - return whole[(...(chpl__computeCyclic(this.idxType, locid, dist.targetLocDom.dims(), dist.startIdx)))] - // supports deprecation by Vass in 1.31 to implement #17131 - : domain(rank, idxType, stridable=true); + return whole[(...(chpl__computeCyclic(idxType, locid, dist.targetLocDom.dims(), dist.startIdx)))] : myBlockType(rank, idxType); } else { - var d: domain(rank, idxType, stridable=true); + var d: myBlockType(rank, idxType); return d; } } diff --git a/modules/dists/DSIUtil.chpl b/modules/dists/DSIUtil.chpl index a38c19243493..a1d760aeccf9 100644 --- a/modules/dists/DSIUtil.chpl +++ b/modules/dists/DSIUtil.chpl @@ -503,7 +503,7 @@ private proc asap1(arg) { // asapP1 = All Strides Are Positive - Param - 1 arg // returns true if all strides are known to be positive at compile time private proc asapP1(arg) param { - return !arg.stridable; + return arg.strides.isPositive(); } private proc asapTuple(dims: _tuple) { diff --git a/modules/dists/DimensionalDist2D.chpl b/modules/dists/DimensionalDist2D.chpl index 3a20f0f7574b..be3b0441961c 100644 --- a/modules/dists/DimensionalDist2D.chpl +++ b/modules/dists/DimensionalDist2D.chpl @@ -276,9 +276,9 @@ private proc stoStridableDom(type stoIndexT, dom1, dom2) param { proc stoStridable1d(dom1d) param { const dummy = dom1d.dsiNewLocalDom1d(stoIndexT, 0:locIdT) .dsiSetLocalIndices1d(dom1d, 0:locIdT); - return dummy.stridable; + return dummy.strides; } - return stoStridable1d(dom1) || stoStridable1d(dom2); + return chpl_strideUnion(stoStridable1d(dom1), stoStridable1d(dom2)); } private proc locDescTypeHelper(param rank : int, type idxType, dom1, dom2) type { @@ -287,10 +287,10 @@ private proc locDescTypeHelper(param rank : int, type idxType, dom1, dom2) type proc strideHelper(dom1d) param { const dummy = dom1d.dsiNewLocalDom1d(idxType, 0).dsiSetLocalIndices1d(dom1d, 0); - return dummy.stridable; + return dummy.strides; } - param str = strideHelper(dom1) || strideHelper(dom2); + param str = chpl_strideUnion(strideHelper(dom1), strideHelper(dom2)); return unmanaged LocDimensionalDom(domain(rank, idxType, str), d1type, d2type); } @@ -301,8 +301,8 @@ class DimensionalDom : BaseRectangularDom { // convenience proc targetIds do return localDdescs.domain; - proc rangeT type do return range(idxType, boundKind.both, stridable); - proc domainT type do return domain(rank, idxType, stridable); + proc rangeT type do return range(idxType, boundKind.both, strides); + proc domainT type do return domain(rank, idxType, strides); proc indexT type do return dist.indexT; // subordinate 1-d global domain descriptors @@ -310,7 +310,7 @@ class DimensionalDom : BaseRectangularDom { // This is our index set; we store it here so we can get to it easily. // Although strictly speaking it is not necessary. - var whole: domain(rank, idxType, stridable); + var whole: domain(rank, idxType, strides); // This is the idxType of the "storage index ranges" to be produced // by dsiSetLocalIndices1d(). It needs to be uniform across dimensions, @@ -320,7 +320,7 @@ class DimensionalDom : BaseRectangularDom { // replace this with 'this.stridable' for simplicity? proc stoStridable param do return stoStridableDom(stoIndexT, dom1, dom2); - proc stoRangeT type do return range(stoIndexT, stridable = stoStridable); + proc stoRangeT type do return range(stoIndexT, strides = stoStridable); proc stoDomainT type do return domain(rank, stoIndexT, stoStridable); // convenience - our instantiation of LocDimensionalDom @@ -536,7 +536,7 @@ proc DimensionalDist2D.dsiPrivatize(privatizeData) { const pdTargetLocales = privatizeData(0); const privTargetIds: domain(pdTargetLocales.domain.rank, pdTargetLocales.domain.idxType, - pdTargetLocales.domain.stridable + pdTargetLocales.domain.strides ) = pdTargetLocales.domain; const privTargetLocales: [privTargetIds] locale = pdTargetLocales; @@ -726,7 +726,7 @@ proc DimensionalDom.dsiPrivatize(privatizeData) { const result = new unmanaged DimensionalDom(rank = this.rank, idxType = this.idxType, - stridable = this.stridable, + strides = this.strides, dist = privdist, dom1 = dom1new, dom2 = dom2new, @@ -764,7 +764,7 @@ proc DimensionalDom.dsiReprivatize(other, reprivatizeData) { compilerAssert(this.rank == other.rank && this.idxType == other.idxType && - this.stridable == other.stridable); + this.strides == other.strides); dom1.dsiReprivatize1d(reprivatizeData(0)); dom2.dsiReprivatize1d(reprivatizeData(1)); @@ -785,12 +785,12 @@ proc DimensionalDom.dimSpecifier(param dim: int) { // create a new domain mapped with this distribution override proc DimensionalDist2D.dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, + param strides: strideKind, inds) -// : DimensionalDom(rank, idxType, stridable, this.type, ...) +// : DimensionalDom(rank, idxType, strides, this.type, ...) { _traceddd(this, ".dsiNewRectangularDom ", - (rank, idxType:string, stridable, inds)); + (rank, idxType:string, strides, inds)); if rank != 2 then compilerError("DimensionalDist2D presently supports only 2 dimensions,", " got ", rank:string, " dimensions"); @@ -809,10 +809,10 @@ override proc DimensionalDist2D.dsiNewRectangularDom(param rank: int, // need this for dsiNewRectangularDom1d() type stoIndexT = this.idxType; - var dom1 = di1.dsiNewRectangularDom1d(idxType, stridable, stoIndexT); + var dom1 = di1.dsiNewRectangularDom1d(idxType, strides, stoIndexT); _passLocalLocIDsDom1d(dom1, di1); - var dom2 = di2.dsiNewRectangularDom1d(idxType, stridable, stoIndexT); + var dom2 = di2.dsiNewRectangularDom1d(idxType, strides, stoIndexT); _passLocalLocIDsDom1d(dom2, di2); // We could try the dummyLB trick from BlockDist instead of the '?'/'!', @@ -831,7 +831,7 @@ override proc DimensionalDist2D.dsiNewRectangularDom(param rank: int, var localDdescsNN = localDdescsTemp!; //#15080 const result = new unmanaged DimensionalDom(rank=rank, idxType=idxType, - stridable=stridable, dist=_to_unmanaged(this), + strides=strides, dist=_to_unmanaged(this), localDdescs = localDdescsNN, dom1 = dom1, dom2 = dom2); // result.whole is initialized to the default value (empty domain) @@ -861,7 +861,7 @@ proc DimensionalDom.dsiDims() do return whole.dims(); proc DimensionalDom.dsiMember(i) do return whole.contains(i); proc DimensionalDom.doiToString() do return whole:string; proc DimensionalDom.dsiSerialWrite(x) do { x.write(whole); } -proc DimensionalDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc DimensionalDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc DimensionalDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc DimensionalDom.dsiMyDist() do return dist; @@ -918,7 +918,7 @@ proc LocDimensionalDom._dsiLocalSetIndicesHelper(type stoRangeT, globDD, locId) proc DimensionalDom.dsiGetIndices(): rank * range(idxType, boundKind.both, - stridable) { + strides) { _traceddd(this, ".dsiGetIndices"); return whole.dims(); } @@ -954,7 +954,7 @@ proc DimensionalArr.dsiPrivatize(privatizeData) { const result = new unmanaged DimensionalArr(rank = this.rank, idxType = this.idxType, - stridable= this.stridable, + strides = this.strides, eltType = this.eltType, localAdescs = privatizeData(2), dom = privDom, @@ -1004,7 +1004,7 @@ proc DimensionalDom.dsiBuildArray(type eltType, param initElts:bool) var localAdescsNN = localAdescsTemp!; //#15080 const result = new unmanaged DimensionalArr(rank = rank, idxType = idxType, - stridable = stridable, + strides = strides, eltType = eltType, localAdescs = localAdescsNN, dom = _to_unmanaged(this), diff --git a/modules/dists/PrivateDist.chpl b/modules/dists/PrivateDist.chpl index 7e62da4430c0..6861a2d31cdc 100644 --- a/modules/dists/PrivateDist.chpl +++ b/modules/dists/PrivateDist.chpl @@ -69,13 +69,13 @@ between locales. */ class Private: BaseDist { override proc dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, inds) { + param strides: strideKind, inds) { for i in inds do if i.size != 0 then halt("Tried to create a privateDom with a specific index set"); return new unmanaged PrivateDom(rank=rank, idxType=idxType, - stridable=stridable, + strides=strides, dist=_to_unmanaged(this)); } @@ -116,7 +116,7 @@ class PrivateDom: BaseRectangularDom { proc dsiBuildArray(type eltType, param initElts:bool) { return new unmanaged PrivateArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, + strides=strides, dom=_to_unmanaged(this), initElts=initElts); } @@ -151,7 +151,7 @@ class PrivateDom: BaseRectangularDom { proc dsiPrivatize(privatizeData) { return new unmanaged PrivateDom(rank=rank, idxType=idxType, - stridable=stridable, + strides=strides, dist=dist); } @@ -170,7 +170,7 @@ private proc checkCanMakeDefaultValue(type eltType) param { class PrivateArr: BaseRectangularArr { - var dom: unmanaged PrivateDom(rank, idxType, stridable); + var dom: unmanaged PrivateDom(rank, idxType, strides); // may be initialized separately // always destroyed explicitly (to control deiniting elts) @@ -183,11 +183,11 @@ class PrivateArr: BaseRectangularArr { proc init(type eltType, param rank, type idxType, - param stridable, - dom: unmanaged PrivateDom(rank, idxType, stridable), + param strides, + dom: unmanaged PrivateDom(rank, idxType, strides), param initElts: bool) { super.init(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable); + strides=strides); this.dom = dom; // this.data not initialized this.isPrivatizedCopy = false; @@ -204,7 +204,7 @@ class PrivateArr: BaseRectangularArr { var privdom = chpl_getPrivatizedCopy(toPrivatize.dom.type, toPrivatize.dom.pid); super.init(eltType=toPrivatize.eltType, rank=toPrivatize.rank, - idxType=toPrivatize.idxType, stridable=toPrivatize.stridable); + idxType=toPrivatize.idxType, strides=toPrivatize.strides); this.dom = privdom; // this.data not initialized this.isPrivatizedCopy = true; diff --git a/modules/dists/ReplicatedDist.chpl b/modules/dists/ReplicatedDist.chpl index 23c778c158fb..3455d01ea92e 100644 --- a/modules/dists/ReplicatedDist.chpl +++ b/modules/dists/ReplicatedDist.chpl @@ -186,11 +186,12 @@ class ReplicatedDom : BaseRectangularDom { const dist : unmanaged Replicated; // must be a Replicated // this is our index set; we store it here so we can get to it easily - var whole: domain(rank, idxType, stridable); + var whole: domain(rank, idxType, strides); // local domain objects // NOTE: if they ever change after the initializer - Reprivatize them - var localDoms: [dist.targetLocDom] unmanaged LocReplicatedDom(rank, idxType, stridable)?; + var localDoms: [dist.targetLocDom] unmanaged LocReplicatedDom(rank, idxType, + strides)?; proc numReplicands do return localDoms.sizeAs(int); @@ -214,10 +215,10 @@ class LocReplicatedDom { // copy from the global domain param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; // our index set, copied from the global domain - var domLocalRep: domain(rank, idxType, stridable); + var domLocalRep: domain(rank, idxType, strides); } @@ -245,7 +246,8 @@ proc ReplicatedDom.dsiPrivatize(privatizeData) { if traceReplicatedDist then writeln("ReplicatedDom.dsiPrivatize on ", here); var privdist = chpl_getPrivatizedCopy(this.dist.type, privatizeData.distpid); - return new unmanaged ReplicatedDom(rank=rank, idxType=idxType, stridable=stridable, + return new unmanaged ReplicatedDom(rank=rank, idxType=idxType, + strides=strides, dist = privdist, whole = privatizeData.whole, localDoms = privatizeData.localDoms); @@ -258,7 +260,7 @@ proc ReplicatedDom.dsiGetReprivatizeData() { proc ReplicatedDom.dsiReprivatize(other, reprivatizeData): void { assert(this.rank == other.rank && this.idxType == other.idxType && - this.stridable == other.stridable); + this.strides == other.strides); this.whole = reprivatizeData; } @@ -274,21 +276,21 @@ proc Replicated.dsiClone(): _to_unmanaged(this.type) { // create a new domain mapped with this distribution override proc Replicated.dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, + param strides: strideKind, inds) { if traceReplicatedDist then writeln("Replicated.dsiNewRectangularDom ", - (rank, idxType:string, stridable, inds)); + (rank, idxType:string, strides, inds)); // Have to call the default initializer because we need to initialize 'dist' // prior to initializing 'localDoms' (which needs a non-nil value for 'dist'. var result = new unmanaged ReplicatedDom(rank=rank, idxType=idxType, - stridable=stridable, dist=_to_unmanaged(this)); + strides=strides, dist=_to_unmanaged(this)); // create local domain objects coforall (loc, locDom) in zip(targetLocales, result.localDoms) do on loc do - locDom = new unmanaged LocReplicatedDom(rank, idxType, stridable); + locDom = new unmanaged LocReplicatedDom(rank, idxType, strides); result.dsiSetIndices(inds); return result; @@ -318,7 +320,7 @@ proc ReplicatedDom.dsiDims() do return whole.dims(); proc ReplicatedDom.dsiMember(i) do return whole.contains(i); proc ReplicatedDom.doiToString() do return whole:string; proc ReplicatedDom.dsiSerialWrite(x) { x.write(whole); } -proc ReplicatedDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc ReplicatedDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc ReplicatedDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc ReplicatedDom.dsiMyDist() do return dist; @@ -341,7 +343,7 @@ proc ReplicatedDom.dsiSetIndices(domArg: domain): void { proc ReplicatedDom.dsiGetIndices(): rank * range(idxType, boundKind.both, - stridable) { + strides) { if traceReplicatedDist then writeln("ReplicatedDom.dsiGetIndices"); return whole.getIndices(); } @@ -393,7 +395,7 @@ class ReplicatedArr : AbsBaseArr { // the replicated arrays // NOTE: 'dom' must be initialized prior to initializing 'localArrs' var localArrs: [dom.dist.targetLocDom] - unmanaged LocReplicatedArr(eltType, dom.rank, dom.idxType, dom.stridable)?; + unmanaged LocReplicatedArr(eltType, dom.rank, dom.idxType, dom.strides)?; // // helper function to get the local array safely @@ -435,9 +437,9 @@ class LocReplicatedArr { type eltType; param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; - var myDom: unmanaged LocReplicatedDom(rank, idxType, stridable); + var myDom: unmanaged LocReplicatedDom(rank, idxType, strides); pragma "local field" pragma "unsafe" pragma "no auto destroy" // may be re-initialized separately // always destroyed explicitly (to control deiniting elts) @@ -446,13 +448,13 @@ class LocReplicatedArr { proc init(type eltType, param rank: int, type idxType, - param stridable: bool, - myDom: unmanaged LocReplicatedDom(rank, idxType, stridable), + param strides: strideKind, + myDom: unmanaged LocReplicatedDom(rank, idxType, strides), param initElts: bool) { this.eltType = eltType; this.rank = rank; this.idxType = idxType; - this.stridable = stridable; + this.strides = strides; this.myDom = myDom; // @@ -486,8 +488,8 @@ proc ReplicatedArr.init(type eltType, dom) { this.dom = dom; } -proc ReplicatedArr.stridable param { - return dom.stridable; +proc ReplicatedArr.strides param { + return dom.strides; } proc ReplicatedArr.idxType type { @@ -558,12 +560,12 @@ proc ReplicatedDom.dsiBuildArray(type eltType, param initElts:bool) // if here == globalArrayLocale && !initElts { locArr = new unmanaged LocReplicatedArr(eltType, rank, idxType, - stridable, + strides, locDom!, initElts=false); } else { locArr = new unmanaged LocReplicatedArr(eltType, rank, idxType, - stridable, + strides, locDom!, initElts=true); } @@ -678,7 +680,7 @@ proc ReplicatedDom.dsiLocalSubdomain(loc: locale) { if localDoms.domain.contains(loc.id) then return whole; else { - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } } @@ -687,7 +689,7 @@ proc ReplicatedArr.dsiLocalSubdomain(loc: locale) { if localArrs.domain.contains(loc.id) then return dom.whole; else { - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } } diff --git a/modules/dists/SparseBlockDist.chpl b/modules/dists/SparseBlockDist.chpl index fe0edfa813a7..8d14823aaf28 100644 --- a/modules/dists/SparseBlockDist.chpl +++ b/modules/dists/SparseBlockDist.chpl @@ -76,19 +76,19 @@ record TargetLocaleComparator { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // dist: reference to distribution class // locDoms: a non-distributed array of local domain classes // whole: a non-distributed domain that defines the domain's indices // class SparseBlockDom: BaseSparseDomImpl { type sparseLayoutType; - param stridable: bool = false; // TODO: remove default value eventually + param strides = strideKind.one; // TODO: remove default value eventually const dist: unmanaged Block(rank, idxType, sparseLayoutType); - var whole: domain(rank=rank, idxType=idxType, stridable=stridable); + var whole: domain(rank=rank, idxType=idxType, strides=strides); var locDoms: [dist.targetLocDom] unmanaged LocSparseBlockDom(rank, idxType, - stridable, sparseLayoutType)?; - var myLocDom: unmanaged LocSparseBlockDom(rank, idxType, stridable, + strides, sparseLayoutType)?; + var myLocDom: unmanaged LocSparseBlockDom(rank, idxType, strides, sparseLayoutType)?; // TODO: move towards init and away from nilable types @@ -101,9 +101,8 @@ class SparseBlockDom: BaseSparseDomImpl { on dist.targetLocales(localeIdx) do { // writeln("Setting up on ", here.id); // writeln("setting up on ", localeIdx, ", whole is: ", whole, ", chunk is: ", dist.getChunk(whole,localeIdx)); - locDoms(localeIdx) = new unmanaged LocSparseBlockDom(rank, idxType, stridable, - // the cast to domain supports deprecation by Vass in 1.31 for #17131 - sparseLayoutType, dist.getChunk(whole,localeIdx): domain(rank, idxType, stridable)); + locDoms(localeIdx) = new unmanaged LocSparseBlockDom(rank, idxType, + strides, sparseLayoutType, dist.getChunk(whole,localeIdx)); // writeln("Back on ", here.id); if thisid == here.id then myLocDom = locDoms(localeIdx); @@ -253,7 +252,7 @@ class SparseBlockDom: BaseSparseDomImpl { var arr = new unmanaged SparseBlockArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, + strides=strides, sparseLayoutType=sparseLayoutType, dom=_to_unmanaged(this)); arr.setup(initElts); @@ -343,15 +342,15 @@ private proc getDefaultSparseDist(type sparseLayoutType) { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // mySparseBlock: a non-distributed domain that defines the local indices // class LocSparseBlockDom { param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; type sparseLayoutType; - var parentDom: domain(rank, idxType, stridable); + var parentDom: domain(rank, idxType, strides); var sparseDist = getDefaultSparseDist(sparseLayoutType); var mySparseBlock: sparse subdomain(parentDom) dmapped sparseDist; @@ -383,13 +382,13 @@ class LocSparseBlockDom { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // dom: reference to domain class // locArr: a non-distributed array of local array classes // myLocArr: optimized reference to here's local array class (or nil) // class SparseBlockArr: BaseSparseArr { - param stridable: bool; + param strides: strideKind; type sparseLayoutType = unmanaged DefaultDist; // INIT TODO: Can we address this constructor/initializer issue now? @@ -398,14 +397,14 @@ class SparseBlockArr: BaseSparseArr { // the constructor for the workaround. var locArrDom: domain(rank,idxType); var locArr: [locArrDom] unmanaged LocSparseBlockArr(eltType, rank, idxType, - stridable, sparseLayoutType)?; - var myLocArr: unmanaged LocSparseBlockArr(eltType, rank, idxType, stridable, + strides, sparseLayoutType)?; + var myLocArr: unmanaged LocSparseBlockArr(eltType, rank, idxType, strides, sparseLayoutType)?; - proc init(type eltType, param rank, type idxType, param stridable, + proc init(type eltType, param rank, type idxType, param strides, type sparseLayoutType ,dom) { super.init(eltType=eltType, rank=rank, idxType=idxType, dom=dom); - this.stridable = stridable; + this.strides = strides; this.sparseLayoutType = sparseLayoutType; this.locArrDom = dom.dist.targetLocDom; } @@ -417,7 +416,7 @@ class SparseBlockArr: BaseSparseArr { const locDom = dom.getLocDom(localeIdx); locArr(localeIdx) = new unmanaged LocSparseBlockArr(eltType, rank, idxType, - stridable, + strides, sparseLayoutType, locDom, initElts=initElts); @@ -548,7 +547,7 @@ class SparseBlockArr: BaseSparseArr { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // locDom: reference to local domain class // myElems: a non-distributed array of local elements // @@ -556,9 +555,10 @@ class LocSparseBlockArr { type eltType; param rank: int; type idxType; - param stridable: bool; + param strides: strideKind; type sparseLayoutType; - const locDom: unmanaged LocSparseBlockDom(rank, idxType, stridable, sparseLayoutType); + const locDom: unmanaged LocSparseBlockDom(rank, idxType, strides, + sparseLayoutType); pragma "local field" pragma "unsafe" // may be initialized separately var myElems: [locDom.mySparseBlock] eltType; @@ -566,15 +566,15 @@ class LocSparseBlockArr { proc init(type eltType, param rank: int, type idxType, - param stridable: bool, + param strides: strideKind, type sparseLayoutType, - const locDom: unmanaged LocSparseBlockDom(rank, idxType, stridable, + const locDom: unmanaged LocSparseBlockDom(rank, idxType, strides, sparseLayoutType), param initElts: bool) { this.eltType = eltType; this.rank = rank; this.idxType = idxType; - this.stridable = stridable; + this.strides = strides; this.sparseLayoutType = sparseLayoutType; this.locDom = locDom; this.myElems = locDom.mySparseBlock.buildArray(eltType, initElts=initElts); @@ -706,10 +706,10 @@ override proc SparseBlockArr.dsiDisplayRepresentation() { } } -inline proc _remoteAccessData.getDataIndex(param stridable, ind: rank*idxType) { +inline proc _remoteAccessData.getDataIndex(param strides, ind: rank*idxType) { // modified from DefaultRectangularArr below var sum = origin; - if stridable { + if !strides.isOne() { for param i in 1..rank do sum += (ind(i) - off(i)) * blk(i) / abs(str(i)):idxType; } else { @@ -819,7 +819,7 @@ proc SparseBlockDom.dsiPrivatize(privatizeData) { var privdist = chpl_getPrivatizedCopy(dist.type, privatizeData(0)); var c = new unmanaged SparseBlockDom(rank=rank, idxType=idxType, sparseLayoutType=sparseLayoutType, - stridable=parentDom.stridable, dist=privdist, + strides=parentDom.strides, dist=privdist, whole=whole, parentDom=parentDom); for i in c.dist.targetLocDom { @@ -846,7 +846,7 @@ proc SparseBlockArr.dsiGetPrivatizeData() do return dom.pid; proc SparseBlockArr.dsiPrivatize(privatizeData) { var privdom = chpl_getPrivatizedCopy(dom.type, privatizeData); var c = new unmanaged SparseBlockArr(sparseLayoutType=sparseLayoutType, - eltType=eltType, rank=rank, idxType=idxType, stridable=stridable, + eltType=eltType, rank=rank, idxType=idxType, strides=strides, dom=privdom); for localeIdx in c.dom.dist.targetLocDom { c.locArr(localeIdx) = locArr(localeIdx); diff --git a/modules/dists/StencilDist.chpl b/modules/dists/StencilDist.chpl index 626907e5d7a8..96eed4830da7 100644 --- a/modules/dists/StencilDist.chpl +++ b/modules/dists/StencilDist.chpl @@ -279,7 +279,7 @@ class LocStencil { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // dist: reference to distribution class // locDoms: a non-distributed array of local domain classes // whole: a non-distributed domain that defines the domain's indices @@ -287,11 +287,12 @@ class LocStencil { class StencilDom: BaseRectangularDom { param ignoreFluff : bool; const dist: unmanaged Stencil(rank, idxType, ignoreFluff); - var locDoms: [dist.targetLocDom] unmanaged LocStencilDom(rank, idxType, stridable); - var whole: domain(rank=rank, idxType=idxType, stridable=stridable); + var locDoms: [dist.targetLocDom] unmanaged LocStencilDom(rank, idxType, + strides); + var whole: domain(rank=rank, idxType=idxType, strides=strides); var fluff: rank*idxType; var periodic: bool = false; - var wholeFluff : domain(rank=rank, idxType=idxType, stridable=stridable); + var wholeFluff : domain(rank, idxType, strides); } // @@ -299,7 +300,7 @@ class StencilDom: BaseRectangularDom { // // rank: generic domain rank // idxType: generic domain index type -// stridable: generic domain stridable parameter +// strides: generic domain stridable parameter // myBlock: a non-distributed domain that defines the local indices // // NeighDom will be a rectangular domain where each dimension is the range @@ -308,12 +309,12 @@ class StencilDom: BaseRectangularDom { class LocStencilDom { param rank: int; type idxType; - param stridable: bool; - var myBlock, myFluff: domain(rank, idxType, stridable); + param strides: strideKind; + var myBlock, myFluff: domain(rank, idxType, strides); var NeighDom: domain(rank); var bufDom : domain(1); var recvDest, recvSrc, - sendDest, sendSrc: [NeighDom] domain(rank, idxType, stridable); + sendDest, sendSrc: [NeighDom] domain(rank, idxType, strides); var Neighs: [NeighDom] rank*int; } @@ -323,7 +324,7 @@ class LocStencilDom { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // dom: reference to domain class // locArr: a non-distributed array of local array classes // myLocArr: optimized reference to here's local array class (or nil) @@ -331,10 +332,11 @@ class LocStencilDom { class StencilArr: BaseRectangularArr { param ignoreFluff: bool; var doRADOpt: bool = defaultDoRADOpt; - var dom: unmanaged StencilDom(rank, idxType, stridable, ignoreFluff); - var locArr: [dom.dist.targetLocDom] unmanaged LocStencilArr(eltType, rank, idxType, stridable); + var dom: unmanaged StencilDom(rank, idxType, strides, ignoreFluff); + var locArr: [dom.dist.targetLocDom] unmanaged LocStencilArr(eltType, rank, + idxType, strides); pragma "local field" - var myLocArr: unmanaged LocStencilArr(eltType, rank, idxType, stridable)?; + var myLocArr: unmanaged LocStencilArr(eltType, rank, idxType, strides)?; const SENTINEL = max(rank*idxType); } @@ -344,7 +346,7 @@ class StencilArr: BaseRectangularArr { // eltType: generic array element type // rank: generic array rank // idxType: generic array index type -// stridable: generic array stridable parameter +// strides: generic array stridable parameter // locDom: reference to local domain class // myElems: a non-distributed array of local elements // @@ -352,9 +354,9 @@ class LocStencilArr { type eltType; param rank: int; type idxType; - param stridable: bool; - const locDom: unmanaged LocStencilDom(rank, idxType, stridable); - var locRAD: unmanaged LocRADCache(eltType, rank, idxType, chpl_strideKind(stridable))?; // non-nil if doRADOpt=true + param strides: strideKind; + const locDom: unmanaged LocStencilDom(rank, idxType, strides); + var locRAD: unmanaged LocRADCache(eltType, rank, idxType, strides)?; // non-nil if doRADOpt=true pragma "local field" pragma "unsafe" // may be initialized separately var myElems: [locDom.myFluff] eltType; @@ -367,13 +369,13 @@ class LocStencilArr { proc init(type eltType, param rank: int, type idxType, - param stridable: bool, - const locDom: unmanaged LocStencilDom(rank, idxType, stridable), + param strides: strideKind, + const locDom: unmanaged LocStencilDom(rank, idxType, strides), param initElts: bool) { this.eltType = eltType; this.rank = rank; this.idxType = idxType; - this.stridable = stridable; + this.strides = strides; this.locDom = locDom; this.myElems = this.locDom.myFluff.buildArray(eltType, initElts=initElts); @@ -446,7 +448,7 @@ proc Stencil.init(boundingBox: domain, this.idxType = idxType; this.ignoreFluff = ignoreFluff; - this.boundingBox = boundingBox : domain(rank, idxType, stridable=false); + this.boundingBox = boundingBox : domain(rank, idxType); this.fluff = fluff; // can't have periodic if there's no fluff @@ -547,23 +549,23 @@ override proc Stencil.dsiDisplayRepresentation() { } override proc Stencil.dsiNewRectangularDom(param rank: int, type idxType, - param stridable: bool, inds) { + param strides: strideKind, inds) { if idxType != this.idxType then compilerError("Stencil domain index type does not match distribution's"); if rank != this.rank then compilerError("Stencil domain rank does not match distribution's"); - const dummyLSD = new unmanaged LocStencilDom(rank, idxType, stridable); + const dummyLSD = new unmanaged LocStencilDom(rank, idxType, strides); var locDomsTemp: [this.targetLocDom] - unmanaged LocStencilDom(rank, idxType, stridable) = dummyLSD; + unmanaged LocStencilDom(rank, idxType, strides) = dummyLSD; coforall localeIdx in this.targetLocDom do on this.targetLocales(localeIdx) do locDomsTemp(localeIdx) = - new unmanaged LocStencilDom(rank, idxType, stridable, + new unmanaged LocStencilDom(rank, idxType, strides, NeighDom=nearestDom(rank)); delete dummyLSD; - var dom = new unmanaged StencilDom(rank, idxType, stridable, ignoreFluff, + var dom = new unmanaged StencilDom(rank, idxType, strides, ignoreFluff, _to_unmanaged(this), locDomsTemp, fluff=fluff, periodic=periodic); dom.dsiSetIndices(inds); @@ -795,14 +797,11 @@ iter StencilDom.these(param tag: iterKind) where tag == iterKind.leader { // stencil communication will be done on a per-locale basis. // iter StencilDom.these(param tag: iterKind, followThis) where tag == iterKind.follower { - proc anyStridable(rangeTuple, param i: int = 0) param do - return if i == rangeTuple.size-1 then rangeTuple(i).stridable - else rangeTuple(i).stridable || anyStridable(rangeTuple, i+1); - if chpl__testParFlag then chpl__testPar("Stencil domain follower invoked on ", followThis); - var t: rank*range(idxType, stridable=stridable||anyStridable(followThis)); + var t: rank*range(idxType, strides=chpl_strideProduct(strides, + chpl_strideUnion(followThis))); for param i in 0..rank-1 { const wholeDim = whole.dim(i); const followDim = followThis(i); @@ -823,17 +822,17 @@ iter StencilDom.these(param tag: iterKind, followThis) where tag == iterKind.fol proc StencilDom.dsiBuildArray(type eltType, param initElts:bool) { const dom = this; const creationLocale = here.id; - const dummyLSD = new unmanaged LocStencilDom(rank, idxType, stridable); + const dummyLSD = new unmanaged LocStencilDom(rank, idxType, strides); const dummyLSA = new unmanaged LocStencilArr(eltType, rank, idxType, - stridable, dummyLSD, false); + strides, dummyLSD, false); var locArrTemp: [dom.dist.targetLocDom] - unmanaged LocStencilArr(eltType, rank, idxType, stridable) = dummyLSA; - var myLocArrTemp: unmanaged LocStencilArr(eltType, rank, idxType, stridable)?; + unmanaged LocStencilArr(eltType, rank, idxType, strides) = dummyLSA; + var myLocArrTemp: unmanaged LocStencilArr(eltType, rank, idxType, strides)?; // formerly in StencilArr.setup() coforall localeIdx in dom.dist.targetLocDom with (ref myLocArrTemp) { on dom.dist.targetLocales(localeIdx) { - const LSA = new unmanaged LocStencilArr(eltType, rank, idxType, stridable, + const LSA = new unmanaged LocStencilArr(eltType, rank, idxType, strides, dom.getLocDom(localeIdx), initElts=initElts); locArrTemp(localeIdx) = LSA; @@ -844,7 +843,7 @@ proc StencilDom.dsiBuildArray(type eltType, param initElts:bool) { delete dummyLSA, dummyLSD; var arr = new unmanaged StencilArr(eltType=eltType, rank=rank, - idxType=idxType, stridable=stridable, ignoreFluff=this.ignoreFluff, + idxType=idxType, strides=strides, ignoreFluff=this.ignoreFluff, dom=_to_unmanaged(this), locArr=locArrTemp, myLocArr=myLocArrTemp); // formerly in StencilArr.setup() @@ -870,7 +869,7 @@ proc StencilDom.dsiGetIndices() do return whole.getIndices(); //proc StencilDom.dsiMember(i) do return whole.contains(i); proc StencilDom.doiToString() do return whole:string; proc StencilDom.dsiSerialWrite(x) { x.write(whole); } -proc StencilDom.dsiLocalSlice(param stridable, ranges) do return whole((...ranges)); +proc StencilDom.dsiLocalSlice(param strides, ranges) do return whole((...ranges)); override proc StencilDom.dsiIndexOrder(i) do return whole.indexOrder(i); override proc StencilDom.dsiMyDist() do return dist; @@ -982,14 +981,14 @@ proc StencilDom.setup() { // TODO: simplify? if to(i) < 0 then - dr(i) = cur.first - fa .. cur.first-abstr(i); + dr(i).chpl_setFields(cur.first - fa, cur.first-abstr(i), + cur.stride); else if to(i) > 0 then - dr(i) = cur.last+abstr(i)..cur.last+fa; + dr(i).chpl_setFields(cur.last+abstr(i), cur.last+fa, + cur.stride); else - dr(i) = cur.first..cur.last; - - if stridable then - dr(i) = dr(i) by cur.stride; + dr(i).chpl_setFields(cur.first, cur.last, + cur.stride); } // destination indices in the fluff region @@ -1113,7 +1112,8 @@ proc StencilArr.setupRADOpt() { myLocArr.locRAD = nil; } if disableStencilLazyRAD { - myLocArr.locRAD = new unmanaged LocRADCache(eltType, rank, idxType, stridable, dom.dist.targetLocDom); + myLocArr.locRAD = new unmanaged LocRADCache(eltType, rank, idxType, + strides, dom.dist.targetLocDom); for l in dom.dist.targetLocDom { if l != localeIdx { myLocArr.locRAD.RAD(l) = locArr(l).myElems._value.dsiGetRAD(); @@ -1209,7 +1209,8 @@ proc StencilArr.nonLocalAccess(i: rank*idxType) ref { if myLocArr.locRAD == nil { myLocArr.locRADLock.lock(); if myLocArr.locRAD == nil { - var tempLocRAD = new unmanaged LocRADCache(eltType, rank, idxType, stridable, dom.dist.targetLocDom); + var tempLocRAD = new unmanaged LocRADCache(eltType, rank, idxType, + strides, dom.dist.targetLocDom); tempLocRAD.RAD.blk = SENTINEL; myLocArr.locRAD = tempLocRAD; } @@ -1298,10 +1299,6 @@ proc StencilArr.dsiDynamicFastFollowCheck(lead: domain) { } iter StencilArr.these(param tag: iterKind, followThis, param fast: bool = false) ref where tag == iterKind.follower { - proc anyStridable(rangeTuple, param i: int = 0) param do - return if i == rangeTuple.size-1 then rangeTuple(i).stridable - else rangeTuple(i).stridable || anyStridable(rangeTuple, i+1); - if chpl__testParFlag { if fast then chpl__testPar("Stencil array fast follower invoked on ", followThis); @@ -1312,7 +1309,8 @@ iter StencilArr.these(param tag: iterKind, followThis, param fast: bool = false) if testFastFollowerOptimization then writeln((if fast then "fast" else "regular") + " follower invoked for Stencil array"); - var myFollowThis: rank*range(idxType=idxType, stridable=stridable || anyStridable(followThis)); + var myFollowThis: rank*range(idxType=idxType, strides=chpl_strideProduct( + strides, chpl_strideUnion(followThis))); var lowIdx: rank*idxType; for param i in 0..rank-1 { @@ -1546,13 +1544,16 @@ proc StencilArr.noFluffView() { dom.dist.dataParTasksPerLocale, dom.dist.dataParIgnoreRunningTasks, dom.dist.dataParMinGranularity, ignoreFluff=true); pragma "no auto destroy" var newDist = new _distribution(tempDist); - pragma "no auto destroy" var tempDom = new _domain(newDist, rank, idxType, dom.stridable, dom.whole.dims()); + pragma "no auto destroy" var tempDom = new _domain(newDist, rank, idxType, + dom.strides, dom.whole.dims()); newDist._value._free_when_no_doms = true; var newDom = tempDom._value; newDom._free_when_no_arrs = true; - var alias = new unmanaged StencilArr(eltType=eltType, rank=rank, idxType=idxType, stridable=newDom.stridable, dom=newDom, ignoreFluff=true, locArr=locArr, myLocArr=myLocArr); + var alias = new unmanaged StencilArr(eltType=eltType, rank=rank, + idxType=idxType, strides=newDom.strides, dom=newDom, + ignoreFluff=true, locArr=locArr, myLocArr=myLocArr); newDom.add_arr(alias, locking=false); return _newArray(alias); @@ -1711,7 +1712,8 @@ proc StencilArr.updateFluff() { } } -override proc StencilArr.dsiReallocate(bounds:rank*range(idxType,boundKind.both,stridable)) +override proc StencilArr.dsiReallocate(bounds:rank*range(idxType, + boundKind.both, strides)) { // // For the default rectangular array, this function changes the data @@ -1798,10 +1800,10 @@ proc StencilDom.dsiPrivatize(privatizeData) { var privdist = chpl_getPrivatizedCopy(dist.type, privatizeData(0)); var locDomsTemp: [privdist.targetLocDom] - unmanaged LocStencilDom(rank, idxType, stridable) + unmanaged LocStencilDom(rank, idxType, strides) = locDoms; - var c = new unmanaged StencilDom(rank, idxType, stridable, ignoreFluff, + var c = new unmanaged StencilDom(rank, idxType, strides, ignoreFluff, privdist, locDomsTemp, {(...privatizeData(1))}, fluff, periodic); if c.whole.sizeAs(int) > 0 { @@ -1841,7 +1843,7 @@ proc type StencilDom.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged StencilDom(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, ignoreFluff=this.ignoreFluff), data); } @@ -1855,7 +1857,7 @@ proc type StencilArr.chpl__deserialize(data) { return chpl_getPrivatizedCopy( unmanaged StencilArr(rank=this.rank, idxType=this.idxType, - stridable=this.stridable, + strides=this.strides, eltType=this.eltType, ignoreFluff=this.ignoreFluff), data); @@ -1869,16 +1871,16 @@ proc StencilArr.dsiPrivatize(privatizeData) { var privdom = chpl_getPrivatizedCopy(dom.type, privatizeData); var locArrTemp: [privdom.dist.targetLocDom] - unmanaged LocStencilArr(eltType, rank, idxType, stridable) + unmanaged LocStencilArr(eltType, rank, idxType, strides) = locArr; - var myLocArrTemp: unmanaged LocStencilArr(eltType, rank, idxType, stridable)?; + var myLocArrTemp: unmanaged LocStencilArr(eltType, rank, idxType, strides)?; for localeIdx in privdom.dist.targetLocDom do if locArrTemp(localeIdx).locale.id == here.id then myLocArrTemp = locArrTemp(localeIdx); var c = new unmanaged StencilArr(eltType=eltType, rank=rank, idxType=idxType, - stridable=stridable, ignoreFluff=ignoreFluff, + strides=strides, ignoreFluff=ignoreFluff, dom=privdom, locArr=locArrTemp, myLocArr=myLocArrTemp); return c; } @@ -1916,7 +1918,7 @@ proc StencilArr.dsiLocalSubdomain(loc: locale) { if myLocArr != nil then return _to_nonnil(myLocArr).locDom.myBlock; // if not, we must not own anything - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } else { return dom.dsiLocalSubdomain(loc); @@ -1928,7 +1930,7 @@ proc StencilDom.dsiLocalSubdomain(loc: locale) { var inds = chpl__computeBlock(locid, dist.targetLocDom, dist.boundingBox); return whole[(...inds)]; } else { - var d: domain(rank, idxType, stridable); + var d: domain(rank, idxType, strides); return d; } } diff --git a/modules/dists/dims/BlockCycDim.chpl b/modules/dists/dims/BlockCycDim.chpl index 21782e67c8a5..db318ee07778 100644 --- a/modules/dists/dims/BlockCycDim.chpl +++ b/modules/dists/dims/BlockCycDim.chpl @@ -86,13 +86,13 @@ record BlockCyclicDim { record BlockCyclic1dom { type idxType; type stoIndexT; - param stridable: bool; + param strides: strideKind; // convenience - proc rangeT type do return range(idxType, boundKind.both, stridable); + proc rangeT type do return range(idxType, boundKind.both, strides); // our range, normalized; its absolute stride - var wholeR: range(idxType, boundKind.both, stridable); + var wholeR: range(idxType, boundKind.both, strides); var wholeRstrideAbs: idxType; // a copy of BlockCyclicDim constants @@ -136,7 +136,7 @@ proc type BlockCyclic1dom.dsiPrivatize1d(privDist, privatizeData) { return new BlockCyclic1dom( idxType = this.idxType, stoIndexT = this.stoIndexT, - stridable = this.stridable, + strides = this.strides, wholeR = privatizeData(0), wholeRstrideAbs = privatizeData(1), storagePerCycle = privatizeData(2), @@ -204,7 +204,7 @@ inline proc _checkFitsWithin(src: integral, type destT) } } -proc BlockCyclicDim.dsiNewRectangularDom1d(type idxType, param stridable: bool, +proc BlockCyclicDim.dsiNewRectangularDom1d(type idxType, param strides, type stoIndexT) { checkInvariants(); @@ -243,7 +243,7 @@ proc BlockCyclicDim.dsiNewRectangularDom1d(type idxType, param stridable: bool, const result = new BlockCyclic1dom(idxType = idxType, stoIndexT = stoIndexT, - stridable = stridable, + strides = strides, adjLowIdx = adjLowIdx: idxType, blockSizePos = this.blockSizePos, numLocalesPos = this.numLocalesPos, @@ -505,8 +505,8 @@ proc BlockCyclic1dom.dsiSetIndices1d(rangeArg: rangeT): void { dsiSetIndicesUnimplementedCase = false; // As of this writing, low/high are valid even for empty ranges - if stridable { - wholeR = rangeArg.low..rangeArg.high by rangeArg.stride; + if !strides.isOne() { + wholeR.chpl_setFields(rangeArg.low, rangeArg.high, rangeArg.stride); wholeRstrideAbs = abs(rangeArg.stride): idxType; storagePerCycle = (1 + divP2(blockSizePos-1, wholeRstrideAbs:int)): bcdPosInt; } else { @@ -521,7 +521,7 @@ proc BlockCyclic1dom.dsiSetIndices1d(rangeArg: rangeT): void { } inline proc BlockCyclic1dom._divByStride(locOff) do return - if stridable then ( locOff / wholeRstrideAbs ): stoIndexT + if !strides.isOne() then ( locOff / wholeRstrideAbs ): stoIndexT else locOff: stoIndexT; // _dsiStorageLow(), _dsiStorageHigh(): save a few mods and divisions @@ -594,8 +594,8 @@ iter BlockCyclic1locdom.dsiMyDensifiedRangeForSingleTask1d(globDD) { const lowIdx = wholeROrig.lowBound; const highIdx = wholeROrig.highBound; type retT = dsiMyDensifiedRangeType1d(globDD); - param stridable = globDD.stridable; - compilerAssert(stridable == wholeR.stridable); // sanity + param strides = globDD.strides; + compilerAssert(strides == wholeR.strides); // sanity _bcddb("\n", "dsiMyDensifiedRangeForSingleTask1d ", "{ wholeR ", globDD.wholeR, @@ -617,29 +617,12 @@ iter BlockCyclic1locdom.dsiMyDensifiedRangeForSingleTask1d(globDD) { _bcddb(" lowCycNo ", lowCycNo, " highCycNo ", highCycNo); assert(lowIdx <= highIdx); - // Right now explicit cast range(64) to range(32) is not implemented. - // We are doing it by hand here. Cf. proc =(range, range). - proc rangecast(ref r1: range(?), r2: range(?)): void { - compilerAssert(r1.bounds == r2.bounds); - if !r1.stridable && r2.stridable && r2._stride != 1 then - halt("range with non-unit stride is cast to non-stridable range"); - r1._low = r2._low: r1.idxType; - r1._high = r2._high: r1.idxType; - if r1.stridable { - r1._stride = r2.stride: r1.strType; - r1._alignment = r2._alignment: r1.idxType; - r1._aligned = r2._aligned; - } - } - // todo: make a cheaper densify() for this case, where // always densifyee==wholeR[smth..smthelse] proc mydensify(densifyee): retT { const temp = densify(densifyee, wholeR); _bcddb(" mydensify(", densifyee, ") = ", temp); - var result: retT; - rangecast(result, temp); - return result; + return temp: retT; } // Cf. wholeR above. We rely on this: @@ -661,15 +644,15 @@ iter BlockCyclic1locdom.dsiMyDensifiedRangeForSingleTask1d(globDD) { proc advance() { curIndices = curIndices.translate( - if !stridable || up then globDD.cycleSizePos else -globDD.cycleSizePos); + if strides.isOne() || up then globDD.cycleSizePos + else -globDD.cycleSizePos); _bcddb(" advance curIndices ", curIndices); } for cycNo in (lowCycNo + 1) .. (highCycNo - 1) { advance(); - const curRange = - if stridable then curIndices by wholeR.stride align wholeR.alignment - else curIndices; + const curRange = if strides.isOne() then curIndices else + curIndices by wholeR.stride align wholeR.alignment; yield mydensify(curRange); } @@ -692,7 +675,7 @@ proc BlockCyclic1locdom.dsiMyDensifiedRangeForTaskID1d(globDD, taskid:int, numTa type resultIdxType = globDD.idxType; // Ensure it is the same as dsiMyDensifiedRangeType1d(globDD).idxType. // Have to do it a bit indirectly. - compilerAssert(range(idxType=resultIdxType, stridable=globDD.stridable) + compilerAssert(range(idxType=resultIdxType, strides=globDD.strides) == dsiMyDensifiedRangeType1d(globDD)); // Assume 2*numLocales always fits in 31 bits, so we can skip this check @@ -723,14 +706,14 @@ proc BlockCyclic1locdom.dsiMyDensifiedRangeForTaskID1d(globDD, taskid:int, numTa } proc BlockCyclic1locdom.dsiMyDensifiedRangeType1d(globDD) type do - return range(idxType=globDD.idxType, stridable=globDD.stridable); + return range(idxType=globDD.idxType, strides=globDD.strides); proc BlockCyclic1locdom.dsiLocalSliceStorageIndices1d(globDD, sliceRange) : range(stoIndexT, sliceRange.bounds, false) { - if sliceRange.stridable { + if !sliceRange.hasUnitStride() { // to be done: figure out sliceRange's stride vs. globDD.wholeR.stride - compilerError("localSlice is not implemented for the Dimensional distribution with a block-cyclic dimension specifier when the slice is stridable"); + compilerError("localSlice is not implemented for the Dimensional distribution with a block-cyclic dimension specifier when the slice's stride != 1"); } else { if sliceRange.hasLowBound() { if sliceRange.hasHighBound() { @@ -750,7 +733,7 @@ proc BlockCyclic1locdom.dsiLocalSliceStorageIndices1d(globDD, sliceRange) iter BlockCyclic1dom.dsiSerialArrayIterator1d() { // dispatch here, for code clarity - if stridable then + if !strides.isOne() then for result in _dsiSerialArrayIterator1dStridable() do yield result; else @@ -759,7 +742,7 @@ iter BlockCyclic1dom.dsiSerialArrayIterator1d() { } iter BlockCyclic1dom._dsiSerialArrayIterator1dUnitstride(rangeToIterateOver) { - assert(!rangeToIterateOver.stridable); + compilerAssert(rangeToIterateOver.hasUnitStride()); const firstIdx = rangeToIterateOver.lowBound; const lastIdx = rangeToIterateOver.highBound; @@ -810,7 +793,7 @@ iter BlockCyclic1dom._dsiSerialArrayIterator1dUnitstride(rangeToIterateOver) { } iter BlockCyclic1dom._dsiSerialArrayIterator1dStridable() { - assert(stridable); + compilerAssert(!strides.isOne()); if BlockCyclicDim_enableArrayIterWarning then compilerWarning("array iterator over stridable block-cyclic-dim arrays is presently not efficient", 4); @@ -820,7 +803,7 @@ iter BlockCyclic1dom._dsiSerialArrayIterator1dStridable() { } iter BlockCyclic1dom.dsiFollowerArrayIterator1d(undensRange): (locIdT, idxType) { - if undensRange.stridable { + if !undensRange.hasUnitStride() { // the simplest way out foreach ix in undensRange do yield dsiAccess1d(ix); diff --git a/modules/dists/dims/BlockDim.chpl b/modules/dists/dims/BlockDim.chpl index 325d67d1cb5e..fc4fd43752e0 100644 --- a/modules/dists/dims/BlockDim.chpl +++ b/modules/dists/dims/BlockDim.chpl @@ -77,13 +77,13 @@ record BlockDim { record Block1dom { type idxType; - param stridable: bool; + param strides: strideKind; // convenience - proc rangeT type do return range(idxType, boundKind.both, stridable); + proc rangeT type do return range(idxType, boundKind.both, strides); // our range - var wholeR: range(idxType, boundKind.both, stridable); + var wholeR: range(idxType, boundKind.both, strides); // privatized distribution descriptor const pdist; @@ -137,7 +137,7 @@ proc Block1dom.dsiGetPrivatizeData1d() { proc type Block1dom.dsiPrivatize1d(privDist, privatizeData) { assert(privDist.locale == here); // sanity check return new Block1dom(idxType = this.idxType, - stridable = this.stridable, + strides = this.strides, wholeR = privatizeData(0), pdist = privDist); } @@ -172,7 +172,7 @@ proc BlockDim.init(numLocales, boundingBoxLow, boundingBoxHigh, type idxType = b proc BlockDim.toString() do return "BlockDim(" + numLocales:string + ", " + boundingBox:string + ")"; -proc BlockDim.dsiNewRectangularDom1d(type idxType, param stridable: bool, +proc BlockDim.dsiNewRectangularDom1d(type idxType, param strides: strideKind, type stoIndexT) { // ignore stoIndexT - all we need is for other places to work out @@ -180,13 +180,13 @@ proc BlockDim.dsiNewRectangularDom1d(type idxType, param stridable: bool, compilerError("The index type ", idxType:string, " does not match the index type ",this.idxType:string, " of the 'BlockDim' 1-d distribution"); - return new Block1dom(idxType = idxType, stridable = stridable, pdist = this); + return new Block1dom(idxType = idxType, strides = strides, pdist = this); } proc Block1dom.dsiIsReplicated1d() param do return false; proc Block1dom.dsiNewLocalDom1d(type stoIndexT, locId: locIdT) { - var defaultVal: range(stoIndexT, stridable=this.stridable); + var defaultVal: range(stoIndexT, strides=this.strides); return new Block1locdom(myRange = defaultVal); } diff --git a/modules/dists/dims/ReplicatedDim.chpl b/modules/dists/dims/ReplicatedDim.chpl index 09ffb0f94613..ede37203ac0d 100644 --- a/modules/dists/dims/ReplicatedDim.chpl +++ b/modules/dists/dims/ReplicatedDim.chpl @@ -64,14 +64,13 @@ record ReplicatedDim { record Replicated1dom { // REQ the parameters of our dimension of the domain being created type idxType; - param stridable: bool; + param strides: strideKind; // convenience - proc rangeT type do return range(idxType, boundKind.both, stridable); -//todo-remove? proc domainT type return domain(1, idxType, stridable); + proc rangeT type do return range(idxType, boundKind.both, strides); // our range - var wholeR: range(idxType, boundKind.both, stridable); + var wholeR: range(idxType, boundKind.both, strides); // locale ID in our dimension of the locale this instance is on var localLocID = invalidLocID; @@ -83,9 +82,9 @@ record Replicated1dom { record Replicated1locdom { type stoIndexT; - param stridable; + param strides; // our copy of wholeR - var locWholeR: range(stoIndexT, stridable=stridable); + var locWholeR: range(stoIndexT, strides=strides); } @@ -142,7 +141,7 @@ proc Replicated1dom.dsiGetPrivatizeData1d() { proc type Replicated1dom.dsiPrivatize1d(privDist, privatizeData) { assert(privDist.locale == here); // sanity check return new Replicated1dom(idxType = this.idxType, - stridable = this.stridable, + strides = this.strides, wholeR = privatizeData(0)); } @@ -197,13 +196,13 @@ proc Replicated1locdom.dsiStoreLocalDescToPrivatizedGlobalDesc1d(privGlobDesc) { // REQ create a 1-d global domain descriptor for dsiNewRectangularDom() -// where our dimension is a range(idxType, bounded, stridable) +// where our dimension is a range(idxType, bounded, strides) // stoIndexT is the same as in Replicated1dom.dsiNewLocalDom1d. -proc ReplicatedDim.dsiNewRectangularDom1d(type idxType, param stridable: bool, +proc ReplicatedDim.dsiNewRectangularDom1d(type idxType, param strides, type stoIndexT) { // ignore stoIndexT - all we need is for other places to work out - return new Replicated1dom(idxType, stridable); + return new Replicated1dom(idxType, strides); } // A nicety: produce a string showing the parameters. @@ -221,7 +220,7 @@ proc Replicated1dom.dsiIsReplicated1d() param do return true; // stoIndexT must be the index type of the range returned by // dsiSetLocalIndices1d(). proc Replicated1dom.dsiNewLocalDom1d(type stoIndexT, locId: locIdT) { - return new Replicated1locdom(stoIndexT, wholeR.stridable); + return new Replicated1locdom(stoIndexT, wholeR.strides); } // REQ given our dimension of the array index, on which locale is it located? diff --git a/modules/internal/ChapelDistribution.chpl b/modules/internal/ChapelDistribution.chpl index e964cf579d84..b069c87cbfd0 100644 --- a/modules/internal/ChapelDistribution.chpl +++ b/modules/internal/ChapelDistribution.chpl @@ -980,7 +980,7 @@ module ChapelDistribution { // deprecated by Vass in 1.31 to implement #17131 //RSDW: @deprecated("[array].stridable is deprecated; use [array].strides instead") proc stridable param do return strides.toStridable(); - //RSDW: @deprecated("domain.stridable is deprecated; use domain.strides instead") + //RSDW: @deprecated("[array].stridable is deprecated; use [array].strides instead") proc type stridable param do return strides.toStridable(); @chpldoc.nodoc proc hasUnitStride() param do return strides.isOne(); diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index 1fc995d6b355..1b720b198d8a 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -753,9 +753,10 @@ module ChapelDomain { proc strideSafe(d, rt, param dim: int=0) param { return if dim == d.rank-1 then - d.dim(dim).stridable || !rt(dim).stridable + chpl_assignStrideIsSafe(d.dim(dim), rt(dim)) else - (d.dim(dim).stridable || !rt(dim).stridable) && strideSafe(d, rt, dim+1); + chpl_assignStrideIsSafe(d.dim(dim), rt(dim)) && + strideSafe(d, rt, dim+1); } return isRangeTuple(t) && d.rank == t.size && strideSafe(d, t); } @@ -1084,7 +1085,8 @@ module ChapelDomain { // handle the type of 'other'. That case is currently managed by the // compiler and various helper functions involving runtime types. proc init=(const ref other : domain) where other.isRectangular() { - this.init(other.dist, other.rank, other.idxType, other.stridable, other.dims()); + this.init(other.dist, other.rank, other.idxType, other.strides, + other.dims()); } proc init=(const ref other : domain) { @@ -1211,6 +1213,7 @@ module ChapelDomain { return _value.parentDom.strides.toStridable(); } + // deprecated by Vass in 1.31 to implement #17131 @chpldoc.nodoc proc stridable param where this.isAssociative() { compilerError("associative domains do not support .stridable"); @@ -1347,7 +1350,7 @@ module ChapelDomain { return new _domain(rcdistRec, uprank, upranges(0).idxType, - upranges(0).stridable, + upranges(0).strides, upranges); } @@ -2110,10 +2113,19 @@ module ChapelDomain { proc high where this.isAssociative() { compilerError("associative domains do not support '.high'"); } + /* Return the stride of the indices in this domain */ proc stride do return _value.dsiStride; + @chpldoc.nodoc proc stride param where rank==1 && + (isRectangular() || isSparse()) && strides.isPosNegOne() do + return if strides.isOne() then 1 else -1; + /* Return the alignment of the indices in this domain */ proc alignment do return _value.dsiAlignment; + + @chpldoc.nodoc proc alignment param where rank==1 && + (isRectangular() || isSparse()) && strides.isPosNegOne() do return 0; + /* Return the first index in this domain */ proc first do return _value.dsiFirst; /* Return the last index in this domain */ @@ -2291,7 +2303,7 @@ module ChapelDomain { } } - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } /* Return a new domain that is the current domain expanded by @@ -2305,7 +2317,7 @@ module ChapelDomain { var ranges = dims(); for i in 0..rank-1 do ranges(i) = dim(i).expand(off); - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } @chpldoc.nodoc @@ -2335,7 +2347,7 @@ module ChapelDomain { var ranges = dims(); for i in 0..rank-1 do ranges(i) = dim(i).exterior(off(i)); - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } /* Return a new domain that is the exterior portion of the @@ -2387,7 +2399,7 @@ module ChapelDomain { } ranges(i) = _value.dsiDim(i).interior(off(i)); } - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } /* Return a new domain that is the interior portion of the @@ -2438,7 +2450,7 @@ module ChapelDomain { var ranges = dims(); for i in 0..rank-1 do ranges(i) = _value.dsiDim(i).translate(off(i)); - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } /* Return a new domain that is the current domain translated by @@ -2468,7 +2480,7 @@ module ChapelDomain { var ranges = dims(); for i in 0..rank-1 do ranges(i) = dim(i).chpl__unTranslate(off(i)); - return new _domain(dist, rank, _value.idxType, stridable, ranges); + return new _domain(dist, rank, _value.idxType, strides, ranges); } @chpldoc.nodoc @@ -2575,24 +2587,27 @@ module ChapelDomain { where chpl__isRectangularDomType(t) && this.isRectangular() { var tmpD: t; if tmpD.rank != this.rank then - compilerError("rank mismatch in cast"); + compilerError("safeCast to a domain with rank=", tmpD.rank, + " from a domain with rank=", this.rank); if tmpD.idxType != this.idxType then - compilerError("idxType mismatch in cast"); - if tmpD.stridable == this.stridable then + // todo: relax this restriction + compilerError("safeCast to a domain with idxType=", tmpD.idxType, + " from a domain with idxType=", this.idxType); + if tmpD.strides == this.strides then return this; - else if !tmpD.stridable && this.stridable { + else if chpl_assignStrideIsUnsafe(tmpD.strides, this.strides) then + compilerError("safeCast to a domain with strides=", tmpD.strides, + " from a domain with strides=", this.strides); + else if ! chpl_assignStrideIsSafe(tmpD.strides, this.strides) { const inds = this.getIndices(); - var unstridableInds: rank*range(tmpD.idxType, stridable=false); + var newInds: tmpD.getIndices().type; for param dim in 0..inds.size-1 { - if inds(dim).stride != 1 then - halt("non-stridable domain assigned non-unit stride in dimension ", dim); - unstridableInds(dim) = inds(dim).safeCast(range(tmpD.idxType, - stridable=false)); + newInds(dim) = inds(dim).safeCast(newInds(dim).type); } - tmpD.setIndices(unstridableInds); + tmpD.setIndices(newInds); return tmpD; - } else /* if tmpD.stridable && !this.stridable */ { + } else { // cast is always safe tmpD = this; return tmpD; } @@ -2665,20 +2680,21 @@ module ChapelDomain { if tmpD.rank != d.rank then compilerError("rank mismatch in cast"); if tmpD.idxType != d.idxType then + // todo: relax this restriction compilerError("idxType mismatch in cast"); if tmpD.strides == d.strides then return d; else if ! chpl_assignStrideIsSafe(tmpD.strides, d.strides) { var inds = d.getIndices(); - var unstridableInds: tmpD.getIndices().type; + var newInds: tmpD.getIndices().type; for param i in 0..tmpD.rank-1 { - unstridableInds(i) = inds(i): unstridableInds(i).type; + newInds(i) = inds(i): newInds(i).type; } - tmpD.setIndices(unstridableInds); + tmpD.setIndices(newInds); return tmpD; - } else /* if tmpD.stridable && !d.stridable */ { + } else { // cast is always safe tmpD = d; return tmpD; } diff --git a/modules/internal/ChapelIteratorSupport.chpl b/modules/internal/ChapelIteratorSupport.chpl index e973406733d3..0acef174d4e6 100644 --- a/modules/internal/ChapelIteratorSupport.chpl +++ b/modules/internal/ChapelIteratorSupport.chpl @@ -166,7 +166,7 @@ module ChapelIteratorSupport { // RTT is **initialized**. Important: no accessing the uninitialized RTTs. // // It took some acrobatics to get the domain's distribution type, - // rank, idxType, stridable from 'domType', and the same plus + // rank, idxType, strides from 'domType', and the same plus // (even more acrobatics) eltType from 'arrType'. // Ideally we'd get them **directly** from domType/arrType. // @@ -276,7 +276,7 @@ module ChapelIteratorSupport { // a BaseDist subclass. We use 'defaultDist' for that. // The other args are always compile-time only. return chpl__buildDomainRuntimeType(defaultDist, domInst.rank, - domInst.idxType, domInst.stridable); + domInst.idxType, domInst.strides); } // Other kinds of arrays/domains are not supported. diff --git a/modules/internal/ChapelRange.chpl b/modules/internal/ChapelRange.chpl index 54b903ce6306..a1266c600042 100644 --- a/modules/internal/ChapelRange.chpl +++ b/modules/internal/ChapelRange.chpl @@ -1049,7 +1049,7 @@ module ChapelRange { @chpldoc.nodoc inline proc range.chpl_alignedLowAsIntForIter { - if stridable && !hasLowBound() && isFiniteIndexType() { + if !hasUnitStride() && !hasLowBound() && isFiniteIndexType() { return helpAlignLow(chpl__idxToInt(lowBoundForIter(this)), _alignment, stride); } else { return alignedLowAsInt; @@ -1145,7 +1145,7 @@ module ChapelRange { @chpldoc.nodoc inline proc range.chpl_alignedHighAsIntForIter { - if stridable && !hasHighBound() && isFiniteIdxType(idxType) { + if !hasUnitStride() && !hasHighBound() && isFiniteIdxType(idxType) { return helpAlignHigh(chpl__idxToInt(highBoundForIter(this)), _alignment, stride); } else { return alignedHighAsInt; @@ -2080,14 +2080,12 @@ private inline proc rangeCastHelper(r, type t) throws { @chpldoc.nodoc inline operator -(r: range(?e,?b,?s), i: integral) { - type strType = chpl__rangeStrideType(e); - return new range(e, b, s, r._low - i, r._high - i, - r.stride : strType, + r._stride, chpl__idxToInt(r.alignment)-i, - r.aligned); + r._aligned, false); } // TODO can this be removed? diff --git a/modules/internal/DefaultRectangular.chpl b/modules/internal/DefaultRectangular.chpl index ec40fd254fa0..010cb6b2e307 100644 --- a/modules/internal/DefaultRectangular.chpl +++ b/modules/internal/DefaultRectangular.chpl @@ -1003,14 +1003,6 @@ module DefaultRectangular { targetLocDom=newTargetLocDom; } - //RSDW remove this once Block, Cyclick, Stencil use 'strides' - pragma "dont disable remote value forwarding" - proc init(type eltType, param rank: int, type idxType, - param stridable: bool, newTargetLocDom: domain(rank)) { - this.init(eltType, rank, idxType, chpl_strideKind(stridable), - newTargetLocDom); - } - inline proc lockRAD(rlocIdx) { RADLocks[rlocIdx].lock(); } diff --git a/modules/internal/DefaultSparse.chpl b/modules/internal/DefaultSparse.chpl index ca84f2fe59d3..86468224de84 100644 --- a/modules/internal/DefaultSparse.chpl +++ b/modules/internal/DefaultSparse.chpl @@ -49,9 +49,9 @@ module DefaultSparse { this.dist = dist; } - proc stridable param { - return parentDom.stridable; - } + // deprecated by Vass in 1.31 to implement #17131 + @deprecated("domain.stridable is deprecated; use domain.strides instead") + proc stridable param do return parentDom.strides.toStridable(); override proc getNNZ(): int{ return _nnz; diff --git a/modules/layouts/LayoutCS.chpl b/modules/layouts/LayoutCS.chpl index 7834b8438a36..94cf22d2ff2a 100644 --- a/modules/layouts/LayoutCS.chpl +++ b/modules/layouts/LayoutCS.chpl @@ -84,7 +84,7 @@ class CS: BaseDist { param sortedIndices: bool = LayoutCSDefaultToSorted; override proc dsiNewSparseDom(param rank: int, type idxType, dom: domain) { - return new unmanaged CSDom(rank, idxType, this.compressRows, this.sortedIndices, dom.stridable, _to_unmanaged(this), dom); + return new unmanaged CSDom(rank, idxType, this.compressRows, this.sortedIndices, dom.strides, _to_unmanaged(this), dom); } proc dsiClone() { @@ -108,11 +108,11 @@ class CS: BaseDist { class CSDom: BaseSparseDomImpl { param compressRows; param sortedIndices; - param stridable; + param strides; var dist: unmanaged CS(compressRows,sortedIndices); - var rowRange: range(idxType, stridable=stridable); - var colRange: range(idxType, stridable=stridable); + var rowRange: range(idxType, strides=strides); + var colRange: range(idxType, strides=strides); /* (row|col) startIdxDom */ var startIdxDom: domain(1, idxType); @@ -127,7 +127,7 @@ class CSDom: BaseSparseDomImpl { var idx: [nnzDom] idxType; // would like index(parentDom.dim(0)) /* Initializer */ - proc init(param rank, type idxType, param compressRows, param sortedIndices, param stridable, dist: unmanaged CS(compressRows,sortedIndices), parentDom: domain) { + proc init(param rank, type idxType, param compressRows, param sortedIndices, param strides, dist: unmanaged CS(compressRows,sortedIndices), parentDom: domain) { if (rank != 2 || parentDom.rank != 2) then compilerError("Only 2D sparse domains are supported by the CS distribution"); if parentDom.idxType != idxType then @@ -137,7 +137,7 @@ class CSDom: BaseSparseDomImpl { this.compressRows = compressRows; this.sortedIndices = sortedIndices; - this.stridable = stridable; + this.strides = strides; this.dist = dist; rowRange = parentDom.dim(0); diff --git a/modules/packages/LinearAlgebra.chpl b/modules/packages/LinearAlgebra.chpl index 77dd989ed3d5..0fd2a87d7fe0 100644 --- a/modules/packages/LinearAlgebra.chpl +++ b/modules/packages/LinearAlgebra.chpl @@ -1153,9 +1153,9 @@ proc _matmatMultHelper(ref AMat: [?Adom] ?eltType, @chpldoc.nodoc private inline proc hasNonStridedIndices(Adom : domain(2)) { - return (if Adom.stridable + return if !Adom.strides.isNegative() then Adom.dim(0).stride == 1 && Adom.dim(1).stride == 1 - else true); + else false; } /* diff --git a/modules/packages/Search.chpl b/modules/packages/Search.chpl index 59deee699ede..23fce4a944a1 100644 --- a/modules/packages/Search.chpl +++ b/modules/packages/Search.chpl @@ -108,18 +108,11 @@ proc linearSearch(Data:[?Dom], val, comparator:?rec=defaultComparator, lo=Dom.lo chpl_check_comparator(comparator, Data.eltType); - const stride = if Dom.stridable then abs(Dom.stride) else 1; - if Dom.stridable { - for i in lo..hi by stride { - if chpl_compare(Data[i], val, comparator=comparator) == 0 then - return (true, i); - } - } else { - for i in lo..hi { - if chpl_compare(Data[i], val, comparator=comparator) == 0 then - return (true, i); - } - } + const stride = abs(Dom.stride); + + for i in lo..hi by if Dom.hasPosNegUnitStride() then 1 else stride:uint do + if chpl_compare(Data[i], val, comparator=comparator) == 0 then + return (true, i); return (false, hi+stride); } @@ -160,8 +153,9 @@ proc linearSearch(Data:[?Dom], val, comparator:?rec=defaultComparator, lo=Dom.lo */ proc binarySearch(Data:[?Dom], val, comparator:?rec=defaultComparator, in lo=Dom.low, in hi=Dom.high) { chpl_check_comparator(comparator, Data.eltType); + if Dom.rank != 1 then compilerError("binarySearch() requires 1-D array"); - const stride = if Dom.stridable then abs(Dom.stride) else 1; + const stride = abs(Dom.stride); while (lo <= hi) { const size = (hi - lo) / stride, @@ -183,8 +177,10 @@ proc binarySearch(Data:[?Dom], val, comparator:?rec=defaultComparator, in lo=Dom @chpldoc.nodoc /* Non-stridable binarySearch */ proc binarySearch(Data:[?Dom], val, comparator:?rec=defaultComparator, in lo=Dom.low, in hi=Dom.high) - where !Dom.stridable { + where Dom.hasUnitStride() +{ chpl_check_comparator(comparator, Data.eltType); + if Dom.rank != 1 then compilerError("binarySearch() requires 1-D array"); while (lo <= hi) { const mid = (hi - lo)/2 + lo; @@ -198,11 +194,4 @@ proc binarySearch(Data:[?Dom], val, comparator:?rec=defaultComparator, in lo=Dom return (false, lo); } - -@chpldoc.nodoc -/* Error message for multi-dimension arrays */ -proc binarySearch(Data:[?Dom], val, comparator:?rec=defaultComparator, in lo=Dom.low, in hi=Dom.high) - where Dom.rank != 1 { - compilerError("binarySearch() requires 1-D array"); -} } // Search module diff --git a/modules/packages/Sort.chpl b/modules/packages/Sort.chpl index 5f4bc5932cdf..d1683a7649f2 100644 --- a/modules/packages/Sort.chpl +++ b/modules/packages/Sort.chpl @@ -408,7 +408,7 @@ proc chpl_check_comparator(comparator, type eltType) param { pragma "unsafe" // due to 'tmp' default-initialized to nil for class types private proc radixSortOk(Data: [?Dom] ?eltType, comparator) param { - if !Dom.stridable { + if Dom.hasUnitStride(){ var tmp:Data[Dom.low].type; if canResolveMethod(comparator, "keyPart", tmp, 0) { return true; @@ -499,7 +499,7 @@ proc sort(Data: [?Dom] ?eltType, comparator:?rec=defaultComparator) proc isSorted(Data: [?Dom] ?eltType, comparator:?rec=defaultComparator): bool { chpl_check_comparator(comparator, eltType); - const stride = if Dom.stridable then abs(Dom.stride) else 1:Dom.idxType; + const stride = abs(Dom.stride): Dom.idxType; var sorted = true; forall (element, i) in zip(Data, Dom) with (&& reduce sorted) { if i > Dom.low { @@ -801,7 +801,7 @@ module BinaryInsertionSort { Does not check for a valid comparator. */ private proc _binarySearchForLastOccurrence(Data: [?Dom], val, comparator:?rec=defaultComparator, in lo=Dom.low, in hi=Dom.high) { - const stride = if Dom.stridable then abs(Dom.stride) else 1; + const stride = abs(Dom.stride): Dom.idxType; var loc = -1; // index of the last occurrence of val in Data @@ -858,7 +858,7 @@ module TimSort { /*Parallelly apply insertionSort on each block of size `blockSize` using forall loop*/ - const stride = if Dom.stridable then abs(Dom.stride) else 1; + const stride = abs(Dom.stride): Dom.idxType; const size = (hi - lo) / stride + 1; const chunks = (size + blockSize - 1) / blockSize; @@ -899,11 +899,13 @@ module TimSort { if mid >= hi { return; } - const stride = if Dom.stridable then abs(Dom.stride) else 1; - const a1range = if Dom.stridable then lo..mid by stride else lo..mid; + const stride = abs(Dom.stride): Dom.idxType; + const a1range = if Dom.hasPosNegUnitStride() then lo..mid + else lo..mid by stride:uint; const a1max = mid; - const a2range = if Dom.stridable then (mid+stride)..hi by stride else (mid+1)..hi; + const a2range = if Dom.hasPosNegUnitStride() then (mid+1)..hi + else (mid+stride)..hi by stride:uint; const a2max = hi; var A1 = Dst[a1range]; @@ -981,7 +983,7 @@ module MergeSort { where Dom.rank == 1 { import Sort.InsertionSort; - const stride = if Dom.stridable then abs(Dom.stride) else 1, + const stride = abs(Dom.stride): Dom.idxType, size = (hi - lo) / stride, mid = lo + (size/2) * stride; @@ -1003,7 +1005,7 @@ module MergeSort { if depth & 1 { // At odd depths, we need to return the results in Scratch. // But if the test above is correct, we'll never reach this point. - if Dom.stridable then + if ! Dom.strides.isPosNegOne() then Scratch[lo..hi by Dom.stride] = Data[lo..hi by Dom.stride]; else Scratch[lo..hi] = Data[lo..hi]; @@ -1031,11 +1033,13 @@ module MergeSort { private proc _Merge(Dst: [?Dom] ?eltType, Src: [], lo:int, mid:int, hi:int, comparator:?rec=defaultComparator) { /* Data[lo..mid by stride] is much slower than Data[lo..mid] when * Dom is unstrided. So specify the latter explicitly when possible. */ - const stride = if Dom.stridable then abs(Dom.stride) else 1; - const a1range = if Dom.stridable then lo..mid by stride else lo..mid; + const stride = abs(Dom.stride): Dom.idxType; + const a1range = if Dom.hasPosNegUnitStride() then lo..mid + else lo..mid by stride; const a1max = mid; - const a2range = if Dom.stridable then (mid+stride)..hi by stride else (mid+1)..hi; + const a2range = if Dom.hasPosNegUnitStride() then (mid+1)..hi + else (mid+stride)..hi by stride; const a2max = hi; ref A1 = Src[a1range]; @@ -1236,7 +1240,7 @@ module QuickSort { compilerError("quickSort() requires 1-D array"); } - if Dom.stridable && Dom.stride != 1 { + if Dom.stride != 1 { ref reindexed = Data.reindex(Dom.low..#Dom.size); assert(reindexed.domain.stride == 1); quickSortImpl(reindexed, minlen, comparator); @@ -1364,7 +1368,7 @@ module ShellSort { if Dom.rank != 1 then compilerError("shellSort() requires 1-D array"); - if Dom.stridable then + if ! Dom.hasUnitStride() then compilerError("shellSort() requires an array over a non-stridable domain"); // Based on Sedgewick's Shell Sort -- see @@ -1476,7 +1480,7 @@ module SampleSortHelp { return numBuckets * (1 + equalBuckets:int); } proc getBinsToRecursivelySort() { - var r:range(stridable=true); + var r:range(strides = strideKind.positive); if equalBuckets { // odd bins will be equality buckets r = (0..(getNumBuckets()-1)) by 2; diff --git a/modules/standard/ChapelIO.chpl b/modules/standard/ChapelIO.chpl index e37eace6ab6e..8c0334295b2f 100644 --- a/modules/standard/ChapelIO.chpl +++ b/modules/standard/ChapelIO.chpl @@ -822,22 +822,34 @@ module ChapelIO { if hasHighBound() then _high = f.read(_high.type); - if stride != 1 { - f._readLiteral(" by "); - _stride = f.read(stride.type); + if f.matchLiteral(" by ") { + const strideVal = f.read(strType); + var expectedStride = ""; + use strideKind; + select strides { + when one do if strideVal != 1 then expectedStride = "stride 1"; + when negOne do if strideVal != 1 then expectedStride = "stride -1"; + when positive do if strideVal < 0 then expectedStride = "a positive"; + when negative do if strideVal > 0 then expectedStride = "a negative"; + when any do; + } + if expectedStride != "" then throw new owned BadFormatError( + "for a range with strides=" + strides:string + ", expected " + + (if expectedStride.size > 2 then expectedStride + " stride" + else expectedStride) + ", got stride ", strideVal:string); + if ! hasParamStride() then + _stride = strideVal; } - try { - f._readLiteral(" align "); - - if stridable { - _alignment = f.read(intIdxType); + if f.matchLiteral(" align ") { + const alignVal = f.read(intIdxType); + if hasParamStrideAltvalAld() { + // It is valid to align this range. We do not store its alignment + // at runtime because the alignment always normalizes to 0. } else { - throw new owned - BadFormatError("Range is not stridable, cannot store alignment"); + _alignment = chpl__mod(alignVal, _stride); + _aligned = true; } - } catch err: BadFormatError { - // Range is naturally aligned. } } @@ -846,41 +858,9 @@ module ChapelIO { param bounds : boundKind = boundKind.both, param strides : strideKind = strideKind.one, reader: fileReader(?), - ref deserializer) { + ref deserializer) throws { this.init(idxType, bounds, strides); - - // TODO: - // The alignment logic here is pretty tricky, so fall back on the - // actual operators for the time being... - - // TODO: experiment with using throwing initializers in this case. - try! { - if hasLowBound() then _low = reader.read(_low.type); - reader._readLiteral(".."); - if hasHighBound() then _high = reader.read(_high.type); - - if stridable { - if reader.matchLiteral(" by ") { - //_stride = reader.read(stride.type); - this = ( this by reader.read(stride.type) ): this.type; - } - } - } - - try! { - try { - if reader.matchLiteral(" align ") { - if stridable { - //_alignment = reader.read(intIdxType); - this = this align reader.read(intIdxType); - } - } else { - // TODO: throw error if not stridable - } - } catch err: BadFormatError { - // Range is naturally aligned. - } - } + this.readThis(reader); } @chpldoc.nodoc diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index 799daec944bd..8035764c8ff4 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -6388,7 +6388,8 @@ proc fileReader.readline(arg: [] uint(8), out numRead : int, start = arg.domain. */ proc fileReader.readLine(ref a: [] ?t, maxSize=a.size, stripNewline=false): int throws - where (t == uint(8) || t == int(8)) && a.rank == 1 && a.isRectangular() && !a.stridable + where (t == uint(8) || t == int(8)) && a.rank == 1 && + a.isRectangular() && a.hasUnitStride() { if maxSize > a.size then throw new IllegalArgumentError("'maxSize' argument exceeds size of array in readLine"); @@ -7202,7 +7203,8 @@ proc fileReader.readAll(ref b: bytes): int throws { due to a :ref:`system error`. */ proc fileReader.readAll(ref a: [?d] ?t): int throws - where (t == uint(8) || t == int(8)) && d.rank == 1 && d.stridable == false + where (t == uint(8) || t == int(8)) && a.rank == 1 && + a.isRectangular() && a.hasUnitStride() { var i = d.low; @@ -7936,8 +7938,8 @@ proc fileWriter.writeBinary(b: bytes, size: int = b.size) throws { due to a :ref:`system error`. */ proc fileWriter.writeBinary(const ref data: [?d] ?t, param endian:ioendian = ioendian.native) throws - where (d.rank == 1 && d.stridable == false && !d.isSparse()) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { var e : errorCode = 0; @@ -7987,8 +7989,8 @@ proc fileWriter.writeBinary(const ref data: [?d] ?t, param endian:ioendian = ioe due to a :ref:`system error`. */ proc fileWriter.writeBinary(const ref data: [?d] ?t, endian:ioendian) throws - where (d.rank == 1 && d.stridable == false) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { select (endian) { when ioendian.native { @@ -8196,8 +8198,9 @@ config param ReadBinaryArrayReturnInt = false; */ @deprecated(notes="The variant of `readBinary(data: [])` that returns a `bool` is deprecated; please recompile with `-sReadBinaryArrayReturnInt=true` to use the new variant") proc fileReader.readBinary(ref data: [?d] ?t, param endian = ioendian.native): bool throws - where ReadBinaryArrayReturnInt == false && (d.rank == 1 && d.stridable == false) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where ReadBinaryArrayReturnInt == false && + d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { var e : errorCode = 0, readSomething = false; @@ -8255,8 +8258,9 @@ proc fileReader.readBinary(ref data: [?d] ?t, param endian = ioendian.native): b due to a :ref:`system error`. */ proc fileReader.readBinary(ref data: [?d] ?t, param endian = ioendian.native): int throws - where ReadBinaryArrayReturnInt == true && (d.rank == 1 && d.stridable == false && !d.isSparse()) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where ReadBinaryArrayReturnInt == true && + d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { var e : errorCode = 0, numRead : c_ssize_t = 0; @@ -8318,8 +8322,9 @@ proc fileReader.readBinary(ref data: [?d] ?t, param endian = ioendian.native): i */ @deprecated(notes="The variant of `readBinary(data: [])` that returns a `bool` is deprecated; please recompile with `-sReadBinaryArrayReturnInt=true` to use the new variant") proc fileReader.readBinary(ref data: [?d] ?t, endian: ioendian):bool throws - where ReadBinaryArrayReturnInt == false && (d.rank == 1 && d.stridable == false && !d.isSparse()) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where ReadBinaryArrayReturnInt == false && + d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { var rv: bool = false; @@ -8357,8 +8362,9 @@ proc fileReader.readBinary(ref data: [?d] ?t, endian: ioendian):bool throws due to a :ref:`system error`. */ proc fileReader.readBinary(ref data: [?d] ?t, endian: ioendian):int throws - where ReadBinaryArrayReturnInt == true && (d.rank == 1 && d.stridable == false && !d.isSparse()) && ( - isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t)) + where ReadBinaryArrayReturnInt == true && + d.rank == 1 && d.isRectangular() && d.hasUnitStride() && ( + isIntegralType(t) || isRealType(t) || isImagType(t) || isComplexType(t) ) { var nr: int = 0; @@ -8875,7 +8881,8 @@ proc read(type t ...?numTypes) throws { /* Equivalent to ``stdin.readLine``. See :proc:`fileReader.readLine` */ proc readLine(ref a: [] ?t, maxSize=a.size, stripNewline=false): int throws - where (t == uint(8) || t == int(8)) && a.rank == 1 && a.isRectangular() && ! a.stridable { + where (t == uint(8) || t == int(8)) && a.rank == 1 && + a.isRectangular() && a.hasUnitStride() { return stdin.readLine(a, maxSize, stripNewline); } diff --git a/modules/standard/Random.chpl b/modules/standard/Random.chpl index 316804911986..b564834f6b14 100644 --- a/modules/standard/Random.chpl +++ b/modules/standard/Random.chpl @@ -658,7 +658,7 @@ module Random { if ``size < 1 || size.size < 1``, if ``replace=false`` and ``size > x.size || size.size > x.size``. */ - proc choice(x: range(stridable=?), size:?sizeType=none, replace=true, prob:?probType=none) throws + proc choice(x: range(strides=?), size:?sizeType=none, replace=true, prob:?probType=none) throws { compilerError("RandomStreamInterface.choice called"); } @@ -1172,16 +1172,13 @@ module Random { if ``size < 1 || size.size < 1``, if ``replace=false`` and ``size > x.size || size.size > x.size``. */ - proc choice(x: range(stridable=?), size:?sizeType=none, replace=true, prob:?probType=none) + proc choice(x: range(?), size:?sizeType=none, replace=true, prob:?probType=none) throws { - var dom: domain(1,stridable=true); - if x.bounds != boundKind.both { compilerError('input range must be bounded'); - } else { - dom = {x}; } + var dom = {x}; return _choice(this, dom, size=size, replace=replace, prob=prob); } @@ -1682,7 +1679,7 @@ module Random { myStart += multiplier * ZD.indexOrder(((...outer), innerRange.lowBound)).safeCast(int(64)); else myStart += multiplier * ZD.indexOrder(innerRange.lowBound).safeCast(int(64)); - if !innerRange.stridable { + if innerRange.hasUnitStride() { var cursor = randlc_skipto(resultType, seed, myStart); for i in innerRange do yield randlc(resultType, cursor); @@ -1735,7 +1732,7 @@ module Random { myStart += multiplier * ZD.indexOrder(((...outer), innerRange.lowBound)).safeCast(int(64)); else myStart += multiplier * ZD.indexOrder(innerRange.lowBound).safeCast(int(64)); - if !innerRange.stridable { + if innerRange.hasUnitStride() { var cursor = randlc_skipto(resultType, seed, myStart); var count = myStart; for i in innerRange { @@ -2803,7 +2800,7 @@ module Random { } @chpldoc.nodoc - proc choice(x: range(stridable=?), size:?sizeType=none, replace=true, prob:?probType=none) + proc choice(x: range(?), size:?sizeType=none, replace=true, prob:?probType=none) throws { compilerError("NPBRandomStream.choice() is not supported."); @@ -3012,7 +3009,7 @@ module Random { myStart += multiplier * ZD.indexOrder(((...outer), innerRange.lowBound)).safeCast(int(64)); else myStart += multiplier * ZD.indexOrder(innerRange.lowBound).safeCast(int(64)); - if !innerRange.stridable { + if innerRange.hasUnitStride() { cursor = randlc_skipto(seed, myStart); for i in innerRange do yield randlc(resultType, cursor); diff --git a/test/distributions/private/PrivateDistNonNilableDefaultInit.good b/test/distributions/private/PrivateDistNonNilableDefaultInit.good index 3176d4b82c81..ac8c27336489 100644 --- a/test/distributions/private/PrivateDistNonNilableDefaultInit.good +++ b/test/distributions/private/PrivateDistNonNilableDefaultInit.good @@ -4,7 +4,7 @@ $CHPL_HOME/modules/dists/PrivateDist.chpl:nnnn: error: use here prevents split-i note: non-nilable class type 'borrowed C' does not support default initialization note: Consider using the type shared C? instead PrivateDistNonNilableDefaultInit.chpl:6: error: cannot default-initialize the array a because it has a non-nilable element type 'shared C' - $CHPL_HOME/modules/dists/PrivateDist.chpl:nnnn: called as PrivateArr.init(type eltType = shared C, param rank = 1, type idxType = int(64), param stridable = false, dom: unmanaged PrivateDom(1,int(64),one), param initElts = true) from method 'dsiBuildArray' + $CHPL_HOME/modules/dists/PrivateDist.chpl:nnnn: called as PrivateArr.init(type eltType = shared C, param rank = 1, type idxType = int(64), param strides = strideKind.one, dom: unmanaged PrivateDom(1,int(64),one), param initElts = true) from method 'dsiBuildArray' $CHPL_HOME/modules/internal/ChapelDomain.chpl:nnnn: called as (PrivateDom(1,int(64),one)).dsiBuildArray(type eltType = shared C, param initElts = true) within internal functions (use --print-callstack-on-error to see) PrivateDistNonNilableDefaultInit.chpl:9: called as test1() diff --git a/test/distributions/robust/arithmetic/basics/test_domain_align.chpl b/test/distributions/robust/arithmetic/basics/test_domain_align.chpl index 8b0560ebeee2..df62a80cacb4 100644 --- a/test/distributions/robust/arithmetic/basics/test_domain_align.chpl +++ b/test/distributions/robust/arithmetic/basics/test_domain_align.chpl @@ -40,7 +40,7 @@ proc compare(D, R, a, s=2) { proc test(ref D) { D = rangeTuple(D.rank, 1..10); - var R : domain(D.rank, D.idxType, D.stridable); + var R : domain(D.rank, D.idxType, D.strides); R; R = D; // disable split init because warning text differs per dist compare(D, R, 0); diff --git a/test/distributions/robust/arithmetic/trivial/test_dot_stridable.chpl b/test/distributions/robust/arithmetic/trivial/test_dot_stridable.chpl index e4119215ed1a..a9e470167fd9 100644 --- a/test/distributions/robust/arithmetic/trivial/test_dot_stridable.chpl +++ b/test/distributions/robust/arithmetic/trivial/test_dot_stridable.chpl @@ -1,19 +1,19 @@ use driver_arrays; -writeln(Dom1D.stridable); -writeln(Dom2D.stridable); -writeln(Dom3D.stridable); -writeln(Dom4D.stridable); -writeln(A1D.stridable); -writeln(A2D.stridable); -writeln(A3D.stridable); -writeln(A4D.stridable); +writeln(Dom1D.strides); +writeln(Dom2D.strides); +writeln(Dom3D.strides); +writeln(Dom4D.strides); +writeln(A1D.strides); +writeln(A2D.strides); +writeln(A3D.strides); +writeln(A4D.strides); -compilerWarning(Dom1D.stridable:string); -compilerWarning(Dom2D.stridable:string); -compilerWarning(Dom3D.stridable:string); -compilerWarning(Dom4D.stridable:string); -compilerWarning(A1D.stridable:string); -compilerWarning(A2D.stridable:string); -compilerWarning(A3D.stridable:string); -compilerWarning(A4D.stridable:string); +compilerWarning(Dom1D.strides:string); +compilerWarning(Dom2D.strides:string); +compilerWarning(Dom3D.strides:string); +compilerWarning(Dom4D.strides:string); +compilerWarning(A1D.strides:string); +compilerWarning(A2D.strides:string); +compilerWarning(A3D.strides:string); +compilerWarning(A4D.strides:string); diff --git a/test/distributions/robust/arithmetic/trivial/test_dot_stridable.good b/test/distributions/robust/arithmetic/trivial/test_dot_stridable.good index 3aceb229180d..6883cd10f737 100644 --- a/test/distributions/robust/arithmetic/trivial/test_dot_stridable.good +++ b/test/distributions/robust/arithmetic/trivial/test_dot_stridable.good @@ -1,16 +1,16 @@ -test_dot_stridable.chpl:12: warning: false -test_dot_stridable.chpl:13: warning: false -test_dot_stridable.chpl:14: warning: false -test_dot_stridable.chpl:15: warning: false -test_dot_stridable.chpl:16: warning: false -test_dot_stridable.chpl:17: warning: false -test_dot_stridable.chpl:18: warning: false -test_dot_stridable.chpl:19: warning: false -false -false -false -false -false -false -false -false +test_dot_stridable.chpl:12: warning: one +test_dot_stridable.chpl:13: warning: one +test_dot_stridable.chpl:14: warning: one +test_dot_stridable.chpl:15: warning: one +test_dot_stridable.chpl:16: warning: one +test_dot_stridable.chpl:17: warning: one +test_dot_stridable.chpl:18: warning: one +test_dot_stridable.chpl:19: warning: one +one +one +one +one +one +one +one +one diff --git a/test/domains/compilerErrors/notsupportedRectOps-ok.good b/test/domains/compilerErrors/notsupportedRectOps-ok.good index 136e15cdae58..b373e75d8cc0 100644 --- a/test/domains/compilerErrors/notsupportedRectOps-ok.good +++ b/test/domains/compilerErrors/notsupportedRectOps-ok.good @@ -22,7 +22,7 @@ DefaultSparseDom(1,int(64),domain(1,int(64),one)) 1 2 -SparseBlockDom(1,int(64),BlockDom(1,int(64),one,unmanaged DefaultDist),unmanaged DefaultDist,false) +SparseBlockDom(1,int(64),BlockDom(1,int(64),one,unmanaged DefaultDist),unmanaged DefaultDist,one) 1 3 1 diff --git a/test/domains/diten/castAwayStridableDomain.good b/test/domains/diten/castAwayStridableDomain.good index 993be227c322..894c5f7dc3ff 100644 --- a/test/domains/diten/castAwayStridableDomain.good +++ b/test/domains/diten/castAwayStridableDomain.good @@ -4,4 +4,4 @@ after cast/assign unstridableDom={1..20} after cast/assign stridableDom={1..20 by 2} after safeCast/assign unstridableDom={1..20} after safeCast/assign stridableDomUnit={1..20} -castAwayStridableDomain.chpl:19: error: halt reached - non-stridable domain assigned non-unit stride in dimension 0 +castAwayStridableDomain.chpl:19: error: halt reached - illegal safeCast from stride 2 to strideKind.one diff --git a/test/users/engin/partial_reduction_support/modules/dsiMethods.chpl b/test/users/engin/partial_reduction_support/modules/dsiMethods.chpl index 68bc3ea2c80c..7ba1dc2d9768 100644 --- a/test/users/engin/partial_reduction_support/modules/dsiMethods.chpl +++ b/test/users/engin/partial_reduction_support/modules/dsiMethods.chpl @@ -428,7 +428,7 @@ iter CSArr.dsiPartialThese(param onlyDim, otherIdx, // Block Distribution support // proc LocBlockArr.clone() { - return new unmanaged LocBlockArr(eltType,rank,idxType,stridable,locDom, + return new unmanaged LocBlockArr(eltType,rank,idxType,strides,locDom, locRAD, myElems, locRADLock); } @@ -685,7 +685,7 @@ iter LocBlockCyclicDom.dsiPartialThese(param onlyDim, otherIdx, } proc LocBlockCyclicArr.clone() { - return new unmanaged LocBlockCyclicArr(eltType,rank,idxType,stridable, + return new unmanaged LocBlockCyclicArr(eltType,rank,idxType,strides, allocDom,indexDom); }