-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Remote implementation without nillable value.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
|
||
|
||
import Time; | ||
|
||
var st = new Time.stopwatch(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |