[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    [PATCH] Replace KisVector2D by Eigen
From:       jacob () math ! jussieu ! fr
Date:       2008-08-22 7:19:44
Message-ID: 20080822091944.v6xp7c5jk8o44w4o () mail ! math ! jussieu ! fr
[Download RAW message or body]

This message is in MIME format.


Hi,

attached is a big patch on which I'd like your opinion. I hope that
eventually you'll be OK to let me commit that, but it would be best if
you could test it a bit before. I checked that the unit-tests succeed
(except for two tests which have nothing to do with that) and took
Krita for a basic test-drive.

* Remove the KisVector2D and KisVector3D code (450 LOC) and instead
make them be just typedef to Eigen2 vectors. These are vectors with
qreal coefficients instead of double, as I think it is trendy to make
things work on ARM embedded devices, but if you prefer we can keep
double instead.

[note: this is the second mini-vector-library that I remove from
Krita, and there still are more (CImg)]

* Port Krita to that change. Not a big deal, but there is at least one
dangerous difference: KisVector2D::KisVector2D() used to initialize
the coeffs to zero, which IMHO is a bad idea. No longer. When one
really wants this behavior, one can now use the following Eigen2
expression: KisVector2D::Zero().

* Fix bogus fuzzy-comparisons of floating-point numbers as I found
them. Sidenote: 99% of the times it is used, the DBL_EPSILON constant
is used in a bogus way. I can elaborate on all that but don't want to
bore you.

* Misc little fixes. For example, KisPaintInformationTest was
generating "random" numbers by doing rand() / RAND_MAX  ;) Fixing this
revealed that the exact comparisons then made between doubles were
indeed failing, so I replaced them with fuzzy comparisons.

*************

Now a few lines to discuss the advantages of replacing the old KisVector2D:

* its fuzzy comparisons were bogus

* in Krita code you do a lot of nested expressions like:
          result_vector = (vector1 + vector2) / 2;
Thanks to expression templates, Eigen2 makes that compile to optimized
code. By contrast, a 'classical' lib like the old KisVector2D
generates very poor code here because it amounts to tmp1 = vector1 +
vector2; tmp2 = tmp1/2; result_vector = tmp2; So there are a lot more
load/store memory accesses.

* Vectors of two double's are perfectly vectorizable since SSE and
AltiVec are 128-bit. Eigen will vectorize all that automatically,
provided SSE2 or AltiVec is enabled. Recall that at least the x86_64
architecture defaults to SSE2 so at least on that arch you get
immediately the benefit. On x86 you have to pass the -msse2 option to
GCC but then you break compatibility with old (pentium 3) CPUs.

* A large source of inefficiency remains the conversions to/from
QPointF. This can be seen e.g. in kis_painter. As discussed on IRC, we
cannot reliably use Eigen's ability to map a memory area as an Eigen
expression here, because QPointF does not store its coords as a
qreal[2] array.

Cheers,
Benoit



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


["diff" (application/octet-stream)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic