I've been looking at Thrust and I stumbled upon a question that almost (but not quite) answered mine: Finding the maximum element value AND its position using CUDA Thrust
The example posted in there in the answer works fine, but how to do the same thing with raw pointers? Let us assume this code which I believe to be correct (ignore the kernel configuration, it's for simplicity):
float* d_A;
const unsigned int noElems = 10;
cudaMalloc(&d_A, noElems * sizeof(float));
initDeviceVector<<<1, noElems>>>(d_A);
thrust::device_ptr<float> d_ptr = thrust::device_pointer_cast(d_A);
thrust::device_vector<float>::iterator iter =
thrust::max_element(d_ptr, d_ptr + noElems);
I can't quite figure out how to extract the position using iter and raw pointers.
Thank you for your time.