Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor synchronization #62

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alexandermorozov
Copy link
Contributor

I've implemented memory access API and syncronization based on bitmasks. Tesnsor/TensorView and decoupling aren't implemented.

Native and CUDA pass all tests. OpenCL compiles but segfaults on my machine, both with this PR and without it.

PR isn't ready to be merged yet -- I'd like to fix plugins and Leaf first to see that there are no unexpected problems.

Remove methods `sync()`, `get()`, `get_mut()`, `remove_copy()` of
`SharedTensor` and introduce new set of methods: `read()`, `read_write()`,
`write_only()`, `drop_device()`. Signature of `SharedTensor::new()` has also
changed.

New API has following benefits:
 - limited checks of use of uninitialized memory,
 - better memory tracking: several memories can be simultaneously marked as
   up-to-date, so some synchronization operations might be skipped,
 - backing memory is automatically allocated on the first use and added to
   `SharedTensor`, even if it's immutable. Mutability is required only for
   reshaping, modifying actual data and dropping memories.

Rationale and design decisions are discussed at the corresponding bugtracker
issue.

BREAKING CHANGE: sync and memory management API of `SharedTensor`

CLOSE: autumnai#37
Implementation of SharedTensor uses `unsafe` to extend lifetime of memory
references that are returned by read/write family of methods. Those tests
verify that attempts to create dangling pointers or otherwise misuse API
fail at compile time.
During refactoring (autumnai#37) several error were upgraded into panics. Those
errors may happen only if internal logic of `SharedTensor` is incorrect
and leads to inconsistent state and broken invariants.
Since plugin operations rely on `SharedTensor`'s memory access and allocation
API, they need to proxy errors. This commit adds new error enum entry to
plugin::Error, and removes deprecated plugin::Error::MissingMemoryForDevice.
It also adds autoconversion from plugin::Error::SharedTensor for convenient
use of `try!`.
…..>`

Allocation of `SharedTensor` may fail only on OOM, so returning `Result` type
is redundant.
alexandermorozov added a commit to alexandermorozov/collenchyma-blas that referenced this pull request Apr 23, 2016
Refactor code CUDA and Native backend to match #autumnai/collenchyma/62 that
provides enchanced memory management and syncronization. Since memory
management is now automatic, `*_plain` variants of functions are removed.

BREAKING CHANGE: *_plain versions of API functions are removed, arguments of
their counterpart functions may have changed in mutablity.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62

refactor/native: convert to the new memory management API

Convert Native backend. Code now compiles.
alexandermorozov added a commit to alexandermorozov/collenchyma-nn that referenced this pull request Apr 24, 2016
Refactor code CUDA and Native backend to match #autumnai/collenchyma/62 that
provides enchanced memory management and syncronization. Since memory
management is now automatic, `*_plain` variants of functions are removed.

BREAKING CHANGE: *_plain versions of API functions are removed, arguments of
their counterpart functions may have changed in mutablity.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62
alexandermorozov added a commit to alexandermorozov/collenchyma-blas that referenced this pull request Apr 24, 2016
Refactor code CUDA and Native backend to match #autumnai/collenchyma/62 that
provides enchanced memory management and syncronization. Since memory
management is now automatic, `*_plain` variants of functions are removed.

BREAKING CHANGE: *_plain versions of API functions are removed, arguments of
their counterpart functions may have changed in mutablity.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62
alexandermorozov added a commit to alexandermorozov/collenchyma-nn that referenced this pull request Apr 24, 2016
Refactor code CUDA and Native backend to match #autumnai/collenchyma/62 that
provides enchanced memory management and syncronization. Since memory
management is now automatic, `*_plain` variants of functions are removed.

BREAKING CHANGE: *_plain versions of API functions are removed, arguments of
their counterpart functions may have changed in mutablity.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62
alexandermorozov added a commit to alexandermorozov/collenchyma-nn that referenced this pull request Apr 28, 2016
Refactor code CUDA and Native backend to match #autumnai/collenchyma/62 that
provides enchanced memory management and syncronization. Since memory
management is now automatic, `*_plain` variants of functions are removed.

BREAKING CHANGE: *_plain versions of API functions are removed, arguments of
their counterpart functions may have changed in mutablity.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62
alexandermorozov added a commit to alexandermorozov/leaf that referenced this pull request Apr 30, 2016
Use .read()/.write_only()/.read_write() instead of .sync()/.add_device()/.get()
calls.

REFERENCE: autumnai/collenchyma#37, autumnai/collenchyma#62
alexandermorozov added a commit to alexandermorozov/leaf that referenced this pull request Apr 30, 2016
alexandermorozov added a commit to alexandermorozov/leaf-examples that referenced this pull request Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant