x86 CPU Dispatching for SSE/AVX in C++

天大地大妈咪最大 提交于 2019-12-05 20:53:58

Just create a "factory" class or function to create appropriate instances of your class and hide all the logic in the file that implements the factory.

Have some class or file local boolean values like "isSSE2Supported" or "isAVXSupported". On startup, call some function to initialize these values. Your factory logic can then check against the values to determine which class to use.

Since SSE2 is always available on x64 chips, you don't really want to avoid all of the ifdefs. You can avoid compiling in some of the classes for x64 builds.

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