Skip to content

[REVIEW] Device buffer class - #99

Merged
harrism merged 29 commits into
rapidsai:branch-0.10from
jrhemstad:fea-ext-device-buffer
Sep 25, 2019
Merged

harrism merged 29 commits into
rapidsai:branch-0.10from
jrhemstad:fea-ext-device-buffer

Conversation

@jrhemstad

@jrhemstad jrhemstad commented Jun 21, 2019 •

Copy link
Copy Markdown
Contributor

Depends on #96

This PR builds on the device_memory_resource design to create RAII wrapper for device memory allocations.

Key points:

  • Integrated with device_memory_resource to use for device memory allocation
  • The allocation is uninitialized
    • In contrast to to std::vector or thrust::device_vector, the device memory allocation will not be default initialized. Therefore, it is UB to rely on the memory being any particular value after construction.
  • device_buffer is untyped, i.e., device_buffer::data returns a void*

Examples:

device_buffer buff(100); // allocates at least 100 bytes of device memory using the default memory resource

custom_memory_resource mr;
device_buffer custom_buff(100, &mr); // allocates at least 100 bytes using the custom memory resource

device_buffer buff_copy(buff); // deep copies `buff` into a new device buffer

device_buffer buff_move(std::move(buff)); // shallow copies `buff` into a new device_buffer, `buff` is now empty

device_buffer buff_default{}; // Default construction. Buffer is empty

buff_default.resize(100); // If the requested sized is larger than the current size, resizes allocation to the new size and deep copies any previous contents. Otherwise, simply updates the value of `size()` to the newly requested size without any allocations or copies

buff_default = buff_copy; // Not allowed. Copy assignment is deleted

buff_default = std::move(buff_copy); // Not allowed. Move assignment is deleted

@jrhemstad jrhemstad added the 3 - Ready for review Ready for review by team label Jun 21, 2019
@jrhemstad
jrhemstad changed the base branch from branch-0.8 to branch-0.9 July 3, 2019 14:48

@harrism harrism left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great. Approving now so you can merge once you respond to my requests and determine the answers to the delete questions.

Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
Comment thread include/rmm/device_buffer.hpp Resolved
@jrhemstad jrhemstad changed the title Device buffer class [REVIEW] Device buffer class Sep 23, 2019
@jrhemstad

Copy link
Copy Markdown
Contributor Author

rerun tests

@harrism
harrism changed the base branch from branch-0.9 to branch-0.10 September 25, 2019 00:30
@harrism
harrism merged commit 347858c into rapidsai:branch-0.10 Sep 25, 2019
@jakirkham

Copy link
Copy Markdown
Member

Thanks for working on this! Would it make sense to expose this to Cython and Python as well?

@harrism

harrism commented Sep 25, 2019

Copy link
Copy Markdown
Member

Not until we have Cython. #132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for review Ready for review by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants