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 DeviceValue/HostValue #34
Conversation
using DevicePointers = DeviceValue<span<byte>>; | ||
using HostPointers = HostValue<span<byte>>; | ||
using constDevicePointers = DeviceValue<span<const byte>>; | ||
using constHostPointers = HostValue<span<const byte>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider using just
using DevicePointers = DeviceValue<span<byte>>; | |
using HostPointers = HostValue<span<byte>>; | |
using constDevicePointers = DeviceValue<span<const byte>>; | |
using constHostPointers = HostValue<span<const byte>>; | |
using HostPointers = span<byte>; | |
using constHostPointers = span<const byte>; |
unless the symmetry is more helpful.
template<class T> | ||
struct DeviceValue | ||
{ | ||
T value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to avoid the double curly braces with
T value; | |
DeviceValue(T &&input) : value(std::move(input)) {}; | |
T value; |
or
T value; | |
template <typename... ArgsTypes> | |
DeviceValue(ArgsTypes... params) : value(params...) {}; | |
T value; |
The later will make the compiler error message a bit more indrect when getting the parameter list wrong.
The only places that should be getting the pointed-to data are:
Another challenge maybe
because (as it is right now)
to read
but that would require a slightly different type, i.e. a version of ParticleParamsPointers that has a We could possibly achieve this will something like
and then we could have:
Underlying some of this rambling is that "DeviceValue/Pointer" is essentially a concept that is solely used in host code to manipulate memory allocate on device. |
Actually I am realizing than in the above I seem to also be thinking that rather that "host" the alternative to "device" is "local" (i.e. host in host code, device in device code) and local can just be straight pointers but at the interface (which is essentially only host code calling device code), there is a need for a "pointer in the other guy" concept (i.e. pointer value that can only be used in the interface routine (cudaFree, cudaCopy and kernel launch) |
And by kernel launch, we can either have:
or
where the former is likely the better one. |
@pcanal I let this drop in August because I got caught up in other stuff. I think you're right that the correct way to look at this is "device vs local" rather than "device vs host" -- I think I got buried in my original implementation here. I'm going to close this branch soon because I'm trying to clean up the |
@pcanal @tmdelellis I'm making a new branch (after merging physics-base) for the DeviceValue code because I think it'll need some iteration to get right. Right now with a simple struct, I don't think it's adding much value and it's adding a LOT of boilerplate code that clutters up the usage. Basically I have to add
{}
around everything to implicitly convert to aXValue
, and add.value
all over the place to get the pointed-to data. Because the struct allows implict construction and direct access of the data, I'm not sure it's doing much in that sense -- it's not likethrust::device_ptr
which forces you to calldevice_ptr_cast
wherever you use it.Please take a quick look at some of the changes and you'll hopefully see what I mean about this first attempt being clumsy -- any suggestions on improvements?