mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] s390x: Add single instruction math functions
Date: Sat, 10 Jun 2017 22:20:44 -0400	[thread overview]
Message-ID: <20170611022044.GV1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAGWvnymnAGvonA=6A7oZcPZnVhvTUC=fgH2Kd5nDQKS+PMAm-Q@mail.gmail.com>

On Sat, Jun 10, 2017 at 05:48:05PM -0400, David Edelsohn wrote:
> On Sat, Jun 10, 2017 at 5:44 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
> > On Sat, Jun 10, 2017 at 5:28 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> >> * David Edelsohn <dje.gcc@gmail.com> [2017-06-10 16:22:24 -0400]:
> >>> On Sat, Jun 10, 2017 at 3:48 PM, Rich Felker <dalias@libc.org> wrote:
> >>> > On Sat, Jun 10, 2017 at 02:53:14PM -0400, David Edelsohn wrote:
> >>> >> On Sat, Jun 10, 2017 at 2:29 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> >>> >> > * David Edelsohn <dje.gcc@gmail.com> [2017-06-10 13:25:00 -0400]:
> >>> >> >> On Sat, Jun 10, 2017 at 11:36 AM, Szabolcs Nagy <nsz@port70.net> wrote:
> >>> >> >> > * David Edelsohn <dje.gcc@gmail.com> [2017-06-09 10:51:25 -0400]:
> >>> >> >> >> The following patch is a start at single instruction math functions
> >>> >> >> >> for s390x architecture to increase performance.
> >>> >> >> >
> >>> >> >> > looks good, i wonder why gcc does not have builtins support for
> >>> >> >> > ceil, floor, nearbyint, round and trunc
> >>> >> >> >
> >>> >> >> > (on aarch64 the builtins expand to single instruction with
> >>> >> >> > -fno-math-errno, but on s390x they remain libc calls
> >>> >> >>
> >>> >> >> Both the functions and builtins are converted to single instructions
> >>> >> >> for me.  What architecture level is your GCC assuming?
> >>> >> >>
> >>> >> >
> >>> >> > i think it's the default s390x config
> >>> >> >
> >>> >> > $ s390x-linux-musl-gcc -v
> >>> >> > Using built-in specs.
> >>> >> > COLLECT_GCC=s390x-linux-musl-gcc
> >>> >> > COLLECT_LTO_WRAPPER=/home/nsz/w/mcm/output/bin/../libexec/gcc/s390x-linux-musl/6.3.0/lto-wrapper
> >>> >> > Target: s390x-linux-musl
> >>> >> > Configured with: ../src_toolchain/configure --enable-languages=c,c++ CFLAGS='-g0 -Os' CXXFLAGS='-g0 -Os' LDFLAGS=-s --disable-nls --with-debug-prefix-map=/home/nsz/w/mcm/build-s390x-linux-musl= --enable-languages=c,c++ --disable-libquadmath --disable-libquadmath-support --disable-decimal-float --disable-multilib --disable-libcilkrts --disable-libvtv --disable-libgomp --disable-libitm --disable-werror --target=s390x-linux-musl --prefix= --libdir=/lib --disable-multilib --with-sysroot=/s390x-linux-musl --enable-tls --disable-libmudflap --disable-libsanitizer --disable-gnu-indirect-function --disable-libmpx --enable-libstdcxx-time --with-build-sysroot=/home/nsz/w/mcm/build-s390x-linux-musl/obj_sysroot
> >>> >> > Thread model: posix
> >>> >> > gcc version 6.3.0 (GCC)
> >>> >> > $ cat a.c
> >>> >> > double f(double x)
> >>> >> > {
> >>> >> >         return __builtin_ceil(x);
> >>> >> > }
> >>> >> > $ s390x-linux-musl-gcc -O3 -fno-math-errno -S a.c -o -
> >>> >> >         .machinemode zarch
> >>> >> >         .machine "z900"
> >>> >>
> >>> >> Note the default architecture is z900 from 2005-2006.  The FP
> >>> >> instructions were added with the z196 processors in 2010.
> >>> >
> >>> > In that case the patch should probably have the code inside something
> >>> > like:
> >>> >
> >>> > #ifdef __Z196__ // or whatever the predef macro for the ISA level is
> >>> > // your code here
> >>> > #else
> >>> > #include "../foo.c"
> >>> > #else
> >>> >
> >>> > See src/math/arm/sqrt.c for a similar example.
> >>> >
> >>> >> s390x-linux-musl probably should default to a much newer processor
> >>> >> level, such as at least z196 or zEC12
> >>> >
> >>> > musl's policy is to just follow whatever ISA level the compiler is
> >>> > configured for; you can set this at musl build time with CFLAGS or use
> >>> > a default built into the toolchain at toolchain build time
> >>> > (--with-arch, I think).
> >>>
> >>> Musl already defaults to the later ISA in the rest of the s390x port.
> >>
> >> would it be hard to support all s390x isa levels?
> >
> > It's a waste of effort and will hurt performance on newer processors.

I don't think this is accurate. There is no asm in any
performance-relevant code paths now. If there were, it could be
conditionally built for the compiler's ISA level (-march) based on
predefined macros.

> > No user of Musl and Alpine is going to -- or even /can/ -- run it on
> > older processors.  All of the Docker containers and underlying Linux
> > distributions don't support the older processors.
> 
> When I worked with Bobby Bingham to create the s390x port of Musl, I
> said that he could assume newer processors.  Also, I don't believe
> that LLVM supports the earlier processors.  I believe that he assumed
> some more recent instructions in other parts of the code.

That seems doubtful; the amount of asm in musl is minimal and unlikely
to benefit from later ISA levels; all the instructions I see look like
very basic stuff that would always have been available.

Now, what likely is accurate is your claim that nobody is using musl
on lower ISA levels, so maybe it doesn't matter.

Rich


  reply	other threads:[~2017-06-11  2:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 14:51 David Edelsohn
2017-06-10 15:36 ` Szabolcs Nagy
2017-06-10 17:25   ` David Edelsohn
2017-06-10 18:29     ` Szabolcs Nagy
2017-06-10 18:53       ` David Edelsohn
2017-06-10 19:48         ` Rich Felker
2017-06-10 20:22           ` David Edelsohn
2017-06-10 21:28             ` Szabolcs Nagy
2017-06-10 21:44               ` David Edelsohn
2017-06-10 21:48                 ` David Edelsohn
2017-06-11  2:20                   ` Rich Felker [this message]
2017-06-11 10:19                     ` Szabolcs Nagy
2017-06-11 15:04                       ` Rich Felker
2017-06-11 16:45                         ` Szabolcs Nagy
2017-06-11 21:45                           ` Rich Felker
2017-06-12  2:46                       ` David Edelsohn
2017-06-12  4:36                         ` Tuan M. Hoang
2017-06-12  9:03                         ` Szabolcs Nagy
2017-06-12 13:28                           ` David Edelsohn
2017-06-12 13:54                             ` David Edelsohn
2017-06-12 20:28                               ` Szabolcs Nagy
2017-06-12 21:02                                 ` David Edelsohn
2017-06-13 15:55                                   ` Szabolcs Nagy
2017-06-14 23:34                                     ` Rich Felker
2017-06-14 23:40                                       ` A. Wilcox
2017-06-14 23:44                             ` Rich Felker
2017-06-15 12:18                               ` David Edelsohn
2017-06-18 17:12                               ` David Edelsohn
2017-06-21  0:49                                 ` Rich Felker
2017-06-21  1:07                                   ` David Edelsohn
2017-06-21  1:20                                     ` Rich Felker
2017-06-21  3:34                                       ` David Edelsohn
2017-06-23 19:31                                         ` Rich Felker
2017-06-10 21:37             ` Rich Felker

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=20170611022044.GV1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).