Re: [eigen] [PATCH] prod() / rowwise().prod() / colwise().prod() |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Tue, 10 Feb 2009 17:38:06 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=muPHcuwZ1Aj0RVPmDbr5taR1IkIOvj4COA01rZjr3yE=; b=BWTfCy8Fu+2tgDBWEmSz/wGPZIT47R2UOlL1rL2KNG42SkM50ETtv6efu4KplfBoyx UUZwvVAxmCDKOQ2+ucjDqieXjdda+d6V65q7j3kY+Gtm7/UoWw1PoWrh3KVz+D8IxGat 8kWonb3ykWDnDQSp/pGzgyRl+dFS+G+sTBifs=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=vcKag0Yb79r0O39IaVcB41WURw5dbrzQngypaJFZi38g/5AsAGp6c1h3CZsvBAiGH/ AxA0bEMnzDOVdDTHpmWP2cZRuAJHIX3vfq3vYaLUod4h4lgqnAtYvQylmebAKtGZvdU/ DmcNNegqavyKCLmXWJbKT75ttWgXi8gQ2pxZs=

Hi, thanks for the patch, however it would be much better to improve the Redux framework on the model of Sum (and now Prod !) such that any reduction operation is seamlessly vectorized. Then MatrixBase::prod() could simply be implemented as "return redux(ei_scalar_prod_op())". Same for sum(). In practice this also requires to extend the respective functors (ei_scalar_sum_op, prod, min, max, etc.) with the following function: inline Scalar redux(const PacketScalar& p); For instance, for ei_scalar_sum_op, this function would simply be "return ei_predux(p)". For the other functors we need to add the respective arch depended redux operations (eg, ei_predux_mul(), ei_predux_min, etc.). I think they can all be generated using a macro based of ei_predux() (not 100% sure for all, especially min/max for integers). This also remind me that we should add a big arch-dependent structure to specify, for each scalar type, which operation is vectorized, and what is the approximate cost. This kind of compile time data base would be used by the functor traits. Perhaps the ei_packet_traits could be used for that purpose, example in arch/SSE/: ei_default_SSE_packet_traits { enum { Mul = 1, MulCost = 1, Add = 1, AddCost = 1, Min = 1, MinCost = 1, // ... }; }; template<> ei_packet_traits<float> : ei_default_SSE_packet_traits { typedef _m128 type; enum {size = 4}; }; template<> ei_packet_traits<int> : ei_default_SSE_packet_traits { typedef _m128i type; enum {size = 4}; // specialization of supported operations enum { Min = 1, MinCost = 4, // their is no native SSE min for integers Max = 1, MaxCost = 4, } }; the main goal is to avoid to have to add some arch dependent #if #else #endif in the definition of the functors, and perhaps, in the future to propagate two "CoeffCost" values: one with vectorization, and one without and check at the evaluation whether the vectorization is really worth it (just a thought). cheers, Gael. On Tue, Feb 10, 2009 at 4:30 PM, Ricard Marxer Piñón <email@xxxxxxxxxxxxxxxx> wrote: > Hi, > > Here is a patch that implements prod() for MatrixBase and PartialRedux. > Prod is an expression representing the product of all the coefficients. > > The numpy equivalent is numpy.prod(). > > -- > ricard > http://www.ricardmarxer.com > http://www.caligraft.com >

**Follow-Ups**:**Re: [eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()***From:*Benoit Jacob

**References**:**[eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()***From:*Ricard Marxer Piñón

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()** - Next by Date:
**Re: [eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()** - Previous by thread:
**[eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()** - Next by thread:
**Re: [eigen] [PATCH] prod() / rowwise().prod() / colwise().prod()**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |