Toward a vectorization mechanism in C++

218 views
Skip to first unread message

VinceRev

unread,
Dec 22, 2012, 12:48:02 PM12/22/12
to std-pr...@isocpp.org
Hello all !

Here is the beginning (it's only the beginning, I am actively working on the technical specifications) of a new proposal concerning the addition of a vectorization mechanism in C++. The goal is to simplify the creation of new containers with vector operations using 3 very generic tools as described in the proposal.

I will update the technical specifications later this week, but if you already have opinions about the problematics and issues addressed by the proposal, do not hesitate to post...

--
Vincent Reverdy
Phd Student @ Laboratory Universe and Theories
Cosmology and General Relativity Group
Observatory of Paris-Meudon, France
vectorization_v01.pdf

VinceRev

unread,
Dec 23, 2012, 10:49:00 PM12/23/12
to std-pr...@isocpp.org
Here is an update of the technical specifications. I have to write the detailed technical description of each method now, but if you already have thoughts/commentaries about the topic, I would be happy to hear it.
vectorization_v02.pdf

Jens Maurer

unread,
Dec 26, 2012, 3:57:56 PM12/26/12
to std-pr...@isocpp.org
On 12/24/2012 04:49 AM, VinceRev wrote:
> Here is an update of the technical specifications. I have to write the detailed technical description of each method now, but if you already have thoughts/commentaries about the topic, I would be happy to hear it.

I'm a bit lost here.

- It would help if the CRTP acronym were expanded as early as the abstract.

- In C++, we don't speak of "methods", but of "member functions", if that's
what you mean (often, you want to have operators as non-member functions to
allow symmetric application of implicit conversions)

- In the motivation section, I need a few examples to show where my class
would benefit automatically from vectorization, with specifics.
(I don't need all operators, but let's focus on MyVector3D::operator+:
How would I implement it? Does it still get all desired implicit conversions?)

Jens
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

VinceRev

unread,
Dec 26, 2012, 10:52:24 PM12/26/12
to std-pr...@isocpp.org
Here is a new version with the description of operators.
The term vectorization can be misleading, but I haven't another word in mind. Maybe "vector creation helper" would be better ?
Keep in mind that it is just a preliminary reflexion.

The benefit of this helper class is if you want to create MyVector3D with all operators, you just have to declare:

template <typename T>
class MyVector3D
: public std::static_vectorizer<T, 3, size_t, MyVector3D>
{
    public:
        T& operator[](const size_t i) {return _data[i];}
        const T& operator[](const size_t i) const {return _data[i];}
    protected:
        std::array<T, 3> _data;
};


Vincent
vectorization_v04.pdf

gre...@obbligato.org

unread,
Dec 27, 2012, 1:18:52 PM12/27/12
to std-pr...@isocpp.org
VinceRev <vinc...@gmail.com> writes:

> Here is a new version with the description of operators. The term
> vectorization can be misleading, but I haven't another word in
> mind. Maybe "vector creation helper" would be better ? Keep in mind
> that it is just a preliminary reflexion.

Vectorizer is a bad name. Is this supposed to aid "real" vectorization
somehow? Because if that's the intent it is a very bad idea. Let the
compiler auto-vectorize. We should define some standard keywords and/or
attributes to aid the compiler when necessary. Adding "restrict" would
be a good first step. Rewriting code to be "better" often hamstrings
the auto-vectorizer.

-David

VinceRev

unread,
Dec 27, 2012, 1:51:29 PM12/27/12
to std-pr...@isocpp.org
The goal is not to provide SIMD or other vector optimization. The goal is to provide generic helper classes in order to be able to create things like Vector3D, Matrix3D, MatrixNxM easily.
Optimizations of these classes can be done through expression template or SIMD, but this is not the main point.
Do you have any name to propose for that instead of "vectorizer" ?
Maybe "vectorializer" ? (but this is more related to image processing isn't it ?)
Or "vectorify" ?
Or "vector_creator", but this is a long name...

Thanks,

Vincent

VinceRev

unread,
Dec 28, 2012, 7:57:22 PM12/28/12
to std-pr...@isocpp.org
Hello.

I need some help for the vocabulary to choose because I am currently rewriting some parts of the document for a clearer view, so for the moment forget the old one (I am changing the some aspect of the technical part too to make the syntax easier).

To make it simple this proposal is about three helper classes to simplify and unify the creation of user-defined mathematical containers (typically all the VectorN, MatrixNxM... that we see in a very large number of libraries) using CRTP (Curiously Recursive Template Pattern).

Basically, these tools can automatically provides all the operators and some function like apply(), reduce(), min(), max(), at() for any user-created container that overload the operator[] and have a template shape like MyContainer<typename T, IntegralType... Parameters>.

First, I need good names for these tools. They will have names of the form:
{word} (base class to manage traits and general aspects)
static_{word} (for constant-size containers)
dynamic_{word}
(for dynamic-size containers)

My first plan was to use the word vectorizer but this was very misleading. Then I thought about:
functionalizer (as it provides functions to the container)
overloader (as it overloads all the standard operators (but not only))
mathematizer (as it overloads all the standard operators (but not only))
vectorializer (to make the difference with "vectorization", but this can be misleading too)
I am searching for the perfect name without finding it and I need some help to find a word that could fits in the standard library without any misconception.

For the title of the proposal, I think of "Simplifying and unifying the design of user-defined mathematical containers" instead of the previous (misleading) one.
So I wait for your feedback and ideas before going further.

Thanks for your help!

Vincent

Daniel Krügler

unread,
Jan 9, 2013, 7:09:10 AM1/9/13
to std-pr...@isocpp.org
[My apologies for the late response, but I'm just returned from holidays]

2012/12/29 VinceRev <vinc...@gmail.com>:
> First, I need good names for these tools. They will have names of the form:
> {word} (base class to manage traits and general aspects)
> static_{word} (for constant-size containers)
> dynamic_{word} (for dynamic-size containers)
>
> My first plan was to use the word vectorizer but this was very misleading.
> Then I thought about:
> functionalizer (as it provides functions to the container)
> overloader (as it overloads all the standard operators (but not only))
> mathematizer (as it overloads all the standard operators (but not only))
> vectorializer (to make the difference with "vectorization", but this can be
> misleading too)
> I am searching for the perfect name without finding it and I need some help
> to find a word that could fits in the standard library without any
> misconception.

I have no good suggestions either, but here are some thoughts:

If it is supposed to be used as base class, it seems reasonable to add
something like "_base" as suffix, so what about "vector_base" or
"matrix_base"?

> For the title of the proposal, I think of "Simplifying and unifying the
> design of user-defined mathematical containers" instead of the previous
> (misleading) one.

Yeah, that sounds quite reasonable.

- Daniel
Reply all
Reply to author
Forward
0 new messages