コード例 #1
0
ファイル: mic_matrix_dia.cpp プロジェクト: dcm3c/agros2d
void MICAcceleratorMatrixDIA<ValueType>::CopyTo(BaseMatrix<ValueType> *dst) const {

  MICAcceleratorMatrixDIA<ValueType> *mic_cast_mat;
  HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == dst->get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<MICAcceleratorMatrixDIA<ValueType>*> (dst)) != NULL) {

    mic_cast_mat->set_backend(this->local_backend_);       

  if (this->get_nnz() == 0)
    mic_cast_mat->AllocateDIA(mic_cast_mat->get_nnz(), mic_cast_mat->get_nrow(), mic_cast_mat->get_ncol(), mic_cast_mat->get_ndiag());

    assert((this->get_nnz()  == dst->get_nnz())  &&
	   (this->get_nrow() == dst->get_nrow()) &&
	   (this->get_ncol() == dst->get_ncol()) );

    if (this->get_nnz() > 0) { 

      copy_mic_mic(this->mat_.val, mic_cast_mat->mat_.val, this->get_nnz());
      copy_mic_mic(this->mat_.offset, mic_cast_mat->mat_.offset, this->mat_.num_diag);

      /*
      // TODO

      for (int j=0; j<this->get_nnz(); ++j)
        mic_cast_mat->mat_.val[j] = this->mat_.val[j];
      
      for (int j=0; j<this->mat_.num_diag; ++j)
        mic_cast_mat->mat_.offset[j] = this->mat_.offset[j];

      FATAL_ERROR(__FILE__, __LINE__);
      */

    }
    
  } else {

    //MIC to CPU
    if ((host_cast_mat = dynamic_cast<HostMatrix<ValueType>*> (dst)) != NULL) {
      
      this->CopyToHost(host_cast_mat);

    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      dst->info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }

  }


}
コード例 #2
0
ファイル: mic_matrix_hyb.cpp プロジェクト: LeiDai/agros2d
void MICAcceleratorMatrixHYB<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const MICAcceleratorMatrixHYB<ValueType> *mic_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<const MICAcceleratorMatrixHYB<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateHYB(mic_cast_mat->get_ell_nnz(), mic_cast_mat->get_coo_nnz(), mic_cast_mat->get_ell_max_row(),
                      mic_cast_mat->get_nrow(), mic_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_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.ELL.val, this->mat_.ELL.val, this->get_ell_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.ELL.col, this->mat_.ELL.col, this->get_ell_nnz());

    }
    
    if (this->get_coo_nnz() > 0) {

      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.COO.row, this->mat_.COO.row, this->get_coo_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.COO.col, this->mat_.COO.col, this->get_coo_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   mic_cast_mat->mat_.COO.val, this->mat_.COO.val, this->get_coo_nnz());
      
    }
   
  } else {

    //CPU to MIC
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
コード例 #3
0
ファイル: mic_matrix_dia.cpp プロジェクト: dcm3c/agros2d
void MICAcceleratorMatrixDIA<ValueType>::CopyFrom(const BaseMatrix<ValueType> &src) {

  const MICAcceleratorMatrixDIA<ValueType> *mic_cast_mat;
  const HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == src.get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<const MICAcceleratorMatrixDIA<ValueType>*> (&src)) != NULL) {
    
  if (this->get_nnz() == 0)
    this->AllocateDIA(mic_cast_mat->get_nnz(), mic_cast_mat->get_nrow(), mic_cast_mat->get_ncol(), mic_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_mic_mic(mic_cast_mat->mat_.val, this->mat_.val, this->get_nnz());
      copy_mic_mic(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] = mic_cast_mat->mat_.val[j];
      
      for (int j=0; j<this->mat_.num_diag; ++j)
        this->mat_.offset[j] = mic_cast_mat->mat_.offset[j];
      */

    }

  } else {

    //CPU to MIC
    if ((host_cast_mat = dynamic_cast<const HostMatrix<ValueType>*> (&src)) != NULL) {
      
      this->CopyFromHost(*host_cast_mat);
      
    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      src.info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }
    
  }

}
コード例 #4
0
void MICAcceleratorMatrixCOO<ValueType>::CopyTo(BaseMatrix<ValueType> *dst) const {

  MICAcceleratorMatrixCOO<ValueType> *mic_cast_mat;
  HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == dst->get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<MICAcceleratorMatrixCOO<ValueType>*> (dst)) != NULL) {

    mic_cast_mat->set_backend(this->local_backend_);       

  if (this->get_nnz() == 0)
    mic_cast_mat->AllocateCOO(dst->get_nnz(), dst->get_nrow(), dst->get_ncol() );

    assert((this->get_nnz()  == dst->get_nnz())  &&
	   (this->get_nrow() == dst->get_nrow()) &&
	   (this->get_ncol() == dst->get_ncol()) );

    if (this->get_nnz() > 0) {

      copy_mic_mic(this->local_backend_.MIC_dev,
		   this->mat_.row, mic_cast_mat->mat_.row, this->get_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   this->mat_.col, mic_cast_mat->mat_.col, this->get_nnz());
      copy_mic_mic(this->local_backend_.MIC_dev,
		   this->mat_.val, mic_cast_mat->mat_.val, this->get_nnz());

    }
    
  } else {

    //MIC to CPU
    if ((host_cast_mat = dynamic_cast<HostMatrix<ValueType>*> (dst)) != NULL) {
      
      this->CopyToHost(host_cast_mat);

    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      dst->info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }

  }


}
コード例 #5
0
ファイル: mic_matrix_hyb.cpp プロジェクト: dcm3c/agros2d
void MICAcceleratorMatrixHYB<ValueType>::CopyTo(BaseMatrix<ValueType> *dst) const {

  MICAcceleratorMatrixHYB<ValueType> *mic_cast_mat;
  HostMatrix<ValueType> *host_cast_mat;

  // copy only in the same format
  assert(this->get_mat_format() == dst->get_mat_format());

  // MIC to MIC copy
  if ((mic_cast_mat = dynamic_cast<MICAcceleratorMatrixHYB<ValueType>*> (dst)) != NULL) {

    mic_cast_mat->set_backend(this->local_backend_);       

  if (this->get_nnz() == 0)
    mic_cast_mat->AllocateHYB(this->get_ell_nnz(), this->get_coo_nnz(), this->get_ell_max_row(),
                      this->get_nrow(), this->get_ncol());

    assert((this->get_nnz()  == dst->get_nnz())  &&
	   (this->get_nrow() == dst->get_nrow()) &&
	   (this->get_ncol() == dst->get_ncol()) );

    // TODO

    if (this->get_ell_nnz() > 0) {

      copy_mic_mic(this->mat_.ELL.val, mic_cast_mat->mat_.ELL.val, this->get_ell_nnz());
      copy_mic_mic(this->mat_.ELL.col, mic_cast_mat->mat_.ELL.col, this->get_ell_nnz());


      /*
      // ELL

      for (int i=0; i<this->get_ell_nnz(); ++i)
        mic_cast_mat->mat_.ELL.col[i] = this->mat_.ELL.col[i];

      for (int i=0; i<this->get_ell_nnz(); ++i)
        mic_cast_mat->mat_.ELL.val[i] = this->mat_.ELL.val[i];
      */

    }
    
    if (this->get_coo_nnz() > 0) {

      copy_mic_mic(this->mat_.COO.row, mic_cast_mat->mat_.COO.row, this->get_coo_nnz());
      copy_mic_mic(this->mat_.COO.col, mic_cast_mat->mat_.COO.col, this->get_coo_nnz());
      copy_mic_mic(this->mat_.COO.val, mic_cast_mat->mat_.COO.val, this->get_coo_nnz());

      /*
      // COO
      for (int i=0; i<this->get_coo_nnz(); ++i)
        mic_cast_mat->mat_.COO.row[i] = this->mat_.COO.row[i];

      for (int i=0; i<this->get_coo_nnz(); ++i)
        mic_cast_mat->mat_.COO.col[i] = this->mat_.COO.col[i];

      for (int i=0; i<this->get_coo_nnz(); ++i)
        mic_cast_mat->mat_.COO.val[i] = this->mat_.COO.val[i];
      */

    }

  } else {

    //MIC to CPU
    if ((host_cast_mat = dynamic_cast<HostMatrix<ValueType>*> (dst)) != NULL) {
      
      this->CopyToHost(host_cast_mat);

    } else {
      
      LOG_INFO("Error unsupported MIC matrix type");
      this->info();
      dst->info();
      FATAL_ERROR(__FILE__, __LINE__);
      
    }

  }


}