Skip to content

Commit 5b5f816

Browse files
authored
Merge pull request #554 from JuliaParallel/jps/dtaskfailedexception
More `Thunk` to `DTask` renames
2 parents 52a97dd + 57e2209 commit 5b5f816

File tree

19 files changed

+77
-68
lines changed

19 files changed

+77
-68
lines changed

docs/src/api-dagger/functions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ addprocs!
5959
rmprocs!
6060
```
6161

62-
## Thunk Execution Environment Functions
62+
## DTask Execution Environment Functions
6363

64-
These functions are used within the function called by a `Thunk`.
64+
These functions are used within the function called by a `DTask`.
6565

6666
```@docs
67-
in_thunk
68-
thunk_processor
67+
in_task
68+
task_processor
6969
```
7070

7171
### Dynamic Scheduler Control Functions

docs/src/darray.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ julia> Dagger.chunks(DZ)
357357
DTask (finished) DTask (finished)
358358
359359
julia> Dagger.chunks(fetch(DZ))
360-
2×2 Matrix{Union{Thunk, Dagger.Chunk}}:
360+
2×2 Matrix{Union{DTask, Dagger.Chunk}}:
361361
Chunk{Matrix{Float64}, DRef, ThreadProc, AnyScope}(Matrix{Float64}, ArrayDomain{2}((1:50, 1:50)), DRef(4, 8, 0x0000000000004e20), ThreadProc(4, 1), AnyScope(), true) … Chunk{Matrix{Float64}, DRef, ThreadProc, AnyScope}(Matrix{Float64}, ArrayDomain{2}((1:50, 1:50)), DRef(2, 5, 0x0000000000004e20), ThreadProc(2, 1), AnyScope(), true)
362362
Chunk{Matrix{Float64}, DRef, ThreadProc, AnyScope}(Matrix{Float64}, ArrayDomain{2}((1:50, 1:50)), DRef(5, 5, 0x0000000000004e20), ThreadProc(5, 1), AnyScope(), true) Chunk{Matrix{Float64}, DRef, ThreadProc, AnyScope}(Matrix{Float64}, ArrayDomain{2}((1:50, 1:50)), DRef(3, 3, 0x0000000000004e20), ThreadProc(3, 1), AnyScope(), true)
363363
```

docs/src/scopes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using VideoIO, Distributed
2323

2424
function get_handle()
2525
handle = VideoIO.opencamera()
26-
proc = Dagger.thunk_processor()
26+
proc = Dagger.task_processor()
2727
scope = Dagger.scope(worker=myid()) # constructs a `ProcessScope`
2828
return Dagger.tochunk(handle, proc, scope)
2929
end
@@ -78,7 +78,7 @@ function generate()
7878
fill!(arr, 1)
7979
Mmap.sync!(arr)
8080
# Note: Dagger.scope() does not yet support node scopes
81-
Dagger.tochunk(path, Dagger.thunk_processor(), NodeScope())
81+
Dagger.tochunk(path, Dagger.task_processor(), NodeScope())
8282
end
8383

8484
function consume(path)
@@ -120,7 +120,7 @@ function generate_secrets()
120120
secrets = open("/shared/secret_results.txt", "r") do io
121121
String(read(io))
122122
end
123-
Dagger.tochunk(secrets, Dagger.thunk_processor(), secrets_scope)
123+
Dagger.tochunk(secrets, Dagger.task_processor(), secrets_scope)
124124
end
125125

126126
summarize(secrets) = occursin("QA Pass", secrets)
@@ -144,7 +144,7 @@ constraints). For example:
144144
ps2 = ProcessScope(2)
145145
ps3 = ProcessScope(3)
146146

147-
generate(scope) = Dagger.tochunk(rand(64), Dagger.thunk_processor(), scope)
147+
generate(scope) = Dagger.tochunk(rand(64), Dagger.task_processor(), scope)
148148

149149
d2 = Dagger.@spawn generate(ps2) # Run on process 2
150150
d3 = Dagger.@spawn generate(ps3) # Run on process 3

src/array/alloc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ function partition(p::AbstractBlocks, dom::ArrayDomain)
2525
end
2626

2727
function allocate_array(f, T, idx, sz)
28-
new_f = allocate_array_func(thunk_processor(), f)
28+
new_f = allocate_array_func(task_processor(), f)
2929
return new_f(idx, T, sz)
3030
end
3131
function allocate_array(f, T, sz)
32-
new_f = allocate_array_func(thunk_processor(), f)
32+
new_f = allocate_array_func(task_processor(), f)
3333
return new_f(T, sz)
3434
end
3535
allocate_array_func(::Processor, f) = f

