the big memory changes. the most important changes are:

ei_aligned_malloc now really behaves like a malloc
 (untyped, doesn't call ctor)
ei_aligned_new is the typed variant calling ctor
EIGEN_MAKE_ALIGNED_OPERATOR_NEW now takes the class name as parameter
This commit is contained in:
Benoit Jacob
2009-01-08 15:20:21 +00:00
parent e2d2a7d222
commit 1d52bd4cad
21 changed files with 215 additions and 243 deletions

View File

@@ -10,7 +10,7 @@ namespace Eigen {
- \ref stillstillstuck
- \ref movetotop
- \ref bugineigen
- \ref nomacro
- \ref conditional
<hr>
\section what What kind of code made this assertion fail?
@@ -54,7 +54,7 @@ class Foo
Eigen::Vector2d v;
...
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW(Foo)
};
...
@@ -144,7 +144,7 @@ class Foo
double x;
Eigen::Vector2d v;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW(Foo)
};
\endcode
@@ -156,7 +156,7 @@ class Foo
Eigen::Vector2d v;
double x;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW(Foo)
};
\endcode
@@ -168,25 +168,6 @@ Dynamic-size matrices and vectors, such as Eigen::VectorXd, allocate dynamically
No, it's not our bug. It's more like an inherent problem of the C++ language -- though it must be said that any other existing language probably has the same problem. The problem is that there is no way that you can specify an aligned "operator new" that would propagate to classes having you as member data.
\section nomacro I don't like macros! Any solution with inheritance?
Yes, you can let your class Foo publicly inherit Eigen::WithAlignedOperatorNew, like this:
\code
class Foo : public Eigen::WithAlignedOperatorNew
{
...
Eigen::Vector2d v;
...
};
...
Foo *foo = new Foo;
\endcode
This solution gives the same result as the macro. It has the disadvantage that if Foo already had a base class, you are now doing multiple inheritance, and this situation is sometimes handled wrongly by certain compilers -- we've been having trouble with MSVC. The solution with the macro is therefore safer.
\section conditional What if I want to do this conditionnally (depending on template parameters) ?
For this situation, we offer the macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign). It will generate aligned operators like EIGEN_MAKE_ALIGNED_OPERATOR_NEW if NeedsToAlign is true. It will generate operators with the default alignment if NeedsToAlign is false.
@@ -202,7 +183,7 @@ template<int n> class Foo
Vector v;
...
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(Foo,NeedsToAlign)
};
...