Skip to content

Commit be61d48

Browse files
committed
Rename remote to rarray; fixes.
1 parent 816ff58 commit be61d48

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

src/RemoteArrays.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module RemoteArrays
22
using Dagger
33
using LinearAlgebra
44

5-
export remote, scopeof, RemoteArray
5+
export rarray, scopeof, RemoteArray
66

77
mutable struct RemoteArray{T, N, A} <: AbstractArray{T, N}
88
task::Any
@@ -19,28 +19,30 @@ end
1919

2020
Base.size(ra::RemoteArray) = ra.size
2121

22+
Dagger.memory_space(ra::RemoteArray) = Dagger.memory_space(ra.task)
23+
2224
function scopeof(ra::RemoteArray)
23-
space = Dagger.memory_space(ra.task)
24-
return scope = UnionScope(map(ExactScope, collect(Dagger.processors(space))))
25+
space = Dagger.memory_space(ra)
26+
return UnionScope(map(ExactScope, collect(Dagger.processors(space))))
2527
end
2628

2729
storagetype(::RemoteArray{T, N, A}) where {T, N, A} = A
2830
storagetype(::Type{<:RemoteArray{T, N, A}}) where {T, N, A} = A
2931

30-
function remote(a::A, options = Dagger.Options()) where {T, N, A <: AbstractArray{T, N}}
32+
function rarray(a::A, options = Dagger.Options()) where {T, N, A <: AbstractArray{T, N}}
3133
task = Dagger.spawn(identity, options, a)
3234
return RemoteArray{T, N, A}(task, size(a))
3335
end
3436

35-
function remote(a::AbstractArray, proc::Dagger.Processor)
37+
function rarray(a::AbstractArray, proc::Dagger.Processor)
3638
scope = ExactScope(proc)
3739
opts = Dagger.Options(; compute_scope = scope)
38-
return remote(a, opts)
40+
return rarray(a, opts)
3941
end
4042

41-
remote(f, dims) = remote(f, Float64, dims)
42-
function remote(f, ::Type{T}, dims::NTuple{N, Int64}) where {T, N}
43-
A = Base.promote_op(f, T, typeof(dims))
43+
rarray(f, dims) = rarray(f, Float64, dims)
44+
function rarray(f, ::Type{T}, dims::NTuple{N, Int64}) where {T, N}
45+
A = Base.promote_op(f, Type{T}, typeof(dims))
4446
return RemoteArray{T, N, A}(Dagger.spawn(f, T, dims), dims)
4547
end
4648

@@ -49,7 +51,7 @@ function Base.getindex(ra::RemoteArray, I::Vararg{Int, N}) where {N}
4951
end
5052

5153
function Base.setindex!(ra::RemoteArray, v, I::Vararg{Int, N}) where {N}
52-
Dagger.spawn(setindex!, ra.task, v, I...)
54+
ra.task = Dagger.spawn(setindex!, ra.task, v, I...)
5355
return ra
5456
end
5557

@@ -86,25 +88,26 @@ function LinearAlgebra.mul!(
8688
end
8789

8890
function Base.show(io::IO, mime::MIME"text/plain", ra::RemoteArray)
91+
ready = isready(ra.task)
8992
n, m = size(ra)
9093

9194
print(io, "$(n)×$(m) $(typeof(ra)) in ")
9295
ion = IOContext(io, :indent => (get(io, :indent, 0) + 0))
93-
if isready(ra.task)
96+
if ready
9497
scope = scopeof(ra)
9598
print(ion, scope, "\n")
9699
else
97100
print(ion, "unknown scope (running):", "\n")
98101
end
99102

100-
char = isready(ra.task) ? i -> "" : i -> rand(['', '', '', ''])
103+
char = ready ? () -> "" : () -> rand(['', '', '', ''])
101104

102105
c = 1
103106
for i in 1:n
104107
print(io, " ")
105108
for j in 1:m
106109
print(io, " ")
107-
print(io, char(c))
110+
print(io, char())
108111
if j < m
109112
print(io, " ")
110113
end

0 commit comments

Comments
 (0)