Commit Graph

895 Commits

Author SHA1 Message Date
Gael Guennebaud
9385793f71 Fix a couple of issue with the vectorization. In particular, default ei_p* functions
are provided to handle not suported types seemlessly.

Added a generic null-ary expression with null-ary functors. They replace
Zero, Ones, Identity and Random.
2008-04-24 18:35:39 +00:00
Benoit Jacob
6ae037dfb5 give up on OpenMP... for now 2008-04-18 07:57:46 +00:00
Benoit Jacob
acfd6f3bda - add _packetCoeff() to Inverse, allowing vectorization.
- let Inverse take template parameter MatrixType instead
  of ExpressionType, in order to reduce executable code size
  when taking inverses of xpr's.
- introduce ei_corrected_matrix_flags : the flags template
  parameter to the Matrix class is only a suggestion. This
  is also useful in ei_eval.
2008-04-16 07:18:27 +00:00
Benoit Jacob
43e2bc14fe +5% optimization in 4x4 inverse:
-only evaluate block expressions for which that is beneficial
-don't check for invertibility unless requested
2008-04-15 20:39:27 +00:00
Benoit Jacob
6747b45ae7 for 4x4 matrices implement the special algorithm that Markos proposed,
falling back to the general algorithm in the bad case.
2008-04-15 20:15:36 +00:00
Benoit Jacob
2a86f052a5 - optimized determinant calculations for small matrices (size <= 4)
(only 30 muls for size 4)
- rework the matrix inversion: now using cofactor technique for size<=3,
  so the ugly unrolling is only used for size 4 anymore, and even there
  I'm looking to get rid of it.
2008-04-14 17:07:12 +00:00
Benoit Jacob
9789c04467 when evaluating an xpr, the result can now be vectorizable
even if the xpr itself wasn't vectorizable.
2008-04-14 08:55:12 +00:00
Benoit Jacob
ea3ccb1e8c * Start of the LU module, with matrix inversion already there and
fully optimized.
* Even if LargeBit is set, only parallelize for large enough objects
  (controlled by EIGEN_PARALLELIZATION_TRESHOLD).
2008-04-14 08:20:24 +00:00
Benoit Jacob
ab4046970b * Add fixed-size template versions of corner(), start(), end().
* Use them to write an unrolled path in echelon.cpp, as an
  experiment before I do this LU module.
* For floating-point types, make ei_random() use an amplitude
  of 1.
2008-04-12 17:37:27 +00:00
Benoit Jacob
dcebc46cdc - cleaner use of OpenMP (no code duplication anymore)
using a macro and _Pragma.
- use OpenMP also in cacheOptimalProduct and in the
  vectorized paths as well
- kill the vector assignment unroller. implement in
  operator= the logic for assigning a row-vector in
  a col-vector.
- CMakeLists support for building tests/examples
  with -fopenmp and/or -msse2
- updates in bench/, especially replace identity()
  by ones() which prevents underflows from perturbing
  bench results.
2008-04-11 14:28:42 +00:00
Benoit Jacob
7bee90a62a Merge Gael's experimental OpenMP parallelization support into Assign.h. 2008-04-11 08:18:47 +00:00
Gael Guennebaud
187b1543ce added a vectorized version of Product::_cacheOptimalProduct,
added the possibility to disable the vectorization using EIGEN_DONT_VECTORIZE
(some architectures has SSE support by default)
2008-04-10 12:34:22 +00:00
Benoit Jacob
613c49b475 * add typedefs for matrices/vectors with LargeBit
* add -pedantic to CXXFLAGS
* cleanup intricated expressions with && and ||
  which gave warnings because of "missing" parentheses
* fix compile error in NumTraits, apparently discovered
  by -pedantic
2008-04-10 10:33:50 +00:00
Benoit Jacob
ca448d2537 split those files in util/
some more renaming
2008-04-10 09:41:13 +00:00
Benoit Jacob
9d8876ce82 * rename XprCopy -> Nested
* rename OperatorEquals -> Assign
* move Util.h and FwDecl.h to a util/ subdir
2008-04-10 09:01:28 +00:00
Gael Guennebaud
212da8ffe0 fix priority operator bugs in the computation
of the VectorizableBit flag, now benchmark.cpp is properly vectorized
2008-04-09 18:24:13 +00:00
Gael Guennebaud
8f957564ec a better bugfix in ei_matrix_operator_equals_packet_unroller 2008-04-09 18:04:26 +00:00
Gael Guennebaud
d95d952e92 bugfix in ei_matrix_operator_equals_packet_unroller 2008-04-09 17:44:59 +00:00
Gael Guennebaud
1985fb0551 Added initial experimental support for explicit vectorization.
Currently only the following platform/operations are supported:
 - SSE2 compatible architecture
 - compiler compatible with intel's SSE2 intrinsics
 - float, double and int data types
 - fixed size matrices with a storage major dimension multiple of 4 (or 2 for double)
 - scalar-matrix product, component wise: +,-,*,min,max
 - matrix-matrix product only if the left matrix is vectorizable and column major
   or the right matrix is vectorizable and row major, e.g.:
   a.transpose() * b is not vectorized with the default column major storage.
