Can I change value of struct's field inside thrust::device_vector?

I have a thrust::device_vector of structs and I find a specific value in it using thrust::find_if. Can I modify only one field of the found struct or do I have to copy the struct back and forth? I don’t want to use unified memory, because the device will access this vector a lot of times, while the host will rarely read and modify it.

You could use a kernel which updates the member variable.

This seems like too much overhead. Isn’t using cudaMemcpy better?

Can you group several updates? Or at least with some CAS (compare-and-swap) idiom?

1 Like

That’s what I already do, but sometimes I need to perform single write operations.

I solved this using pointers and cudaMemcpy, however I plan on using some thrust functions for bulk operations.