void MICAcceleratorMatrixHYB<ValueType>::CopyFromHost(const HostMatrix<ValueType> &src) { const HostMatrixHYB<ValueType> *cast_mat; // copy only in the same format assert(this->get_mat_format() == src.get_mat_format()); // CPU to MIC copy if ((cast_mat = dynamic_cast<const HostMatrixHYB<ValueType>*> (&src)) != NULL) { if (this->get_nnz() == 0) this->AllocateHYB(cast_mat->get_ell_nnz(), cast_mat->get_coo_nnz(), cast_mat->get_ell_max_row(), cast_mat->get_nrow(), cast_mat->get_ncol()); assert((this->get_nnz() == src.get_nnz()) && (this->get_nrow() == src.get_nrow()) && (this->get_ncol() == src.get_ncol()) ); if (this->get_ell_nnz() > 0) { copy_to_mic(this->local_backend_.MIC_dev, cast_mat->mat_.ELL.val, this->mat_.ELL.val, this->get_ell_nnz()); copy_to_mic(this->local_backend_.MIC_dev, cast_mat->mat_.ELL.col, this->mat_.ELL.col, this->get_ell_nnz()); } if (this->get_coo_nnz() > 0) { copy_to_mic(this->local_backend_.MIC_dev, cast_mat->mat_.COO.row, this->mat_.COO.row, this->get_coo_nnz()); copy_to_mic(this->local_backend_.MIC_dev, cast_mat->mat_.COO.col, this->mat_.COO.col, this->get_coo_nnz()); copy_to_mic(this->local_backend_.MIC_dev, cast_mat->mat_.COO.val, this->mat_.COO.val, this->get_coo_nnz()); } } else { LOG_INFO("Error unsupported MIC matrix type"); this->info(); src.info(); FATAL_ERROR(__FILE__, __LINE__); } }
void MICAcceleratorMatrixDIA<ValueType>::CopyFromHost(const HostMatrix<ValueType> &src) { const HostMatrixDIA<ValueType> *cast_mat; // copy only in the same format assert(this->get_mat_format() == src.get_mat_format()); // CPU to MIC copy if ((cast_mat = dynamic_cast<const HostMatrixDIA<ValueType>*> (&src)) != NULL) { if (this->get_nnz() == 0) this->AllocateDIA(cast_mat->get_nnz(), cast_mat->get_nrow(), cast_mat->get_ncol(), cast_mat->get_ndiag()); assert((this->get_nnz() == src.get_nnz()) && (this->get_nrow() == src.get_nrow()) && (this->get_ncol() == src.get_ncol()) ); if (this->get_nnz() > 0) { copy_to_mic(cast_mat->mat_.val, this->mat_.val, this->get_nnz()); copy_to_mic(cast_mat->mat_.offset, this->mat_.offset, this->mat_.num_diag); /* // TODO for (int j=0; j<this->get_nnz(); ++j) this->mat_.val[j] = cast_mat->mat_.val[j]; for (int j=0; j<this->mat_.num_diag; ++j) this->mat_.offset[j] = cast_mat->mat_.offset[j]; */ } } else { LOG_INFO("Error unsupported MIC matrix type"); this->info(); src.info(); FATAL_ERROR(__FILE__, __LINE__); } }