void prod_impl(const viennacl::matrix_expression< const matrix_base<NumericT>, const matrix_base<NumericT>, op_trans> & A,
                   const viennacl::matrix_expression< const matrix_base<NumericT>, const matrix_base<NumericT>, op_trans> & B,
                   matrix_base<NumericT> & C,
                   ScalarType alpha,
                   ScalarType beta)
    {
      assert(viennacl::traits::size2(A.lhs()) == viennacl::traits::size1(C)       && bool("Size check failed at C = prod(trans(A), trans(B)): size2(A) != size1(C)"));
      assert(viennacl::traits::size1(A.lhs()) == viennacl::traits::size2(B.lhs()) && bool("Size check failed at C = prod(trans(A), trans(B)): size1(A) != size2(B)"));
      assert(viennacl::traits::size1(B.lhs()) == viennacl::traits::size2(C)       && bool("Size check failed at C = prod(trans(A), trans(B)): size1(B) != size2(C)"));

      switch (viennacl::traits::handle(A.lhs()).get_active_handle_id())
      {
        case viennacl::MAIN_MEMORY:
          viennacl::linalg::host_based::prod_impl(A.lhs(), true, B.lhs(), true, C, alpha, beta);
          break;
#ifdef VIENNACL_WITH_OPENCL
        case viennacl::OPENCL_MEMORY:
          viennacl::linalg::opencl::prod_impl(A.lhs(), true, B.lhs(), true, C, alpha, beta);
          break;
#endif
#ifdef VIENNACL_WITH_CUDA
        case viennacl::CUDA_MEMORY:
          viennacl::linalg::cuda::prod_impl(A.lhs(), true, B.lhs(), true, C, alpha, beta);
          break;
#endif
        case viennacl::MEMORY_NOT_INITIALIZED:
          throw memory_exception("not initialised!");
        default:
          throw memory_exception("not implemented");
      }
    }
Exemple #2
0
 static size_t size(const viennacl::matrix_expression< const viennacl::matrix<ScalarType, F, Amat>,
                                                       const viennacl::matrix<ScalarType, F, Amat>,
                                                       op_trans> & lhs,
                    const viennacl::vector<ScalarType, A> & rhs) { return lhs.lhs().size2(); }
 static vcl_size_t size2(viennacl::matrix_expression<const LHS, const RHS, OP> const & lhs,
                         ScalarType const & /*rhs*/) { return MATRIX_SIZE_DEDUCER<const LHS, const RHS, OP>::size2(lhs.lhs(), lhs.rhs()); }
 static vcl_size_t size2(viennacl::matrix_base<ScalarType> const & /*lhs*/,
                         viennacl::matrix_expression<T2,
                         T2,
                         op_trans> const & rhs) { return rhs.lhs().size1(); }
 static vcl_size_t size1(viennacl::matrix_expression<T1,
                         T1,
                         op_trans> const & lhs,
                         viennacl::matrix_base<ScalarType> const & /*rhs*/) { return lhs.lhs().size2(); }
Exemple #6
0
viennacl::memory_types active_handle_id(viennacl::matrix_expression<LHS, RHS, OP> const & obj)
{
  return active_handle_id(obj.lhs());
}
 static vcl_size_t size2(viennacl::matrix_expression<const LHS1, const RHS1, OP1> const & lhs,
                         viennacl::matrix_expression<const LHS2, const RHS2, OP2> const & /*rhs*/) { return MATRIX_SIZE_DEDUCER<const LHS1, const RHS1, OP1>::size2(lhs.lhs(), lhs.rhs()); }
 static vcl_size_t size1(ScalarType const & /*lhs*/,
                         viennacl::matrix_expression<const LHS, const RHS, OP> const & rhs) { return MATRIX_SIZE_DEDUCER<const LHS, const RHS, OP>::size1(rhs.lhs(), rhs.rhs()); }
 static size_t size2(viennacl::matrix<ScalarType, F1, A1> const & lhs,
                     viennacl::matrix_expression<const viennacl::matrix<ScalarType, F2, A2>,
                                                 const viennacl::matrix<ScalarType, F2, A2>,
                                                 op_trans> const & rhs) { return rhs.lhs().size1(); }