To use it you must define EIGEN_VECTORIZE and EIGEN_INTEL_PLATFORM.
2008-04-09 12:31:55 +00:00
Benoit Jacob
4920f2011e finish making use of CoeffReadCost and the new XprCopy everywhere
seems appropriate to me.
2008-04-08 14:15:01 +00:00
Benoit Jacob
371d302efb - merge ei_xpr_copy and ei_eval_if_needed_before_nesting
- make use of CoeffReadCost to determine when to unroll the loops,
  for now only in Product.h and in OperatorEquals.h
performance remains the same: generally still not as good as before the
big changes.
2008-04-06 18:01:03 +00:00
Benoit Jacob
30ec34de36 fix compilation (finish removal of EIGEN_UNROLLED_LOOPS) 2008-04-05 14:20:30 +00:00
Benoit Jacob
61e58cf602 fixes as discussed with Gael on IRC. Mainly, in Fuzzy.h, and Dot.h, use
ei_xpr_copy to evaluate args when needed. Had to introduce an ugly
trick with ei_unref as when the XprCopy type is a reference one can't
directly access member typedefs such as Scalar.
2008-04-05 14:15:02 +00:00
Gael Guennebaud
b4a156671f * make use of the EvalBeforeNestingBit and EvalBeforeAssigningBit
in ei_xpr_copy and operator=, respectively.
 * added Matrix::lazyAssign() when EvalBeforeAssigningBit must be skipped
   (mainly internal use only)
 * all expressions are now stored by const reference
 * added Temporary xpr: .temporary() must be called on any temporary expression
   not directly returned by a function (mainly internal use only)
 * moved all functors in the Functors.h header
 * added some preliminaries stuff for the explicit vectorization
2008-04-05 11:10:54 +00:00
Gael Guennebaud
048910caae * added cwise comparisons
* added "all" and "any" special redux operators
 * added support bool matrices
 * added support for cost model of STL functors via ei_functor_traits
  (By default ei_functor_traits query the functor member Cost)
2008-04-03 18:13:27 +00:00
Benoit Jacob
249dc4f482 current state of the mess. One line fails in the tests, and
useless copies are made when evaluating nested expressions.
Changes:
- kill LazyBit, introduce EvalBeforeNestingBit and EvalBeforeAssigningBit
- product and random don't evaluate immediately anymore
- eval() always evaluates
- change the value of Dynamic to some large positive value,
  in preparation of future simplifications
2008-04-03 16:54:19 +00:00
Benoit Jacob
b8900d0b80 More clever evaluation of arguments: now it occurs in earlier, in operator*,
before the Product<> type is constructed. This resets template depth on each
intermediate evaluation, and gives simpler code. Introducing
ei_eval_if_expensive<Derived, n> which evaluates Derived if it's worth it
given that each of its coeffs will be accessed n times. Operator*
uses this with adequate values of n to evaluate args exactly when needed.
2008-04-03 14:17:56 +00:00
Gael Guennebaud
4448f2620d fix a compilation issue with gcc-3.3 and ei_result_of 2008-04-03 12:39:39 +00:00
Benoit Jacob
d1a29d6319 -new: recursive costs system, useful to determine automatically
when to evaluate arguments and when to meta-unroll.
-use it in Product to determine when to eval args. not yet used
 to determine when to unroll. for now, not used anywhere else but
 that'll follow.
-fix badness of my last commit
2008-04-03 11:10:17 +00:00
Benoit Jacob
e74fbfb2bc - remove Eval/EvalOMP (moving them to a disabled/ subdir in order
to preserve SVN history). They are made useless by the new
  ei_eval_unless_lazy.
- introduce a generic Eval member typedef so one can do e.g.
  T t; U u; Product<T, U>::Eval m; m = t*u;
2008-03-31 17:24:09 +00:00
Benoit Jacob
cff5e3ce9c Make use of the LazyBit, introduce .lazy(), remove lazyProduct. 2008-03-31 16:20:06 +00:00
Benoit Jacob
f279162ec4 * introducte recursive Flags system for the expressions
-- currently 3 flags: RowMajor, Lazy and Large
 -- only RowMajor actually used for now
* many minor improvements
2008-03-30 18:43:22 +00:00
Benoit Jacob
758b26551a * fix compilation with gcc-4.0 which doesn't like "using" too much
* add Eigen:: in some macros to allow using them from outside
  of namespace Eigen
Problems and solutions communicated by Gael.
2008-03-29 16:48:04 +00:00
Benoit Jacob
c9b0dcd733 look at that subtle difference in Product.h...
the cacheOptimal is only good for large enough matrices.
When taking a block in a fixed-size (hence small) matrix,
the SizeAtCompileTime is Dynamic hence that's not a good
indicator. This example shows that the good indicator is
MaxSizeAtCompileTime.
Result: +10% speed in echelon.cpp
2008-03-26 09:29:29 +00:00
Benoit Jacob
a994e51c96 * add Gael copyright lines on 2 more files
* macro renaming: EIGEN_NDEBUG becomes EIGEN_NO_DEBUG
  as this is much better (and similar to Qt) and
  EIGEN_CUSTOM_ASSERT becomes EIGEN_USE_CUSTOM_ASSERT
