Handmade Hero»Forums»Code
14 posts
Floats are 2 Times Faster than Doubles
Edited by Blu342 on
https://hero.handmade.network/episode/code/day049/#5201

In the above Q&A Casey says that floats are two times faster than doubles, because we can do double the amount of operations on them in the same # of cycles. On Day 49, when this question was asked, he hadn't yet used SIMD instrinsics, but is this what he was referring to by the 2x gain in speed? In other words, at the time of this statement simply using a float instead of a double did not actually garner double the speed, rather Casey is saying that he prefers to use floats as a default because they allow for this optimization to happen. Is that right?
Mārtiņš Možeiko
2559 posts / 2 projects
Floats are 2 Times Faster than Doubles
Edited by Mārtiņš Možeiko on
Yes, he is referring to SIMD when he said they are 2x faster. With approximately same amount of instructions you can process 2x more of data. Sure there are some differences in speed for float and double SIMD operations. But most simple ops run with exactly same throughput - like min/max/add/sub/cmp/mul.

If I remember correctly this question came up multiple times, maybe in later episodes or could be in prestream. Next time he answered it, he mentioned SIMD.
14 posts
Floats are 2 Times Faster than Doubles
yeah that makes sense. i just wanted to clarify that he wasn't saying regular float ops are 2x as fast as doubles without use of SIMD intrinsics, because that seemed a little farfetched. i understand now though.