コード例 #1
0
ファイル: vector_proxy.hpp プロジェクト: GnsP/viennacl-dev
  void copy(vector_slice<vector<SCALARTYPE> > const & gpu_vector_slice,
            VectorType & cpu_vector)
  {
    assert(gpu_vector_slice.end() - gpu_vector_slice.begin() >= 0 && bool("Range must have nonnegative length!"));

    if (gpu_vector_slice.end() - gpu_vector_slice.begin() > 0)
    {
      std::vector<SCALARTYPE> temp_buffer(gpu_vector_slice.stride() * gpu_vector_slice.size());
      viennacl::backend::memory_read(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0]));

      for (vcl_size_t i=0; i<cpu_vector.size(); ++i)
        cpu_vector[i] = temp_buffer[i * gpu_vector_slice.stride()];
    }
  }
コード例 #2
0
 void operator() (const state_type rhot, double t) const
 {
     // Find dimension of density matric from vector.
     int side = int(sqrt(float(rhot.size())));
     
     // Grab elements corresponding to diagonals in density matrix.
     const vector_slice<const state_type> diags(rhot, slice(0,side+1,side));
     
     // Print diagonal elements.
     m_out << t;
     for(size_t n = 0; n < diags.size(); n++) m_out << "\t" << diags[n].real();
     m_out << "\t" << sum(diags).real();
     m_out << endl;
 }
コード例 #3
0
ファイル: vector_proxy.hpp プロジェクト: GnsP/viennacl-dev
  void copy(const VectorType & cpu_vector,
            vector_slice<vector<SCALARTYPE> > & gpu_vector_slice )
  {
    if (cpu_vector.size() > 0)
    {
      std::vector<SCALARTYPE> temp_buffer(gpu_vector_slice.stride() * gpu_vector_slice.size());

      viennacl::backend::memory_read(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0]));

      for (vcl_size_t i=0; i<cpu_vector.size(); ++i)
        temp_buffer[i * gpu_vector_slice.stride()] = cpu_vector[i];

      viennacl::backend::memory_write(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0]));
    }
  }