GNU bug report logs -
#53895
[PATCH 0/5] More CPU detection
Previous Next
Reported by: Efraim Flashner <efraim <at> flashner.co.il>
Date: Wed, 9 Feb 2022 10:19:01 UTC
Severity: normal
Tags: patch
Done: Efraim Flashner <efraim <at> flashner.co.il>
Bug is archived. No further changes may be made.
Full log
Message #32 received at 53895 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wed, Feb 09, 2022 at 11:43:21AM +0100, Ludovic Courtès wrote:
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
>
> > * guix/cpu.scm <cpu>: Add vendor field.
> > (current-cpu): Also fill in the 'vendor' field.
> > (cpu->gcc-architecture): Add detection logic for AMD CPUs.
>
> [...]
>
> > + (and (equal? "AuthenticAMD" (cpu-vendor cpu))
>
> Isn’t that equivalent to (= (cpu-family cpu) some-value)?
It looks to me like 'family' started as the prefix for iX86, so Intel is
mostly using family 6, except when a couple of other processors slip in.
I wasn't able to find a hard and fast rule for what family AMD typically
uses, on my machine its 23. In driver-i386.c it's sort by vendor first:
if (vendor == VENDOR_AMD)
> > + (letrec-syntax ((if-flags (syntax-rules (=>)
> > + ((_)
> > + #f)
> > + ((_ (flags ... => name) rest ...)
> > + (if (every (lambda (flag)
> > + (set-contains? (cpu-flags cpu)
> > + flag))
> > + '(flags ...))
> > + name
> > + (if-flags rest ...))))))
> > +
> > + (when (= 22 (cpu-family cpu))
> > + (if-flags ("movbe" => "btver2")))
> > + (when (= 6 (cpu-family cpu))
> > + (if-flags ("3dnowp" => "athalon")))
>
> This has no effect (because ‘if-flags’ returns a value that is ignored
> since it’s not returned.)
>
> What we could do is extend ‘if-flags’ so that it can optionally check
> for a family number:
>
> (if-flags ((family 22) "movbe" => "btver2")
> …)
That sounds like a good idea.
> > + (if-flags ("vaes" => "znver3")
> > + ("clwb" => "znver2")
> > + ("clzero" => "znver1")
>
> However, the code in driver-i386.c seems to look at model IDs (the big
> “switch (processor)” thing) and not feature flags. Or am I overlooking
> something?
switch (processor) comes after all the AMD chips are sorted. It looks
like all of Intel's i686 and x86_64 are PROCESSOR_PENTIUMPRO, while AMD
has a separate processor per chip design. The AMD chips are sorted about
90 lines above the switch (processor) line
> Thanks,
> Ludo’.
--
Efraim Flashner <efraim <at> flashner.co.il> רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 3 years and 97 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.