A new Gamasutra feature article
by Gustavo Oliveira delves into the construction of fast vector libraries, based in part on the experience the author had while developing VMath.
Oliveira, a Qualcomm senior software engineer who has worked for Sony Computer Entertainment America and Electronic Arts, includes a number of examples and principles throughout the piece, which he introduces as follows:
"Inside most 3D applications there exists a vector library to perform routine calculations such as vector arithmetic, logic, comparison, dot and cross products, and so on. Although there are countless ways to go about designing this type of library, developers often miss key factors to allow a vector library to perform these calculations the fastest possible way.
"Around late 2004 I was assigned to develop such a vector library code-named VMath, standing for "Vector Math." The primary goal of VMath was not only to be the fastest but also easily portable across different platforms.
"To my surprise in 2009, the compiler technology has not changed much. Indeed the results presented in this article resulted from my research during that time, with some exceptions, are nearly the same that when I was working on VMath five years ago.
"Since this article is mostly written in C++ and focused primarily in performance, defining the fastest library can be misleading sometimes.
"Therefore, the fastest library as described in here, is the one that generates the smallest assembly code compared to other libraries when compiling the same code using the same settings (assuming release mode of course). This is because the fastest library generates fewer instructions to perform the same exact calculations. Or in other words, the fastest library is the one the bloats the code the least."
The full article, which includes code samples, is now available to read on Gamasutra