Esempio n. 1
0
typename Promotion<T1, T2>::type
dotp_ext(
  const_Vector<T1, Block1> op1,
  const_Vector<T2, Block2> op2)
{
  typedef typename Promotion<T1, T2>::type value_type;

  test_assert(op1.size() == op2.size());

  vsip::dda::Data<Block1, dda::in> raw1(op1.block());
  T1 const *p1   = raw1.ptr();
  stride_type str1 = raw1.stride(0);

  vsip::dda::Data<Block2, dda::in> raw2(op2.block());
  T2 const *p2   = raw2.ptr();
  stride_type str2 = raw2.stride(0);

  value_type sum = value_type();
  
  for (index_type i=0; i<op1.size(); ++i)
  {
    sum  += *p1 * *p2;
    p1 += str1;
    p2 += str2;
  }

  return sum;
}
Esempio n. 2
0
void
vector_add(
  const_Vector<T, Block1> res,
  const_Vector<T, Block2> op1,
  const_Vector<T, Block3> op2)
{
  vsip::dda::Data<Block1, vsip::dda::out> raw_res(res.block());
  float*   p_raw   = raw_res.ptr();
  stride_type str_raw = raw_res.stride(0);

  vsip::dda::Data<Block2, vsip::dda::in> raw1(op1.block());
  float const *p1   = raw1.ptr();
  stride_type str1 = raw1.stride(0);

  vsip::dda::Data<Block3, vsip::dda::in> raw2(op2.block());
  float const *p2   = raw2.ptr();
  stride_type str2 = raw2.stride(0);

  for (index_type i=0; i<res.size(); ++i)
  {
    *p_raw = *p1 + *p2;

    p1    += str1;
    p2    += str2;
    p_raw += str_raw;
  }
}
Esempio n. 3
0
  void operator()(
    char const *            str,
    const_Vector<T, Block1> vin,
    Vector      <T, Block2> vout)
  {
    typedef vsip::impl::Layout<1, row1_type,
      vsip::impl::Stride_unit, vsip::impl::Cmplx_split_fmt>
		LP;
    typedef vsip::impl::Ext_data<Block1, LP> layout1;
    typedef vsip::impl::Ext_data<Block2, LP> layout2;

    // PROFILE: Check sizes, check layout costs.

    // Important to check size.  If vectors are too large, our
    // buffers will overflow.
    test_assert(vin.size()  == size_);
    test_assert(vout.size() == size_);

    if (verbose_)
    {
      cout << "Test_FFT_split: " << str << endl;
      cout << "Block_layout<Block1>:\n";
      print_layout<typename vsip::impl::Block_layout<Block1>::layout_type>(cout);
      cout << endl;
      
      cout << "LP:\n";
      print_layout<LP>(cout);
      cout << endl;
      
      cout << "  access_type<LP>(vin.block()) = "
	   <<    access_type<LP>(vin.block()) << endl;
      cout << "  access_type<LP>(vout.block()) = "
	   <<    access_type<LP>(vout.block()) << endl;
      
      cout << "  mem_required<LP>(vin.block()) = "
	   <<    vsip::impl::mem_required<LP>(vin.block()) << endl;
      cout << "  mem_required<LP>(vout.block()) = "
	   <<    vsip::impl::mem_required<LP>(vout.block()) << endl;
    }

    test_assert(vsip::impl::mem_required<LP>(vin.block())  <= sizeof(T)*size_);
    test_assert(vsip::impl::mem_required<LP>(vout.block()) <= sizeof(T)*size_);

    layout1 rin (vin.block(),  vsip::impl::SYNC_IN,  
		 make_pair(buffer_ + 0, buffer_ + size_));
    layout2 rout(vout.block(), vsip::impl::SYNC_OUT,
		 make_pair(buffer_ + 2*size_, buffer_ + 3*size_));

    test_assert(rin.stride(0) == 1);
    test_assert(rin.size(0) == size_);

    test_assert(rout.stride(0) == 1);
    test_assert(rout.size(0) == size_);

    fft_unit_stride_split(rin.data().first,  rin.data().second,
			  rout.data().first, rout.data().second,
			  size_);
  }
Esempio n. 4
0
inline
const_Vector<typename Promotion<T1, T2>::type,
	     expr::Binary<expr::op::Mult, Block1, Block2, true> const>
