[patch] Run-time external data access.
Jules Bergmann
jules at codesourcery.com
Sat May 6 20:07:15 UTC 2006
Attach patch implements and tests external data access with run-time
selection of the layout.
In theory, should work something like this:
// Assume this is an operator() function for a class similar
// to Fft. It calls a backend (backend_) to do the work.
// Since the backend is chosen at run-time (and is derived
// from a virtual base class), we can't use the normal
// Ext_data because it requires that layout be chosen
// at compile-time. Instead we need to use run-time ext_data.
operator()(
const_Vector<T, Block0> in,
Vector<T, Block1> out)
{
// First, determine layout of blocks:
Rt_layout<1> rtl_in = block_layout(in.block());
Rt_layout<1> rtl_out = block_layout(out.block());
// Second, queury the backend about what layout
// it can support.
// Backend will modify rtl_in and rtl_out.
//
// For example, it might:
// - set strides to unit-stride if it only supports
// unit-stride,
// - set complex formats to match,
// - set dimension-ordering ,
// - etc.
backend_->query_layout(rtl_in, rtl_out);
// Thrid, create run-time Ext_data objects
Rt_ext_data<Block0, 1> ext_in(in.block(), rtl_in);
Rt_ext_data<Block1, 1> ext_out(out.block(), rtl_out);
// Fourth, call functions in backend.
//
// Some knowledge may get encoded here. In particular,
// because split- and interleaved- complex have
// different types, we need to call the appropriate
// backend function. The backends could do this dispatch
// too.
// backends don't have functions with mixed split/interleaved
// arguments.
assert(rtl_in.complex == rtl_out.complex);
if (rtl_in.complex == cmplx_inter_fmt)
{
backend_->doit(rtl_in.data().as_inter(),
rtl_in.stride(0),
rtl_out.data().as_inter(),
rtl_out.stride(0),
out.size());
}
else // (rtl_in.complex == cmplx_split_fmt)
{
backend_->doit(rtl_in.data().as_split(),
rtl_in.stride(0),
rtl_out.data().as_split(),
rtl_out.stride(0),
out.size());
}
}
-- Jules
--
Jules Bergmann
CodeSourcery
jules at codesourcery.com
(650) 331-3385 x705
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rtex.diff
URL: <http://sourcerytools.com/pipermail/vsipl++/attachments/20060506/bc3016da/attachment.ksh>
More information about the vsipl++
mailing list