mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Model specific optimizations?
Date: Thu, 29 Sep 2016 16:57:51 +0200	[thread overview]
Message-ID: <20160929145751.GH1280@port70.net> (raw)
In-Reply-To: <20160929142126.GB22343@voyager>

* Markus Wichmann <nullplan@gmx.net> [2016-09-29 16:21:26 +0200]:
> I wanted to ask if there is any wish for the near future to support
> model-specific optimizations. What I mean by that is multiple
> implementations of the same function, where the best implementation is
> decided at run-time.

musl already does some runtime selection based on hw/kernel
features (arm atomics, vdso).

it could use similar approaches for micro-architecture specific
optimizations.

this has a maintenance cost (hard to test, hard to benchmark),
code size cost (all variants has to be present at runtime)
and dispatch cost (it has to happen at startup or lazily) these
costs are rarely justified.

(there are secondary effects: glibc dispatches memcpy at runtime
so the compilers have a hard time deciding when to inline it,
as a consequence sometimes -O0 gives better performance than -O3
on x86 with glibc.)

> One simple example would be PowerPC's fsqrt instruction. The PowerPC
> Book 1 defines it as optional and provides no way to know specifically,
> if the currently running processor supports this instruction besides
> executing it and seeing if you get a SIGILL.

if there is no linux hwcap bit for this then we cant do much about it.

runtime dispatch only works if there is a reasonable way to detect
hw features (hwcap, cpuid instruction, vdso something) e.g. parsing
/proc/cpuinfo to figure out the cpu and guessing features from that
or registering sigill signal handlers are not ok.

> Then organization: Are we going the glibc route, which gathers all
> indirect functions in a single section and initializes all of the
> pointers at startup (__libc_init_main()), or do we put these checks
> separately in each function?

glibc uses ifunc for this, musl does not support ifunc at this point.


  reply	other threads:[~2016-09-29 14:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 14:21 Markus Wichmann
2016-09-29 14:57 ` Szabolcs Nagy [this message]
2016-09-29 15:23 ` Rich Felker
2016-09-29 17:08   ` Markus Wichmann
2016-09-29 18:13     ` Rich Felker
2016-09-29 18:52       ` Adhemerval Zanella
2016-09-29 22:05         ` Szabolcs Nagy
2016-09-29 23:14           ` Adhemerval Zanella
2016-09-30  4:56       ` Markus Wichmann
2016-10-01  5:50         ` Rich Felker
2016-10-01  8:52           ` Markus Wichmann
2016-10-01 15:10             ` Rich Felker
2016-10-01 19:53               ` Markus Wichmann
2016-10-02 13:59                 ` Adhemerval Zanella

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=20160929145751.GH1280@port70.net \
    --to=nsz@port70.net \
    --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).