All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Khem Raj" <raj.khem@gmail.com>
To: Tanu Kaskinen <tanuk@iki.fi>
Cc: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] Why disable NEON support in recipes if runtime detection works?
Date: Sun, 26 Jul 2020 07:01:44 -0700	[thread overview]
Message-ID: <CAMKF1srEGQnkaZutfPaH5QS_vK8Yx0NeWvWo_10rOQpD7s8=0A@mail.gmail.com> (raw)
In-Reply-To: <65325f6d63b5927ea8f0f7a167119d0ca8dcfd34.camel@iki.fi>

[-- Attachment #1: Type: text/plain, Size: 3689 bytes --]

On Sun, Jul 26, 2020 at 12:59 AM Tanu Kaskinen <tanuk@iki.fi> wrote:

> On Sun, 2020-07-26 at 09:27 +0300, Tanu Kaskinen wrote:
> > On Mon, 2020-07-20 at 15:26 -0700, Khem Raj wrote:
> > > On Sun, Jul 19, 2020 at 2:06 AM Tanu Kaskinen <tanuk@iki.fi> wrote:
> > > > Hi!
> > > >
> > > > If a recipe provides NEON optimizations, should those be explicitly
> > > > disabled when "neon" is not in TUNE_FEATUERS, even if the software is
> > > > able to detect NEON availability at runtime?
> > > >
> > > > I'm currently converting the pulseaudio recipe from Autotools to
> Meson,
> > > > and the old Autotools build system supports disabling NEON
> > > > optimizations but the Meson build system doesn't. So I'm wondering
> if I
> > > > should add the missing feature to the Meson build system, or just let
> > > > the runtime detection do its work.
> > > >
> > > > Is there ever need for disabling NEON optimizations if the CPU
> > > > indicates NEON support? I guess it could be useful for testing the
> "no
> > > > NEON" case (I today found out that dropping "neon" from TUNE_FEATURES
> > > > doesn't remove NEON support from the qemuarm machine), but otherwise
> it
> > > > seems unnecessary, unless there are CPUs that advertise NEON support
> > > > but don't actually support it.
> > > >
> > >
> > > I think the issue will result in a compiler error perhaps when neon is
> > > disabled via
> > > compiler command line which would be the case when neon is not in
> TUNE_FEATURES
> > > the compiler might warn or error out when it finds neon instructions
> > > being compiled via inline
> > > assembly.  you just can try passing something like -mfpu=vfpv3d16 or
> > > some such and see if
> > > compiler/assembler complains during build, if not then perhaps its
> fine.
> >
> > If the last -mfpu is something else than neon, then including
> > arm_neon.h will succeed but compiling neon code will fail.
> >
> > I did some experiments, and what I found was that when I remove neon
> > from TUNE_FEATURES, OE adds -mfpu=vfp to CC, not CFLAGS, so it's very
> > early in the compiler command line. PulseAudio adds -mfpu=neon to
> > CFLAGS when building neon code, and the last -mfpu wins, so the neon
> > code gets built without errors.
> >
> > The configure check in PulseAudio only checks that the compiler accepts
> > -mfpu=neon and #include <arm_neon.h>, it doesn't try to compile any
> > actual neon code. This means that if the user adds -mfpu=vfp (or other
> > non-neon) to CFLAGS rather than CC, configure will pass but building
> > will fail. Is this something to guard against? A default qemuarm build
> > doesn't do this, so I don't know if this ever happens in OE.
> >
> > I don't know yet how Meson behaves, I'll continue testing...
>
> I tested Meson now. Meson too enables Neon even if -mfpu=vfp is in CC.
> Unlike Autotools, Meson doesn't fail if -mfpu=vfp is added to CFLAGS (I
> tried CFLAGS_append = " -mfpu=vfp" in the pulseaudio recipe). Neon is
> enabled in any case.
>
> So, Meson seems pretty safe, although I guess it would be nice not to
> override the user's -mfpu setting. I think this isn't a big problem is
> practice, since runtime detection works.
>
> I haven't tested with a compiler that truly can't build Neon code,
> because I don't know how to do that.


Right. Cpu implementations without neon do exist
 But they are perhaps rare enough and may not use the package too so
chances are slim that we encounter this issue

Qemuarm emulated a cpu with neon so yes it won’t show on qemuarm

>
>
> --
> Tanu
>
> https://www.patreon.com/tanuk
> https://liberapay.com/tanuk
>
>

[-- Attachment #2: Type: text/html, Size: 4909 bytes --]

  reply	other threads:[~2020-07-26 14:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19  9:06 Why disable NEON support in recipes if runtime detection works? Tanu Kaskinen
2020-07-19  9:30 ` [OE-core] " Adrian Bunk
2020-07-19  9:46   ` Tanu Kaskinen
2020-07-20 22:26 ` Khem Raj
2020-07-26  6:27   ` Tanu Kaskinen
     [not found]   ` <1625397D9F68474B.26462@lists.openembedded.org>
2020-07-26  7:59     ` Tanu Kaskinen
2020-07-26 14:01       ` Khem Raj [this message]
2020-07-27 20:45         ` Andre McCurdy
2020-07-29 13:46           ` Tanu Kaskinen
2020-07-29 22:08             ` Andre McCurdy
2020-08-23  8:53               ` Tanu Kaskinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMKF1srEGQnkaZutfPaH5QS_vK8Yx0NeWvWo_10rOQpD7s8=0A@mail.gmail.com' \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=tanuk@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.