Readings on vector class optimization

Now that Revision has passed, we feel tempted to grab the ax and happily chop into parts of our code base we wanted to change but couldn’t really since we had other priorities. One tempting part is the linear algebra one: vector, quaternion and matrix data structures. Lets say vector for a start. Not that it’s really necessary, but the transformations are the most time consuming parts after the rendering itself, and the problem itself is somewhat interesting.

After a little googling, I basically found three approaches to this problem:

Every here and there, people seem to think of SSE instructions as a silver bullet and propose various examples of code, snippets or full implementations. The idea being to use dedicated processor instructions to apply operations on four components at a time instead of one after another.

Quite on the opposite, Fabian Giesen argued some years ago that it was not such a good idea. A quick look at the recently publicly released Farbrausch codebase shows they indeed used purely conventional C++ code for it.

At last this quite dated article (with regards to hardware evolution) by Tomas Arce takes a completely orthogonal approach, consisting of using C++ templates to evaluate a full expression component after component, thus avoiding wasting time moving and copying things around.

I am curious to implement and compare them on nowadays hardware.


Update: this is 2016 and the topic was brought back recently when someone wrote the article How to write a math library in 2016.

The point of the article is that the old advice to not bother with SSE and stick with floats doesn’t apply anymore, and it goes on to show results and sample code. This sparked a few discussions on Twitter, with opinions voiced to put it mildly.

It seemed the consensus was still against the use of SSE for the following reasons:

  • Implementation is tedious.
  • For 3 dimensional vector, which is the most common case, there is a 25% waste.
  • For 4 dimensional vectors, like homogeneous coordinates and RGBA, it doesn’t work so well either since the fourth component is treated differently than the other ones.
  • Even if the implementation detail is hidden behind a nice interface, the alignment requirements will leak and become constraints to the rest of the code.
  • Compilers like clang are smart enough to generate SSE code from usual float operations.

Solarized environment

During last year I tested and adopted two tools for my environment: the Anonymous Pro font and the Solarized color palette. After months of use, there is no way back: the difference of comfort is significant, and any text application allowing to be configured so gets them on my work stations.

Solarized has a repository of configuration files for various applications. Unfortunately those are made by different people, with different tastes, and thus the color choices are not consistent from one application to another. This means you may still have to go through a good deal of tweaking if this is annoying to you.

Like it’s Web 1.0 all over again

Back then I wasn’t so much of a blog reader. I had at most a dozen of sources I would read on a regular basis. Then somewhere around 2008 I discovered Google Reader: an awesome tool that allowed not only to subscribe to feeds, organize them and read them through a unified interface just like any news aggregator, but more importantly allowed to share news of interest with other people. By following people I knew were interested in topics relevant to me, I would get insights from those topics without the burden of browsing other hundreds of sources by myself. I used Google Reader daily for the last years, sharpening my fields of interest over the time.

Until that fateful day when Reader was shot in the head after someone decided Google+ was the way to go. They probably thought people would have no choice but embracing it. I don’t know how things went after that, but from what I saw most felt less than happy at having it forced down their throat. The user base of Newsblur skyrocketed, much expectations were put on HiveMined, but then came the status quo: Newsblur doesn’t have the social feature yet, and HiveMined is not ready yet either. Meanwhile, some argue Google Reader is still the best newsreader around.

We Google Reader orphans are looking for a new home to party again, but we all know the community is shattered. What made the strength of Reader was its ubiquity. Many of us wouldn’t even try Google+, because of the feeling that we were betrayed by Google and that it’s likely to happen again anytime. And now we are waiting to see where everyone will go.

Until we have that answer, supposing it ever comes, I thought I would give a try at a good old blog. One thing I learned while using Reader is that just gathering things one find of interest can already make an interesting editorial line. So from now on I will use this blog the way I was sharing things, making it a reliable bookmark reference for myself and hopefully an interesting feed for other people. Oh, and I plan to write things too: it will be an opportunity to try myself at publishing in English, since it’s not my mother tongue. For more autenticity, feel free to read with an outrageous French accent. :)

Stowage platform

Stowage platform