* protect Core header by a EIGEN_CORE_H
2008-03-26 09:13:11 +00:00
Benoit Jacob
729618c945 * #define EIGEN_NDEBUG now also disables asserts. Useful
to disable eigen's asserts without disabling one's own program's
  asserts. Notice that Eigen code should now use ei_assert()
  instead of assert().
* Remove findBiggestCoeff() as it's now almost redundant.
* Improve echelon.cpp: inner for loop replaced by xprs.
* remove useless "(*this)." here and there. I think they were
  first introduced by automatic search&replace.
* fix compilation in Visitor.h (issue triggered by echelon.cpp)
* improve comment on swap().
2008-03-26 08:48:04 +00:00
Gael Guennebaud
4342f024d9 * support for matrix-scalar quotient with integer scalar types.
* added cache efficient matrix-matrix product.
   - provides a huge speed-up for large matrices.
   - currently it is enabled when an explicit unrolling is not possible.
2008-03-21 20:26:14 +00:00
Benoit Jacob
0ef1efdbdb * cleanup: in public api docs, don't put \sa links to \internal things.
(the global funcs in MathFunctions.h and Fuzzy.h don't count as internal).
* Mainpage.dox. Add a few prospective Eigen users; change the recommended
  -finline-limit from 10000 to 1000. The reason is: it could be harmful to have
  a too big value here, couldn't it? (e.g. exceedingly large executables, cache
  misses). Looking at gcc, a value of 900 would exactly mean "determine the inlining
  of all functions as if they were marked with 'inline' keyword". So a value of
  1000 seems a reasonable round number. In the benchmark that motivated this
  (TestEigenSolvers) a value of 400 is enough on my system.
2008-03-17 07:35:22 +00:00
Benoit Jacob
af131fe770 update to fix compilation 2008-03-16 21:04:33 +00:00
Gael Guennebaud
612350e3f8 * Added a generic *redux* mini framework allowing custom redux operations
as well as partial redux (vertical or horizontal redux).
   Includes shortcuts for: sum, minCoeff and maxCoeff.
   There is no shortcut for the partial redux.

 * Added a generic *visitor* mini framework. A visitor is a custom object
   sequentially applied on each coefficient with knowledge of its value and
   coordinates.
   It is currentlly used to implement minCoeff(int*,int*) and maxCoeff(int*,int*).
   findBiggestCoeff is now a shortcut for "this->cwiseAbs().maxCoeff(i,j)"

 * Added coeff-wise min and max.
 * fixed an issue with ei_pow(int,int) and gcc < 4.3 or ICC
2008-03-16 14:36:25 +00:00
Benoit Jacob
29184ad27d - introduce sum() returning the sum of the coeffs of a vector
- reimplement trace() as just diagonal().sum()
- apidoc fixes
2008-03-15 11:05:38 +00:00
Benoit Jacob
fb3438e609 - expand MathFunctions.h to provide more functions, like exp, log...
- add cwiseExp(), cwiseLog()...
   --> for example, doing a gamma-correction on a bitmap image stored as
       an array of floats is a simple matter of:
         Eigen::Map<VectorXf> m = VectorXf::map(bitmap,size);
         m = m.cwisePow(gamma);
- apidoc improvements, reorganization of the \name's
- remove obsolete examples
- remove EIGEN_ALWAYS_INLINE on lazyProduct(), it seems useless.
2008-03-14 10:38:37 +00:00
Benoit Jacob
fe569b060c get rid of MatrixRef, simplifications. 2008-03-13 20:36:01 +00:00
Gael Guennebaud
908a0fbab5 small fix of VERIFY_ASSERT in debug mode 2008-03-13 09:51:18 +00:00
Benoit Jacob
afc64f3332 a lot of renaming
internal classes: AaBb -> ei_aa_bb
IntAtRunTimeIfDynamic -> ei_int_if_dynamic
unify UNROLLING_LIMIT (there was no reason to have operator= use
a higher limit)
etc...
2008-03-13 09:33:26 +00:00
Gael Guennebaud
16257d44dd fixed an issue with VERIFY_ASSERT 2008-03-12 18:44:42 +00:00
Gael Guennebaud
35bce20954 Removed Column and Row in favor of Block 2008-03-12 18:10:52 +00:00
Benoit Jacob
6da4d9d256 fix compilation (forgot to update that file after last big change) 2008-03-12 17:25:14 +00:00
Benoit Jacob
2ee68a074e generalized ei_traits<>.
Finally the importing macro is named EIGEN_BASIC_PUBLIC_INTERFACE
because it does not only import the ei_traits, it also makes the base class
a friend, etc.
2008-03-12 17:17:36 +00:00
Benoit Jacob
01572b9f54 big change: MatrixBase only takes one template parameter "Derived", the
template parameter "Scalar" is removed. This is achieved by introducting a
template <typename Derived> struct Scalar to achieve a forward-declaration of
the Scalar typedefs.
2008-03-10 17:23:11 +00:00