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

Provide span abstractions for host and device memory #752

Open
jrhemstad opened this issue Nov 6, 2020 · 6 comments
Open

Provide span abstractions for host and device memory #752

jrhemstad opened this issue Nov 6, 2020 · 6 comments
Labels
thrust For all items related to Thrust.

Comments

@jrhemstad
Copy link
Collaborator

I would like Thrust to provide the equivalent of a std::span, i.e., a non-owning view of a contiguous sequence of objects.

Like host_vector and device_vector, I believe there should be separate host_span and device_span (and universal?) classes to indicate if the data is safe to touch from host or device.

A key requirement is that device_span must work to pass by value and is usable directly into CUDA kernels, e.g.,

__global__ void kernel(device_span<int> a, device_span<const int> b){
   if(tid < b.size()){
      a[tid] = b[tid] * 42;
   }
}
@hcedwar
Copy link

hcedwar commented Nov 17, 2020

Another strategy is to follow the cuda::atomic<T,scope> vs. cuda::std::atomic<T> pattern for extension; for example, cuda::span<T,Extent,Property> where Property denotes the memory space.

@griwes
Copy link
Collaborator

griwes commented Nov 17, 2020

@hcedwar yeah, I think we'll end up doing something like that for libcu++; however, the Thrust types are more involved and should follow the pattern of allowing access to device-only memory from the host by copying it when used with non-managed memory. These would serve a slightly different usage pattern than the libcu++ ones.

@brycelelbach
Copy link
Collaborator

brycelelbach commented Nov 17, 2020 via email

@alliepiper
Copy link
Collaborator

@hschwane submitted NVIDIA/thrust#1407, which implements a vector_reference that provides a non-owning view, similar to span. We'll wait for the proper span implementation to settle instead of merging a temporary workaround into main, but folks may be interested in that patch in the meantime.

@jrhemstad jrhemstad added the thrust For all items related to Thrust. label Feb 22, 2023
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 8, 2023
@jarmak-nv jarmak-nv transferred this issue from NVIDIA/thrust Nov 8, 2023
@fortminors
Copy link

Hello! Are there any news on implementing this?

@jrhemstad
Copy link
Collaborator Author

Hello! Are there any news on implementing this?

libcu++ now provides <cuda/std/span>: https://godbolt.org/z/113Mhfv9h

However, there is no device or host specific span type yet. That is something we're still talking about though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thrust For all items related to Thrust.
Projects
Status: Todo
Development

No branches or pull requests

6 participants