实现DSI

时间:2017-12-20 18:52:57

标签: chapel

(chpl version 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函数。

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您最直接的问题是MyDom(因此BlockDom)没有名为' dist'的字段。与var dist : MyDist; 一样,您希望添加一个' dist'字段,可能像:

{{1}}

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

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

相关问题