svn commit: r520468 - in head/sysutils: . cpuid2cpuflags

Jan Beich jbeich at FreeBSD.org
Fri Dec 20 10:45:52 UTC 2019


Alexey Dokuchaev <danfe at freebsd.org> writes:

> On Fri, Dec 20, 2019 at 09:45:49AM +0400, Gleb Popov wrote:
>
>> On Fri, Dec 20, 2019 at 9:18 AM Alexey Dokuchaev wrote:
>> > New Revision: 520468
>> > URL: https://svnweb.freebsd.org/changeset/ports/520468
>> >
>> > Log:
>> >   The program attempts to obtain the identification and capabilities
>> >   of the currently used CPU, and print the matching set of CPU_FLAGS_*
>> >   flags for Gentoo Linux, but it could be useful for FreeBSD as well.
>> 
>> I wrote something similar for FreeBSD specifically: sysutils/hs-cputype
>
> Sure thing, except that it's written in Haskell, so one has to either use
> the binary package or download and/or build rather heavy environment to
> "make install" it.
>
> It also reports slightly different (and scarcer) values, e.g. on this AMD
> A8-5550M of mine:
>
>   $ cpuid2cpuflags
>   CPU_FLAGS_X86: aes avx f16c fma3 fma4 mmx mmxext pclmul popcnt
>   sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop
>
>   $ /usr/local/bin/cputype -f
>   xop avx sse42 sse41 ssse3 sse4a sse3 amd64 sse2 sse mmx
>
> That said, I think both tools can be useful and have their place in the
> ports tree. :)-

Neither supports non-x86 architectures[1] on FreeBSD. Even on x86 both
are incomplete compared to "cc -march=native -v" e.g., cpuid2cpuflags
lacks avx512bf16 while hs-cputype doesn't support avx512 at all.

[1] Here're various ways to detect CPU features:

aarch64:
- READ_SPECIALREG(id_aa64isar0)
- elf_aux_info: AT_HWCAP (on FreeBSD 13+)

armv6 and armv7:
- sysctl(KERN_PROC_AUXV): AT_HWCAP + AT_HWCAP2
- elf_aux_info: AT_HWCAP + AT_HWCAP2 (on FreeBSD 12+)

powerpc and powerpc64:
- sysctlbyname: kern.cpu_features + kern.cpu_features2
- elf_aux_info: AT_HWCAP + AT_HWCAP2 (on FreeBSD 12+)

riscv64:
- elf_aux_info: AT_HWCAP (on FreeBSD 13+)


More information about the svn-ports-head mailing list