You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to write a procedure that can create block-distributed sparse arrays that have either a CSR or CSC layout selected by a param argument, I'm running into a strange compiler error. The following procedure should be creating a fully concrete array type which is either using csrLayout or cscLayout; however, something is going wrong with runtime type construction, where the compiler thinks that one of the underlying data structures would be generic.
Steps to Reproduce
Source Code:
use BlockDist, CompressedSparseLayout;
enum Layout { CSR, CSC }
proc makeSparseMatrix(m:int, n:int, param layout: Layout) {
const dom = {1..m, 1..n},
locsPerDim =sqrt(numLocales:real):int,
grid = {0..<locsPerDim, 0..<locsPerDim},
localeGrid = reshape(Locales[0..<grid.size], grid);
type layoutType =if layout == Layout.CSR then csrLayout else cscLayout;
const DenseBlkDom = dom dmappednew blockDist(boundingBox=dom,
targetLocales=localeGrid,
sparseLayoutType=layoutType);
var SD:sparsesubdomain(DenseBlkDom);
var A:[SD]int;
return A;
}
var sm = makeSparseMatrix(10, 10, Layout.CSR);
Error message:
The above code produces the following error message:
$CHPL_HOME/modules/internal/ChapelDomain.chpl:1621: In method 'buildArray':
$CHPL_HOME/modules/internal/ChapelDomain.chpl:1622: warning: creating an array with element type unmanaged LocSparseBlockDom(2,int(64),one,csrLayout)?
$CHPL_HOME/modules/internal/ChapelDomain.chpl:1622: error: array element type cannot currently be generic
$CHPL_HOME/modules/internal/ChapelArray.chpl:226: called as (domain(unmanaged DefaultRectangularDom(2,int(64),one))).buildArray(type eltType = unmanaged LocSparseBlockDom(2,int(64),one,csrLayout)?, param initElts = false) from function 'chpl__buildArrayRuntimeType'
$CHPL_HOME/modules/dists/SparseBlockDist.chpl:91: called as chpl__buildArrayRuntimeType(dom: domain(unmanaged DefaultRectangularDom(2,int(64),one)), type eltType = unmanaged LocSparseBlockDom(2,int(64),one,csrLayout)?) from initializer
$CHPL_HOME/modules/dists/BlockDist.chpl:847: called as SparseBlockDom.init(param rank = 2, idxType: int(64), parentDom: domain(unmanaged BlockDom(2,int(64),one,csrLayout)), nnzDom: domain(unmanaged DefaultRectangularDom(1,int(64),one)), sparseLayoutType: csrLayout(?), param strides = strideKind.one, dist: unmanaged BlockImpl(2,int(64),csrLayout), whole: domain(unmanaged DefaultRectangularDom(2,int(64),one)), locDoms: <type unknown>, myLocDom: <type unknown>) from method 'dsiNewSparseDom'
$CHPL_HOME/modules/dists/DSIUtil.chpl:783: called as (BlockImpl(2,int(64),csrLayout)).dsiNewSparseDom(param rank = 2, type idxType = int(64), dom: domain(unmanaged BlockDom(2,int(64),one,csrLayout))) from method 'newSparseDom'
$CHPL_HOME/modules/internal/ChapelDomain.chpl:1124: called as (chpl_PrivatizedDistHelper(unmanaged BlockImpl(2,int(64),csrLayout))).newSparseDom(param rank = 2, type idxType = int(64), dom: domain(unmanaged BlockDom(2,int(64),one,csrLayout))) from initializer
$CHPL_HOME/modules/internal/ChapelDomain.chpl:129: called as (domain(?)).init(d: blockDist(2,int(64),csrLayout), dom: domain(unmanaged BlockDom(2,int(64),one,csrLayout)), definedConst: bool) from function 'chpl__buildSparseDomainRuntimeType'
$CHPL_HOME/modules/internal/ChapelDomain.chpl:137: called as chpl__buildSparseDomainRuntimeType(dist: blockDist(2,int(64),csrLayout), parentDom: domain(unmanaged BlockDom(2,int(64),one,csrLayout))) from function 'chpl__buildSparseDomainRuntimeTypeForParentDomain'
asdf.chpl:16: called as chpl__buildSparseDomainRuntimeTypeForParentDomain(parentDom: domain(unmanaged BlockDom(2,int(64),one,csrLayout))) from function 'makeSparseMatrix'
asdf.chpl:21: called as makeSparseMatrix(m: int(64), n: int(64), param layout = Layout.CSR)
note: generic instantiations are underlined in the above callstack
However, if the sparseLayoutType=layoutType argument in blockDist's initializer is hard-coded to either csrLayout or cscLayout, then the code compiles successfully. Additionally, if the whole initializer call is replaced with the following, the code will also compile successfully:
const DenseBlkDom;
if layout == Layout.CSR {
DenseBlkDom = dom dmappednew blockDist(boundingBox=dom,
targetLocales=localeGrid,
sparseLayoutType=csrLayout);
} else {
DenseBlkDom = dom dmappednew blockDist(boundingBox=dom,
targetLocales=localeGrid,
sparseLayoutType=cscLayout);
}
This indicates that there is something going wrong when creating a "type alias" for either csrLayout or cscLayout.
Summary of Problem
Description:
When attempting to write a procedure that can create block-distributed sparse arrays that have either a CSR or CSC layout selected by a param argument, I'm running into a strange compiler error. The following procedure should be creating a fully concrete array type which is either using csrLayout or cscLayout; however, something is going wrong with runtime type construction, where the compiler thinks that one of the underlying data structures would be generic.
Steps to Reproduce
Source Code:
Error message:
The above code produces the following error message:
However, if the
sparseLayoutType=layoutType
argument inblockDist
's initializer is hard-coded to eithercsrLayout
orcscLayout
, then the code compiles successfully. Additionally, if the whole initializer call is replaced with the following, the code will also compile successfully:This indicates that there is something going wrong when creating a "type alias" for either
csrLayout
orcscLayout
.Configuration Information
printchplenv...
The text was updated successfully, but these errors were encountered: