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

Add complete set of resource ref aliases #1479

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

nvdbaranec
Copy link
Contributor

Adds new aliases to resource_ref.hpp

using host_resource_ref = cuda::mr::resource_ref<cuda::mr::host_accessible>;

using host_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::host_accessible>;

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

…:mr::resource_ref and cudf::mr::async_resource_ref, respectively.
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Only requesting changes so we can discuss question below.

include/rmm/resource_ref.hpp Show resolved Hide resolved
* @brief Alias for a `cuda::mr::async_resource_ref` with the property
* `cuda::mr::host_accessible`.
*/
using host_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::host_accessible>;
Copy link
Member

@harrism harrism Feb 21, 2024

Choose a reason for hiding this comment

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

I think it will be common for users of async_resource_ref for pinned host memory to also want device_accessible. (I expect you will want it in your cuDF usage eventually too...) My question is, do we want to just add cuda::mr::device_accessible to this alias, or add another one:

using host_device_async_resource_ref = 
  cuda::mr::async_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;

Thoughts @nvdbaranec @Missco @jrhemstad ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would not add device_accessible to the host_async_resource_ref as that would all potential memory resource to satisfy device_accessible

On the other hand an async resource has no real value without device_accessible

Copy link
Member

Choose a reason for hiding this comment

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

Good point. However I think an async resource ref that is host-only has value because it specifies that it will only be used on the host, but it may still be backed by pinned memory. And then it benefits from stream-ordered allocation (e.g. can be used in a stream-ordered pool) and also can be used as the host memory for SOL cudaMemcpyAsync.

So really for completeness I think we probably need the full set:

using host_resource_ref = cuda::mr::resource_ref<cuda::mr::host_accessible>;
using device_resource_ref = cuda::mr::resource_ref<cuda::mr::device_accessible>;
using host_device_resource_ref = cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;
using host_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::host_accessible>;
using device_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::device_accessible>;
using host_device_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use case for this right now in cudf is strictly in the hostdevice_vector class, whose sole purpose is to force explicit host<->device copying onto the user. That is: entirely avoiding the device touching pinned memory directly. So in that sense, stream ordering at the allocator level isn't necessary.

https://github.com/rapidsai/cudf/blob/branch-24.04/cpp/src/io/utilities/hostdevice_vector.hpp

As for whether cudf at large will ever need this, I'm not sure. At the moment it definitely prefers to be explicit about all host<-> device handoffs.

@harrism
Copy link
Member

harrism commented Feb 21, 2024

Opened #1480 to cover this work.

@harrism harrism added feature request New feature or request non-breaking Non-breaking change labels Feb 21, 2024
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Thank you @nvdbaranec

@bdice
Copy link
Contributor

bdice commented Feb 26, 2024

/merge

@rapids-bot rapids-bot bot merged commit 1226ef0 into rapidsai:branch-24.04 Feb 26, 2024
56 checks passed
@harrism harrism changed the title Add host_resource_ref and async_host_resource ref as aliases to cudf resource types. Add Complete set of resource ref aliases Feb 26, 2024
@harrism harrism changed the title Add Complete set of resource ref aliases Add complete set of resource ref aliases Feb 26, 2024
@harrism harrism linked an issue Feb 27, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Pertains to C++ code feature request New feature or request non-breaking Non-breaking change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEA] Add a full set of resource_ref aliases
4 participants