检查运行时是否支持SSE

编程入门 行业动态 更新时间:2024-10-10 04:20:53
本文介绍了检查运行时是否支持SSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在运行时检查是否支持SSE4或AVX,以便我的程序可以利用特定于处理器的指令,而无需为每个处理器创建二进制文件.

I would like to check if SSE4 or AVX is supported at runtime, so that my program may take advantage of processor specific instructions without creating a binary for each processor.

如果我可以在运行时确定它,则可以使用一个接口并在不同的指令集之间进行切换.

If I could determine it at runtime, I could use an interface and switch between different instruction sets.

推荐答案

GCC有一种方法,首先调用__builtin_cpu_init,然后调用__builtin_cpu_is和__builtin_cpu_supports来检查功能. gcc.gnu/onlinedocs/gcc- 4.8.2/gcc/X86-Built-in-Functions.html

GCC has a way of doing this that starts by calling __builtin_cpu_init then calling __builtin_cpu_is and __builtin_cpu_supports to check features. gcc.gnu/onlinedocs/gcc-4.8.2/gcc/X86-Built-in-Functions.html

在x86上,当使用C ++前端时,GCC支持功能多版本",该功能允许您编写该功能的多个版本,指定应在其上使用的目标,并让GCC负责确保调用该功能. . gcc.gnu/onlinedocs/gcc-4.9.0/gcc/Function-Multiversioning.html

On x86, when using the C++ frontend, GCC supports "function multiversioning", which allows you to write multiple versions of the function, specify the target it should be used on, and let GCC take care of making sure it is called. gcc.gnu/onlinedocs/gcc-4.9.0/gcc/Function-Multiversioning.html

更多推荐

检查运行时是否支持SSE

本文发布于:2023-11-30 21:42:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SSE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!