I am using cusp for sparse matrix multiplication. From the resultant matrix i need the max value without copying the matrix from device memory to host memory. I am planning to wrap the resultant matrix in thrust device pointer and then use the function thrust::max_element to get max element. The matrices are in coo format. If C is resultant sparse matrix then
C.row_indices[] : contains row number
C.column_indices[]: contains column number
C.values[]: contain actual value
So basically i need highest value from C.values array.
Using
thrust::device_ptr<int> dev_ptr = C.values;
is giving error
error: no instance of constructor "thrust::device_ptr<T>::device_ptr [with T=int]" matches the argument list
argument types are: (cusp::array1d<float, cusp::host_memory>)
How can i wrap my resultant matrix in order to use it in thrust library ?
If my device matrix definition is like this:
cusp::coo_matrix<int, double, cusp::device_memory> A_d = A;
Then try this:
thrust::device_ptr<double> dev_ptr = &(A_d.values[0]);
thrust::device_ptr<double> max_ptr = thrust::max_element(dev_ptr, dev_ptr + 6);