-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sparse matrix compat module for 2.0
Signed-off-by: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com>
- Loading branch information
1 parent
5fcbec6
commit 52fcb3a
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
module ArkoudaSparseMatrixCompat { | ||
use SparseBlockDist; | ||
|
||
proc SparseBlockDom.setLocalSubdomain(locIndices, loc: locale = here) { | ||
if loc != here then | ||
halt("setLocalSubdomain() doesn't currently support remote updates"); | ||
ref myBlock = this.myLocDom!.mySparseBlock; | ||
if myBlock.type != locIndices.type then | ||
compilerError("setLocalSubdomain() expects its argument to be of type ", | ||
myBlock.type:string); | ||
else | ||
myBlock = locIndices; | ||
} | ||
|
||
proc SparseBlockArr.getLocalSubarray(localeRow, localeCol) const ref { | ||
return this.locArr[localeRow, localeCol]!.myElems; | ||
} | ||
|
||
proc SparseBlockArr.getLocalSubarray(localeIdx) const ref { | ||
return this.locArr[localeIdx]!.myElems; | ||
} | ||
|
||
proc SparseBlockArr.setLocalSubarray(locNonzeroes, loc: locale = here) { | ||
if loc != here then | ||
halt("setLocalSubarray() doesn't currently support remote updates"); | ||
ref myBlock = this.myLocArr!.myElems; | ||
if myBlock.type != locNonzeroes.type then | ||
compilerError("setLocalSubarray() expects its argument to be of type ", | ||
myBlock.type:string); | ||
else | ||
myBlock.data = locNonzeroes.data; | ||
} | ||
|
||
proc SparseBlockDom.dsiTargetLocales() const ref { | ||
return dist.targetLocales; | ||
} | ||
|
||
proc SparseBlockArr.dsiTargetLocales() const ref { | ||
return dom.dsiTargetLocales(); | ||
} | ||
|
||
use LayoutCS; | ||
|
||
proc CSDom.rows() { | ||
return this.rowRange; | ||
} | ||
|
||
proc CSDom.cols() { | ||
return this.colRange; | ||
} | ||
|
||
@chpldoc.nodoc | ||
iter CSDom.uidsInRowCol(rc) { | ||
for uid in startIdx[rc]..<startIdx[rc+1] do | ||
yield uid; | ||
} | ||
|
||
proc CSArr.rows() { | ||
return this.dom.rows(); | ||
} | ||
|
||
proc CSArr.cols() { | ||
return this.dom.cols(); | ||
} | ||
|
||
@chpldoc.nodoc | ||
iter CSArr.indsAndVals(rc) { | ||
ref dom = this.dom; | ||
for uid in dom.uidsInRowCol(rc) do | ||
yield (dom.idx[uid], this.data[uid]); | ||
} | ||
|
||
iter CSArr.colsAndVals(r) { | ||
if this.dom.compressRows == false then | ||
compilerError("Can't (efficiently) iterate over rows using a CSC layout"); | ||
for colVal in indsAndVals(r) do | ||
yield colVal; | ||
} | ||
|
||
iter CSArr.rowsAndVals(c) { | ||
if this.dom.compressRows == true then | ||
compilerError("Can't (efficiently) iterate over columns using a CSR layout"); | ||
for rowVal in indsAndVals(c) do | ||
yield rowVal; | ||
} | ||
} |