 |
|
|
|
Actions
|
|
[ Date Prev][ Date Next][ Thread Prev][ Thread Next][ Date Index][ Thread Index]
Re: [vsipl++] [patch] CML bindings for matrix transpose operations
- To: Stefan Seefeld <stefan@xxxxxxxxxxxxxxxx>
- Subject: Re: [vsipl++] [patch] CML bindings for matrix transpose operations
- From: Jules Bergmann <jules@xxxxxxxxxxxxxxxx>
- Date: Thu, 05 Jun 2008 09:50:44 -0400
Stefan, Don,
for the first case, which I find much more readable than the macro
code above.
I agree that macros are pretty much always less readable than straight
code (in fact the first thing I usually do when debugging a problem in a
macro is manually expand it).
However, in defense of Don's approach, the macros will quickly scale
when CML supports additional types (double, complex<double>, int, short,
etc etc). Moreover, the functions created by the macros don't do much
(just wrap a CML function with a consistent overloaded function
interface), so there isn't much to understand.
The other way to get more mileage out of the macros is to use them for
more than just a single function. Transpose is an example of a 1-input,
1-output matrix function. Instead of calling the macro
VSIP_IMPL_CML_TRANS, it could be called VSIP_IMPL_CML_MUNARY ("matrix
function, unary ~ 1 argument"). Then the macro could be reused across
mtrans, matrix copy (when we add it), and so on. We don't have too many
unary matrix functions yet, but the idea generalizes.
+ static bool rt_valid(DstBlock& dst, SrcBlock const& src)
+ { + bool rt = true;
+
+ // If performing a copy, both source and destination blocks
+ // must be unit stride.
+ if (Type_equal<src_order_type, dst_order_type>::value)
+ {
+ Ext_data<DstBlock> dst_ext(dst, SYNC_OUT);
+ Ext_data<SrcBlock> src_ext(src, SYNC_IN);
These objects only exist to check the strides, right ? I'm aware that we
don't have any SYNC enumerators to indicate 'no-copy', but shouldn't we
? Using SYNC_OUT and SYNC_IN looks a bit misleading to me, in this
context. Jules ?
I think SYNC_OUT and SYNC_IN make sense because they indicate how the
data access will be used.
Because ct_valid includes a check that the cost of data access is 0, in
rt_valid there is no danger that data access will require a copy.
Using SYNC_OUT and SYNC_IN allows the rt_valid declarations to exactly
match those used in exec.
-- Jules
--
Jules Bergmann
CodeSourcery
jules@xxxxxxxxxxxxxxxx
(650) 331-3385 x705
|
|