Search code examples
c++pointerscudathrust

Do I need to free device_ptr returned by thrust?


I have a function to get the minimum value of an array and it's executed within a loop.

thrust::device_ptr<float> min_ptr = thrust::min_element(populationFitness, populationFitness + POPULATION);

Do I have to free the returned device_ptr? I tried with thrust::device_free(min_ptr) but an exception is thrown.


Solution

  • thrust::min_element returns an iterator. You should not free it directly.