Re: [eigen] Issues regarding Quaternion-alignment and const Maps

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


Gael Guennebaud wrote:
>> And another question: Do I have to make sure, that no Options besides
>> DontAlign can be set?
> 
> would be nice. For instance you could add a protected
> check_template_param() containing a static assertion in Quaternion
> that would be called by each constructor.

2nd attempt is attached (it's a patch against the current head, not
against the old patch).

I implemented a _check_template_param(), but I did not actually call it
as it already rises an exception (if options other than DontAlign or
AutoAlign are passed).
If that is just a g++ behavior feel free to add it to each constructor
for portability.

Another note: After looking at the assembly (using g++ 4.3.2) I noted
that ei_pset1 generates the same code no matter if either sse2 or sse3
is enabled. Looking closer at _mm_loaddup_pd in pmmintrin.h I saw that
it doesn't actually call a __builtin but is merely a convenience-wrapper
doing basically the same as ei_pset1 does. It should however call
movddup [1]

Should ei_pset1 directly call the corresponding builtin (when using g++)
or should we wait till someone from gcc fixes pmmintrin.h? If [1] is
correct _mm_loadup_pd seems to work correctly with icc.

Christoph


[1] http://en.wikipedia.org/wiki/MOVDDUP


-- 
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252
----------------------------------------------
# HG changeset patch
# User Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
# Date 1279881825 -7200
# Node ID da27b0f16c9eb155326171f5e9e94bc413180505
# Parent  35e8d70f566d11f5b52260ee177b7859c3ac4a1e
Support for unaligned Quaternions

diff -r 35e8d70f566d -r da27b0f16c9e Eigen/src/Core/util/ForwardDeclarations.h
--- a/Eigen/src/Core/util/ForwardDeclarations.h	Thu Jul 22 21:52:04 2010 +0100
+++ b/Eigen/src/Core/util/ForwardDeclarations.h	Fri Jul 23 12:43:45 2010 +0200
@@ -177,7 +177,7 @@
 template<typename Derived, int _Dim> class RotationBase;
 template<typename Lhs, typename Rhs> class Cross;
 template<typename Derived> class QuaternionBase;
-template<typename Scalar> class Quaternion;
+template<typename Scalar, int Options = AutoAlign> class Quaternion;
 template<typename Scalar> class Rotation2D;
 template<typename Scalar> class AngleAxis;
 template<typename Scalar,int Dim,int Mode=Affine> class Transform;
diff -r 35e8d70f566d -r da27b0f16c9e Eigen/src/Geometry/Quaternion.h
--- a/Eigen/src/Geometry/Quaternion.h	Thu Jul 22 21:52:04 2010 +0100
+++ b/Eigen/src/Geometry/Quaternion.h	Fri Jul 23 12:43:45 2010 +0200
@@ -208,27 +208,27 @@
   * \sa  class AngleAxis, class Transform
   */
 
-template<typename _Scalar>
-struct ei_traits<Quaternion<_Scalar> >
+template<typename _Scalar, int _Options>
+struct ei_traits<Quaternion<_Scalar, _Options> >
 {
-  typedef Quaternion<_Scalar> PlainObject;
+  typedef Quaternion<_Scalar, _Options> PlainObject;
   typedef _Scalar Scalar;
-  typedef Matrix<_Scalar,4,1> Coefficients;
+  typedef Matrix<_Scalar,4,1, _Options> Coefficients;
   enum{
-    PacketAccess = Aligned
+    PacketAccess = _Options & DontAlign ? Unaligned : Aligned
   };
 };
 
-template<typename _Scalar>
-class Quaternion : public QuaternionBase<Quaternion<_Scalar> >{
-  typedef QuaternionBase<Quaternion<_Scalar> > Base;
+template<typename _Scalar, int _Options>
+class Quaternion : public QuaternionBase<Quaternion<_Scalar, _Options> >{
+  typedef QuaternionBase<Quaternion<_Scalar, _Options> > Base;
 public:
   typedef _Scalar Scalar;
 
-  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion<Scalar>)
+  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion)
   using Base::operator*=;
 
-  typedef typename ei_traits<Quaternion<Scalar> >::Coefficients Coefficients;
+  typedef typename ei_traits<Quaternion<Scalar, _Options> >::Coefficients Coefficients;
   typedef typename Base::AngleAxisType AngleAxisType;
 
   /** Default constructor leaving the quaternion uninitialized. */
@@ -264,6 +264,14 @@
 
 protected:
   Coefficients m_coeffs;
+  
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+    EIGEN_STRONG_INLINE static void _check_template_params()
+    {
+      EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
+        INVALID_MATRIX_TEMPLATE_PARAMETERS)
+    }
+#endif
 };
 
 /** \ingroup Geometry_Module


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