Skip to content

Commit

Permalink
Add new Remote implementation without nillable value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iainmon committed Aug 21, 2024
1 parent a53d565 commit a4f34b4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/gputil/Remote.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


class _remoteVarContainer {
var containedValue;
}

class Remote {
type eltType;
var value: owned _remoteVarContainer(eltType);
var device: locale;

proc init(in value: owned _remoteVarContainer(?eltType)) {
const loc = value.locale;
this.eltType = eltType;
this.value = value;
this.device = loc;
}


proc init(value: ?eltType, device: locale = Remote.defaultDevice) {
var v: owned _remoteVarContainer(eltType)?;
on device do v = new _remoteVarContainer(value);
this.init(try! v : owned _remoteVarContainer(eltType));
}

proc init(type eltType, in tr: ?inType, device: locale = Remote.defaultDevice) {
var v: owned _remoteVarContainer(eltType)?;
on device {
var val: eltType = tr;
v = new _remoteVarContainer(val);
}
this.init(try! v : owned _remoteVarContainer(eltType));
}
}

proc type Remote.defaultDevice: locale do
return if here.gpus.size >= 1 then here.gpus[0] else here;

8 changes: 8 additions & 0 deletions lib/gputil/remoteTest.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use Remote;

var D = {0..<10,0..<10};

var A: [D] real(32);

var a = new shared Remote(A);
writeln(a);
7 changes: 7 additions & 0 deletions onspeed.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@



import Time;

var st = new Time.stopwatch();

8 changes: 8 additions & 0 deletions onvar.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


on Locales[0] var x: int = 1;


writeln((x.type:string,x.locale));

writeln(x.get());

0 comments on commit a4f34b4

Please sign in to comment.