Ejemplo n.º 1
0
      void level_scheduling_substitute(vector<ScalarType> & vec,
                                  viennacl::backend::mem_handle const & row_index_array,
                                  viennacl::backend::mem_handle const & row_buffer,
                                  viennacl::backend::mem_handle const & col_buffer,
                                  viennacl::backend::mem_handle const & element_buffer,
                                  std::size_t num_rows
                                  )
      {
        assert( viennacl::traits::handle(vec).get_active_handle_id() == row_index_array.get_active_handle_id() && bool("Incompatible memory domains"));
        assert( viennacl::traits::handle(vec).get_active_handle_id() ==      row_buffer.get_active_handle_id() && bool("Incompatible memory domains"));
        assert( viennacl::traits::handle(vec).get_active_handle_id() ==      col_buffer.get_active_handle_id() && bool("Incompatible memory domains"));
        assert( viennacl::traits::handle(vec).get_active_handle_id() ==  element_buffer.get_active_handle_id() && bool("Incompatible memory domains"));
        
        switch (viennacl::traits::handle(vec).get_active_handle_id())
        {
          case viennacl::MAIN_MEMORY:
            viennacl::linalg::host_based::detail::level_scheduling_substitute(vec, row_index_array, row_buffer, col_buffer, element_buffer, num_rows);
            break;
#ifdef VIENNACL_WITH_OPENCL
          case viennacl::OPENCL_MEMORY:
            viennacl::linalg::opencl::detail::level_scheduling_substitute(vec, row_index_array, row_buffer, col_buffer, element_buffer, num_rows);
            break;
#endif
#ifdef VIENNACL_WITH_CUDA
          case viennacl::CUDA_MEMORY:
            viennacl::linalg::cuda::detail::level_scheduling_substitute(vec, row_index_array, row_buffer, col_buffer, element_buffer, num_rows);
            break;
#endif
          default:
            throw "not implemented";
        }
      }
Ejemplo n.º 2
0
/** @brief Returns an ID for the currently active memory domain of an object */
inline viennacl::context context(viennacl::backend::mem_handle const & h)
{
#ifdef VIENNACL_WITH_OPENCL
  if (h.get_active_handle_id() == OPENCL_MEMORY)
    return viennacl::context(h.opencl_handle().context());
#endif

  return viennacl::context(h.get_active_handle_id());
}