@@ -2,7 +2,7 @@ module RemoteArrays
22using Dagger
33using LinearAlgebra
44
5- export remote , scopeof, RemoteArray
5+ export rarray , scopeof, RemoteArray
66
77mutable struct RemoteArray{T, N, A} <: AbstractArray{T, N}
88 task:: Any
1919
2020Base. size (ra:: RemoteArray ) = ra. size
2121
22+ Dagger. memory_space (ra:: RemoteArray ) = Dagger. memory_space (ra. task)
23+
2224function 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))))
2527end
2628
2729storagetype (:: RemoteArray{T, N, A} ) where {T, N, A} = A
2830storagetype (:: 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))
3335end
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)
3941end
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)
4547end
4648
@@ -49,7 +51,7 @@ function Base.getindex(ra::RemoteArray, I::Vararg{Int, N}) where {N}
4951end
5052
5153function 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
5456end
5557
@@ -86,25 +88,26 @@ function LinearAlgebra.mul!(
8688end
8789
8890function 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