I look on the profiling results and see that thrust::min_element() calls cudaMalloc(), hence uses the additional memory. I do not need the array data after the reduction, so would prefer to find the minimal element in-place. Is it possible?
2
votes
1 Answers
1
votes
Thrust's reductions only use O(1) temporary storage (actually O(#processors)), but if you insist on managing the allocations yourself, you can implement your own custom allocation scheme.
thrust::min_elementis not really a reduction, but a search. This is a good question. It could be generalized to ask if it's possible to make faster search algorithms on the GPU if the algorithms are allowed to destroy the input data. - Roger Dahl