Skip to content

Instantly share code, notes, and snippets.

@vasslitvinov
Created July 6, 2017 00:18
Show Gist options
  • Save vasslitvinov/bf1b23aeb49fbaf062ceaa269eda57ff to your computer and use it in GitHub Desktop.
Save vasslitvinov/bf1b23aeb49fbaf062ceaa269eda57ff to your computer and use it in GitHub Desktop.
Making CSR act as a rectangular domain map
diff --git a/modules/layouts/LayoutCSR.chpl b/modules/layouts/LayoutCSR.chpl
index a388bfc..8d46293 100644
--- a/modules/layouts/LayoutCSR.chpl
+++ b/modules/layouts/LayoutCSR.chpl
@@ -52,6 +52,10 @@ class CSR: BaseDist {
return new CSRDom(rank=rank, idxType=idxType, dist=this, parentDom=dom);
}
+ proc dsiNewRectangularDom(param rank: int, type idxType, param stridable: bool, inds) {
+ return new CSRDom(rank=rank, idxType=idxType, dist=this, parentDom={(...inds)});
+ }
+
proc dsiClone() return new CSR();
proc dsiEqualDMaps(that: CSR) param {
@@ -63,9 +67,20 @@ class CSR: BaseDist {
}
}
-class CSRDom: BaseSparseDomImpl {
+class CSRDom: BaseRectangularDom {
+ // rank and idxType will be moved to BaseDom
+ param rank: int;
+ type idxType;
+ var parentDom;
+
+ proc stridable param return parentDom.stridable;
+
var dist: CSR;
+ var nnz = 0; //: int;
+ var nnzDom = {1..nnz};
+
+
var rowRange: range(idxType);
var colRange: range(idxType);
@@ -458,7 +473,17 @@ class CSRDom: BaseSparseDomImpl {
}
-class CSRArr: BaseSparseArrImpl {
+class CSRArr: BaseArr {
+ type eltType;
+ param rank : int;
+ type idxType;
+
+ var dom; /* : DefaultSparseDom(?); */
+
+ // NOTE I tried to put `data` in `BaseSparseArrImpl`. However, it wasn't
+ // clear how to initialize this in that class.
+ var data: [dom.nnzDom] eltType;
+ var irv: eltType;
proc dsiAccess(ind: rank*idxType) ref {
// make sure we're in the dense bounding box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment