Skip to content

Commit c66b8c9

Browse files
KDr2yebai
andauthored
TArray Indexing Performance (#83)
* improve TArray benchmarks * update benchmarks * 1. Base.@propagate_inbounds, 2. use function in benchmarks * optimize indexing for Matrix{Float64} * indent code * move TArray data into TArray * update benchmarks * update comments and fix other issues * more performant way to perdicate if a weakref is empty * underlying array type as a parametric type of TArray * minor update * update according to code review * fix broadcasting * Update Project.toml Co-authored-by: Hong Ge <[email protected]>
1 parent ca8099f commit c66b8c9

File tree

6 files changed

+159
-117
lines changed

6 files changed

+159
-117
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
33
license = "MIT"
44
desc = "C shim for task copying in Turing"
55
repo = "https://github.com/TuringLang/Libtask.jl.git"
6-
version = "0.5.1"
6+
version = "0.5.2"
77

88
[deps]
99
Libtask_jll = "3ae2931a-708c-5973-9c38-ccf7496fb450"

Diff for: src/ctask.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ struct CTask
77
task::Task
88

99
function CTask(task::Task)
10-
new(enable_stack_copying(task))
10+
ret = new(enable_stack_copying(task))
11+
task.storage === nothing && (task.storage = IdDict())
12+
task.storage[:ctask] = ret
13+
ret
1114
end
1215
end
1316

@@ -24,12 +27,13 @@ end
2427

2528
function Base.showerror(io::IO, ex::CTaskException)
2629
println(io, "CTaskException:")
30+
ct = ex.task
2731
bt = @static if VERSION < v"1.6.0-DEV.1145"
2832
ct.backtrace
2933
else
3034
ct.storage[:_libtask_bt]
3135
end
32-
showerror(io, ex.task.exception, bt)
36+
showerror(io, ct.exception, bt)
3337
end
3438

3539
# Utility function for self-copying mechanism
@@ -107,6 +111,7 @@ function Base.copy(ctask::CTask)
107111
setstate!(newtask, getstate(task))
108112
newtask.result = task.result
109113

114+
copy_tarrays(task, newtask)
110115
return CTask(newtask)
111116
end
112117

0 commit comments

Comments
 (0)