Skip to content

Commit

Permalink
Add sparse matrix compat module for 2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com>
  • Loading branch information
ShreyasKhandekar committed Sep 11, 2024
1 parent e12a212 commit af63bf4
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SparseMatrix.chpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module SparseMatrix {

public use SpsMatUtil;
use ArkoudaSparseMatrixCompat;


// Quick and dirty, not permanent
Expand Down
86 changes: 86 additions & 0 deletions src/compat/eq-20/ArkoudaSparseMatrixCompat.chpl
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;
}
}
1 change: 1 addition & 0 deletions src/compat/eq-21/ArkoudaSparseMatrixCompat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module ArkoudaSparseMatrixCompat {}
1 change: 1 addition & 0 deletions src/compat/ge-22/ArkoudaSparseMatrixCompat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module ArkoudaSparseMatrixCompat {}

0 comments on commit af63bf4

Please sign in to comment.