Skip to content

Commit

Permalink
Add SimpleDomain back in for merge to main.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iainmon committed Aug 30, 2024
1 parent 1c01dd8 commit 4d8f272
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
26 changes: 20 additions & 6 deletions lib/NDArray.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,42 @@ record ndarray : serializable {
param rank: int;
type eltType = real(32);
var _domain: domain(rank,int);
var data: [_domain] eltType = noinit;
var simpleDomain: rect(rank);
var data: [_domain] eltType;

forwarding data except shape, _dom;

// pragma "no copy return"
// pragma "return not owned"
proc _dom do return _domain;
// proc _dom do return _domain;

proc shape do return _domain.fastShape;
proc _dom const {
if boundsChecking {
compilerWarning("Bounds checking on.");
// assert(simpleDomain.toDomain() == _domain);
// assert(simpleDomain == _domain.simple());
}
return simpleDomain;
}

proc shape: rank * int do
return simpleDomain.shape;

inline
proc init(type eltType, dom: domain) {
proc init(type eltType, const sd: rect(?rank)) {
this.rank = rank;
this.eltType = eltType;
this._domain = dom;
this._domain = sd.toDomain();
this.simpleDomain = sd;
this.data = noinit;
}

inline
proc init(type eltType, param rank: , const in fill: eltType) {
proc init(type eltType, const sd: rect(?rank), const in fill: eltType) {
this.rank = rank;
this.eltType = eltType;
this._domain = sd.toDomain();
this.simpleDomain = sd;
compilerWarning("Could be a point of performance issues.");
this.data = fill;
}
Expand Down
1 change: 0 additions & 1 deletion lib/SimpleDomain.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ record rect : serializable {
foreach i in 0..<size do
yield indexAt(i);
else {
compilerError("Iain, you should not be using this.");
const dom = toDomain();
foreach idx in dom do
yield idx;
Expand Down

0 comments on commit 4d8f272

Please sign in to comment.