Hi, today I bring to you a question about something different, and perhaps completely useless anyways... :P
After user logicmachine's brilliant SSE solution to some problem (Link), I wonder how much SSE instructions really help program run speed. From the comments in that thread, it helps cut the speed by a factor of approximately 1/4, but is it really true?
I personally am not familiar with these things, but if they will really cut the speed of a program, that would be something curious to look into (maybe fit the TL with O(N^2) for N=1e5 ;))
Now you think, just get better, who needs these magic tricks, they're not even fair :P. But there are always some cases where I have some program, and it's barely over TL, and microoptimizations like these would (maybe?) bring it down to the TL. There's been some case where I've changed all the ints to shorts just to fit the TL... xD
So just for fun, if anyone can provide some light on SSE instructions (do they really help?), that would be pretty cool!
Thanks,
minimario
I'm really interested in this, too. It seems like pretty awesome knowledge to have (even if not always useful) but I"m not sure how to go about learning it.
If a large part of your algorithm can be vectorized, then you can indeed get a 4 times speedup. Source: recently fixed a bug at my job that lead to a non-SSE matrix multiplication at one point.
To compute the Hamming Distance of two strings we can use this function:
If we make 200000 calls with len = 200000, it takes 8.196 seconds.
This AVX implementation only takes 0.538 seconds: (Edit: this uses AVX2)