Rust-GPU/rust-cuda

`DeviceCopy` should not require `Copy`

juntyr opened this issue · 0 comments

juntyr commented

I am currently exploring moving from rustacuda to cust. cust now requires DeviceCopy: Copy, which is an insurmountable blocker for me:

  1. Copy is not strong enough by itself. For instance, *const T and &T are Copy but must not be DeviceCopy in general (unless they point to unified memory).

  2. Copy is too strict. Passing data to the GPU can be modelled as a borrow instead of a copy. The bitwise copy is just an implementation detail. A well-designed API on the host can then ensure that the borrow (or even move or copy semantics) on the host and on the GPU are maintained. However, this requires some unsafe escape hatch for copying !Copy types to the GPU.

Since cust does not implement any advanced rules for which types can and should be copied, it should - in my opinion - also not impose an overly strict requirement on DeviceCopy. Otherwise, it severely limits the safe APIs one can develop on top of cust.