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

make_buffer and execution space properties on buffer types #4098

Open
brycelelbach opened this issue Mar 11, 2025 · 1 comment
Open

make_buffer and execution space properties on buffer types #4098

brycelelbach opened this issue Mar 11, 2025 · 1 comment

Comments

@brycelelbach
Copy link
Contributor

Why is execution space a required property on a buffer type? We should be able to infer this from the memory resource provided. I fear we've created a design that is too complicated.

I want to be able to do this:

auto ax = cuda::buffer<float>(cuda::device_memory_resource, 100, cuda::uninit);

auto y = cuda::async_buffer<float>(my_stream, cuda::device_memory_resource, 100, cuda::uninit);

(I know this can't work today because we don't have partial CTAD, but this is aspirational)

This is a fundamental interface everyone will have to use frequently. It should not be more complicated than this. I shouldn't need to create an environment or deal with properties in the simple case, which is "I want a typed buffer of device memory that is not initialized".

Given we have no partial CTAD, we should create make_* helper functions for this.

auto ax = cuda::make_buffer<float>(cuda::device_memory_resource, 100, cuda::uninit);

auto y = cuda::make_async_buffer<float>(my_stream, cuda::device_memory_resource, 100, cuda::uninit);
@miscco
Copy link
Contributor

miscco commented Mar 12, 2025

The root of the issue is that properties are an open set.

The way we designed them is that they are not part of the type signature. That means that the compiler does not know which properties to choose, because it would need to query all possible properties.

Also we do want to use any_resource and any_resource_ref as the vocabulary types, which are type erased wrappers around memory resources. However, any subset of the properties is also valid, so the compiler cannot determine the "right" one.

Finally, a lot of the designs go towards more explicit APIs that are less error prone, which often requires the user to properly state their intend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants