bheisler / RustaCUDA

Rusty wrapper for the CUDA Driver API
Apache License 2.0
758 stars 60 forks source link

Manually implement traits for pointer types #39

Closed mypmc closed 4 years ago

mypmc commented 5 years ago

Deriving generates code like

impl<T: Trait> Trait for DevicePointer<T>

But pointer primitives in std do not constraint like that.

bheisler commented 5 years ago

Hey, thanks for the pull request! Also, thanks for your patience.

For the most part this looks good. I do have one concern, though - are you sure the impls for DevicePointer (especially things like Hash and PartialOrd) won't dereference the inner raw pointer? It isn't a valid pointer in the sense that it doesn't refer to a value in the CPU's memory space, so any attempt to dereference that pointer will cause a segfault. I'd like to have some basic unit tests, just to execute this code just to be sure of that. Dereferencing a UnifiedPointer is fine, though.