3 ms·
Anecdote: a very long time ago, I optimized (as in 40% speed up) the inner loop of a computation heavy application (a custom document clustering application) by
by gpderetta 9y ago
Anecdote: a very long time ago, I optimized (as in 40% speed up) the inner loop of a computation heavy application (a custom document clustering application) by using __builtin_prefetch [1]. The code was simply a series of sparse-vector/sparse-vector multiplications, with each vector kept in a linked list [2]. The big win was in overlapping the prefetching the next list node and the contained vector while the multiplication was in progress.
This optimization worked fine the Core 2 architecture. After moving to Westmere, the optimization didn't have any significant effect (I doubt the hardware was doing list prefetching, so some other bottleneck was preventing it from being effective). On the other hand, enabling hyper-threading gave a near 100% speedup (the application was trivially parallelizable and already parallelized via openmp).
[1] Actually for portability, I ended up doing explicit throwaway reads in the released code instead of using prefetch instructions.
[2] The linked list was not optimal but the vectors were shuffled around a lot so a fast splice was useful. Prefetching the vector itself would still have been a win though.