SSE ints vs. floats practice

时光毁灭记忆、已成空白 提交于 2019-12-24 00:33:47

问题


When dealing with both ints and floats in SSE (AVX) is it a good practice to convert all ints to floats and work only with floats? Because we need only a few SIMD instructions after that, and all we need to use is addition and compare instructions (<, <=, ==) which this conversion, I hope, should retain completely.


回答1:


Expand my comments into an answer.

Basically you weighing the following trade-off:

Stick with integer:

  • Integer SSE is low-latency, high throughput. (dual issue on Sandy Bridge)
  • Limited to 128-bit SIMD width.

Convert to floating-point:

  • Benefit from 256-bit AVX.
  • Higher latencies, and only single-issue addition/subtraction (on Sandy Bridge)
  • Incurs initial conversion overhead.
  • Restricts input to those that fit into a float without precision loss.

I'd say stick with integer for now. If you don't want to duplicate code with the float versions, then that's your call.

The only times I've seen where emulating integers with floating-point becomes faster are when you have to do divisions.


Note that I've made no mention of readability as diving into manual vectorization probably implies that performance is more important.



来源:https://stackoverflow.com/questions/9437860/sse-ints-vs-floats-practice

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!