Does thrust copy data if its device_vector is created from iterator?

444 views Asked by At

Suppose that I have the following code

float *raw_data;
cudaMalloc(&raw_data, 100*sizeof(float));
thrust::device_vector <float> vec(raw_data, raw_data+100);

When executing the last line, does thrust copy the memory from raw_data to that of the device_vector, or does it just set the corresponding range of the vector?

Thanks.

1

There are 1 answers

0
Steephen On BEST ANSWER
thrust::device_vector <float> vec(raw_data, raw_data+100);

vec variable is filled with data copied from pointer variable raw_data of range 0 to 100.

It is using the following constructor to initialize the variable vec.

template<typename InputIterator >
__host__    device_vector (InputIterator first, InputIterator last)