Re: [eigen] AVX/LRB and SSE with SoA support

```On 09/02/2010 10:56 AM, Gael Guennebaud wrote:
```
```On Wed, Sep 1, 2010 at 9:23 PM, keller<christoph-keller@xxxxxx>  wrote:
```
```On 08/23/2010 08:53 PM, Gael Guennebaud wrote:
```
```well, Eigen is a general purpose math library and so such "hacks" does
not match well with our objectives. We have to find a better solution.

```
```Hi,

If one wants to use the Vector units of the processor and store masks for
comparisons, the comparison operators cannot return values of type bool.
```
```
The problem is that we cannot know in advance whether a comparison
depends on the underlying vectorization engine.
So the idea is to have powerful high level expressions such that there
is no need to expose special scalar types. For instance, in:

c = (a<  b).select(x,y);

```
```Well, as is said before: I dont't think this is flexible enough
```
```returns an expression of bool, not a matrix of bool, and so
vectorization is still possible. Then when we call select on it we can
known whether this whole expression can be vectorized. If so we would
generate something like:

c(i) = ei_pselect(ei_plt(a(i),b(i)),x(i),y(i));

where ei_pselect would be implemented in term of pand/pnotand,por for
SSE2 and 3, and using BLENDVP* with SSE4. Note that the BLENDVP*
instructions read only the first bit and are therefore much more
flexible.

```
Ok, i did read the AVX-docs that careful. They have a select instruction, that is better than the or and and solution.
```Maybe it is possible to define a type
EigenBool<type T, int VEC_ENGINE>

```
The <=, < return an expression of this type. This type can be evaluated in two ways:
```-with sth. like toBool(), which returns a normal bool
-with sth. like toVecBool(), which returns a mask in format VEC_ENGINE
-these can be templatized with a function toEBool<EigenBoolType>

```
This adresses the two problems you mentioned at the beginning. Basically the type itself does not need to know the way it will be evaluated. This has to be used to decide if to return a bitmask or a bool (different eval functions).
```
```
-With this approach one can store the result of a comparison with each vectorisation engine. This is typesafe. Say one part of the Software uses SSE and the other does not, then the typesystem takes care of the Format of bools (at least it gives errors).
```-The systax can be like your select syntax
-If one wants to store normal bool types with sth. like this
Matrix<bool,...> = (a < b)
```
maybe we can add a function toBool<EigenBoolType>() to the expressions of type bool. So they can basically be transformed to any other EigenBool type. Every boolean expression inherits these transformation functions from a base class. The operator= of Matrix <bool, ..., >, Matrix <EigenBool, ..., > use the toBool function to evaluate a boolean expression, so this would not break existing code. -Last, but not least: EigenBool<> types can be used with logical operators and the Vectorisation Engine.
```
This just an idea, i dunno if it would work like this.

Greetings,
Christoph

```

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