consider the following code, when p is a pointer allocated GPU-side.
thrust::device_ptr<float> pWrapper(p); thrust::device_ptr<float> fDevPos = thrust::min_element(pWrapper, pWrapper + MAXX * MAXY, thrust::minimum<float>()); fRes = *fDevPos; *fDicVal = fRes; after applying the same thing on cpu side.
float *hVec = new float[MAXX * MAXY]; cudaMemcpy(hVec, p, MAXX*MAXY*sizeof(float), cudaMemcpyDeviceToHost); float min = 999; int index = -1; for(int i = 0 ; i < MAXX* MAXY; i++) { if(min > hVec[i]) { min = hVec[i]; index = i; } } printf("index :%d a wrapper : %f, as vectorDevice : %f\n",index, fRes, min); delete hVec; i get that min != fRes. what am i doing wrong here?