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.
thrust::min_element returns an iterator. You should not free it directly.
I dont think you need to free the memory returned by the thrust::min_element
Looking at the example code given at http://docs.thrust.googlecode.com/hg/group__extrema.html
#include <thrust/extrema.h>
...
int data[6] = {1, 0, 2, 2, 1, 3};
int *result = thrust::max_element(data, data + 6);
Seems that it returns an pointer to the array element and you need not delete it .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.