What's the differrence among cflgs sse options

2019-03-14 22:46发布

For the GCC CFLAGS options: -msse, -msse2, -mssse3, -msse4, -msse4.1, -msse4.2. Are they exclusive in their use or can the be used together?

My understanding is that the choosing which to set depends on whether the target arch, which the program will run on, supports it or not, is this correct?

If so, how could I know what sse my target arch supports? In Linux, I cat /proc/cpuinfo, but what if mac or Windows?

Thanks!

1条回答
我命由我不由天
2楼-- · 2019-03-14 23:08

The -m switched can be used in parallel, furthermore some of them are implied by the architecture or other switches. For instance, if you build code for x86_64, -msse -msse2 is always enabled.

For code intended to run on your system you should choose -march=native, which will select what is available on your processor. For instance, if you have a Sandy Bridge, this will enable -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx.

If you want to specify in detail which instruction set to use, you should only use what is available, not always the "latest". The "latest" one is currently -mavx2, which I don't recommend: The first processor which will support it will be available in 2013.

查看更多
登录 后发表回答