实现DSI时,未解析的域映射类中的'init'

问题描述 投票:2回答:1

(chpl版本1.16.0.e43acc7)

我开始学习DSI interface,并且在从Distribution类中的dsiNewRectangularDom函数构造Domain类时遇到了一个令人困惑的问题:

class MyDist : BaseDist {

  proc MyDist( fold_dimensions ...?dims ){ }

  proc dsiNewRectangularDom(param rank: int, type idxType, param stridable: bool, inds) {
    var dom = new MyDom( rank=rank, idxType=idxType, stridable=stridable, dist=this);
    return dom;
  }
}

class MyDom : BaseRectangularDom { }

class MyArr : BaseArr { }

config const n = 4;
config const m = 8;
const base_domain = {1..#n,1..#m};
const mapped_domain = base_domain dmapped MyDist( 1 );

(这是非常基本的代码,我不希望它完全编译,但我坚持这一部分。)

这会产生编译错误:

file.chpl:5: In function 'dsiNewRectangularDom':
file.chpl:6: error: unresolved call 'MyDom.init(rank=2, idxType=type int(64), stridable=0, dist=MyDist)'
file.chpl:11: note: candidates are: MyDom.init(_arrs, _arrs_containing_dom: int(64), _arrsLock: atomicbool, _free_when_no_arrs: bool, pid: int(64), param rank: int(64), type idxType, param stridable: bool)

(见this TIO instance

我对这个init函数的来源有点困惑。我正在遵循Block,BlockDist和BlockDom的行为(特别是BlockDist.chpl:533,其中Block.dsiNewRectangularDom调用BlockDom的构造函数。由于MyDom继承自BaseRectangularDom,I(1)不需要声明rank,idxType等成员变量, (2)不需要定义MyDom(rank,idxType,...)构造函数。我也没有看到可以学习的BlockDom.init函数。

我错过了什么?

chapel
1个回答
1
投票

你最直接的问题是BaseRectangularDom(因此MyDom)没有名为'dist'的字段。像BlockDom一样,你需要添加一个'dist'字段,可能就像:

var dist : MyDist;

一旦你解决了这个问题,你就会遇到下一个错误(dsiAssignDomain没有实现)。

错误消息可能提到'init'作为从构造函数到initializers的持续转换的副作用。

© www.soinside.com 2019 - 2024. All rights reserved.