* \brief Performs a synchronous copy from the * device memory of this matrix into the * specified host memory * This copy is synchronized on the default stream, * hence synchronous to every computation but slow. * \param data the data in which the matrix is stored */
| 845 | * \param data the data in which the matrix is stored |
| 846 | */ |
| 847 | void copyToHost(_Scalar* data) const |
| 848 | { |
| 849 | //slower, conservative: full synchronization |
| 850 | //CUMAT_SAFE_CALL(cudaStreamSynchronize(Context::current().stream())); |
| 851 | //CUMAT_SAFE_CALL(cudaMemcpy(data, data_.data(), sizeof(_Scalar)*size(), cudaMemcpyDeviceToHost)); |
| 852 | |
| 853 | //faster: only synchronize this stream |
| 854 | CUMAT_SAFE_CALL(cudaMemcpyAsync(data, data_.data(), sizeof(_Scalar)*size(), cudaMemcpyDeviceToHost, Context::current().stream())); |
| 855 | CUMAT_SAFE_CALL(cudaStreamSynchronize(Context::current().stream())); |
| 856 | |
| 857 | CUMAT_PROFILING_INC(MemcpyDeviceToHost); |
| 858 | } |
| 859 | |
| 860 | // EIGEN INTEROP |
| 861 | #if CUMAT_EIGEN_SUPPORT==1 |