Re: [eigen] Re: Strong inlining is sometimes ignored... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Re: Strong inlining is sometimes ignored...
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 15 Oct 2009 09:12:43 -0400
- 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=F1Z7x9deaeJmA39wbdr/vfqbKqpSIU1kAsKhm6zzTqw=; b=o8JuJTPp8SBh4jf9P7H1f0NYIydiE1nBhqsBLVPKbiMEyGnMZ9GDoQPW+OEKaX95OU gE9hI8XViBPayxW0v/fkbkvEWWfkdWdPz2VxIPwBQjU2Lxf+GAvWWDYAObygLvCv63Jj 5tdZIorlwC1MT0l/jzbYLt5eS+Yz7tJq6LXLI=
- 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=onVBp72T+9WNg9YU38lZf56ruBy35rastl6+e6uBLeEpPOvqatzG5Q6XJ7d04f5x01 6+RaOZOS0QLHC3kIQV01n3ZlzfIaJxHoVpVg8DGgGdQCVhjT5vs9YKW9puANNb61tsTm osxkS+fApFq+75DGqlZLd94Fs5kuL98jctYeM=
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
>>
>
>