Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Dec 2019 11:45:48 +0100
From:      Jan Beich <jbeich@FreeBSD.org>
To:        Alexey Dokuchaev <danfe@freebsd.org>
Cc:        Gleb Popov <arrowd@freebsd.org>, svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org
Subject:   Re: svn commit: r520468 - in head/sysutils: . cpuid2cpuflags
Message-ID:  <v9qb-ff6r-wny@FreeBSD.org>
In-Reply-To: <20191220084532.GA30042@FreeBSD.org> (Alexey Dokuchaev's message of "Fri, 20 Dec 2019 08:45:32 %2B0000")
References:  <201912200518.xBK5IHPq022253@repo.freebsd.org> <CALH631m10%2B0eDY_8BKQxErA2Bpo2dv6B6h7DRb77yO3cJCboSw@mail.gmail.com> <20191220084532.GA30042@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alexey Dokuchaev <danfe@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+)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v9qb-ff6r-wny>