[vsipl++] [rfc] preview patch for RBO
Stefan Seefeld
stefan at codesourcery.com
Wed Feb 7 14:23:37 UTC 2007
Jules Bergmann wrote:
> This preview patch adds support for "return block optimization", for
> example to allow by-value FFTs to be lazily evaluated.
Jules,
this patch looks great !
> diff -rN -uN old-rbo-merge/src/vsip/core/fft.hpp new-rbo-merge/src/vsip/core/fft.hpp
> --- old-rbo-merge/src/vsip/core/fft.hpp 2007-02-01 10:03:50.000000000 -0500
> +++ new-rbo-merge/src/vsip/core/fft.hpp 2007-02-01 10:03:54.000000000 -0500
> @@ -25,6 +25,7 @@
> # include <vsip/opt/fft/workspace.hpp>
> #endif
> #include <vsip/core/metaprogramming.hpp>
> +#include <vsip/opt/expr/return_block.hpp>
> #include <vsip/core/profile.hpp>
>
> #ifndef VSIP_IMPL_REF_IMPL
> @@ -193,16 +194,21 @@
> {}
>
> template <typename ViewT>
> - typename fft::result<O, typename ViewT::block_type>::view_type
> + typename fft::Result_rbo<D, I, O, ViewT, workspace, axis, exponent>
> + ::view_type
> operator()(ViewT in) VSIP_THROW((std::bad_alloc))
> {
> typename base::Scope scope(*this);
> assert(extent(in) == extent(this->input_size()));
> - typedef fft::result<O, typename ViewT::block_type> traits;
> - typename traits::view_type out(traits::create(this->output_size(),
> - in.block().map()));
> - workspace_.by_reference(this->backend_.get(), in, out);
> - return out;
> + typedef fft::Result_rbo<D, I, O, ViewT, workspace, axis, exponent>
> + traits;
> + typedef typename traits::functor_type functor_type;
> + typedef typename traits::block_type block_type;
> + typedef typename traits::view_type view_type;
> +
> + functor_type rf(in, *(this->backend_.get()), workspace_);
> + block_type block(rf);
> + return view_type(block);
> }
> private:
> std::auto_ptr<fft::backend<D, I, O, axis, exponent> > backend_;
I think it would be good to also expose the return type in a way that
allows expressions to be written out over multiple lines (as we discussed
in Palm Springs), such as
typedef Fft<...> fwd_fft_type;
typedef fwd_fft_type::result_type<my_view_type>::type fft_result_type;
...
fwd_fft_type fwd_fft(1024, 1.);
fft_result_type result(fwd_fft(my_view));
view_type C = result * kernel;
...
> diff -rN -uN old-rbo-merge/src/vsip/core/impl_tags.hpp new-rbo-merge/src/vsip/core/impl_tags.hpp
> --- old-rbo-merge/src/vsip/core/impl_tags.hpp 2007-02-01 10:03:50.000000000 -0500
> +++ new-rbo-merge/src/vsip/core/impl_tags.hpp 2007-02-01 10:03:54.000000000 -0500
> @@ -40,6 +40,7 @@
> struct Copy_tag {}; // Optimized Copy
> struct Op_expr_tag {}; // Special expr handling (vmmul, etc)
> struct Simd_loop_fusion_tag {}; // SIMD Loop Fusion.
> +struct Special_tag; // Special evaluators.
> struct Loop_fusion_tag {}; // Generic Loop Fusion (base case).
> struct Cbe_sdk_tag {}; // IBM CBE SDK.
Could we find a somewhat more descriptive tag name ? :-)
Thanks,
Stefan
--
Stefan Seefeld
CodeSourcery
stefan at codesourcery.com
(650) 331-3385 x718
More information about the vsipl++
mailing list