[vsipl++] [patch] scalar-complex multiply-add user-defined kernel

Jules Bergmann jules at codesourcery.com
Tue Sep 2 15:22:58 UTC 2008


Don McCoy wrote:
> This patch extends the Cell/BE user-defined kernel framework to allow
> passing of views with different data types down to the kernels.  The
> scalar-complex multiply add (where A in A * B + C is a scalar and the
> rest are complex) is used as a test case.
> 
> Ok to commit?

Don,

This looks good, please commit, modulo comments below.

			-- Jules

> +#ifndef DEBUG
>  #define DEBUG 0
> +#endif

If this define collides with one in another file, we should:
  - undefine DEBUG at the end of the other file, to prevent
    the collision,
  - disambiguate DEBUG
     DEBUG_ALF_BASE
     DEBUG_FOO


>  // Helper functor, converts void buffer pointer to appropriate type.
> +//
> +// The 'off' parameter is a byte offset, while 'size' is in elements.
> +// This is necessary because the first is calculated from the amount
> +// data previously allocated, which may or may not have the same data
> +// type.  Conversely, the second parameter refers to the amount of
> +// data for the current segment and it is therefore easier to use
> +// pointer arithmetic since the type is known.

Thanks for documenting this, it has the potential to be confusing.


> +
> +// Converts a size in number of elements (or index value) into an offset 
> +// based on the type referenced by the pointer.
> +
>  template <typename PtrT>
> +struct Byte_offset
> +{
> +  static size_t index(size_t size) { return (size_t)((PtrT)0 + size); }

The following would be more clear:

    template <typename T>
    struct Byte_offset;

    template <typename T>
    struct Byte_offset<T*>
    {
      static size_t index(size_t size) { return sizeof(T)*size; }
    };


> +};
> +
> +template <typename T>
> +struct Byte_offset<std::pair<T*, T*> >
> +{
> +  static size_t index(size_t size) { return (size_t)((T*)0 + size) * 2; }

Likewise,

	return 2*sizeof(T)*size;

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



More information about the vsipl++ mailing list