Re: [eigen] Re: Strong inlining is sometimes ignored...

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


I'd like to understand, why is the case Length=0 case ever called?
If Length>=2 this unroller halves the Length. If Length=1 it handles
it as the base case.
So I'm surprised that the case Length=0 is ever called...?

Second, I'd like to understand, why is this in
ei_redux_novec_unroller, while precisely you found that the issue
happened with vectorizable cases, so why not in ei_redux_vec_unroller
?

Benoit


2009/10/15 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> I've just had a few minutes to investigate this. I was so blind. Look at the
> last template parameter of ei_redux_novec_unroller - it's zero and that's of
> course not unrolled.
>
> Adding the specialization
>
> template<typename Func, typename Derived, int Start>
> struct ei_redux_novec_unroller<Func, Derived, Start, 0>
> {
>   typedef typename Derived::Scalar Scalar;
>   EIGEN_STRONG_INLINE static Scalar run(const Derived&, const Func&) {
> return Scalar(); }
> };
>
> resolved the issue with the unroller... shall I commit it?
>
> - Hauke
>
> On Wed, Oct 14, 2009 at 5:04 PM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
> wrote:
>>
>> While fixing some of the /W4 warnings, I recognized that with the
>> following code:
>>
>> #include "Eigen/Core"
>> #include "Eigen/Array"
>>
>> template <int size>
>> void redux_prod()
>> {
>>   typedef typename Eigen::Matrix<double,1,size> Vector;
>>   Vector a = Vector::Random();
>>   std::cout << a.prod() << std::endl;
>> }
>>
>> int main()
>> {
>>   redux_prod<1>();
>>   redux_prod<2>();
>>   redux_prod<3>();
>>   redux_prod<4>();
>> }
>>
>> I am getting the warning C4714, which tells us that a function marked as
>> _forceinline has not been inlined. The actual output is here:
>>
>> Warning    6    warning C4714: function 'static double __cdecl
>> Eigen::ei_redux_novec_unroller<struct
>> Eigen::ei_scalar_product_op<double>,class
>> Eigen::Matrix<double,1,4,0,1,4>,4,0>::run(class
>> Eigen::Matrix<double,1,4,0,1,4> const & __ptr64,struct
>> Eigen::ei_scalar_product_op<double> const & __ptr64)' marked as
>> __forceinline not inlined    \eigen\src\core\redux.h    95
>> Warning    7    warning C4714: function 'static double __cdecl
>> Eigen::ei_redux_novec_unroller<struct
>> Eigen::ei_scalar_product_op<double>,class
>> Eigen::Matrix<double,1,4,0,1,4>,4,0>::run(class
>> Eigen::Matrix<double,1,4,0,1,4> const & __ptr64,struct
>> Eigen::ei_scalar_product_op<double> const & __ptr64)' marked as
>> __forceinline not inlined    \eigen\src\core\redux.h    95
>> Warning    8    warning C4714: function 'static double __cdecl
>> Eigen::ei_redux_novec_unroller<struct
>> Eigen::ei_scalar_product_op<double>,class
>> Eigen::Matrix<double,1,2,0,1,2>,2,0>::run(class
>> Eigen::Matrix<double,1,2,0,1,2> const & __ptr64,struct
>> Eigen::ei_scalar_product_op<double> const & __ptr64)' marked as
>> __forceinline not inlined    \eigen\src\core\redux.h    95
>> Warning    9    warning C4714: function 'static double __cdecl
>> Eigen::ei_redux_novec_unroller<struct
>> Eigen::ei_scalar_product_op<double>,class
>> Eigen::Matrix<double,1,2,0,1,2>,2,0>::run(class
>> Eigen::Matrix<double,1,2,0,1,2> const & __ptr64,struct
>> Eigen::ei_scalar_product_op<double> const & __ptr64)' marked as
>> __forceinline not inlined    \eigen\src\core\redux.h    95
>>
>> As you can see, it happens here only for even size vectors.
>>
>> I tried to disable exceptions and it did not help, I tried to declare
>> ei_redux_novec_unroller::run with declspec(nothrow), again no help. I have
>> no idea how to fix this.
>>
>> Maybe someone has more experience with issues like this and is ready to
>> help us.
>>
>> Cheers,
>> Hauke
>>
>
>



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