I have the following code snippet
uint64_t myvec[] = {1,2,3,4,5}; int main(void) { uint64_t* dev; cudaMalloc(&dev, 5*sizeof(uint64_t)); cudaMemcpy(dev,myvec,sizeof(uint64_t)*5,cudaMemcpyHostToDevice); uint64_t* min_iter = thrust::min_element(thrust::device, dev, dev+5); return 0; } This code crashes with a segfault because of min_element on device.
But this code seems to be working if i perform it on host
uint64_t* min_iter = thrust::min_element(thrust::host, myvec, myvec+5); I don't know what's wrong. I am using cuda 7.5. Is this a bug?
uint64_t* min_iter = thrust::min_element(thrust::device, thrust::device_pointer_cast(dev), thrust::device_pointer_cast(dev+5)).get();