[vsipl++] [patch] CML backend fir FIR filters

Jules Bergmann jules at codesourcery.com
Wed Jun 11 12:45:14 UTC 2008


Don McCoy wrote:
> This patch adds support for real, single-precision, floating point FIR
> filters using CML. 
> 
> There is some overlap with another patch of mine (06/07: [patch] Fix for
> Fir destructor not getting called) as well as one of Stefan's (06/09:
> patch: Fix various FIR backends to support negative strides), but it's
> minimal as most of my changes are in the file opt/cbe/cml/fir.hpp.  I
> will merge before committing, once those patches are in.

Don,

This looks good, along with the reference counting and stride fixes.

Please apply.

				thanks,
				-- Jules

> +  Fir_impl(Fir_impl const &fir)
> +    : base(fir),
> +      fir_obj_ptr_(NULL),
> +      filter_state_(fir.filter_state_)
> +  {
> +    fir_create(
> +      &fir_obj_ptr_,
> +      fir.fir_obj_ptr_->K,

CML objects are intended to be opaque.

Let's keep this for now, but create an issue (#175) to add a new CML
attribute function that returns a pointer to the kernel coefficients.

	float*
	cml_fir_attr_kernel_f(
	   cml_fir_f* obj);


> +      1, // kernel stride
> +      this->decimation(),
> +      this->filter_state_,
> +      this->kernel_size(),
> +      this->input_size());
> +  }



> +template <typename T, symmetry_type S, obj_state C> 
> +struct Evaluator<Fir_tag, Cml_tag,
> +                 Ref_counted_ptr<Fir_backend<T, S, C> >
> +                 (aligned_array<T>, 
> +                  length_type, length_type, length_type,
> +                  unsigned, alg_hint_type)>
> +{
> +  static bool const ct_valid = // false;

Some left-over debug code         ^^^^^^^^^

> +    Type_equal<T, float>::value;
> +
> +  typedef Ref_counted_ptr<Fir_backend<T, S, C> > return_type;
> +  // rt_valid takes the first argument by reference to avoid taking
> +  // ownership.
> +  static bool rt_valid(aligned_array<T> const &, length_type k,
> +                       length_type i, length_type d,
> +                       unsigned, alg_hint_type)
> +  {
> +    length_type o = k * (1 + (S != nonsym)) - (S == sym_even_len_odd) - 1;
> +    assert(i > 0); // input size
> +    assert(d > 0); // decimation
> +    assert(o + 1 > d); // M >= decimation
> +    assert(i >= o);    // input_size >= M 
> +
> +    length_type output_size = (i + d - 1) / d;
> +    return i == output_size * d;

What is rt_valid checking exactly?

I think I see.  Does CML FIR not work on fixed size inputs if i % d !=
0?  Argh!  That's a mistake on my part with the API design.  I wonder
how often such cases happen in practice.

Regardless, can you add a comment to that effect?

"CML FIR objects have fixed output size, whereas VSIPL++ FIR objects
have fixed input size.  If input size is not a multiple of the
decimation, output size will vary from frame to frame."


> +  }

-- 
Jules Bergmann
CodeSourcery
jules at codesourcery.com
(650) 331-3385 x705



More information about the vsipl++ mailing list