Skip to content
C shim for task copying in Turing
Julia
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
deps filter libraries according to Julia version Jul 31, 2019
src fix version comparison Jul 30, 2019
test Fix test cases Jun 3, 2019
.gitignore
.travis.yml
LICENSE Initial commit Aug 18, 2018
Project.toml
README.md add `Project.toml` Mar 9, 2019
appveyor.yml Update appveyor.yml Jul 30, 2019

README.md

Libtask

Build Status Build status

C shim for task copying in Turing

Getting Started

using Libtask

# Stack allocated objects are deep copied.
function f_ct()
  t = 0;
  while true
    produce(t)
    t = 1 + t
  end
end

t = CTask(f_ct)

consume(t) == 0
consume(t) == 1
a = copy(t);
consume(a) == 2
consume(a) == 3
consume(t) == 2
consume(t) == 3

# Heap allocated objects are shallow copied.

function f_ct2()
  t = [0 1 2];
  while true
    produce(t[1])
    t[1] = 1 + t[1]
  end
end

t = CTask(f_ct2)

consume(t) == 0
consume(t) == 1
a = copy(t);
consume(a) == 2
consume(a) == 3
consume(t) == 4
consume(t) == 5

# `TArray` implements a copy-on-write array. This is useful for task copying.
#  In constrast to standard arrays, which are only shallow copied during task copying,
#  `TArray` are deep copied after task copying.

function f_cta()
  t = TArray(Int, 1);
  t[1] = 0;
  while true
    produce(t[1])
    t[1] = 1 + t[1]
  end
end

t = CTask(f_cta)

consume(t) == 0
consume(t) == 1
a = copy(t);
consume(a) == 2
consume(a) == 3
consume(t) == 2
consume(t) == 3

Note: The Turing probabilistic programming language uses this task copying feature in an efficient implementation of the particle filtering sampling algorithm for arbitary order Markov processes.

Disclaimer: This feature is still experimental and should only be used with caution. Some discussions on its potential caveats can be found here.

For Developer

Release a new version

1. Update the new version number in `Project.toml`;
2. Commit all the changes;
3. Tag the current commit with git, the tag name should be version number with a preceding "v";
4. Push the tag to the repo on GitHub.
You can’t perform that action at this time.