Hacker News new | ask | show | jobs
by mattclase 2261 days ago
One thing to keep in mind is for SIMD memory locality is very important; a diagonal vector with a standard 2D DP grid is gonna lead to a lot of cache misses. Just something else to learn about.
1 comments

Since I am storing the entire DP matrix as diagonal vectors that are flattened, I don't think there will be many cache misses. Each diagonal only depends on its previous two diagonals, and each diagonal is stored contiguously in memory.

The problem with handling diagonals is that indexing cells and comparing characters on the diagonal becomes complex. Dealing with this without many branches (less branch mispredictions) is the hard part.