How to initilize thrust device vector from another device vector declared by cuda #1038
-
I have a device vector d_b[100], I want to creat a thrust vector with d_b[80:100]. How to resolve this mission. |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 5 replies
-
I am not fully sure what you mean with However, you could always use one of the algorithms such like https://github.com/NVIDIA/thrust/blob/main/thrust/fill.h |
Beta Was this translation helpful? Give feedback.
-
I mean fill thrust vector with d_b from the 80'th to the 100'th values. |
Beta Was this translation helpful? Give feedback.
-
In that case you would need to use |
Beta Was this translation helpful? Give feedback.
-
If possibe, I would rather just use the right constructor to avoid unnecessary initialisation, i.e. thrust::device_vector<float> d_c(d_b.cbegin() + 80, d_b.cend());
// or
thrust::device_vector<float> d_c(d_b.cbegin() + 80, d_b.cbegin() + 100); |
Beta Was this translation helpful? Give feedback.
-
this can work for u:
int main() |
Beta Was this translation helpful? Give feedback.
If possibe, I would rather just use the right constructor to avoid unnecessary initialisation, i.e.