t_mul(const_Vector<T1, Block1> v1, const_Vector<T2, Block2> v2)
{
  typedef typename Promotion<T1, T2>::type RT;
  typedef expr::Binary<expr::op::Mult, Block1, Block2, true> block_t;

  return const_Vector<RT, const block_t>(block_t(v1.block(), v2.block()));
}
Esempio n. 5
0
lazy_Vector<T, Unary<Scale, BlockType> const>
scale(const_Vector<T, BlockType> input, T value)
{
  Scale<BlockType> s(input.block(), value);
  Unary<Scale, BlockType> block(s);
  return lazy_Vector<T, Unary<Scale, BlockType> const>(block);
}
Esempio n. 6
0
const_Vector<T, Unary<Scale, BlockType> const>
scale(const_Vector<T, BlockType> input, T value)
{
  typedef Unary<Scale, BlockType> block_type;
  Scale<BlockType> s(input.block(), value);
  block_type block(s);
  return const_Vector<T, Unary<Scale, BlockType> const>(block);
}
Esempio n. 7
0
inline
const_Vector<T, expr::Unary<expr::op::Minus, Block, true> const>
t_neg(const_Vector<T, Block> v1)
{
  typedef expr::Unary<expr::op::Minus, Block, true> block_t;

  return const_Vector<T, const block_t>(block_t(v1.block()));
}
Esempio n. 8
0
void
generic_prod(
  const_Vector<T0, Block0> a,
  const_Matrix<T1, Block1> b,
  Vector<T2, Block2>       r)
{
  using namespace vsip_csl::dispatcher;

  assert(r.size() == b.size(1));
  assert(a.size() == b.size(0));

#ifdef VSIP_IMPL_REF_IMPL
  Evaluator<op::prod_vm, dispatcher::be::cvsip,
    void(Block2&, Block0 const&, Block1 const&)>::exec
    (r.block(), a.block(), b.block());
#else
  vsip_csl::dispatch<op::prod_vm, void,
    Block2&, Block0 const&, Block1 const&>
    (r.block(), a.block(), b.block());
#endif
}
Esempio n. 9
0
  void
  operator()(const_Vector<T, Block1> in, Vector<T, Block2> out)
  {
    typedef impl::Layout<1, row1_type, impl::Stride_unit, impl::Cmplx_inter_fmt> layout_t;

    impl::Ext_data<Block1, layout_t> in_ext (in.block(), impl::SYNC_IN);
    impl::Ext_data<Block2, layout_t> out_ext(out.block(), impl::SYNC_OUT);

    assert(in_ext.stride(0) == 1);
    assert(out_ext.stride(0) == 1);

    if (Dir == -1)
      IppFFT<T>::forward(fft_, in_ext.data(), out_ext.data(), buffer_);
    else
      IppFFT<T>::inverse(fft_, in_ext.data(), out_ext.data(), buffer_);
  }
Esempio n. 10
0
T
sum_ext(const_Vector<T, Block> view)
{
  vsip::dda::Data<Block, dda::in> raw(view.block());
  float const *data   = raw.ptr();
  stride_type stride = raw.stride(0);

  T sum = T();
  
  for (index_type i=0; i<view.size(); ++i)
  {
    sum  += *data;
    data += stride;
  }

  return sum;
}
Esempio n. 11
0
  void out_of_place(BE *backend,
		    const_Vector<InT, Block0>& in,
		    Vector<OutT, Block1>& out)
  {
    {
      dda::Data<Block0, dda::in> in_data(in.block());
      dda::Data<Block1, dda::out> out_data(out.block());

      backend->out_of_place(in_data.ptr(),  in_data.stride(0),
			    out_data.ptr(), out_data.stride(0),
			    select_fft_size<InT, OutT>(in_data.size(0), out_data.size(0)));
    }

    // Scale the data if not already done by the backend.
    if (!backend->supports_scale() && !almost_equal(scale_, scalar_type(1.)))
      out *= scale_;
  }
Esempio n. 12
0
  void by_reference(BE *backend,
		    const_Vector<InT, Block0>& in,
		    Vector<OutT, Block1>& out)
  {
    {
      Ext_data<Block0> in_ext (in.block(),  SYNC_IN);
      Ext_data<Block1> out_ext(out.block(), SYNC_OUT);

      backend->by_reference(
		in_ext.data(),  in_ext.stride(0),
		out_ext.data(), out_ext.stride(0),
		select_fft_size<InT, OutT>(in_ext.size(0), out_ext.size(0)));
    }

    // Scale the data if not already done by the backend.
    if (!backend->supports_scale() && !almost_equal(scale_, scalar_type(1.)))
      out *= scale_;
  }