src/array/cholesky.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LinearAlgebra.cholcopy(A::DArray{T,2}) where T = copy(A)
22
function potrf_checked!(uplo, A, info_arr)
3-
_A, info = move(thunk_processor(), LAPACK.potrf!)(uplo, A)
3+
_A, info = move(task_processor(), LAPACK.potrf!)(uplo, A)
44
if info != 0
55
fill!(info_arr, info)
66
throw(PosDefException(info))
@@ -41,7 +41,7 @@ function LinearAlgebra._chol!(A::DArray{T,2}, ::Type{UpperTriangular}) where T
4141
end
4242
end
4343
catch err
44-
err isa ThunkFailedException || rethrow()
44+
err isa DTaskFailedException || rethrow()
4545
err = Dagger.Sch.unwrap_nested_exception(err.ex)
4646
err isa PosDefException || rethrow()
4747
end
@@ -82,7 +82,7 @@ function LinearAlgebra._chol!(A::DArray{T,2}, ::Type{LowerTriangular}) where T
8282
end
8383
end
8484
catch err
85-
err isa ThunkFailedException || rethrow()
85+
err isa DTaskFailedException || rethrow()
8686
err = Dagger.Sch.unwrap_nested_exception(err.ex)
8787
err isa PosDefException || rethrow()
8888
end

src/dtask.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export DTask
2+
13
"A future holding the result of a `Thunk`."
24
struct ThunkFuture
35
future::Future

src/sch/Sch.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Random: randperm
88
import Base: @invokelatest
99

1010
import ..Dagger
11-
import ..Dagger: Context, Processor, Thunk, WeakThunk, ThunkFuture, ThunkFailedException, Chunk, WeakChunk, OSProc, AnyScope, DefaultScope, LockedObject
12-
import ..Dagger: order, dependents, noffspring, istask, inputs, unwrap_weak_checked, affinity, tochunk, timespan_start, timespan_finish, procs, move, chunktype, processor, get_processors, get_parent, execute!, rmprocs!, thunk_processor, constrain, cputhreadtime
11+
import ..Dagger: Context, Processor, Thunk, WeakThunk, ThunkFuture, DTaskFailedException, Chunk, WeakChunk, OSProc, AnyScope, DefaultScope, LockedObject
12+
import ..Dagger: order, dependents, noffspring, istask, inputs, unwrap_weak_checked, affinity, tochunk, timespan_start, timespan_finish, procs, move, chunktype, processor, get_processors, get_parent, execute!, rmprocs!, task_processor, constrain, cputhreadtime
1313
import ..Dagger: @dagdebug, @safe_lock_spin1
1414
import DataStructures: PriorityQueue, enqueue!, dequeue_pair!, peek
1515

src/sch/dynamic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ end
132132
function Base.fetch(h::SchedulerHandle, id::ThunkID)
133133
future = ThunkFuture(Future(1))
134134
exec!(_register_future!, h, future, id, true)
135-
fetch(future; proc=thunk_processor())
135+
fetch(future; proc=task_processor())
136136
end
137137
"""
138138
Waits on a thunk to complete, and fetches its result. If `check` is set to

src/sch/eager.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Allows a thunk to safely wait on another thunk by temporarily reducing its
6161
effective occupancy to 0, which allows a newly-spawned task to run.
6262
"""
6363
function thunk_yield(f)
64-
if Dagger.in_thunk()
64+
if Dagger.in_task()
6565
h = sch_handle()
6666
tls = Dagger.get_tls()
67-
proc = Dagger.thunk_processor()
67+
proc = Dagger.task_processor()
6868
proc_istate = proc_states(tls.sch_uid) do states
6969
states[proc].state
7070
end

src/sch/util.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ end
175175
"Marks `thunk` and all dependent thunks as failed."
176176
function set_failed!(state, origin, thunk=origin)
177177
filter!(x->x!==thunk, state.ready)
178-
state.cache[thunk] = ThunkFailedException(thunk, origin, state.cache[origin])
178+
ex = state.cache[origin]
179+
if ex isa RemoteException
180+
ex = ex.captured
181+
end
182+
state.cache[thunk] = DTaskFailedException(thunk, origin, ex)
179183
state.errored[thunk] = true
180184
finish_failed!(state, thunk, origin)
181185
end

0 commit comments

Comments
 (0)