Skip to content

Commit

Permalink
TArray Indexing Performance (#83)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
KDr2 and yebai authored Jan 28, 2021
1 parent ca8099f commit c66b8c9
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
license = "MIT"
desc = "C shim for task copying in Turing"
repo = "https://github.com/TuringLang/Libtask.jl.git"
version = "0.5.1"
version = "0.5.2"

[deps]
Libtask_jll = "3ae2931a-708c-5973-9c38-ccf7496fb450"
Expand Down
9 changes: 7 additions & 2 deletions src/ctask.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ struct CTask
task::Task

function CTask(task::Task)
new(enable_stack_copying(task))
ret = new(enable_stack_copying(task))
task.storage === nothing && (task.storage = IdDict())
task.storage[:ctask] = ret
ret
end
end

Expand All @@ -24,12 +27,13 @@ end

function Base.showerror(io::IO, ex::CTaskException)
println(io, "CTaskException:")
ct = ex.task
bt = @static if VERSION < v"1.6.0-DEV.1145"
ct.backtrace
else
ct.storage[:_libtask_bt]
end
showerror(io, ex.task.exception, bt)
showerror(io, ct.exception, bt)
end

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

copy_tarrays(task, newtask)
return CTask(newtask)
end

Expand Down
Loading

2 comments on commit c66b8c9

@devmotion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/38273

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" c66b8c90a8413d4532aecf36cc157767ec51d68d
git push origin v0.5.2

Please sign in to comment.